添加后端
This commit is contained in:
parent
39fed9f57f
commit
eefbc98d93
126
README.md
126
README.md
@ -1,126 +0,0 @@
|
||||
### 项目说明
|
||||
- renren-security是一个轻量级的,前后端分离的Java快速开发平台,能快速开发项目并交付【接私活利器】
|
||||
- 采用SpringBoot3.x、Shiro、MyBatis-Plus、Vue3、TypeScript、Element Plus、Vue Router、Pinia、Axios、Vite框架,开发的一套权限系统,极低门槛,拿来即用。设计之初,就非常注重安全性,为企业系统保驾护航,让一切都变得如此简单。
|
||||
- 提供了代码生成器,只需编写30%左右代码,其余的代码交给系统自动生成,可快速完成开发任务
|
||||
- 支持MySQL、达梦、Oracle、SQL Server、PostgreSQL等主流数据库
|
||||
- 演示地址:http://demo.open.renren.io/renren-security (账号密码:admin/admin)
|
||||
|
||||
<br>
|
||||
|
||||
### 微信交流群
|
||||
我们提供了微信交流群,扫码下面的二维码,关注【系统】公众号,回复【加群】,即可根据提示加入微信群!
|
||||
<br><br>
|
||||

|
||||
|
||||
<br>
|
||||
|
||||
### 具有如下特点
|
||||
- 友好的代码结构及注释,便于阅读及二次开发
|
||||
- 实现前后端分离,通过token进行数据交互,前端再也不用关注后端技术
|
||||
- 灵活的权限控制,可控制到页面或按钮,满足绝大部分的权限需求
|
||||
- 提供CrudService接口,对增删改查进行封装,代码更简洁
|
||||
- 页面交互使用Vue3.x,极大的提高了开发效率
|
||||
- 完善的部门管理及数据权限,通过注解实现数据权限的控制
|
||||
- 完善的XSS防范及脚本过滤,彻底杜绝XSS攻击
|
||||
- 完善的代码生成机制,可在线生成entity、xml、dao、service、vue、sql代码,减少70%以上的开发任务
|
||||
- 引入quartz定时任务,可动态完成任务的添加、修改、删除、暂停、恢复及日志查看等功能
|
||||
- 引入Hibernate Validator校验框架,轻松实现后端校验
|
||||
- 引入云存储服务,已支持:七牛云、阿里云、腾讯云等
|
||||
- 引入swagger文档支持,方便编写API接口文档
|
||||
|
||||
<br>
|
||||
|
||||
### 数据权限设计思想
|
||||
- 用户管理、角色管理、部门管理,可操作本部门及子部门数据
|
||||
- 菜单管理、定时任务、参数管理、字典管理、系统日志,没有数据权限
|
||||
- 业务功能,按照用户数据权限,查询、操作数据【没有本部门数据权限,也能查询本人数据】
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
**项目结构**
|
||||
```
|
||||
renren-security
|
||||
├─renren-common 公共模块
|
||||
│
|
||||
├─renren-admin 管理后台
|
||||
│ ├─db 数据库SQL脚本
|
||||
│ │
|
||||
│ ├─modules 模块
|
||||
│ │ ├─job 定时任务
|
||||
│ │ ├─log 日志管理
|
||||
│ │ ├─oss 文件存储
|
||||
│ │ ├─security 安全模块
|
||||
│ │ └─sys 系统管理(核心)
|
||||
│ │
|
||||
│ └─resources
|
||||
│ ├─mapper MyBatis文件
|
||||
│ ├─public 静态资源
|
||||
│ └─application.yml 全局配置文件
|
||||
│
|
||||
│
|
||||
├─renren-api API服务
|
||||
│
|
||||
├─renren-generator 代码生成器
|
||||
│ └─resources
|
||||
│ ├─mapper MyBatis文件
|
||||
│ ├─template 代码生成器模板(可增加或修改相应模板)
|
||||
│ ├─application.yml 全局配置文件
|
||||
│ └─generator.properties 代码生成器,配置文件
|
||||
│
|
||||
├─renren-ui Vue3前端工程
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
**技术选型:**
|
||||
- 核心框架:Spring Boot 3.x
|
||||
- 安全框架:Apache Shiro 1.12
|
||||
- 持久层框架:MyBatis 3.5
|
||||
- 定时器:Quartz 2.3
|
||||
- 数据库连接池:Druid 1.2
|
||||
- 日志管理:Logback
|
||||
- 页面交互:Vue3.x
|
||||
|
||||
<br>
|
||||
|
||||
**软件需求**
|
||||
- JDK17+
|
||||
- Maven3.6+
|
||||
- MySQL8.0+
|
||||
- Oracle 11g+
|
||||
- SQLServer 2012+
|
||||
- PostgreSQL 9.4+
|
||||
- 达梦8
|
||||
<br>
|
||||
|
||||
|
||||
**本地部署**
|
||||
- 通过git下载源码
|
||||
- idea、eclipse需安装lombok插件,不然会提示找不到entity的get set方法
|
||||
- 创建数据库renren_security,数据库编码为UTF-8
|
||||
- 执行db/mysql.sql文件,初始化数据
|
||||
- 修改application-dev.yml文件,更新MySQL账号和密码
|
||||
- 在renren-security目录下,执行mvn clean install
|
||||
- Eclipse、IDEA运行AdminApplication.java,则可启动项目【renren-admin】
|
||||
- renren-admin访问路径:http://localhost:8080/renren-admin
|
||||
- swagger文档路径:http://localhost:8080/renren-admin/doc.html
|
||||
- 再启动前端项目,前端地址:https://gitee.com/renrenio/renren-ui
|
||||
- 账号密码:admin/admin
|
||||
<br>
|
||||
|
||||

|
||||
|
||||
<br>
|
||||
|
||||

|
||||
|
||||
<br>
|
||||
|
||||
### 如何交流、反馈、参与贡献?
|
||||
- 开发文档:https://www.renren.io/guide/security
|
||||
- Gitee仓库:https://gitee.com/renrenio/renren-security
|
||||
- [系统](https://www.renren.io):https://www.renren.io
|
||||
- 如需关注项目最新动态,请Watch、Star项目,同时也是对项目最好的支持
|
||||
<br>
|
||||
|
@ -114,7 +114,6 @@ public class SysMenuController {
|
||||
if (list.size() > 0) {
|
||||
return new Result().error("先删除子菜单或按钮!");
|
||||
}
|
||||
|
||||
sysMenuService.delete(id);
|
||||
|
||||
return new Result();
|
||||
@ -126,7 +125,6 @@ public class SysMenuController {
|
||||
public Result<List<SysMenuDTO>> select() {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
List<SysMenuDTO> list = sysMenuService.getUserMenuList(user, null);
|
||||
|
||||
return new Result<List<SysMenuDTO>>().ok(list);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,6 @@ public class SysUserController {
|
||||
@RequiresPermissions("sys:user:page")
|
||||
public Result<PageData<SysUserDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
PageData<SysUserDTO> page = sysUserService.page(params);
|
||||
|
||||
return new Result<PageData<SysUserDTO>>().ok(page);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,101 @@
|
||||
package io.modules.sys.controller;
|
||||
|
||||
|
||||
import io.common.annotation.LogOperation;
|
||||
import io.common.constant.Constant;
|
||||
import io.common.page.PageData;
|
||||
import io.common.utils.ExcelUtils;
|
||||
import io.common.utils.Result;
|
||||
import io.common.validator.AssertUtils;
|
||||
import io.common.validator.ValidatorUtils;
|
||||
import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.modules.item.dto.UserDTO;
|
||||
import io.modules.item.service.UserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/user-front")
|
||||
@Tag(name="用户")
|
||||
public class UserController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref="int") ,
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY,required = true, ref="int") ,
|
||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref="String") ,
|
||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref="String")
|
||||
})
|
||||
@RequiresPermissions("item:user:page")
|
||||
public Result<PageData<UserDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){
|
||||
PageData<UserDTO> page = userService.page(params);
|
||||
|
||||
return new Result<PageData<UserDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@RequiresPermissions("item:user:info")
|
||||
public Result<UserDTO> get(@PathVariable("id") Long id){
|
||||
UserDTO data = userService.get(id);
|
||||
|
||||
return new Result<UserDTO>().ok(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@LogOperation("保存")
|
||||
@RequiresPermissions("item:user:save")
|
||||
public Result save(@RequestBody UserDTO dto){
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||
|
||||
userService.save(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@LogOperation("修改")
|
||||
@RequiresPermissions("item:user:update")
|
||||
public Result update(@RequestBody UserDTO dto){
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
userService.update(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("item:user:delete")
|
||||
public Result delete(@RequestBody Long[] ids){
|
||||
//效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
userService.delete(ids);
|
||||
return new Result();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -3,7 +3,7 @@ spring:
|
||||
druid:
|
||||
#MySQL
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/admin-template?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://localhost:3306/movies?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: 123456
|
||||
initial-size: 10
|
||||
@ -20,18 +20,18 @@ spring:
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
url-pattern: /druid/*
|
||||
#mybatis
|
||||
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:/mapper/**/*.xml
|
||||
#实体扫描,多个package用逗号或者分号分隔
|
||||
|
||||
typeAliasesPackage: io.modules.*.entity,io.modules.*.entity
|
||||
global-config:
|
||||
#数据库相关配置
|
||||
|
||||
db-config:
|
||||
#主键类型
|
||||
|
||||
id-type: AUTO
|
||||
banner: false
|
||||
#原生配置
|
||||
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
cache-enabled: false
|
||||
|
@ -20,7 +20,7 @@ knife4j:
|
||||
setting:
|
||||
enableFooter: false
|
||||
spring:
|
||||
# 环境 dev|test|prod
|
||||
|
||||
profiles:
|
||||
active: dev
|
||||
messages:
|
||||
@ -37,15 +37,15 @@ spring:
|
||||
#mybatis
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:/mapper/**/*.xml
|
||||
#实体扫描,多个package用逗号或者分号分隔
|
||||
|
||||
typeAliasesPackage: io.modules.*.entity
|
||||
global-config:
|
||||
#数据库相关配置
|
||||
|
||||
db-config:
|
||||
#主键类型
|
||||
|
||||
id-type: AUTO
|
||||
banner: false
|
||||
#原生配置
|
||||
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
cache-enabled: false
|
||||
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.oss.dao.SysOssDao">
|
||||
|
||||
|
||||
</mapper>
|
16
common/src/main/java/io/modules/item/dao/UserDao.java
Normal file
16
common/src/main/java/io/modules/item/dao/UserDao.java
Normal file
@ -0,0 +1,16 @@
|
||||
package io.modules.item.dao;
|
||||
|
||||
import io.common.dao.BaseDao;
|
||||
import io.modules.item.entity.UserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
* @author Mark #
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserDao extends BaseDao<UserEntity> {
|
||||
|
||||
}
|
40
common/src/main/java/io/modules/item/dto/UserDTO.java
Normal file
40
common/src/main/java/io/modules/item/dto/UserDTO.java
Normal file
@ -0,0 +1,40 @@
|
||||
package io.modules.item.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.SchemaProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
* @author Mark #
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@Data
|
||||
@Schema(name = "用户")
|
||||
public class UserDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SchemaProperty(name = "id")
|
||||
private Long id;
|
||||
|
||||
@SchemaProperty(name = "手机号")
|
||||
private String username;
|
||||
|
||||
@SchemaProperty(name = "密码")
|
||||
private String password;
|
||||
|
||||
@SchemaProperty(name = "创建时间")
|
||||
private Date createDate;
|
||||
|
||||
@SchemaProperty(name = "昵称")
|
||||
private String nickName;
|
||||
|
||||
@SchemaProperty(name = "介绍")
|
||||
private String introduce;
|
||||
|
||||
|
||||
}
|
37
common/src/main/java/io/modules/item/entity/UserEntity.java
Normal file
37
common/src/main/java/io/modules/item/entity/UserEntity.java
Normal file
@ -0,0 +1,37 @@
|
||||
package io.modules.item.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
@Data
|
||||
@TableName("tb_user")
|
||||
public class UserEntity {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createDate;
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickName;
|
||||
/**
|
||||
* 介绍
|
||||
*/
|
||||
private String introduce;
|
||||
}
|
@ -2,14 +2,11 @@ package io.modules.item.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 吐槽墙
|
||||
*
|
||||
* @author Mark #
|
||||
* @since 1.0.0 2024-12-12
|
||||
|
||||
*/
|
||||
@Data
|
||||
@TableName("tb_wall")
|
||||
|
@ -0,0 +1,16 @@
|
||||
package io.modules.item.service;
|
||||
|
||||
|
||||
import io.common.service.CrudService;
|
||||
import io.modules.item.dto.UserDTO;
|
||||
import io.modules.item.entity.UserEntity;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
* @author Mark #
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
public interface UserService extends CrudService<UserEntity, UserDTO> {
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package io.modules.item.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.common.service.impl.CrudServiceImpl;
|
||||
import io.modules.item.dao.UserDao;
|
||||
import io.modules.item.dto.UserDTO;
|
||||
import io.modules.item.entity.UserEntity;
|
||||
import io.modules.item.service.UserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
* @author Mark #
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl extends CrudServiceImpl<UserDao, UserEntity, UserDTO> implements UserService {
|
||||
|
||||
@Override
|
||||
public QueryWrapper<UserEntity> getWrapper(Map<String, Object> params){
|
||||
String id = (String)params.get("id");
|
||||
|
||||
QueryWrapper<UserEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq(StrUtil.isNotBlank(id), "id", id);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ spring:
|
||||
datasource:
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/admin-template?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://localhost:3306/movies?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: 123456
|
||||
initial-size: 10
|
||||
|
@ -9,7 +9,7 @@ spring:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
#MySQL配置
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/wenhua?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://localhost:3306/movies?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: 123456
|
||||
#达梦8
|
||||
|
Loading…
Reference in New Issue
Block a user