提交 8174916c authored 作者: YunaiV's avatar YunaiV

精简 system-service-project 项目

上级 b1149279
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>system-service-project</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>system-service-api</artifactId>
<dependencies>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies>
</project>
package cn.iocoder.mall.systemservice.enums;
import cn.iocoder.common.framework.exception.ErrorCode;
/**
* 错误码枚举类
*
* system 系统,使用 1-002-000-000 段
*/
public interface SystemErrorCodeConstants {
// ========== OAUTH2 模块 ==========
ErrorCode OAUTH2_UNKNOWN = new ErrorCode(1001001000, "未知错误"); // 预留
// 预留 1001001001 ~ 1001001099 错误码,方便前端
ErrorCode OAUTH2_ACCESS_TOKEN_NOT_FOUND = new ErrorCode(1001001001, "访问令牌不存在");
ErrorCode OAUTH2_ACCESS_TOKEN_TOKEN_EXPIRED = new ErrorCode(1001001002, "访问令牌已过期");
ErrorCode OAUTH2_ACCESS_TOKEN_INVALID = new ErrorCode(1001001003, "访问令牌已失效");
ErrorCode OAUTH2_REFRESH_TOKEN_NOT_FOUND = new ErrorCode(1001001005, "刷新令牌不存在");
ErrorCode OAUTH_REFRESH_TOKEN_EXPIRED = new ErrorCode(1001001006, "访问令牌已过期");
ErrorCode OAUTH_REFRESH_TOKEN_INVALID = new ErrorCode(1001001007, "刷新令牌已失效");
// 其它 1001001100 开始
ErrorCode OAUTH_USER_TYPE_ERROR = new ErrorCode(1001001101, "用户类型并不正确");
// ========== 管理员模块 1002002000 ==========
ErrorCode ADMIN_NOT_FOUND = new ErrorCode(1002002000, "管理员不存在");
ErrorCode ADMIN_PASSWORD_ERROR = new ErrorCode(1002002001, "密码不正确");
ErrorCode ADMIN_IS_DISABLE = new ErrorCode(1002002002, "账号被禁用");
ErrorCode ADMIN_USERNAME_EXISTS = new ErrorCode(1002002003, "账号已经存在");
ErrorCode ADMIN_STATUS_EQUALS = new ErrorCode(1002002004, "账号已经是该状态");
ErrorCode ADMIN_ADMIN_STATUS_CAN_NOT_UPDATE = new ErrorCode(1002002005, "管理员的账号状态不允许变更");
ErrorCode ADMIN_ASSIGN_ROLE_NOT_EXISTS = new ErrorCode(1002002006, "分配员工角色时,有角色不存在");
ErrorCode ADMIN_ADMIN_CAN_NOT_UPDATE = new ErrorCode(1002002008, "管理员的账号不允许变更");
ErrorCode ADMIN_USERNAME_NOT_EXISTS = new ErrorCode(1002002009, "账号不存在");
// ========== 资源模块 1002003000 ==========
ErrorCode RESOURCE_NAME_DUPLICATE = new ErrorCode(1002003000, "已经存在该名字的资源");
ErrorCode RESOURCE_PARENT_NOT_EXISTS = new ErrorCode(1002003001, "父资源不存在");
ErrorCode RESOURCE_PARENT_ERROR = new ErrorCode(1002003002, "不能设置自己为父资源");
ErrorCode RESOURCE_NOT_EXISTS = new ErrorCode(1002003003, "资源不存在");
ErrorCode RESOURCE_EXISTS_CHILDREN = new ErrorCode(1002003004, "存在子资源,无法删除");
ErrorCode RESOURCE_PARENT_NOT_MENU = new ErrorCode(1002003005, "父资源的类型必须是菜单");
// ========== 角色模块 1002004000 ==========
ErrorCode ROLE_NOT_EXISTS = new ErrorCode(1002004000, "角色不存在");
ErrorCode ROLE_NAME_DUPLICATE = new ErrorCode(1002004001, "已经存在名为【{}}】的角色");
ErrorCode ROLE_CODE_DUPLICATE = new ErrorCode(1002004002, "已经存在编码为【{}}】的角色");
ErrorCode ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE = new ErrorCode(1002004004, "不能修改类型为系统内置的角色");
ErrorCode ROLE_CAN_NOT_DELETE_SYSTEM_TYPE_ROLE = new ErrorCode(1002004005, "不能删除类型为系统内置的角色");
// ========== 数据字典模块 1002005000 ==========
ErrorCode DATA_DICT_EXISTS = new ErrorCode(1002005000, "数据字典已经存在");
ErrorCode DATA_DICT_NOT_EXISTS = new ErrorCode(1002005001, "数据字典不存在");
// ========== 短信模板 1002006000 ==========
ErrorCode SMS_PLATFORM_FAIL = new ErrorCode(1002006000, "短信平台调用失败【具体错误会动态替换】");
ErrorCode SMS_SIGN_NOT_EXISTENT = new ErrorCode(1002006001, "短信签名不存在");
ErrorCode SMS_SIGN_IS_EXISTENT = new ErrorCode(1002006002, "短信签名已存在");
ErrorCode SMS_TEMPLATE_NOT_EXISTENT = new ErrorCode(1002006020, "短信签名不存在");
ErrorCode SMS_TEMPLATE_IS_EXISTENT = new ErrorCode(1002006021, "短信签名不存在");
ErrorCode SMS_NOT_SEND_CLIENT = new ErrorCode(1002006030, "短信没有发送的client");
// ========== 部门模块 1002007000 ==========
ErrorCode DEPARTMENT_NAME_DUPLICATE = new ErrorCode(1002007001, "已经存在该名字的部门");
ErrorCode DEPARTMENT_PARENT_NOT_EXITS = new ErrorCode(1002007002,"父级部门不存在");
ErrorCode DEPARTMENT_NOT_FOUND = new ErrorCode(1002007003, "当前部门不存在");
ErrorCode DEPARTMENT_EXITS_CHILDREN = new ErrorCode(1002007004, "存在子部门,无法删除");
ErrorCode DEPARTMENT_PARENT_ERROR = new ErrorCode(1002007005, "不能设置自己为父资源");
ErrorCode DEPARTMENT_EXISTS_ADMIN = new ErrorCode(1002007006, "部门中存在员工,无法删除");
// ========== 权限模块 1002008000 ==========
ErrorCode PERMISSION_DEMO_PERMISSION_DENY = new ErrorCode(1002008002, "演示账号,暂不允许写操作。欢迎加入我们的交流群:http://t.cn/EKEr5WE");
ErrorCode PERMISSION_ROLE_ASSIGN_RESOURCE_NOT_EXISTS = new ErrorCode(1002008004, "分配角色资源时,有资源不存在");
// ========== 错误码模块 1002009000 ==========
ErrorCode ERROR_CODE_NOT_EXISTS = new ErrorCode(1002009000, "错误码不存在");
ErrorCode ERROR_CODE_DUPLICATE = new ErrorCode(1002009001, "已经存在编码为【{}}】的错误码");
ErrorCode ERROR_CAN_NOT_UPDATE_SYSTEM_TYPE_ERROR = new ErrorCode(1002004003, "不能修改类型为系统内置的错误码");
// ========== 系统异常日志模块 1002010000 ==========
ErrorCode SYSTEM_EXCEPTION_LOG_NOT_FOUND = new ErrorCode(1002010000, "系统异常日志不存在");
ErrorCode SYSTEM_EXCEPTION_LOG_PROCESSED = new ErrorCode(1002010001, "系统异常日志已处理");
}
package cn.iocoder.mall.systemservice.enums.admin;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
* 管理员的状态枚举
*/
public enum AdminStatusEnum implements IntArrayValuable {
ACTIVE(1, "在职"),
INACTIVE(2, "离职");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AdminStatusEnum::getStatus).toArray();
/**
* 在职状态
*/
private final Integer status;
/**
* 描述
*/
private final String name;
AdminStatusEnum(Integer status, String name) {
this.status = status;
this.name = name;
}
public Integer getStatus() {
return status;
}
public String getName() {
return name;
}
@Override
public int[] array() {
return ARRAYS;
}
}
package cn.iocoder.mall.systemservice.enums.admin;
/**
* 管理员的账号枚举,一般枚举特殊的账号
*
* 例如说,特殊管理员 admin 禁止编辑
*/
public enum AdminUsernameEnum {
ADMIN("admin"),
DEMO("yudaoyuanma"),
;
private final String username;
AdminUsernameEnum(String username) {
this.username = username;
}
public String getUsername() {
return username;
}
}
package cn.iocoder.mall.systemservice.enums.admin;
/**
* 部门的编号枚举
*/
public enum DepartmentIdEnum {
/**
* 根节点
*/
ROOT(0);
private final Integer id;
DepartmentIdEnum(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
}
package cn.iocoder.mall.systemservice.enums.errorcode;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
* 错误码的类型枚举
*
* 考虑到便利性,我们会扫描每个项目的错误码枚举类,自动添加到错误码数据库中,并标记为 {@link #AUTO_GENERATION} 类型
* 经过管理员手动编辑过的错误码,会标记为 {@link #MANUAL_OPERATION} 类型,并禁止自动同步
*
* @author ding
*/
public enum ErrorCodeTypeEnum implements IntArrayValuable {
/**
* 自动生成
*/
AUTO_GENERATION(1),
/**
* 手动编辑
*/
MANUAL_OPERATION(2);
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErrorCodeTypeEnum::getType).toArray();
private final Integer type;
ErrorCodeTypeEnum(Integer type) {
this.type = type;
}
public Integer getType() {
return type;
}
@Override
public int[] array() {
return ARRAYS;
}
}
package cn.iocoder.mall.systemservice.enums.permission;
/**
* Resource 编号枚举
*/
public enum ResourceIdEnum {
/**
* 根节点
*/
ROOT(0);
private final Integer id;
ResourceIdEnum(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
}
package cn.iocoder.mall.systemservice.enums.permission;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
* Resource 类型枚举
*/
public enum ResourceTypeEnum implements IntArrayValuable {
MENU(1, "菜单"),
BUTTON(2, "按钮");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ResourceTypeEnum::getType).toArray();
/**
* 资源类型
*/
private final Integer type;
/**
* 资源类型名
*/
private final String name;
ResourceTypeEnum(Integer type, String name) {
this.type = type;
this.name = name;
}
public Integer getType() {
return type;
}
public String getName() {
return name;
}
@Override
public int[] array() {
return ARRAYS;
}
}
package cn.iocoder.mall.systemservice.enums.permission;
public enum RoleCodeEnum {
SUPER_ADMIN("SUPER_ADMIN"), // 超级管理员
;
/**
* 角色编码
*/
private final String code;
RoleCodeEnum(String code) {
this.code = code;
}
public String getCode() {
return code;
}
}
package cn.iocoder.mall.systemservice.enums.permission;
public enum RoleTypeEnum {
/**
* 内置角色
*/
SYSTEM(1),
/**
* 自定义角色
*/
CUSTOM(2);
private final Integer type;
RoleTypeEnum(Integer type) {
this.type = type;
}
public Integer getType() {
return type;
}
}
package cn.iocoder.mall.systemservice.enums.systemlog;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
* 系统异常日志的处理状态枚举
*/
public enum SystemExceptionLogProcessStatusEnum implements IntArrayValuable {
INIT(0, "未处理"),
DONE(1, "已处理"),
IGNORE(2, "已忽略");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(SystemExceptionLogProcessStatusEnum::getStatus).toArray();
/**
* 状态
*/
private final Integer status;
/**
* 资源类型名
*/
private final String name;
SystemExceptionLogProcessStatusEnum(Integer status, String name) {
this.status = status;
this.name = name;
}
public Integer getStatus() {
return status;
}
public String getName() {
return name;
}
@Override
public int[] array() {
return ARRAYS;
}
}
package cn.iocoder.mall.systemservice.rpc.admin;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminCreateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminPageDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminVerifyPasswordDTO;
import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/11
*/
@FeignClient("system-service")
public interface AdminFeign {
@PostMapping("/system/admin/verifyPassword")
public CommonResult<AdminVO> verifyPassword(@RequestBody AdminVerifyPasswordDTO verifyPasswordDTO) ;
@PostMapping("/system/admin/createAdmin")
public CommonResult<Integer> createAdmin(@RequestBody AdminCreateDTO createDTO) ;
@PostMapping("/system/admin/updateAdmin")
public CommonResult<Boolean> updateAdmin(@RequestBody AdminUpdateDTO updateDTO) ;
@PostMapping("/system/admin/pageAdmin")
public CommonResult<PageResult<AdminVO>> pageAdmin(@RequestBody AdminPageDTO pageDTO);
@GetMapping("/system/admin/getAdmin")
public CommonResult<AdminVO> getAdmin(@RequestParam("adminId") Integer adminId) ;
}
package cn.iocoder.mall.systemservice.rpc.admin;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.systemservice.rpc.admin.dto.DepartmentCreateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.DepartmentUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* 部门 Rpc 接口
*/
@FeignClient("system-service")
public interface DepartmentFeign {
@PostMapping("/system/department/createDepartment")
public CommonResult<Integer> createDepartment(@RequestBody DepartmentCreateDTO createDTO) ;
@PostMapping("/system/department/updateDepartment")
public CommonResult<Boolean> updateDepartment(@RequestBody DepartmentUpdateDTO updateDTO);
@GetMapping("/system/department/deleteDepartment")
public CommonResult<Boolean> deleteDepartment(@RequestParam("departmentId")Integer departmentId);
@GetMapping("/system/department/getDepartment")
public CommonResult<DepartmentVO> getDepartment(@RequestParam("departmentId") Integer departmentId) ;
@GetMapping("/system/department/listDepartments")
public CommonResult<List<DepartmentVO>> listDepartments(@RequestParam("departmentIds")Collection<Integer> departmentIds) ;
@GetMapping("/system/department/listAllDepartments")
public CommonResult<List<DepartmentVO>> listDepartments();
}
package cn.iocoder.mall.systemservice.rpc.admin.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
/**
* 管理员添加 BO
*/
@Data
@Accessors(chain = true)
public class AdminCreateDTO implements Serializable {
/**
* 昵称
*/
@NotEmpty(message = "真实名字不能为空")
@Length(max = 10, message = "真实名字长度最大为 10 位")
private String name;
/**
* 部门编号
*/
@NotNull(message = "部门不能为空")
private Integer departmentId;
/**
* 登陆账号
*/
@NotEmpty(message = "登陆账号不能为空")
@Length(min = 5, max = 16, message = "账号长度为 5-16 位")
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
private String username;
/**
* 密码
*/
@NotEmpty(message = "密码不能为空")
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
private String password;
/**
* 创建管理员编号
*/
@NotNull(message = "创建管理员编号不能为空")
private Integer createAdminId;
/**
* 创建 IP
*/
@NotNull(message = "创建 IP 不能为空")
private String createIp;
}
package cn.iocoder.mall.systemservice.rpc.admin.dto;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 管理员分页查询 DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class AdminPageDTO extends PageParam {
/**
* 真实名字,模糊匹配
*/
private String name;
/**
* 部门编号
*/
private Integer departmentId;
}
package cn.iocoder.mall.systemservice.rpc.admin.dto;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
/**
* 管理员修改 DTO
*/
@Data
@Accessors(chain = true)
public class AdminUpdateDTO implements Serializable {
/**
* 管理员编号
*/
@NotNull(message = "管理员编号不能为空")
private Integer id;
/**
* 真实名字
*/
@Length(max = 10, message = "真实名字长度最大为 10 位")
private String name;
/**
* 部门编号
*/
private Integer departmentId;
/**
* 状态
*/
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
/**
* 登录账号
*/
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
private String username;
/**
* 密码
*/
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
private String password;
}
package cn.iocoder.mall.systemservice.rpc.admin.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
/**
* 管理员校验密码 DTO
*/
@Data
@Accessors(chain = true)
public class AdminVerifyPasswordDTO implements Serializable {
/**
* 用户名
*/
@NotEmpty(message = "登陆账号不能为空")
@Length(min = 5, max = 16, message = "账号长度为 5-16 位")
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
private String username;
/**
* 密码
*/
@NotEmpty(message = "密码不能为空")
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
private String password;
/**
* IP
*/
@NotEmpty(message = "IP 不能为空")
private String ip;
}
package cn.iocoder.mall.systemservice.rpc.admin.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 部门创建 DTO
*/
@Data
@Accessors(chain = true)
public class DepartmentCreateDTO implements Serializable {
/**
* 部门名称
*/
@NotEmpty(message = "部门名称不能为空")
private String name;
/**
* 排序字段
*/
@NotNull(message = "排序字段不能为空")
private Integer sort;
/**
* 父级部门编号
*/
@NotNull(message = "父级部门编号不能为空")
private Integer pid;
}
package cn.iocoder.mall.systemservice.rpc.admin.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 部门更新 DTO
*/
@Data
@Accessors(chain = true)
public class DepartmentUpdateDTO implements Serializable {
/**
* 部门编号
*/
@NotNull(message = "部门编号不能为空")
private Integer id;
/**
* 部门名称
*/
@NotEmpty(message = "部门名称不能为空")
private String name;
/**
* 排序字段
*/
@NotNull(message = "排序字段不能为空")
private Integer sort;
/**
* 父级部门编号
*/
@NotNull(message = "父级部门编号不能为空")
private Integer pid;
}
package cn.iocoder.mall.systemservice.rpc.admin.vo;
import cn.iocoder.mall.systemservice.enums.admin.AdminStatusEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 管理员 DO
*/
@Data
@Accessors(chain = true)
public class AdminVO implements Serializable {
/**
* 管理员编号
*/
private Integer id;
/**
* 真实名字
*/
private String name;
/**
* 部门编号
*/
private Integer departmentId;
/**
* 在职状态
*
* 枚举 {@link AdminStatusEnum}
*/
private Integer status;
/**
* 登陆账号
*/
private String username;
/**
* 创建时间
*/
private Date createTime;
}
package cn.iocoder.mall.systemservice.rpc.admin.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 部门 VO
*/
@Data
@Accessors(chain = true)
public class DepartmentVO implements Serializable {
/**
* 部门编号
*/
private Integer id;
/**
* 部门名称
*/
private String name;
/**
* 排序字段
*/
private Integer sort;
/**
* 父级部门编号
*/
private Integer pid;
/**
* 创建时间
*/
private Date createTime;
}
package cn.iocoder.mall.systemservice.rpc.datadict;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.systemservice.rpc.admin.dto.DepartmentCreateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.DepartmentUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO;
import cn.iocoder.mall.systemservice.rpc.datadict.dto.DataDictCreateDTO;
import cn.iocoder.mall.systemservice.rpc.datadict.dto.DataDictUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* 部门 Rpc 接口
*/
@FeignClient("system-service")
public interface DataDictFeign {
@PostMapping("/system/datadict/createDataDict")
public CommonResult<Integer> createDataDict(@RequestBody DataDictCreateDTO createDTO) ;
@PostMapping("/system/datadict/updateDataDict")
public CommonResult<Boolean> updateDataDict(@RequestBody DataDictUpdateDTO updateDTO);
@GetMapping("/system/datadict/deleteDataDict")
public CommonResult<Boolean> deleteDataDict(@RequestParam("dataDictId") Integer dataDictId);
@GetMapping("/system/datadict/getDataDict")
public CommonResult<DataDictVO> getDataDict(@RequestParam("dataDictId") Integer dataDictId);
@GetMapping("/system/datadict/listAllDataDicts")
public CommonResult<List<DataDictVO>> listDataDicts() ;
@GetMapping("/system/datadict/listDataDicts")
public CommonResult<List<DataDictVO>> listDataDicts(@RequestParam("dataDictIds") List<Integer> dataDictIds);
}
package cn.iocoder.mall.systemservice.rpc.datadict.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 数据字典创建 DTO
*/
@Data
@Accessors(chain = true)
public class DataDictCreateDTO implements Serializable {
/**
* 大类枚举值
*/
@NotEmpty(message = "大类枚举值不能为空")
private String enumValue;
/**
* 小类数值
*/
@NotEmpty(message = "小类数值不能为空")
private String value;
/**
* 展示名
*/
@NotEmpty(message = "展示名不能为空")
private String displayName;
/**
* 排序值
*/
@NotNull(message = "排序值不能为空")
private Integer sort;
/**
* 备注
*/
private String memo;
}
package cn.iocoder.mall.systemservice.rpc.datadict.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 数据字典更新 DTO
*/
@Data
@Accessors(chain = true)
public class DataDictUpdateDTO implements Serializable {
/**
* 编号
*/
@NotNull(message = "编号不能为空")
private Integer id;
/**
* 大类枚举值
*/
@NotEmpty(message = "大类枚举值不能为空")
private String enumValue;
/**
* 小类数值
*/
@NotEmpty(message = "小类数值不能为空")
private String value;
/**
* 展示名
*/
@NotEmpty(message = "展示名不能为空")
private String displayName;
/**
* 排序值
*/
@NotNull(message = "排序值不能为空")
private Integer sort;
/**
* 备注
*/
private String memo;
}
package cn.iocoder.mall.systemservice.rpc.datadict.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 数据字典 VO
*/
@Data
@Accessors(chain = true)
public class DataDictVO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 大类枚举值
*/
private String enumValue;
/**
* 小类数值
*/
private String value;
/**
* 展示名
*/
private String displayName;
/**
* 排序值
*/
private Integer sort;
/**
* 备注
*/
private String memo;
/**
* 创建时间
*/
private Date createTime;
}
package cn.iocoder.mall.systemservice.rpc.oauth;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 部门 Rpc 接口
*/
@FeignClient(value = "system-service")
public interface OAuthFeign {
@PostMapping("/system/oauth/createAccessToken")
public CommonResult<OAuth2AccessTokenRespDTO> createAccessToken(@RequestBody OAuth2CreateAccessTokenReqDTO createAccessTokenDTO);
@GetMapping("/system/oauth/checkAccessToken")
public CommonResult<OAuth2AccessTokenRespDTO> checkAccessToken(@RequestParam("accessToken") String accessToken) ;
@PostMapping("/system/oauth/refreshAccessToken")
public CommonResult<OAuth2AccessTokenRespDTO> refreshAccessToken(@RequestBody OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO);
@PostMapping("/system/oauth/removeToken")
public CommonResult<Boolean> removeToken(@RequestBody OAuth2RemoveTokenByUserReqDTO removeTokenDTO);
}
package cn.iocoder.mall.systemservice.rpc.oauth.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* OAuth2.0 访问令牌 Response DTO
*/
@Data
@Accessors(chain = true)
public class OAuth2AccessTokenRespDTO implements Serializable {
/**
* 访问令牌
*/
private String accessToken;
/**
* 刷新令牌
*/
private String refreshToken;
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*/
private Integer userType;
/**
* 过期时间
*/
private Date expiresTime;
}
package cn.iocoder.mall.systemservice.rpc.oauth.dto;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* OAuth2.0 访问令牌创建 Request DTO
*/
@Data
@Accessors(chain = true)
public class OAuth2CreateAccessTokenReqDTO implements Serializable {
/**
* 用户编号
*/
@NotNull(message = "用户编号不能为空")
private Integer userId;
/**
* 用户类型
*/
@NotNull(message = "用户类型不能为空")
@InEnum(value = UserTypeEnum.class, message = "用户类型必须是 {value}")
private Integer userType;
/**
* 创建 IP
*/
private String createIp;
}
package cn.iocoder.mall.systemservice.rpc.oauth.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* OAuth2.0 访问令牌创建 Request DTO
*/
@Data
@Accessors(chain = true)
public class OAuth2RefreshAccessTokenReqDTO implements Serializable {
/**
* 刷新令牌
*/
private String refreshToken;
/**
* 创建 IP
*/
private String createIp;
}
package cn.iocoder.mall.systemservice.rpc.oauth.dto;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* OAuth2.0 移除用户令牌 Request DTO
*
* 包括访问令牌和刷新令牌
*/
@Data
@Accessors(chain = true)
public class OAuth2RemoveTokenByUserReqDTO implements Serializable {
/**
* 用户编号
*/
@NotNull(message = "用户编号不能为空")
private Integer userId;
/**
* 用户类型
*/
@NotNull(message = "用户类型不能为空")
@InEnum(value = UserTypeEnum.class, message = "用户类型必须是 {value}")
private Integer userType;
}
package cn.iocoder.mall.systemservice.rpc.permission;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.systemservice.rpc.permission.dto.PermissionAssignAdminRoleDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.PermissionAssignRoleResourceDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.PermissionCheckDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
/**
*/
@FeignClient("system-service")
public interface PermissionFeign {
@GetMapping("/system/permission/listRoleResourceIds")
public CommonResult<Set<Integer>> listRoleResourceIds(@RequestParam("roleId")Integer roleId) ;
@PostMapping("/system/permission/assignRoleResource")
public CommonResult<Boolean> assignRoleResource(@RequestBody PermissionAssignRoleResourceDTO assignRoleResourceDTO);
@GetMapping("/system/permission/listAdminRoleIds")
public CommonResult<Set<Integer>> listAdminRoleIds(@RequestParam("adminId")Integer adminId);
@GetMapping("/system/permission/mapAdminRoleIds")
public CommonResult<Map<Integer, Set<Integer>>> mapAdminRoleIds(@RequestParam("adminIds") Collection<Integer> adminIds);
@PostMapping("/system/permission/assignAdminRole")
public CommonResult<Boolean> assignAdminRole(@RequestBody PermissionAssignAdminRoleDTO assignAdminRoleDTO);
@PostMapping("/system/permission/checkPermission")
public CommonResult<Boolean> checkPermission(@RequestBody PermissionCheckDTO checkDTO) ;
}
package cn.iocoder.mall.systemservice.rpc.permission;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.systemservice.rpc.permission.dto.ResourceCreateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.ResourceUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
import java.util.List;
/**
* 部门 Rpc 接口
*/
@FeignClient("system-service")
public interface ResourceFeign {
@PostMapping("/system/resource/createResource")
public CommonResult<Integer> createResource(@RequestBody ResourceCreateDTO createDTO);
@PostMapping("/system/resource/updateResource")
public CommonResult<Boolean> updateResource(@RequestBody ResourceUpdateDTO updateDTO);
@GetMapping("/system/resource/deleteResource")
public CommonResult<Boolean> deleteResource(@RequestParam("resourceId") Integer resourceId) ;
@GetMapping("/system/resource/getResource")
public CommonResult<ResourceVO> getResource(@RequestParam("resourceId") Integer resourceId);
@GetMapping("/system/resource/listAllResource")
public CommonResult<List<ResourceVO>> listResource() ;
@GetMapping("/system/resource/listResource")
public CommonResult<List<ResourceVO>> listResource(@RequestParam("resourceIds") List<Integer> resourceIds);
@GetMapping("/system/resource/listRoleResource")
public CommonResult<List<ResourceVO>> listRoleResource(@RequestParam("roleIds") Collection<Integer> roleIds, @RequestParam("type") Integer type) ;
}
package cn.iocoder.mall.systemservice.rpc.permission;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.rpc.permission.dto.ResourceCreateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.ResourceUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.RolePageDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.RoleUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO;
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleCreateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
* 部门 Rpc 接口
*/
@FeignClient("system-service")
public interface RoleFeign {
@PostMapping("/system/role/createRole")
public CommonResult<Integer> createRole(@RequestBody RoleCreateDTO createDTO) ;
@PostMapping("/system/role/updateRole")
public CommonResult<Boolean> updateRole(@RequestBody RoleUpdateDTO updateDTO);
@GetMapping("/system/role/deleteRole")
public CommonResult<Boolean> deleteRole(@RequestParam("roleId")Integer roleId) ;
@GetMapping("/system/role/getRole")
public CommonResult<RoleVO> getRole(@RequestParam("roleId")Integer roleId);
@GetMapping("/system/role/listAllRoles")
public CommonResult<List<RoleVO>> listAllRoles() ;
@GetMapping("/system/role/listRoles")
public CommonResult<List<RoleVO>> listRoles(@RequestParam("roleIds")Collection<Integer> roleIds) ;
@PostMapping("/system/role/pageRole")
public CommonResult<PageResult<RoleVO>> pageRole(@RequestBody RolePageDTO pageDTO);
@GetMapping("/system/role/listAdminRoleIds")
public CommonResult<Set<Integer>> listAdminRoleIds(@RequestParam("adminId") Integer adminId) ;
}
package cn.iocoder.mall.systemservice.rpc.permission.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Set;
/**
* 赋予管理员角色 DTO
*/
@Data
@Accessors(chain = true)
public class PermissionAssignAdminRoleDTO implements Serializable {
/**
* 管理员编号
*/
@NotNull(message = "管理员编号不能为空")
private Integer adminId;
/**
* 角色编号列表
*/
private Set<Integer> roleIds;
}
package cn.iocoder.mall.systemservice.rpc.permission.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Set;
/**
* 赋予角色资源 DTO
*/
@Data
@Accessors(chain = true)
public class PermissionAssignRoleResourceDTO implements Serializable {
/**
* 角色编号
*/
@NotNull(message = "角色编号不能为空")
private Integer roleId;
/**
* 资源编号列表
*/
private Set<Integer> resourceIds;
}
package cn.iocoder.mall.systemservice.rpc.permission.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Collection;
/**
* 权限校验 DTO
*/
@Data
@Accessors(chain = true)
public class PermissionCheckDTO implements Serializable {
@NotNull(message = "管理员编号不能为空")
private Integer adminId;
@NotNull(message = "权限不能为空")
private Collection<String> permissions;
}
package cn.iocoder.mall.systemservice.rpc.permission.dto;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 资源创建 DTO
*/
@Data
@Accessors(chain = true)
public class ResourceCreateDTO implements Serializable {
/**
* 菜单名
*/
@NotEmpty(message = "菜单名不能为空")
private String name;
/**
* 权限标识
*/
private String permission;
/**
* 资源类型
*/
@NotNull(message = "资源类型不能为空")
@InEnum(value = ResourceTypeEnum.class, message = "资源类型必须是 {value}")
private Integer type;
/**
* 排序
*/
@NotNull(message = "排序不能为空")
private Integer sort;
/**
* 父级资源编号
*/
@NotNull(message = "父级资源编号不能为空")
private Integer pid;
/**
* 前端路由
*/
private String route;
/**
* 菜单图标
*/
private String icon;
/**
* 前端界面
*/
private String view;
/**
* 创建管理员编号
*/
@NotNull(message = "创建管理员编号不能为空")
private Integer createAdminId;
}
package cn.iocoder.mall.systemservice.rpc.permission.dto;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 资源更新 DTO
*/
@Data
@Accessors(chain = true)
public class ResourceUpdateDTO implements Serializable {
/**
* 资源编号
*/
@NotNull(message = "资源编号不能为空")
private Integer id;
/**
* 菜单名
*/
@NotEmpty(message = "菜单名不能为空")
private String name;
/**
* 权限标识
*/
private String permission;
/**
* 资源类型
*/
@NotNull(message = "资源类型不能为空")
@InEnum(value = ResourceTypeEnum.class, message = "资源类型必须是 {value}")
private Integer type;
/**
* 排序
*/
@NotNull(message = "排序不能为空")
private Integer sort;
/**
* 父级资源编号
*/
@NotNull(message = "父级资源编号不能为空")
private Integer pid;
/**
* 前端路由
*/
private String route;
/**
* 菜单图标
*/
private String icon;
/**
* 前端界面
*/
private String view;
}
package cn.iocoder.mall.systemservice.rpc.permission.dto;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 角色分页 DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class RolePageDTO extends PageParam {
/**
* 角色名
*/
private String name;
}
package cn.iocoder.mall.systemservice.rpc.permission.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 角色更新 DTO
*/
@Data
@Accessors(chain = true)
public class RoleUpdateDTO implements Serializable {
/**
* 角色编号
*/
@NotNull(message = "角色编号不能为空")
private Integer id;
/**
* 角色名
*/
@NotEmpty(message = "角色名不能为空")
private String name;
/**
* 角色编码
*/
private String code;
}
package cn.iocoder.mall.systemservice.rpc.permission.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 资源 VO
*/
@Data
@Accessors(chain = true)
public class ResourceVO implements Serializable {
/**
* 资源编号
*/
private Integer id;
/**
* 菜单名
*/
private String name;
/**
* 权限标识
*/
private String permission;
/**
* 资源类型
*/
private Integer type;
/**
* 排序
*/
private Integer sort;
/**
* 父级资源编号
*/
private Integer pid;
/**
* 前端路由
*/
private String route;
/**
* 菜单图标
*/
private String icon;
/**
* 前端界面
*/
private String view;
/**
* 添加时间
*/
private Date createTime;
}
package cn.iocoder.mall.systemservice.rpc.permission.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 角色创建 DTO
*/
@Data
@Accessors(chain = true)
public class RoleCreateDTO implements Serializable {
/**
* 角色名
*/
@NotEmpty(message = "角色名不能为空")
private String name;
/**
* 角色编码
*/
private String code;
/**
* 创建管理员编号
*/
@NotNull(message = "创建管理员编号不能为空")
private Integer createAdminId;
}
package cn.iocoder.mall.systemservice.rpc.permission.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 角色 VO
*/
@Data
@Accessors(chain = true)
public class RoleVO implements Serializable {
/**
* 角色编号
*/
private Integer id;
/**
* 角色名
*/
private String name;
/**
* 角色编码
*/
private String code;
/**
* 角色类型
*/
private Integer type;
/**
* 创建管理员编号
*/
private Integer createAdminId;
/**
* 创建时间
*/
private Date createTime;
/**
* 最后更新时间
*/
private Date updateTime;
}
package cn.iocoder.mall.systemservice.rpc.systemlog;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* 部门 Rpc 接口
*/
@FeignClient("system-service")
public interface SystemAccessLogFeign {
@PostMapping("/system/accesslog/createSystemAccessLog")
public CommonResult<Boolean> createSystemAccessLog(@RequestBody SystemAccessLogCreateDTO createDTO);
@PostMapping("/system/accesslog/pageSystemAccessLog")
public CommonResult<PageResult<SystemAccessLogVO>> pageSystemAccessLog(@RequestBody SystemAccessLogPageDTO pageDTO);
}
\ No newline at end of file
package cn.iocoder.mall.systemservice.rpc.systemlog;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogPageDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogProcessDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemExceptionLogVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 部门 Rpc 接口
*/
@FeignClient("system-service")
public interface SystemExceptionLogFeign {
@PostMapping("/system/exceptionlog/createSystemExceptionLog")
public CommonResult<Boolean> createSystemExceptionLog(@RequestBody SystemExceptionLogCreateDTO createDTO);
@GetMapping("/system/exceptionlog/getSystemExceptionLog")
public CommonResult<SystemExceptionLogVO> getSystemExceptionLog(@RequestParam("systemExceptionLogId") Integer systemExceptionLogId);
@PostMapping("/system/exceptionlog/pageSystemExceptionLog")
public CommonResult<PageResult<SystemExceptionLogVO>> pageSystemExceptionLog(@RequestBody SystemExceptionLogPageDTO pageDTO) ;
@PostMapping("/system/exceptionlog/processSystemExceptionLog")
public CommonResult<Boolean> processSystemExceptionLog(@RequestBody SystemExceptionLogProcessDTO processDTO) ;
}
\ No newline at end of file
package cn.iocoder.mall.systemservice.rpc.systemlog.dto;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* 系统访问日志添加 DTO
*/
@Data
@Accessors(chain = true)
public class SystemAccessLogCreateDTO implements Serializable {
/**
* 账号编号
*/
private Integer userId;
/**
* 用户类型
*
* 枚举 {@link UserTypeEnum}
*/
private Integer userType;
/**
* 链路编号
*/
private String traceId;
@NotNull(message = "应用名不能为空")
private String applicationName;
@NotNull(message = "访问地址不能为空")
private String uri;
@NotNull(message = "请求参数不能为空")
private String queryString;
@NotNull(message = "http 请求方法不能为空")
private String method;
@NotNull(message = "User-Agent 不能为空")
private String userAgent;
@NotNull(message = "ip 不能为空")
private String ip;
@NotNull(message = "请求时间不能为空")
private Date startTime;
@NotNull(message = "响应时长不能为空")
private Integer responseTime;
@NotNull(message = "错误码不能为空")
private Integer errorCode;
/**
* 错误提示
*/
private String errorMessage;
}
package cn.iocoder.mall.systemservice.rpc.systemlog.dto;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* 系统异常日志添加 DTO
*/
@Data
@Accessors(chain = true)
public class SystemExceptionLogCreateDTO implements Serializable {
/**
* 账号编号
*/
private Integer userId;
/**
* 用户类型
*
* 枚举 {@link UserTypeEnum}
*/
private Integer userType;
/**
* 链路编号
*/
private String traceId;
@NotNull(message = "应用名不能为空")
private String applicationName;
@NotNull(message = "访问地址不能为空")
private String uri;
@NotNull(message = "请求参数不能为空")
private String queryString;
@NotNull(message = "http 请求方法不能为空")
private String method;
@NotNull(message = "User-Agent 不能为空")
private String userAgent;
@NotNull(message = "ip 不能为空")
private String ip;
@NotNull(message = "异常时间不能为空")
private Date exceptionTime;
@NotNull(message = "异常名不能为空")
private String exceptionName;
@NotNull(message = "异常发生的类全名不能为空")
private String exceptionClassName;
@NotNull(message = "异常发生的类文件不能为空")
private String exceptionFileName;
@NotNull(message = "异常发生的方法名不能为空")
private String exceptionMethodName;
@NotNull(message = "异常发生的方法所在行不能为空")
private Integer exceptionLineNumber;
@NotNull(message = "异常的栈轨迹不能为空")
private String exceptionStackTrace;
@NotNull(message = "异常导致的根消息不能为空")
private String exceptionRootCauseMessage;
@NotNull(message = "异常导致的消息不能为空")
private String exceptionMessage;
}
package cn.iocoder.mall.systemservice.rpc.systemlog.dto;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 系统异常日志分页 DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SystemExceptionLogPageDTO extends PageParam {
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*/
private Integer userType;
/**
* 应用名
*
* 目前读取 spring.application.name
*/
private String applicationName;
/**
* 处理状态
*/
private Integer processStatus;
}
package cn.iocoder.mall.systemservice.rpc.systemlog.dto;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.common.framework.vo.PageParam;
import cn.iocoder.mall.systemservice.enums.systemlog.SystemExceptionLogProcessStatusEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* 系统异常日志处理 DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SystemExceptionLogProcessDTO extends PageParam {
/**
* 系统异常日志编号
*/
@NotNull(message = "系统异常日志编号不能为空")
private Integer logId;
/**
* 处理状态
*/
@NotNull(message = "处理状态不能为空")
@InEnum(value = SystemExceptionLogProcessStatusEnum.class, message = "处理状态必须是 {value}")
private Integer processStatus;
/**
* 处理管理员编号
*/
@NotNull(message = "处理管理员编号不能为空")
private Integer processAdminId;
}
package cn.iocoder.mall.systemservice.rpc.systemlog.vo;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 系统访问日志分页 DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SystemAccessLogPageDTO extends PageParam {
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*/
private Integer userType;
/**
* 应用名
*/
private String applicationName;
}
package cn.iocoder.mall.systemservice.rpc.systemlog.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 系统访问日志 VO
*/
@Data
@Accessors(chain = true)
public class SystemAccessLogVO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*/
private Integer userType;
/**
* 链路追踪编号
*/
private String traceId;
/**
* 应用名
*/
private String applicationName;
/**
* 访问地址
*/
private String uri;
/**
* 参数
*/
private String queryString;
/**
* http 方法
*/
private String method;
/**
* userAgent
*/
private String userAgent;
/**
* ip
*/
private String ip;
/**
* 请求时间
*/
private Date startTime;
/**
* 响应时长 -- 毫秒级
*/
private Integer responseTime;
/**
* 错误码
*/
private Integer errorCode;
/**
* 错误提示
*/
private String errorMessage;
}
package cn.iocoder.mall.systemservice.rpc.systemlog.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 系统异常日志 VO
*/
@Data
@Accessors(chain = true)
public class SystemExceptionLogVO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*/
private Integer userType;
/**
* 链路追踪编号
*
* 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。
*/
private String traceId;
/**
* 应用名
*
* 目前读取 spring.application.name
*/
private String applicationName;
/**
* 访问地址
*/
private String uri;
/**
* 参数
*/
private String queryString;
/**
* http 方法
*/
private String method;
/**
* userAgent
*/
private String userAgent;
/**
* ip
*/
private String ip;
/**
* 异常发生时间
*/
private Date exceptionTime;
/**
* 异常名
*
* {@link Throwable#getClass()} 的类全名
*/
private String exceptionName;
/**
* 异常导致的消息
*
* {@link cn.iocoder.common.framework.util.ExceptionUtil#getMessage(Throwable)}
*/
private String exceptionMessage;
/**
* 异常导致的根消息
*
* {@link cn.iocoder.common.framework.util.ExceptionUtil#getRootCauseMessage(Throwable)}
*/
private String exceptionRootCauseMessage;
/**
* 异常的栈轨迹
*
* {@link cn.iocoder.common.framework.util.ExceptionUtil#getServiceException(Exception)}
*/
private String exceptionStackTrace;
/**
* 异常发生的类全名
*
* {@link StackTraceElement#getClassName()}
*/
private String exceptionClassName;
/**
* 异常发生的类文件
*
* {@link StackTraceElement#getFileName()}
*/
private String exceptionFileName;
/**
* 异常发生的方法名
*
* {@link StackTraceElement#getMethodName()}
*/
private String exceptionMethodName;
/**
* 异常发生的方法所在行
*
* {@link StackTraceElement#getLineNumber()}
*/
private Integer exceptionLineNumber;
/**
* 处理状态
*/
private Integer processStatus;
/**
* 处理时间
*/
private Date processTime;
/**
* 处理管理员编号
*/
private Integer processAdminId;
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>system-service-project</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>system-service-app</artifactId>
<dependencies>
<!-- RPC 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-dubbo</artifactId>
</dependency>
<dependency>
<!-- 系统服务 -->
<groupId>cn.iocoder.mall</groupId>
<artifactId>system-service-api</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-system-error-code</artifactId> <!-- 错误码 -->
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <!-- 需要开启 Web 容器,因为 Actuator 需要使用到 -->
</dependency>
<!-- Registry 和 Config 相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-redis</artifactId>
</dependency>
<!-- 监控相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher -->
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
</dependency>
</dependencies>
<build>
<!-- 设置构建的 jar 包名 -->
<finalName>${project.artifactId}</finalName>
<!-- 使用 spring-boot-maven-plugin 插件打包 -->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package cn.iocoder.mall.systemservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.iocoder.mall.systemservice.rpc"})
public class SystemServiceApplication {
public static void main(String[] args) {
SpringApplication.run(SystemServiceApplication.class, args);
}
}
package cn.iocoder.mall.systemservice.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
@Configuration
@EnableAsync(proxyTargetClass = true) // 开启 Spring Async 异步的功能
public class AsyncConfiguration {
}
package cn.iocoder.mall.systemservice.config;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@MapperScan("cn.iocoder.mall.systemservice.dal.mysql.mapper") // 扫描对应的 Mapper 接口
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。
public class DatabaseConfiguration {
// 数据库连接池 Druid
@Bean
public ISqlInjector sqlInjector() {
return new DefaultSqlInjector(); // MyBatis Plus 逻辑删除
}
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor(); // MyBatis Plus 分页插件
}
}
package cn.iocoder.mall.systemservice.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
/**
* 系统服务的业务配置项
*/
@Component
@ConfigurationProperties("biz")
@Validated
@Data
public class SystemBizProperties {
/**
* 访问令牌过期时间,单位:毫秒
*/
@NotNull(message = "访问令牌过期时间不能为空")
private int accessTokenExpireTimeMillis;
/**
* 刷新令牌过期时间,单位:毫秒
*/
@NotNull(message = "刷新令牌过期时间不能为空")
private int refreshTokenExpireTimeMillis;
}
package cn.iocoder.mall.systemservice.convert.admin;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.AdminDO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminCreateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminPageDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminBO;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminCreateBO;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminPageBO;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminUpdateBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
@Mapper
public interface AdminConvert {
AdminConvert INSTANCE = Mappers.getMapper(AdminConvert.class);
AdminBO convert(AdminDO bean);
AdminVO convert(AdminBO bean);
AdminDO convert(AdminCreateBO bean);
AdminDO convert(AdminUpdateBO bean);
AdminCreateBO convert(AdminCreateDTO bean);
AdminUpdateBO convert(AdminUpdateDTO bean);
@Mapping(source = "records", target = "list")
PageResult<AdminBO> convertPage(IPage<AdminDO> page);
AdminPageBO convert(AdminPageDTO page);
PageResult<AdminVO> convert(PageResult<AdminBO> adminPage);
}
package cn.iocoder.mall.systemservice.convert.admin;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.DepartmentDO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.DepartmentCreateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.DepartmentUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO;
import cn.iocoder.mall.systemservice.service.admin.bo.DepartmentBO;
import cn.iocoder.mall.systemservice.service.admin.bo.DepartmentCreateBO;
import cn.iocoder.mall.systemservice.service.admin.bo.DepartmentUpdateBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface DepartmentConvert {
DepartmentConvert INSTANCE = Mappers.getMapper(DepartmentConvert.class);
DepartmentDO convert(DepartmentCreateBO bean);
DepartmentBO convert(DepartmentDO bean);
DepartmentDO convert(DepartmentUpdateBO bean);
DepartmentUpdateBO convert(DepartmentUpdateDTO bean);
DepartmentCreateBO convert(DepartmentCreateDTO bean);
DepartmentVO convert(DepartmentBO bean);
List<DepartmentBO> convertList(List<DepartmentDO> list);
List<DepartmentVO> convertList02(List<DepartmentBO> list);
}
package cn.iocoder.mall.systemservice.convert.datadict;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.datadict.DataDictDO;
import cn.iocoder.mall.systemservice.rpc.datadict.dto.DataDictCreateDTO;
import cn.iocoder.mall.systemservice.rpc.datadict.dto.DataDictUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO;
import cn.iocoder.mall.systemservice.service.datadict.bo.DataDictBO;
import cn.iocoder.mall.systemservice.service.datadict.bo.DataDictCreateBO;
import cn.iocoder.mall.systemservice.service.datadict.bo.DataDictUpdateBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface DataDictConvert {
DataDictConvert INSTANCE = Mappers.getMapper(DataDictConvert.class);
DataDictDO convert(DataDictCreateBO bean);
DataDictBO convert(DataDictDO bean);
DataDictDO convert(DataDictUpdateBO bean);
List<DataDictBO> convertList(List<DataDictDO> list);
DataDictCreateBO convert(DataDictCreateDTO bean);
DataDictUpdateBO convert(DataDictUpdateDTO bean);
DataDictVO convert(DataDictBO bean);
List<DataDictVO> convertList02(List<DataDictBO> list);
}
package cn.iocoder.mall.systemservice.convert.errorcode;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.errorcode.ErrorCodeDO;
import cn.iocoder.mall.systemservice.rpc.errorcode.dto.ErrorCodeAutoGenerateDTO;
import cn.iocoder.mall.systemservice.rpc.errorcode.dto.ErrorCodeCreateDTO;
import cn.iocoder.mall.systemservice.rpc.errorcode.dto.ErrorCodePageDTO;
import cn.iocoder.mall.systemservice.rpc.errorcode.dto.ErrorCodeUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.errorcode.vo.ErrorCodeVO;
import cn.iocoder.mall.systemservice.service.errorcode.bo.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface ErrorCodeConvert {
ErrorCodeConvert INSTANCE = Mappers.getMapper(ErrorCodeConvert.class);
ErrorCodeDO convert(ErrorCodeCreateBO bean);
ErrorCodeBO convert(ErrorCodeDO bean);
List<ErrorCodeBO> convertList(List<ErrorCodeDO> list);
@Mapping(source = "records", target = "list")
PageResult<ErrorCodeBO> convertPage(IPage<ErrorCodeDO> page);
ErrorCodeDO convert(ErrorCodeUpdateBO bean);
ErrorCodeCreateBO convert(ErrorCodeCreateDTO bean);
ErrorCodeUpdateBO convert(ErrorCodeUpdateDTO bean);
ErrorCodeVO convert(ErrorCodeBO bean);
List<ErrorCodeVO> convertList02(List<ErrorCodeBO> list);
PageResult<ErrorCodeVO> convertPage(PageResult<ErrorCodeBO> page);
ErrorCodePageBO convert(ErrorCodePageDTO bean);
ErrorCodeDO convert(ErrorCodeAutoGenerateBO bean);
List<ErrorCodeAutoGenerateBO> convertList03(List<ErrorCodeAutoGenerateDTO> list);
}
package cn.iocoder.mall.systemservice.convert.oauth;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
@Mapper
public interface OAuth2Convert {
OAuth2Convert INSTANCE = Mappers.getMapper(OAuth2Convert.class);
@Mapping(source = "id", target = "accessToken")
OAuth2AccessTokenRespDTO convert(OAuth2AccessTokenDO bean);
}
package cn.iocoder.mall.systemservice.convert.permission;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.ResourceDO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.ResourceCreateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.ResourceUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO;
import cn.iocoder.mall.systemservice.service.permission.bo.ResourceBO;
import cn.iocoder.mall.systemservice.service.permission.bo.ResourceCreateBO;
import cn.iocoder.mall.systemservice.service.permission.bo.ResourceUpdateBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface ResourceConvert {
ResourceConvert INSTANCE = Mappers.getMapper(ResourceConvert.class);
ResourceDO convert(ResourceCreateBO bean);
ResourceBO convert(ResourceDO bean);
ResourceDO convert(ResourceUpdateBO bean);
ResourceCreateBO convert(ResourceCreateDTO bean);
ResourceVO convert(ResourceBO bean);
ResourceUpdateBO convert(ResourceUpdateDTO bean);
List<ResourceBO> convertList(List<ResourceDO> list);
List<ResourceVO> convertList02(List<ResourceBO> list);
}
package cn.iocoder.mall.systemservice.convert.permission;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.RoleDO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.RolePageDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.RoleUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleCreateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO;
import cn.iocoder.mall.systemservice.service.permission.bo.RoleBO;
import cn.iocoder.mall.systemservice.service.permission.bo.RoleCreateBO;
import cn.iocoder.mall.systemservice.service.permission.bo.RolePageBO;
import cn.iocoder.mall.systemservice.service.permission.bo.RoleUpdateBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface RoleConvert {
RoleConvert INSTANCE = Mappers.getMapper(RoleConvert.class);
RoleDO convert(RoleCreateBO bean);
RoleBO convert(RoleDO bean);
RoleDO convert(RoleUpdateBO bean);
RoleCreateBO convert(RoleCreateDTO bean);
RoleUpdateBO convert(RoleUpdateDTO bean);
RolePageBO convert(RolePageDTO bean);
RoleVO convert(RoleBO bean);
List<RoleBO> convertList(List<RoleDO> list);
List<RoleVO> convertList02(List<RoleBO> list);
@Mapping(source = "records", target = "list")
PageResult<RoleBO> convertPage(IPage<RoleDO> page);
PageResult<RoleVO> convertPage(PageResult<RoleBO> page);
}
package cn.iocoder.mall.systemservice.convert.systemlog;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemAccessLogDO;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogBO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogCreateBO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogPageBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SystemAccessLogConvert {
SystemAccessLogConvert INSTANCE = Mappers.getMapper(SystemAccessLogConvert.class);
SystemAccessLogDO convert(SystemAccessLogCreateBO bean);
SystemAccessLogCreateBO convert(SystemAccessLogCreateDTO bean);
@Mapping(source = "records", target = "list")
PageResult<SystemAccessLogBO> convertPage(IPage<SystemAccessLogDO> page);
SystemAccessLogPageBO convert(SystemAccessLogPageDTO bean);
PageResult<SystemAccessLogVO> convertPage(PageResult<SystemAccessLogBO> page);
}
package cn.iocoder.mall.systemservice.convert.systemlog;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemExceptionLogDO;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogPageDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemExceptionLogVO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogBO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogCreateBO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogPageBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SystemExceptionLogConvert {
SystemExceptionLogConvert INSTANCE = Mappers.getMapper(SystemExceptionLogConvert.class);
SystemExceptionLogDO convert(SystemExceptionLogCreateBO bean);
SystemExceptionLogCreateBO convert(SystemExceptionLogCreateDTO bean);
@Mapping(source = "records", target = "list")
PageResult<SystemExceptionLogBO> convertPage(IPage<SystemExceptionLogDO> page);
SystemExceptionLogBO convert(SystemExceptionLogDO bean);
SystemExceptionLogVO convert(SystemExceptionLogBO bean);
SystemExceptionLogPageBO convert(SystemExceptionLogPageDTO bean);
PageResult<SystemExceptionLogVO> convertPage(PageResult<SystemExceptionLogBO> page);
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin;
import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
import cn.iocoder.mall.systemservice.enums.admin.AdminStatusEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 管理员实体
*
* uk_username 索引:基于 {@link #username} 字段
*/
@TableName(value = "admin")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class AdminDO extends BaseDO {
/**
* 管理员编号
*/
private Integer id;
/**
* 真实名字
*/
private String name;
/**
* 头像
*/
private String avatar;
/**
* 部门编号
*
* 关联 {@link DepartmentDO#getId()}
*/
private Integer departmentId;
/**
* 在职状态
*
* 枚举 {@link AdminStatusEnum}
*/
private Integer status;
/**
* 登陆账号
*/
private String username;
/**
* 经过加密的密码串
*/
private String password;
/**
* {@link #password} 的盐
*/
private String passwordSalt;
/**
* 创建管理员编号
*
* 外键 {@link AdminDO#id}
*/
private Integer createAdminId;
/**
* 创建 IP
*/
private String createIp;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 部门实体
*/
@TableName(value = "admin_department")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class DepartmentDO extends DeletableDO {
/**
* 部门编号
*/
private Integer id;
/**
* 部门名称
*/
private String name;
/**
* 排序值
*/
private Integer sort;
/**
* 父级部门编号
*
* 外键 {@link #id}
*/
private Integer pid;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.datadict;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 数据字典
*
* 使用 {@link #enumValue} 作为聚合。例如说:
*
* enumValue :gender 性别
* value:1 男
* value:2 女
*/
@TableName("system_data_dict")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class DataDictDO extends DeletableDO {
/**
* 编号
*/
private Integer id;
/**
* 大类枚举值
*/
private String enumValue;
/**
* 小类数值
*/
private String value;
/**
* 展示名
*/
private String displayName;
/**
* 排序值
*/
private Integer sort;
/**
* 备注
*/
private String memo;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.errorcode;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import cn.iocoder.mall.systemservice.enums.errorcode.ErrorCodeTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 错误码实体
*/
@TableName(value = "system_error_code")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ErrorCodeDO extends DeletableDO {
/**
* 错误码编号
*/
private Integer id;
/**
* 错误码编码
*/
private Integer code;
/**
* 错误码错误提示
*/
private String message;
/**
* 错误码类型
*
* 外键 {@link ErrorCodeTypeEnum}
*/
private Integer type;
/**
* 错误码分组
*
* 一般情况下,可以采用应用名
*/
@TableField("`group`") // 避免和数据库关键字冲突
private String group;
/**
* 错误码备注
*/
private String memo;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* OAuth2 访问令牌
*
* idx_userId 索引:对应 {@link #userId} 字段
* idx_refreshToken 索引:对应 {@link #refreshToken} 字段
*/
@TableName("oauth2_access_token")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class OAuth2AccessTokenDO extends BaseDO {
/**
* 访问令牌
*/
@TableId(type = IdType.INPUT)
private String id;
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*
* 枚举 {@link UserTypeEnum}
*/
private Integer userType;
/**
* 刷新令牌
*
* 关联 {@link OAuth2RefreshTokenDO#getId()}
*/
private String refreshToken;
/**
* 过期时间
*/
private Date expiresTime;
/**
* 创建 IP
*/
private String createIp;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* OAuth2 刷新令牌
*
* idx_userId 索引:对应 {@link #userId} 字段
*/
@TableName("oauth2_refresh_token")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class OAuth2RefreshTokenDO extends DeletableDO {
/**
* 刷新令牌
*/
@TableId(type = IdType.INPUT)
private String id;
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*
* 枚举 {@link UserTypeEnum}
*/
private Integer userType;
/**
* 过期时间
*/
private Date expiresTime;
/**
* 创建 IP
*/
private String createIp;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.AdminDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* {@link AdminDO} 和 {@link RoleDO} 的关联表
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("permission_admin_role")
public class AdminRoleDO extends DeletableDO {
/**
* 编号
*/
private Integer id;
/**
* 账号编号
*
* 关联 {@link AdminDO#getId()}
*/
private Integer adminId;
/**
* 角色编号
*
* 关联 {@link RoleDO#getId()}
*/
private Integer roleId;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.AdminDO;
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 资源实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "permission_resource")
public class ResourceDO extends DeletableDO {
/**
* 资源编号
*/
private Integer id;
/**
* 菜单名
*/
private String name;
/**
* 权限标识
*
* 一般格式为:${系统}:${模块}:${操作}
* 例如说:system:admin:add,即 system 服务的添加管理员。
*
* 当我们把该 ResourceDO 赋予给角色后,意味着该角色有该资源:
* - 对于后端,配合 @RequiresPermissions 注解,配置 API 接口需要该权限,从而对 API 接口进行权限控制。
* - 对于前端,配合前端标签,配置按钮是否展示,避免用户没有该权限时,结果可以看到该操作。
*/
private String permission;
/**
* 资源类型
*
* 关联 {@link ResourceTypeEnum}
*/
private Integer type;
/**
* 排序
*/
private Integer sort;
/**
* 父级资源编号
*
* 关联:{@link ResourceDO#getId()}
*/
private Integer pid;
/**
* 前端路由
*
* 目前当且仅当资源类型为 {@link ResourceTypeEnum#MENU} 时,才会生效
*/
private String route;
/**
* 菜单图标
*
* 目前当且仅当资源类型为 {@link ResourceTypeEnum#MENU} 时,才会生效
*/
private String icon;
/**
* 前端界面
* 例如说,vue 框架下的 component 对应的 view 页面。
*
* 目前当且仅当资源类型为 {@link ResourceTypeEnum#MENU} 时,才会生效
*/
private String view;
/**
* 创建管理员编号
*
* 外键 {@link AdminDO#getId()}
*/
private Integer createAdminId;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import cn.iocoder.mall.systemservice.enums.permission.RoleCodeEnum;
import cn.iocoder.mall.systemservice.enums.permission.RoleTypeEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 角色实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("permission_role")
public class RoleDO extends DeletableDO {
/**
* 角色编号
*/
private Integer id;
/**
* 角色名
*/
private String name;
/**
* 角色编码
*
* 关联 {@link RoleCodeEnum}
*/
private String code;
/**
* 角色类型
*
* 关联 {@link RoleTypeEnum}
*/
private Integer type;
/**
* 创建管理员编号
*/
private Integer createAdminId;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* {@link RoleDO} 和 {@link ResourceDO} 的关联表
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("permission_role_resource")
public class RoleResourceDO extends DeletableDO {
/**
* 编号
*/
private Integer id;
/**
* 角色编号(外键:{@link RoleDO}
*/
private Integer roleId;
/**
* 资源编号(外键:{@link ResourceDO}
*/
private Integer resourceId;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 系统访问日志 DO
*
* 记录用户、管理员对 API 接口的调用
*
* TODO 优化点:考虑到架构简单,暂时记录到 MySQL。因为访问日志容易比较大,所以建议未来存储到 ES 中,同时能够提供更丰富的检索能力
*/
@TableName("system_access_log")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SystemAccessLogDO extends BaseDO {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*
* 枚举 {@link UserTypeEnum}
*/
private Integer userType;
/**
* 链路追踪编号
*
* 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。
*/
private String traceId;
/**
* 应用名
*
* 目前读取 `spring.application.name` 配置项
*/
private String applicationName;
/**
* 访问地址
*/
private String uri;
/**
* 参数
*/
private String queryString;
/**
* http 方法
*/
private String method;
/**
* userAgent
*/
private String userAgent;
/**
* ip
*/
private String ip;
/**
* 请求时间
*/
private Date startTime;
/**
* 响应时长 -- 毫秒级
*/
private Integer responseTime;
/**
* 错误码
*
* 目前的结果,是使用 {@link CommonResult#getCode()} 属性
*/
private Integer errorCode;
/**
* 错误提示
*
* 目前的结果,是使用 {@link CommonResult#getMessage()} 属性
*/
private String errorMessage;
}
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.AdminDO;
import cn.iocoder.mall.systemservice.enums.systemlog.SystemExceptionLogProcessStatusEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 系统异常日志 DO
*/
@TableName("system_exception_log")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SystemExceptionLogDO extends BaseDO {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*
* 枚举 {@link UserTypeEnum}
*/
private Integer userType;
/**
* 链路追踪编号
*
* 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。
*/
private String traceId;
/**
* 应用名
*
* 目前读取 spring.application.name
*/
private String applicationName;
/**
* 访问地址
*/
private String uri;
/**
* 参数
*/
private String queryString;
/**
* http 方法
*/
private String method;
/**
* userAgent
*/
private String userAgent;
/**
* ip
*/
private String ip;
/**
* 异常发生时间
*/
private Date exceptionTime;
/**
* 异常名
*
* {@link Throwable#getClass()} 的类全名
*/
private String exceptionName;
/**
* 异常导致的消息
*
* {@link cn.iocoder.common.framework.util.ExceptionUtil#getMessage(Throwable)}
*/
private String exceptionMessage;
/**
* 异常导致的根消息
*
* {@link cn.iocoder.common.framework.util.ExceptionUtil#getRootCauseMessage(Throwable)}
*/
private String exceptionRootCauseMessage;
/**
* 异常的栈轨迹
*
* {@link cn.iocoder.common.framework.util.ExceptionUtil#getServiceException(Exception)}
*/
private String exceptionStackTrace;
/**
* 异常发生的类全名
*
* {@link StackTraceElement#getClassName()}
*/
private String exceptionClassName;
/**
* 异常发生的类文件
*
* {@link StackTraceElement#getFileName()}
*/
private String exceptionFileName;
/**
* 异常发生的方法名
*
* {@link StackTraceElement#getMethodName()}
*/
private String exceptionMethodName;
/**
* 异常发生的方法所在行
*
* {@link StackTraceElement#getLineNumber()}
*/
private Integer exceptionLineNumber;
/**
* 处理状态
*
* 外键 {@link SystemExceptionLogProcessStatusEnum}
*/
private Integer processStatus;
/**
* 处理时间
*/
private Date processTime;
/**
* 处理管理员编号
*
* 外键 {@link AdminDO#getId()}
*/
private Integer processAdminId;
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.admin;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.AdminDO;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminPageBO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
@Repository
public interface AdminMapper extends BaseMapper<AdminDO> {
default AdminDO selectByUsername(String username) {
return selectOne(new QueryWrapper<AdminDO>()
.eq("username", username)
);
}
default Integer selectCountByDepartmentId(Integer departmentId) {
return selectCount(new QueryWrapper<AdminDO>()
.eq("department_id", departmentId)
);
}
default IPage<AdminDO> selectPage(AdminPageBO pageBO) {
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
new QueryWrapperX<AdminDO>().likeIfPresent("name", pageBO.getName())
.eqIfPresent("department_id", pageBO.getDepartmentId()));
}
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.admin;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.DepartmentDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface DepartmentMapper extends BaseMapper<DepartmentDO> {
default DepartmentDO selectByPidAndName(Integer pid, String name) {
return selectOne(new QueryWrapperX<DepartmentDO>().eqIfPresent("pid", pid)
.eqIfPresent("name", name));
}
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.datadict;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.datadict.DataDictDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
@Repository
public interface DataDictMapper extends BaseMapper<DataDictDO> {
default DataDictDO selectByEnumValueAndValue(String enumValue, String value) {
return selectOne(new QueryWrapper<DataDictDO>()
.eq("enum_value", enumValue).eq("value", value));
}
default List<DataDictDO> selectByEnumValueAndValues(String enumValue, Collection<String> values) {
return selectList(new QueryWrapper<DataDictDO>()
.eq("enum_value", enumValue).in("value", values));
}
default List<DataDictDO> selectByEnumValue(String enumValue) {
return selectList(new QueryWrapper<DataDictDO>().eq("enum_value", enumValue));
}
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.errorcode;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.errorcode.ErrorCodeDO;
import cn.iocoder.mall.systemservice.service.errorcode.bo.ErrorCodePageBO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@Repository
public interface ErrorCodeMapper extends BaseMapper<ErrorCodeDO> {
default IPage<ErrorCodeDO> selectPage(ErrorCodePageBO pageBO) {
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
new QueryWrapperX<ErrorCodeDO>().likeIfPresent("`group`", pageBO.getGroup())
.eqIfPresent("code", pageBO.getCode()).likeIfPresent("message", pageBO.getMessage()));
}
default List<ErrorCodeDO> selectListByCodes(Collection<Integer> codes) {
return selectList(new QueryWrapper<ErrorCodeDO>().in("code", codes));
}
default ErrorCodeDO selectByCode(Integer code) {
return selectOne(new QueryWrapper<ErrorCodeDO>().eq("code", code));
}
default List<ErrorCodeDO> selectListByGroup(String group, Date minUpdateTime) {
return selectList(new QueryWrapperX<ErrorCodeDO>().eq("`group`", group)
.gtIfPresent("update_time", minUpdateTime));
}
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.oauth;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface OAuth2AccessTokenMapper extends BaseMapper<OAuth2AccessTokenDO> {
default OAuth2AccessTokenDO selectByUserIdAndUserType(Integer userId, Integer userType) {
return selectOne(new QueryWrapper<OAuth2AccessTokenDO>()
.eq("user_id", userId).eq("user_type", userType));
}
default int deleteByUserIdAndUserType(Integer userId, Integer userType) {
return delete(new QueryWrapper<OAuth2AccessTokenDO>()
.eq("user_id", userId).eq("user_type", userType));
}
default int deleteByRefreshToken(String refreshToken) {
return delete(new QueryWrapper<OAuth2AccessTokenDO>().eq("refresh_token", refreshToken));
}
default List<OAuth2AccessTokenDO> selectListByRefreshToken(String refreshToken) {
return selectList(new QueryWrapper<OAuth2AccessTokenDO>().eq("refresh_token", refreshToken));
}
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.oauth;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2RefreshTokenDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface OAuth2RefreshTokenMapper extends BaseMapper<OAuth2RefreshTokenDO> {
default int deleteByUserIdAndUserType(Integer userId, Integer userType) {
return delete(new QueryWrapper<OAuth2RefreshTokenDO>()
.eq("user_id", userId).eq("user_type", userType));
}
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.permission;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.AdminRoleDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
@Repository
public interface AdminRoleMapper extends BaseMapper<AdminRoleDO> {
default List<AdminRoleDO> selectByAdminId(Integer adminId) {
return selectList(new QueryWrapper<AdminRoleDO>().eq("admin_id", adminId));
}
default List<AdminRoleDO> selectListByAdminId(Integer adminId) {
return selectList(new QueryWrapper<AdminRoleDO>().eq("admin_id", adminId));
}
default List<AdminRoleDO> selectListByAdminIds(Collection<Integer> adminIds) {
return selectList(new QueryWrapper<AdminRoleDO>().in("admin_id", adminIds));
}
default int deleteByAdminId(Integer adminId) {
return delete(new QueryWrapper<AdminRoleDO>().eq("admin_id", adminId));
}
default int deleteByRoleId(Integer roleId) {
return delete(new QueryWrapper<AdminRoleDO>().eq("role_id", roleId));
}
/**
* 批量插入。因为 MyBaits Plus 的批量插入是基于 Service 实现,所以只好写 XML
*
* @param adminRoleDOs 数组
*/
int insertList(@Param("adminRoleDOs") List<AdminRoleDO> adminRoleDOs);
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.permission;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.ResourceDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
@Repository
public interface ResourceMapper extends BaseMapper<ResourceDO> {
default ResourceDO selectByPermission(String permission) {
return selectOne(new QueryWrapper<ResourceDO>().eq("permission", permission));
}
/**
* 查询指定类型的资源列表
*
* @param type 资源类型,允许空
* @return 资源列表
*/
default List<ResourceDO> selectListByType(Integer type) {
return selectList(new QueryWrapperX<ResourceDO>().eqIfPresent("type", type));
}
default ResourceDO selectByPidAndName(Integer pid, String name) {
return selectOne(new QueryWrapperX<ResourceDO>().eqIfPresent("pid", pid)
.eqIfPresent("name", name));
}
default List<ResourceDO> selectListByPermissions(Collection<String> permissions) {
return selectList(new QueryWrapper<ResourceDO>().in("permission", permissions));
}
default List<ResourceDO> selectListByIdsAndType(Collection<Integer> ids, Integer type) {
return selectList(new QueryWrapperX<ResourceDO>().inIfPresent("id", ids)
.eqIfPresent("type", type));
}
default int selectCountByIdsAndType(Collection<Integer> ids, Integer type) {
return selectCount(new QueryWrapperX<ResourceDO>().inIfPresent("id", ids)
.eqIfPresent("type", type));
}
default int selectCountByPid(Integer pid) {
return selectCount(new QueryWrapper<ResourceDO>().eq("pid", pid));
}
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.permission;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.RoleDO;
import cn.iocoder.mall.systemservice.service.permission.bo.RolePageBO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
@Repository
public interface RoleMapper extends BaseMapper<RoleDO> {
default IPage<RoleDO> selectPage(RolePageBO pageBO) {
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
new QueryWrapperX<RoleDO>().likeIfPresent("name", pageBO.getName()));
}
// default List<RoleDO> selectListByIds(Collection<Integer> ids) {
// return selectList(new QueryWrapperX<RoleDO>().inIfPresent("id", ids));
// }
default RoleDO selectByName(String name) {
return selectOne(new QueryWrapperX<RoleDO>().eqIfPresent("name", name));
}
default RoleDO selectByCode(String code) {
return selectOne(new QueryWrapperX<RoleDO>().eqIfPresent("code", code));
}
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.permission;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.RoleResourceDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
@Repository
public interface RoleResourceMapper extends BaseMapper<RoleResourceDO> {
/**
* 批量插入。因为 MyBaits Plus 的批量插入是基于 Service 实现,所以只好写 XML
*
* @param roleResources 数组
*/
int insertList(@Param("roleResources") List<RoleResourceDO> roleResources);
default List<RoleResourceDO> selectListByResourceId(Integer resourceId) {
return selectList(new QueryWrapper<RoleResourceDO>().eq("resource_id", resourceId));
}
default List<RoleResourceDO> selectListByResourceIds(Collection<Integer> resourceIds) {
return selectList(new QueryWrapper<RoleResourceDO>().in("resource_id", resourceIds));
}
default List<RoleResourceDO> selectListByRoleId(Integer roleId) {
return selectList(new QueryWrapper<RoleResourceDO>().eq("role_id", roleId));
}
default List<RoleResourceDO> selectListByRoleIds(Collection<Integer> roleIds) {
return selectList(new QueryWrapper<RoleResourceDO>().in("role_id", roleIds));
}
default int deleteByResourceId(Integer resourceId) {
return delete(new QueryWrapper<RoleResourceDO>().eq("resource_id", resourceId));
}
default int deleteByRoleId(Integer roleId) {
return delete(new QueryWrapper<RoleResourceDO>().eq("role_id", roleId));
}
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemAccessLogDO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogPageBO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
/**
* 系统访问日志 Mapper
*/
@Repository
public interface SystemAccessLogMapper extends BaseMapper<SystemAccessLogDO> {
default IPage<SystemAccessLogDO> selectPage(SystemAccessLogPageBO pageBO) {
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
new QueryWrapperX<SystemAccessLogDO>()
.eqIfPresent("user_id", pageBO.getUserId())
.eqIfPresent("user_type", pageBO.getUserType())
.eqIfPresent("application_name", pageBO.getApplicationName())
.orderByDesc("start_time"));
}
}
package cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemExceptionLogDO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogPageBO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
@Repository
public interface SystemExceptionLogMapper extends BaseMapper<SystemExceptionLogDO> {
default IPage<SystemExceptionLogDO> selectPage(SystemExceptionLogPageBO pageBO) {
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
new QueryWrapperX<SystemExceptionLogDO>()
.eqIfPresent("user_id", pageBO.getUserId())
.eqIfPresent("user_type", pageBO.getUserType())
.eqIfPresent("application_name", pageBO.getApplicationName())
.eqIfPresent("process_status", pageBO.getProcessStatus())
.orderByDesc("exception_time"));
}
}
package cn.iocoder.mall.systemservice.dal.redis;
import cn.iocoder.mall.redis.core.RedisKeyDefine;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO;
import java.time.Duration;
import static cn.iocoder.mall.redis.core.RedisKeyDefine.KeyTypeEnum.STRING;
/**
* Redis Key 枚举类
*
* 通过将项目中的 Key 枚举在该类中,方便统一管理。
*/
public interface RedisKeyConstants {
/**
* {@link OAuth2AccessTokenDO} 的缓存
*
* key 的 format 的参数是 [{@link OAuth2AccessTokenDO#getId()}]
*/
RedisKeyDefine OAUTH2_ACCESS_TOKEN = new RedisKeyDefine("oauth2_access_token:%s", STRING, OAuth2AccessTokenDO.class, Duration.ofHours(2));
}
package cn.iocoder.mall.systemservice.dal.redis.dao;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;
import static cn.iocoder.mall.systemservice.dal.redis.RedisKeyConstants.OAUTH2_ACCESS_TOKEN;
@Repository
public class OAuth2AccessTokenRedisDAO {
@Autowired
private StringRedisTemplate redisTemplate;
public OAuth2AccessTokenDO get(String accessToken) {
String redisKey = formatKey(accessToken);
return JSON.parseObject(redisTemplate.opsForValue().get(redisKey), OAuth2AccessTokenDO.class);
}
public void set(OAuth2AccessTokenDO accessTokenDO) {
String redisKey = formatKey(accessTokenDO.getId());
redisTemplate.opsForValue().set(redisKey, JSON.toJSONString(accessTokenDO), OAUTH2_ACCESS_TOKEN.getTimeout());
}
public void delete(String accessToken) {
String redisKey = formatKey(accessToken);
redisTemplate.delete(redisKey);
}
private static String formatKey(String accessToken) {
return String.format(OAUTH2_ACCESS_TOKEN.getKeyTemplate(), accessToken);
}
}
package cn.iocoder.mall.systemservice.manager.admin;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import cn.iocoder.common.framework.util.StringUtils;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.convert.admin.AdminConvert;
import cn.iocoder.mall.systemservice.enums.admin.AdminStatusEnum;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminCreateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminPageDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminVerifyPasswordDTO;
import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO;
import cn.iocoder.mall.systemservice.service.admin.AdminService;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminBO;
import cn.iocoder.mall.systemservice.service.oauth.OAuth2ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class AdminManager {
@Autowired
private AdminService adminService;
@Autowired
private OAuth2ServiceImpl oauth2Service;
public AdminVO verifyPassword(AdminVerifyPasswordDTO verifyPasswordDTO) {
AdminBO adminBO = adminService.verifyPassword(verifyPasswordDTO.getUsername(),
verifyPasswordDTO.getPassword(), verifyPasswordDTO.getIp());
return AdminConvert.INSTANCE.convert(adminBO);
}
public AdminVO createAdmin(AdminCreateDTO createDTO) {
AdminBO adminBO = adminService.createAdmin(AdminConvert.INSTANCE.convert(createDTO));
return AdminConvert.INSTANCE.convert(adminBO);
}
@Transactional
public void updateAdmin(AdminUpdateDTO updateDTO) {
// 更新管理员信息
adminService.updateAdmin(AdminConvert.INSTANCE.convert(updateDTO));
// 如果修改密码,或者禁用管理员
if (StringUtils.hasText(updateDTO.getPassword())
|| AdminStatusEnum.INACTIVE.getStatus().equals(updateDTO.getStatus())) {
oauth2Service.removeToken(new OAuth2RemoveTokenByUserReqDTO().setUserId(updateDTO.getId()).setUserType(UserTypeEnum.ADMIN.getValue()));
}
}
public PageResult<AdminVO> pageAdmin(AdminPageDTO pageDTO) {
PageResult<AdminBO> adminPage = adminService.pageAdmin(AdminConvert.INSTANCE.convert(pageDTO));
return AdminConvert.INSTANCE.convert(adminPage);
}
public AdminVO getAdmin(Integer adminId) {
AdminBO adminBO = adminService.getAdmin(adminId);
return AdminConvert.INSTANCE.convert(adminBO);
}
}
package cn.iocoder.mall.systemservice.manager.admin;
import cn.iocoder.mall.systemservice.convert.admin.DepartmentConvert;
import cn.iocoder.mall.systemservice.rpc.admin.dto.DepartmentCreateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.DepartmentUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO;
import cn.iocoder.mall.systemservice.service.admin.DepartmentService;
import cn.iocoder.mall.systemservice.service.admin.bo.DepartmentBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
/**
* 部门 Manager
*/
@Service
public class DepartmentManager {
@Autowired
private DepartmentService departmentService;
/**
* 创建部门
*
* @param createDTO 创建部门 DTO
* @return 部门
*/
public Integer createDepartment(DepartmentCreateDTO createDTO) {
DepartmentBO departmentBO = departmentService.createDepartment(DepartmentConvert.INSTANCE.convert(createDTO));
return departmentBO.getId();
}
/**
* 更新部门
*
* @param updateDTO 更新部门 DTO
*/
public void updateDepartment(DepartmentUpdateDTO updateDTO) {
departmentService.updateDepartment(DepartmentConvert.INSTANCE.convert(updateDTO));
}
/**
* 删除部门
*
* @param departmentId 部门编号
*/
public void deleteDepartment(Integer departmentId) {
departmentService.deleteDepartment(departmentId);
}
/**
* 获得部门
*
* @param departmentId 部门编号
* @return 部门
*/
public DepartmentVO getDepartment(Integer departmentId) {
DepartmentBO departmentBO = departmentService.getDepartment(departmentId);
return DepartmentConvert.INSTANCE.convert(departmentBO);
}
/**
* 获得部门列表
*
* @param departmentIds 部门编号列表
* @return 部门列表
*/
public List<DepartmentVO> listDepartments(Collection<Integer> departmentIds) {
List<DepartmentBO> departmentBOs = departmentService.listDepartments(departmentIds);
return DepartmentConvert.INSTANCE.convertList02(departmentBOs);
}
/**
* 获得部门全列表
*
* @return 资源列表
*/
public List<DepartmentVO> listDepartments() {
List<DepartmentBO> departmentBOs = departmentService.listDepartments();
return DepartmentConvert.INSTANCE.convertList02(departmentBOs);
}
}
package cn.iocoder.mall.systemservice.manager.datadict;
import cn.iocoder.mall.systemservice.convert.datadict.DataDictConvert;
import cn.iocoder.mall.systemservice.rpc.datadict.dto.DataDictCreateDTO;
import cn.iocoder.mall.systemservice.rpc.datadict.dto.DataDictUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO;
import cn.iocoder.mall.systemservice.service.datadict.DataDictService;
import cn.iocoder.mall.systemservice.service.datadict.bo.DataDictBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 数据字典 Manager
*/
@Service
public class DataDictManager {
@Autowired
private DataDictService dataDictService;
/**
* 创建数据字典
*
* @param createDTO 创建数据字典 DTO
* @return 数据字典
*/
public Integer createDataDict(DataDictCreateDTO createDTO) {
DataDictBO dataDictBO = dataDictService.createDataDict(DataDictConvert.INSTANCE.convert(createDTO));
return dataDictBO.getId();
}
/**
* 更新数据字典
*
* @param updateDTO 更新数据字典 DTO
*/
public void updateDataDict(DataDictUpdateDTO updateDTO) {
dataDictService.updateDataDict(DataDictConvert.INSTANCE.convert(updateDTO));
}
/**
* 删除数据字典
*
* @param dataDictId 数据字典编号
*/
public void deleteDataDict(Integer dataDictId) {
dataDictService.deleteDataDict(dataDictId);
}
/**
* 获得数据字典
*
* @param dataDictId 数据字典编号
* @return 数据字典
*/
public DataDictVO getDataDict(Integer dataDictId) {
DataDictBO dataDictBO = dataDictService.getDataDict(dataDictId);
return DataDictConvert.INSTANCE.convert(dataDictBO);
}
/**
* 获得全部数据字典
*
* @return 数据字典列表
*/
public List<DataDictVO> listDataDicts() {
List<DataDictBO> dataDictBOs = dataDictService.listDataDicts();
return DataDictConvert.INSTANCE.convertList02(dataDictBOs);
}
/**
* 获得数据字典列表
*
* @param dataDictIds 数据字典编号列表
* @return 数据字典列表
*/
public List<DataDictVO> listDataDicts(List<Integer> dataDictIds) {
List<DataDictBO> dataDictBOs = dataDictService.listDataDicts(dataDictIds);
return DataDictConvert.INSTANCE.convertList02(dataDictBOs);
}
}
package cn.iocoder.mall.systemservice.manager.errorcode;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.convert.errorcode.ErrorCodeConvert;
import cn.iocoder.mall.systemservice.rpc.errorcode.dto.ErrorCodeAutoGenerateDTO;
import cn.iocoder.mall.systemservice.rpc.errorcode.dto.ErrorCodeCreateDTO;
import cn.iocoder.mall.systemservice.rpc.errorcode.dto.ErrorCodePageDTO;
import cn.iocoder.mall.systemservice.rpc.errorcode.dto.ErrorCodeUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.errorcode.vo.ErrorCodeVO;
import cn.iocoder.mall.systemservice.service.errorcode.ErrorCodeService;
import cn.iocoder.mall.systemservice.service.errorcode.bo.ErrorCodeBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 错误码 Manager
*/
@Service
public class ErrorCodeManager {
@Autowired
private ErrorCodeService errorCodeService;
/**
* 创建错误码
*
* @param createDTO 创建错误码 DTO
* @return 错误码
*/
public Integer createErrorCode(ErrorCodeCreateDTO createDTO) {
ErrorCodeBO errorCodeBO = errorCodeService.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO));
return errorCodeBO.getId();
}
/**
* 更新错误码
*
* @param updateDTO 更新错误码 DTO
*/
public void updateErrorCode(ErrorCodeUpdateDTO updateDTO) {
errorCodeService.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO));
}
/**
* 自动生成错误码
*
* @param autoGenerateDTOs 自动生成信息 DTO
*/
public void autoGenerateErrorCodes(List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) {
errorCodeService.autoGenerateErrorCodes(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs));
}
/**
* 删除错误码
*
* @param errorCodeId 错误码编号
*/
public void deleteErrorCode(Integer errorCodeId) {
errorCodeService.deleteErrorCode(errorCodeId);
}
/**
* 获得错误码
*
* @param errorCodeId 错误码编号
* @return 错误码
*/
public ErrorCodeVO getErrorCode(Integer errorCodeId) {
ErrorCodeBO errorCodeBO = errorCodeService.getErrorCode(errorCodeId);
return ErrorCodeConvert.INSTANCE.convert(errorCodeBO);
}
/**
* 获得错误码列表
*
* @param errorCodeIds 错误码编号列表
* @return 错误码列表
*/
public List<ErrorCodeVO> listErrorCodes(List<Integer> errorCodeIds) {
List<ErrorCodeBO> errorCodeBOs = errorCodeService.listErrorCodes(errorCodeIds);
return ErrorCodeConvert.INSTANCE.convertList02(errorCodeBOs);
}
/**
* 获得错误码分页
*
* @param pageDTO 错误码分页查询
* @return 错误码分页结果
*/
public PageResult<ErrorCodeVO> pageErrorCode(ErrorCodePageDTO pageDTO) {
PageResult<ErrorCodeBO> pageResultBO = errorCodeService.pageErrorCode(ErrorCodeConvert.INSTANCE.convert(pageDTO));
return ErrorCodeConvert.INSTANCE.convertPage(pageResultBO);
}
public List<ErrorCodeVO> listErrorCodes(String group, Date minUpdateTime) {
List<ErrorCodeBO> errorCodeBOs = errorCodeService.listErrorCodes(group, minUpdateTime);
return ErrorCodeConvert.INSTANCE.convertList02(errorCodeBOs);
}
}
package cn.iocoder.mall.systemservice.manager.permission;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.common.framework.exception.GlobalException;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.mall.systemservice.rpc.permission.dto.PermissionAssignAdminRoleDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.PermissionAssignRoleResourceDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.PermissionCheckDTO;
import cn.iocoder.mall.systemservice.service.permission.PermissionService;
import cn.iocoder.mall.systemservice.service.permission.ResourceServiceImpl;
import cn.iocoder.mall.systemservice.service.permission.RoleService;
import cn.iocoder.mall.systemservice.service.permission.bo.ResourceBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import static cn.iocoder.common.framework.exception.enums.GlobalErrorCodeConstants.FORBIDDEN;
/**
* 权限 Manager
*/
@Service
public class PermissionManager {
@Autowired
private PermissionService permissionService;
@Autowired
private RoleService roleService;
@Autowired
private ResourceServiceImpl resourceService;
/**
* 获得角色拥有的资源编号
*
* @param roleId 角色编号
* @return 资源编号列表
*/
public Set<Integer> listRoleResourceIds(Integer roleId) {
// 超级管理员,拥有所有资源
if (roleService.hasSuperAdmin(Collections.singleton(roleId))) {
return CollectionUtils.convertSet(resourceService.listResources(), ResourceBO::getId);
}
// 非超级管理员,查询拥有资源
return permissionService.listRoleResourceIds(roleId);
}
/**
* 赋予角色资源
*
* @param assignResourceDTO 赋予角色资源 DTO
*/
public void assignRoleResource(PermissionAssignRoleResourceDTO assignResourceDTO) {
permissionService.assignRoleResource(assignResourceDTO.getRoleId(), assignResourceDTO.getResourceIds());
}
/**
* 获得管理员拥有的角色编号列表
*
* @param adminId 管理员编号
* @return 角色编号列表
*/
public Set<Integer> listAdminRoleIds(Integer adminId) {
return permissionService.listAdminRoleIds(adminId);
}
/**
* 获得每个管理员拥有的角色编号
* 返回的结果,key 为管理员编号
*
* @param adminIds 管理员编号列表
* @return 每个管理员拥有的角色编号
*/
public Map<Integer, Set<Integer>> mapAdminRoleIds(Collection<Integer> adminIds) {
return permissionService.mapAdminRoleIds(adminIds);
}
/**
* 赋予管理员角色
*
* @param assignAdminRoleDTO 赋予管理员角色 DTO
*/
public void assignAdminRole(PermissionAssignAdminRoleDTO assignAdminRoleDTO) {
permissionService.assignAdminRole(assignAdminRoleDTO.getAdminId(), assignAdminRoleDTO.getRoleIds());
}
/**
* 校验管理员是否拥有指定权限。
*
* 如果没有,则抛出 {@link cn.iocoder.common.framework.exception.ServiceException} 异常
*
* @param checkDTO 校验权限 DTO
*/
public void checkPermission(PermissionCheckDTO checkDTO) {
// 查询管理员拥有的角色关联数据
Set<Integer> roleIds = permissionService.listAdminRoleIds(checkDTO.getAdminId());
if (CollectionUtil.isEmpty(roleIds)) { // 如果没有角色,默认无法访问
throw new GlobalException(FORBIDDEN);
}
// 判断是否为超管。若是超管,默认有所有权限
if (roleService.hasSuperAdmin(roleIds)) {
return;
}
// 校验权限
permissionService.checkPermission(roleIds, checkDTO.getPermissions());
}
}
package cn.iocoder.mall.systemservice.manager.permission;
import cn.iocoder.mall.systemservice.convert.permission.ResourceConvert;
import cn.iocoder.mall.systemservice.rpc.permission.dto.ResourceCreateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.ResourceUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO;
import cn.iocoder.mall.systemservice.service.permission.ResourceServiceImpl;
import cn.iocoder.mall.systemservice.service.permission.RoleService;
import cn.iocoder.mall.systemservice.service.permission.bo.ResourceBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
/**
* 资源 Manager
*/
@Service
public class ResourceManager {
@Autowired
private ResourceServiceImpl resourceService;
@Autowired
private RoleService roleService;
/**
* 创建资源
*
* @param createDTO 创建资源 DTO
* @return 资源
*/
public Integer createResource(ResourceCreateDTO createDTO) {
ResourceBO resourceBO = resourceService.createResource(ResourceConvert.INSTANCE.convert(createDTO));
return resourceBO.getId();
}
/**
* 更新资源
*
* @param updateDTO 更新资源 DTO
*/
public void updateResource(ResourceUpdateDTO updateDTO) {
resourceService.updateResource(ResourceConvert.INSTANCE.convert(updateDTO));
}
/**
* 删除资源
*
* @param resourceId 资源编号
*/
public void deleteResource(Integer resourceId) {
resourceService.deleteResource(resourceId);
}
/**
* 获得资源
*
* @param resourceId 资源编号
* @return 资源
*/
public ResourceVO getResource(Integer resourceId) {
ResourceBO resourceBO = resourceService.getResource(resourceId);
return ResourceConvert.INSTANCE.convert(resourceBO);
}
/**
* 获得资源全列表
*
* @return 资源列表
*/
public List<ResourceVO> listResources() {
List<ResourceBO> resourceBOs = resourceService.listResources();
return ResourceConvert.INSTANCE.convertList02(resourceBOs);
}
/**
* 获得资源列表
*
* @param resourceIds 资源编号列表
* @return 资源列表
*/
public List<ResourceVO> listResources(List<Integer> resourceIds) {
List<ResourceBO> resourceBOs = resourceService.listResources(resourceIds);
return ResourceConvert.INSTANCE.convertList02(resourceBOs);
}
/**
* 获得指定角色的资源列表
*
* @param roleIds 角色编号列表
* @param type 资源类型,允许空
* @return 资源列表
*/
public List<ResourceVO> listRoleResources(Collection<Integer> roleIds, Integer type) {
List<ResourceBO> resourceBOs;
// 判断是否为超管。若是超管,默认有所有权限
if (roleService.hasSuperAdmin(roleIds)) {
resourceBOs = resourceService.listResourcesByType(type);
} else {
resourceBOs = resourceService.listRoleResourcesByType(roleIds, type);
}
return ResourceConvert.INSTANCE.convertList02(resourceBOs);
}
}
package cn.iocoder.mall.systemservice.manager.permission;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.convert.permission.RoleConvert;
import cn.iocoder.mall.systemservice.rpc.permission.dto.RolePageDTO;
import cn.iocoder.mall.systemservice.rpc.permission.dto.RoleUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleCreateDTO;
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO;
import cn.iocoder.mall.systemservice.service.permission.RoleService;
import cn.iocoder.mall.systemservice.service.permission.bo.RoleBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
* 角色 Manager
*/
@Service
public class RoleManager {
@Autowired
private RoleService roleService;
/**
* 创建角色
*
* @param createDTO 创建角色 DTO
* @return 角色
*/
public Integer createRole(RoleCreateDTO createDTO) {
RoleBO roleBO = roleService.createRole(RoleConvert.INSTANCE.convert(createDTO));
return roleBO.getId();
}
/**
* 更新角色
*
* @param updateDTO 更新角色 DTO
*/
public void updateRole(RoleUpdateDTO updateDTO) {
roleService.updateRole(RoleConvert.INSTANCE.convert(updateDTO));
}
/**
* 删除角色
*
* @param roleId 角色编号
*/
public void deleteRole(Integer roleId) {
roleService.deleteRole(roleId);
}
/**
* 获得角色
*
* @param roleId 角色编号
* @return 角色
*/
public RoleVO getRole(Integer roleId) {
RoleBO roleBO = roleService.getRole(roleId);
return RoleConvert.INSTANCE.convert(roleBO);
}
/**
* 获得所有角色
*
* @return 角色列表
*/
public List<RoleVO> listAllRoles() {
List<RoleBO> roleBOs = roleService.listAllRole();
return RoleConvert.INSTANCE.convertList02(roleBOs);
}
/**
* 获得角色列表
*
* @param roleIds 角色编号列表
* @return 角色列表
*/
public List<RoleVO> listRoles(Collection<Integer> roleIds) {
List<RoleBO> roleBOs = roleService.listRole(roleIds);
return RoleConvert.INSTANCE.convertList02(roleBOs);
}
/**
* 获得角色分页
*
* @param pageDTO 角色分页查询
* @return 角色分页结果
*/
public PageResult<RoleVO> pageRole(RolePageDTO pageDTO) {
PageResult<RoleBO> pageResultBO = roleService.pageRole(RoleConvert.INSTANCE.convert(pageDTO));
return RoleConvert.INSTANCE.convertPage(pageResultBO);
}
/**
* 获得管理员拥有的角色编号列表
*
* @param adminId 管理员编号
* @return 角色编号列表
*/
public Set<Integer> listAdminRoleIds(Integer adminId) {
return roleService.listAdminRoleIds(adminId);
}
}
package cn.iocoder.mall.systemservice.manager.systemlog;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.convert.systemlog.SystemAccessLogConvert;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO;
import cn.iocoder.mall.systemservice.service.systemlog.SystemAccessLogService;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 系统访问日志 Manager
*/
@Service
public class SystemAccessLogManager {
@Autowired
private SystemAccessLogService systemAccessLogService;
/**
* 创建系统访问日志
*
* @param createDTO 创建系统访问日志 DTO
*/
public void createSystemAccessLog(SystemAccessLogCreateDTO createDTO) {
systemAccessLogService.createSystemAccessLog(SystemAccessLogConvert.INSTANCE.convert(createDTO));
}
/**
* 获得系统访问日志分页
*
* @param pageDTO 系统访问日志分页查询
* @return 系统访问日志分页结果
*/
public PageResult<SystemAccessLogVO> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) {
PageResult<SystemAccessLogBO> pageResultBO = systemAccessLogService.pageSystemAccessLog(SystemAccessLogConvert.INSTANCE.convert(pageDTO));
return SystemAccessLogConvert.INSTANCE.convertPage(pageResultBO);
}
}
package cn.iocoder.mall.systemservice.manager.systemlog;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.convert.systemlog.SystemExceptionLogConvert;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogPageDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogProcessDTO;
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemExceptionLogVO;
import cn.iocoder.mall.systemservice.service.systemlog.SystemExceptionLogService;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 系统异常日志 Manager
*/
@Service
public class SystemExceptionLogManager {
@Autowired
private SystemExceptionLogService systemExceptionLogService;
/**
* 创建系统异常日志
*
* @param createDTO 创建系统异常日志 DTO
*/
public void createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO) {
systemExceptionLogService.createSystemExceptionLog(SystemExceptionLogConvert.INSTANCE.convert(createDTO));
}
/**
* 获得系统异常日志
*
* @param systemExceptionLogId 系统异常日志编号
* @return 系统异常日志
*/
public SystemExceptionLogVO getSystemExceptionLog(Integer systemExceptionLogId) {
SystemExceptionLogBO systemExceptionLogBO = systemExceptionLogService.getSystemExceptionLog(systemExceptionLogId);
return SystemExceptionLogConvert.INSTANCE.convert(systemExceptionLogBO);
}
/**
* 获得系统异常日志分页
*
* @param pageDTO 系统异常日志分页查询
* @return 系统异常日志分页结果
*/
public PageResult<SystemExceptionLogVO> pageSystemExceptionLog(SystemExceptionLogPageDTO pageDTO) {
PageResult<SystemExceptionLogBO> pageResultBO = systemExceptionLogService.pageSystemExceptionLog(SystemExceptionLogConvert.INSTANCE.convert(pageDTO));
return SystemExceptionLogConvert.INSTANCE.convertPage(pageResultBO);
}
/**
* 处理系统异常日志,完成或者忽略
*
* @param processDTO 处理 DTO
*/
public void processSystemExceptionLog(SystemExceptionLogProcessDTO processDTO) {
systemExceptionLogService.processSystemExceptionLog(processDTO.getLogId(), processDTO.getProcessAdminId(),
processDTO.getProcessStatus());
}
}
package cn.iocoder.mall.systemservice.service.admin;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.util.DigestUtils;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.util.StringUtils;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.convert.admin.AdminConvert;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.AdminDO;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.admin.AdminMapper;
import cn.iocoder.mall.systemservice.enums.admin.AdminStatusEnum;
import cn.iocoder.mall.systemservice.enums.admin.AdminUsernameEnum;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminBO;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminCreateBO;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminPageBO;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminUpdateBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.*;
@Service
public class AdminService {
@Autowired
private AdminMapper adminMapper;
/**
* 校验登陆的账号密码是否正确
*
* @param username 账号
* @param password 密码
* @param ip 登陆 IP
* @return 管理员信息
*/
public AdminBO verifyPassword(String username, String password, String ip) {
AdminDO adminDO = adminMapper.selectByUsername(username);
if (adminDO == null) {
throw ServiceExceptionUtil.exception(ADMIN_USERNAME_NOT_EXISTS);
}
// 校验密码是否正确
String encodedPassword = DigestUtils.bcrypt(password, adminDO.getPasswordSalt());
if (!encodedPassword.equals(adminDO.getPassword())) {
// TODO 需要补充密码错误上限
throw ServiceExceptionUtil.exception(ADMIN_PASSWORD_ERROR);
}
// 账号被禁用
if (!AdminStatusEnum.ACTIVE.getStatus().equals(adminDO.getStatus())) {
throw ServiceExceptionUtil.exception(ADMIN_IS_DISABLE);
}
// 返回
return AdminConvert.INSTANCE.convert(adminDO);
}
public PageResult<AdminBO> pageAdmin(AdminPageBO adminPageBO) {
return AdminConvert.INSTANCE.convertPage(adminMapper.selectPage(adminPageBO));
}
public AdminBO createAdmin(AdminCreateBO createBO) {
// 校验账号唯一
if (adminMapper.selectByUsername(createBO.getUsername()) != null) {
throw ServiceExceptionUtil.exception(ADMIN_USERNAME_EXISTS);
}
// 加密密码
String passwordSalt = genPasswordSalt();
String password = encodePassword(createBO.getPassword(), passwordSalt);
// 保存到数据库
AdminDO admin = AdminConvert.INSTANCE.convert(createBO)
.setPassword(password).setPasswordSalt(passwordSalt)
.setStatus(CommonStatusEnum.ENABLE.getValue());
adminMapper.insert(admin);
// 返回成功
return AdminConvert.INSTANCE.convert(admin);
}
private String genPasswordSalt() {
return DigestUtils.genBcryptSalt();
}
private String encodePassword(String password, String salt) {
return DigestUtils.bcrypt(password, salt);
}
public void updateAdmin(AdminUpdateBO updateBO) {
// 校验账号存在
AdminDO adminDO = adminMapper.selectById(updateBO.getId());
if (adminDO == null) {
throw ServiceExceptionUtil.exception(ADMIN_NOT_FOUND);
}
// 校验是否为特殊账号,不允许编辑
if (AdminUsernameEnum.ADMIN.getUsername().equals(adminDO.getUsername())
|| AdminUsernameEnum.DEMO.getUsername().equals(adminDO.getUsername())) {
throw ServiceExceptionUtil.exception(ADMIN_ADMIN_CAN_NOT_UPDATE);
}
// 校验账号唯一
if (StringUtils.hasText(updateBO.getUsername())) {
AdminDO usernameAdmin = adminMapper.selectByUsername(updateBO.getUsername());
if (usernameAdmin != null && !usernameAdmin.getId().equals(updateBO.getId())) {
throw ServiceExceptionUtil.exception(ADMIN_USERNAME_EXISTS);
}
}
// 如果有更新状态,则校验是否已经是该状态
if (updateBO.getStatus() != null && updateBO.getStatus().equals(adminDO.getStatus())) {
throw ServiceExceptionUtil.exception(ADMIN_STATUS_EQUALS);
}
// 更新到数据库
AdminDO updateAdmin = AdminConvert.INSTANCE.convert(updateBO);
// 如果更新密码,需要特殊加密
if (StringUtils.hasText(updateBO.getPassword())) {
String passwordSalt = genPasswordSalt();
String password = encodePassword(updateBO.getPassword(), passwordSalt);
updateAdmin.setPassword(password).setPasswordSalt(passwordSalt);
}
adminMapper.updateById(updateAdmin);
}
public AdminBO getAdmin(Integer adminId) {
AdminDO adminDO = adminMapper.selectById(adminId);
return AdminConvert.INSTANCE.convert(adminDO);
}
}
package cn.iocoder.mall.systemservice.service.admin;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.mall.systemservice.convert.admin.DepartmentConvert;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.DepartmentDO;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.admin.AdminMapper;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.admin.DepartmentMapper;
import cn.iocoder.mall.systemservice.enums.admin.DepartmentIdEnum;
import cn.iocoder.mall.systemservice.service.admin.bo.DepartmentBO;
import cn.iocoder.mall.systemservice.service.admin.bo.DepartmentCreateBO;
import cn.iocoder.mall.systemservice.service.admin.bo.DepartmentUpdateBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.*;
/**
* 部门 Service
*/
@Service
@Validated
public class DepartmentService {
@Autowired
private DepartmentMapper departmentMapper;
@Autowired
private AdminMapper adminMapper;
/**
* 创建部门
*
* @param createBO 创建部门 BO
* @return 部门
*/
public DepartmentBO createDepartment(@Valid DepartmentCreateBO createBO) {
// 校验父部门存在
checkParentDepartment(createBO.getPid(), null);
// 校验部门(自己)
checkDepartment(createBO.getPid(), createBO.getName(), null);
// 插入到数据库
DepartmentDO departmentDO = DepartmentConvert.INSTANCE.convert(createBO);
departmentMapper.insert(departmentDO);
// 返回
return DepartmentConvert.INSTANCE.convert(departmentDO);
}
/**
* 更新部门
*
* @param updateBO 更新部门 BO
*/
public void updateDepartment(@Valid DepartmentUpdateBO updateBO) {
// 校验更新的部门是否存在
if (departmentMapper.selectById(updateBO.getId()) == null) {
throw ServiceExceptionUtil.exception(DEPARTMENT_NOT_FOUND);
}
// 校验父部门存在
checkParentDepartment(updateBO.getPid(), updateBO.getId());
// 校验部门(自己)
checkDepartment(updateBO.getPid(), updateBO.getName(), updateBO.getId());
// 更新到数据库
DepartmentDO updateObject = DepartmentConvert.INSTANCE.convert(updateBO);
departmentMapper.updateById(updateObject);
}
/**
* 删除部门
*
* @param departmentId 部门编号
*/
public void deleteDepartment(Integer departmentId) {
// 校验删除的部门是否存在
if (departmentMapper.selectById(departmentId) == null) {
throw ServiceExceptionUtil.exception(DEPARTMENT_NOT_FOUND);
}
// 校验部门里没管理员
if (adminMapper.selectCountByDepartmentId(departmentId) > 0) {
throw ServiceExceptionUtil.exception(DEPARTMENT_NOT_FOUND);
}
// 标记删除
departmentMapper.deleteById(departmentId);
}
/**
* 获得部门
*
* @param departmentId 部门编号
* @return 部门
*/
public DepartmentBO getDepartment(Integer departmentId) {
DepartmentDO departmentDO = departmentMapper.selectById(departmentId);
return DepartmentConvert.INSTANCE.convert(departmentDO);
}
/**
* 获得部门列表
*
* @param departmentIds 部门编号列表
* @return 部门列表
*/
public List<DepartmentBO> listDepartments(Collection<Integer> departmentIds) {
List<DepartmentDO> departmentDOs = departmentMapper.selectBatchIds(departmentIds);
return DepartmentConvert.INSTANCE.convertList(departmentDOs);
}
/**
* 获得部门全列表
*
* @return 资源列表
*/
public List<DepartmentBO> listDepartments() {
List<DepartmentDO> departmentDOs = departmentMapper.selectList(null);
return DepartmentConvert.INSTANCE.convertList(departmentDOs);
}
/**
* 校验父部门是否合法
*
* 1. 不能设置自己为父部门
* 2. 父部门不存在
*
* @param pid 父部门编号
* @param childId 当前部门编号
*/
private void checkParentDepartment(Integer pid, Integer childId) {
if (pid == null || DepartmentIdEnum.ROOT.getId().equals(pid)) {
return;
}
// 不能设置自己为父部门
if (pid.equals(childId)) {
throw ServiceExceptionUtil.exception(DEPARTMENT_PARENT_ERROR);
}
DepartmentDO resource = departmentMapper.selectById(pid);
// 父部门不存在
if (resource == null) {
throw ServiceExceptionUtil.exception(DEPARTMENT_PARENT_NOT_EXITS);
}
}
/**
* 校验部门是否合法
*
* 1. 校验相同父部门编号下,是否存在相同的部门名
*
* @param name 部门名字
* @param pid 父部门编号
* @param id 部门编号
*/
private void checkDepartment(Integer pid, String name, Integer id) {
DepartmentDO resource = departmentMapper.selectByPidAndName(pid, name);
if (resource == null) {
return;
}
// 如果 id 为空,说明不用比较是否为相同 id 的部门
if (id == null) {
throw ServiceExceptionUtil.exception(DEPARTMENT_NAME_DUPLICATE);
}
if (!resource.getId().equals(id)) {
throw ServiceExceptionUtil.exception(DEPARTMENT_NAME_DUPLICATE);
}
}
}
package cn.iocoder.mall.systemservice.service.admin.bo;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.DepartmentDO;
import cn.iocoder.mall.systemservice.enums.admin.AdminStatusEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 管理员信息 BO
*/
@Data
@Accessors(chain = true)
public class AdminBO {
/**
* 管理员编号
*/
private Integer id;
/**
* 真实名字
*/
private String name;
/**
* 部门编号
*
* 关联 {@link DepartmentDO#getId()}
*/
private Integer departmentId;
/**
* 在职状态
*
* 枚举 {@link AdminStatusEnum}
*/
private Integer status;
/**
* 登陆账号
*/
private String username;
/**
* 创建时间
*/
private Date createTime;
}
package cn.iocoder.mall.systemservice.service.admin.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* 管理员添加 BO
*/
@Data
@Accessors(chain = true)
public class AdminCreateBO {
/**
* 昵称
*/
@NotEmpty(message = "真实名字不能为空")
@Length(max = 10, message = "真实名字长度最大为 10 位")
private String name;
/**
* 部门编号
*/
@NotNull(message = "部门不能为空")
private Integer departmentId;
/**
* 登录账号
*/
@NotEmpty(message = "登陆账号不能为空")
@Length(min = 5, max = 16, message = "账号长度为 5-16 位")
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
private String username;
/**
* 密码
*/
@NotEmpty(message = "密码不能为空")
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
private String password;
/**
* 创建管理员编号
*/
@NotNull(message = "创建管理员编号不能为空")
private Integer createAdminId;
/**
* 创建 IP
*/
@NotNull(message = "创建 IP 不能为空")
private String createIp;
}
package cn.iocoder.mall.systemservice.service.admin.bo;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class AdminPageBO extends PageParam {
/**
* 真实名字,模糊匹配
*/
private String name;
/**
* 部门编号
*/
private Integer departmentId;
}
package cn.iocoder.mall.systemservice.service.admin.bo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* 管理员修改 BO
*/
@Data
@Accessors(chain = true)
public class AdminUpdateBO {
/**
* 管理员编号
*/
@NotNull(message = "管理员编号不能为空")
private Integer id;
/**
* 昵称
*/
@Length(max = 10, message = "真实名字长度最大为 10 位")
private String name;
/**
* 部门编号
*/
@NotNull(message = "部门不能为空")
private Integer departmentId;
/**
* 状态
*/
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
/**
* 登录账号
*/
@Length(min = 5, max = 16, message = "账号长度为 5-16 位")
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
private String username;
/**
* 密码
*/
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
private String password;
}
package cn.iocoder.mall.systemservice.service.admin.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 部门 BO
*/
@Data
@Accessors(chain = true)
public class DepartmentBO {
/**
* 部门编号
*/
private Integer id;
/**
* 部门名称
*/
private String name;
/**
* 排序字段
*/
private Integer sort;
/**
* 父级部门编号
*/
private Integer pid;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 删除标记
*/
private Integer deleted;
}
package cn.iocoder.mall.systemservice.service.admin.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 部门创建 BO
*/
@Data
@Accessors(chain = true)
public class DepartmentCreateBO {
/**
* 部门名称
*/
@NotEmpty(message = "部门名称不能为空")
private String name;
/**
* 排序字段
*/
@NotNull(message = "排序字段不能为空")
private Integer sort;
/**
* 父级部门编号
*/
@NotNull(message = "父级部门编号不能为空")
private Integer pid;
}
package cn.iocoder.mall.systemservice.service.admin.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 部门更新 BO
*/
@Data
@Accessors(chain = true)
public class DepartmentUpdateBO {
/**
* 部门编号
*/
@NotNull(message = "部门编号不能为空")
private Integer id;
/**
* 部门名称
*/
@NotEmpty(message = "部门名称不能为空")
private String name;
/**
* 排序字段
*/
@NotNull(message = "排序字段不能为空")
private Integer sort;
/**
* 父级部门编号
*/
@NotNull(message = "父级部门编号不能为空")
private Integer pid;
}
package cn.iocoder.mall.systemservice.service.datadict;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.mall.systemservice.convert.datadict.DataDictConvert;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.datadict.DataDictDO;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.datadict.DataDictMapper;
import cn.iocoder.mall.systemservice.service.datadict.bo.DataDictBO;
import cn.iocoder.mall.systemservice.service.datadict.bo.DataDictCreateBO;
import cn.iocoder.mall.systemservice.service.datadict.bo.DataDictUpdateBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.*;
/**
* 数据字典 Service
*/
@Service
@Validated
public class DataDictService {
@Autowired
private DataDictMapper dataDictMapper;
/**
* 创建数据字典
*
* @param createBO 创建数据字典 BO
* @return 数据字典
*/
public DataDictBO createDataDict(@Valid DataDictCreateBO createBO) {
// 校验数据字典重复
checkDataDict(createBO.getEnumValue(), createBO.getValue(), null);
// 插入到数据库
DataDictDO dataDictDO = DataDictConvert.INSTANCE.convert(createBO);
dataDictMapper.insert(dataDictDO);
// 返回
return DataDictConvert.INSTANCE.convert(dataDictDO);
}
/**
* 更新数据字典
*
* @param updateBO 更新数据字典 BO
*/
public void updateDataDict(@Valid DataDictUpdateBO updateBO) {
// 校验更新的数据字典是否存在
if (dataDictMapper.selectById(updateBO.getId()) == null) {
throw ServiceExceptionUtil.exception(DATA_DICT_NOT_EXISTS);
}
// 校验数据字典重复
checkDataDict(updateBO.getEnumValue(), updateBO.getValue(), updateBO.getId());
// 更新到数据库
DataDictDO updateObject = DataDictConvert.INSTANCE.convert(updateBO);
dataDictMapper.updateById(updateObject);
}
/**
* 删除数据字典
*
* @param dataDictId 数据字典编号
*/
public void deleteDataDict(Integer dataDictId) {
// 校验删除的数据字典是否存在
if (dataDictMapper.selectById(dataDictId) == null) {
throw ServiceExceptionUtil.exception(DATA_DICT_NOT_EXISTS);
}
// 标记删除
dataDictMapper.deleteById(dataDictId);
}
/**
* 获得数据字典
*
* @param dataDictId 数据字典编号
* @return 数据字典
*/
public DataDictBO getDataDict(Integer dataDictId) {
DataDictDO dataDictDO = dataDictMapper.selectById(dataDictId);
return DataDictConvert.INSTANCE.convert(dataDictDO);
}
/**
* 获得全部数据字典
*
* @return 数据字典列表
*/
public List<DataDictBO> listDataDicts() {
List<DataDictDO> dataDictDOs = dataDictMapper.selectList(null);
return DataDictConvert.INSTANCE.convertList(dataDictDOs);
}
/**
* 获得数据字典列表
*
* @param dataDictIds 数据字典编号列表
* @return 数据字典列表
*/
public List<DataDictBO> listDataDicts(List<Integer> dataDictIds) {
List<DataDictDO> dataDictDOs = dataDictMapper.selectBatchIds(dataDictIds);
return DataDictConvert.INSTANCE.convertList(dataDictDOs);
}
/**
* 校验数据字典是否合法
*
* 1. 校验相同大类下,是否有相同的小类
*
* @param enumValue 枚举大类
* @param value 枚举小类
* @param id 资源编号
*/
private void checkDataDict(String enumValue, String value, Integer id) {
DataDictDO dataDict = dataDictMapper.selectByEnumValueAndValue(enumValue, value);
if (dataDict == null) {
return;
}
// 如果 id 为空,说明不用比较是否为相同 id 的资源
if (id == null) {
throw ServiceExceptionUtil.exception(DATA_DICT_EXISTS);
}
if (!dataDict.getId().equals(id)) {
throw ServiceExceptionUtil.exception(DATA_DICT_EXISTS);
}
}
// @Override
// public CommonResult<DataDictBO> getDataDict(String dictKey, Object dictValue) {
// DataDictDO dataDictDO = dataDictMapper.selectByEnumValueAndValue(dictKey, String.valueOf(dictValue));
// DataDictBO dataDictBO = DataDictConvert.INSTANCE.convert(dataDictDO);
// return CommonResult.success(dataDictBO);
// }
//
// @Override
// public CommonResult<List<DataDictBO>> getDataDict(String dictKey) {
// List<DataDictDO> dataDictDOList = dataDictMapper.selectByEnumValue(dictKey);
// List<DataDictBO> dataDictBOList = DataDictConvert.INSTANCE.convert(dataDictDOList);
// return CommonResult.success(dataDictBOList);
// }
//
// @Override
// public CommonResult<List<DataDictBO>> getDataDictList(String dictKey, Collection<?> dictValueList) {
// Set<String> convertDictValueList = dictValueList.stream().map(String::valueOf).collect(Collectors.toSet());
// List<DataDictDO> dataDictDOList = dataDictMapper.selectByEnumValueAndValues(dictKey, convertDictValueList);
// List<DataDictBO> dataDictBOList = DataDictConvert.INSTANCE.convert(dataDictDOList);
// return CommonResult.success(dataDictBOList);
// }
}
package cn.iocoder.mall.systemservice.service.datadict.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 数据字典 BO
*/
@Data
@Accessors(chain = true)
public class DataDictBO {
/**
* 编号
*/
private Integer id;
/**
* 大类枚举值
*/
private String enumValue;
/**
* 小类数值
*/
private String value;
/**
* 展示名
*/
private String displayName;
/**
* 排序值
*/
private Integer sort;
/**
* 备注
*/
private String memo;
/**
* 创建时间
*/
private Date createTime;
}
package cn.iocoder.mall.systemservice.service.datadict.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 数据字典创建 BO
*/
@Data
@Accessors(chain = true)
public class DataDictCreateBO {
/**
* 大类枚举值
*/
@NotEmpty(message = "大类枚举值不能为空")
private String enumValue;
/**
* 小类数值
*/
@NotEmpty(message = "小类数值不能为空")
private String value;
/**
* 展示名
*/
@NotEmpty(message = "展示名不能为空")
private String displayName;
/**
* 排序值
*/
@NotNull(message = "排序值不能为空")
private Integer sort;
/**
* 备注
*/
private String memo;
}
package cn.iocoder.mall.systemservice.service.datadict.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 数据字典更新 BO
*/
@Data
@Accessors(chain = true)
public class DataDictUpdateBO {
/**
* 编号
*/
@NotNull(message = "编号不能为空")
private Integer id;
/**
* 大类枚举值
*/
@NotEmpty(message = "大类枚举值不能为空")
private String enumValue;
/**
* 小类数值
*/
@NotEmpty(message = "小类数值不能为空")
private String value;
/**
* 展示名
*/
@NotEmpty(message = "展示名不能为空")
private String displayName;
/**
* 排序值
*/
@NotNull(message = "排序值不能为空")
private Integer sort;
/**
* 备注
*/
private String memo;
}
package cn.iocoder.mall.systemservice.service.errorcode;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.convert.errorcode.ErrorCodeConvert;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.errorcode.ErrorCodeDO;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.errorcode.ErrorCodeMapper;
import cn.iocoder.mall.systemservice.enums.errorcode.ErrorCodeTypeEnum;
import cn.iocoder.mall.systemservice.service.errorcode.bo.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.ERROR_CODE_DUPLICATE;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.ERROR_CODE_NOT_EXISTS;
/**
* 错误码 Service
*/
@Service
@Validated
@Slf4j
public class ErrorCodeService {
@Autowired
private ErrorCodeMapper errorCodeMapper;
/**
* 创建错误码
*
* @param createBO 创建错误码 BO
* @return 错误码
*/
public ErrorCodeBO createErrorCode(@Valid ErrorCodeCreateBO createBO) {
checkDuplicateErrorCode(createBO.getCode(), null);
// 插入到数据库
ErrorCodeDO errorCodeDO = ErrorCodeConvert.INSTANCE.convert(createBO);
errorCodeMapper.insert(errorCodeDO);
// 返回
return ErrorCodeConvert.INSTANCE.convert(errorCodeDO);
}
/**
* 更新错误码
*
* @param updateBO 更新错误码 BO
*/
public void updateErrorCode(@Valid ErrorCodeUpdateBO updateBO) {
checkDuplicateErrorCode(updateBO.getCode(), updateBO.getId());
// 校验更新的错误码是否存在
if (errorCodeMapper.selectById(updateBO.getId()) == null) {
throw ServiceExceptionUtil.exception(ERROR_CODE_NOT_EXISTS);
}
// 更新到数据库
ErrorCodeDO updateObject = ErrorCodeConvert.INSTANCE.convert(updateBO);
errorCodeMapper.updateById(updateObject);
}
@Transactional
public void autoGenerateErrorCodes(@Valid List<ErrorCodeAutoGenerateBO> autoGenerateBOs) {
if (CollectionUtils.isEmpty(autoGenerateBOs)) {
return;
}
List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectListByCodes(
CollectionUtils.convertSet(autoGenerateBOs, ErrorCodeAutoGenerateBO::getCode));
Map<Integer, ErrorCodeDO> errorCodeDOMap = CollectionUtils.convertMap(errorCodeDOs, ErrorCodeDO::getCode);
// 遍历 autoGenerateBOs 数组,逐个插入或更新。考虑到每次量级不大,就不走批量了
autoGenerateBOs.forEach(autoGenerateBO -> {
ErrorCodeDO errorCodeDO = errorCodeDOMap.get(autoGenerateBO.getCode());
// 不存在,则进行新增
if (errorCodeDO == null) {
errorCodeDO = ErrorCodeConvert.INSTANCE.convert(autoGenerateBO)
.setType(ErrorCodeTypeEnum.AUTO_GENERATION.getType());
errorCodeMapper.insert(errorCodeDO);
return;
}
// 存在,则进行更新。更新有三个前置条件:
// 条件 1. 只更新自动生成的错误码,即 Type 为 ErrorCodeTypeEnum.AUTO_GENERATION
if (!ErrorCodeTypeEnum.AUTO_GENERATION.getType().equals(errorCodeDO.getType())) {
return;
}
// 条件 2. 分组 group 必须匹配,避免存在错误码冲突的情况
if (!autoGenerateBO.getGroup().equals(errorCodeDO.getGroup())) {
log.error("[autoGenerateErrorCodes][自动创建({}/{}) 错误码失败,数据库中已经存在({}/{})]",
autoGenerateBO.getCode(), autoGenerateBO.getGroup(),
errorCodeDO.getCode(), errorCodeDO.getGroup());
return;
}
// 条件 3. 错误提示语存在差异
if (autoGenerateBO.getMessage().equals(errorCodeDO.getMessage())) {
return;
}
// 最终匹配,进行更新
errorCodeMapper.updateById(new ErrorCodeDO().setId(errorCodeDO.getId()).setMessage(autoGenerateBO.getMessage()));
});
}
/**
* 删除错误码
*
* @param errorCodeId 错误码编号
*/
public void deleteErrorCode(Integer errorCodeId) {
// 校验删除的错误码是否存在
if (errorCodeMapper.selectById(errorCodeId) == null) {
throw ServiceExceptionUtil.exception(ERROR_CODE_NOT_EXISTS);
}
// 标记删除
errorCodeMapper.deleteById(errorCodeId);
}
/**
* 获得错误码
*
* @param errorCodeId 错误码编号
* @return 错误码
*/
public ErrorCodeBO getErrorCode(Integer errorCodeId) {
ErrorCodeDO errorCodeDO = errorCodeMapper.selectById(errorCodeId);
return ErrorCodeConvert.INSTANCE.convert(errorCodeDO);
}
/**
* 获得错误码列表
*
* @param errorCodeIds 错误码编号列表
* @return 错误码列表
*/
public List<ErrorCodeBO> listErrorCodes(List<Integer> errorCodeIds) {
List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectBatchIds(errorCodeIds);
return ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs);
}
/**
* 获得错误码分页
*
* @param pageBO 错误码分页查询
* @return 错误码分页结果
*/
public PageResult<ErrorCodeBO> pageErrorCode(ErrorCodePageBO pageBO) {
IPage<ErrorCodeDO> errorCodeDOPage = errorCodeMapper.selectPage(pageBO);
return ErrorCodeConvert.INSTANCE.convertPage(errorCodeDOPage);
}
/**
* 校验错误码的唯一字段是否重复
*
* 是否存在相同编码的错误码
*
* @param code 错误码编码
* @param id 错误码编号
*/
private void checkDuplicateErrorCode(Integer code, Integer id) {
ErrorCodeDO errorCodeDO = errorCodeMapper.selectByCode(code);
if (errorCodeDO == null) {
return;
}
// 如果 id 为空,说明不用比较是否为相同 id 的错误码
if (id == null) {
throw ServiceExceptionUtil.exception(ERROR_CODE_DUPLICATE);
}
if (!errorCodeDO.getId().equals(id)) {
throw ServiceExceptionUtil.exception(ERROR_CODE_DUPLICATE);
}
}
public List<ErrorCodeBO> listErrorCodes(String group, Date minUpdateTime) {
List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectListByGroup(group, minUpdateTime);
return ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs);
}
}
package cn.iocoder.mall.systemservice.service.errorcode.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 错误码自动生成 BO
*/
@Data
@Accessors(chain = true)
public class ErrorCodeAutoGenerateBO implements Serializable {
/**
* 错误码编码
*/
@NotNull(message = "错误码编码不能为空")
private Integer code;
/**
* 错误码错误提示
*/
@NotEmpty(message = "错误码错误提示不能为空")
private String message;
/**
* 错误码分组
*/
@NotNull(message = "错误码分组不能为空")
private String group;
}
package cn.iocoder.mall.systemservice.service.errorcode.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 错误码 BO
*/
@Data
@Accessors(chain = true)
public class ErrorCodeBO {
/**
* 错误码编号
*/
private Integer id;
/**
* 错误码编码
*/
private Integer code;
/**
* 错误码错误提示
*/
private String message;
/**
* 错误码类型
*/
private Integer type;
/**
* 错误码分组
*/
private String group;
/**
* 错误码备注
*/
private String memo;
/**
* 创建时间
*/
private Date createTime;
/**
* 最后更新时间
*/
private Date updateTime;
}
package cn.iocoder.mall.systemservice.service.errorcode.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 错误码创建 BO
*/
@Data
@Accessors(chain = true)
public class ErrorCodeCreateBO {
/**
* 错误码编码
*/
@NotNull(message = "错误码编码不能为空")
private Integer code;
/**
* 错误码错误提示
*/
@NotEmpty(message = "错误码错误提示不能为空")
private String message;
/**
* 错误码类型
*/
@NotNull(message = "错误码类型不能为空")
private Integer type;
/**
* 错误码分组
*/
private String group;
/**
* 错误码备注
*/
private String memo;
}
package cn.iocoder.mall.systemservice.service.errorcode.bo;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 错误码分页 BO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ErrorCodePageBO extends PageParam {
/**
* 错误码编码
*/
private Integer code;
/**
* 错误码错误提示
*/
private String message;
/**
* 错误码分组
*/
private String group;
}
package cn.iocoder.mall.systemservice.service.errorcode.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 错误码更新 BO
*/
@Data
@Accessors(chain = true)
public class ErrorCodeUpdateBO {
/**
* 错误码编号
*/
@NotNull(message = "错误码编号不能为空")
private Integer id;
/**
* 错误码编码
*/
@NotNull(message = "错误码编码不能为空")
private Integer code;
/**
* 错误码错误提示
*/
@NotEmpty(message = "错误码错误提示不能为空")
private String message;
/**
* 错误码类型
*/
@NotNull(message = "错误码类型不能为空")
private Integer type;
/**
* 错误码分组
*/
private String group;
/**
* 错误码备注
*/
private String memo;
}
package cn.iocoder.mall.systemservice.service.oauth;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO;
/**
* OAuth2.0 Service 接口
*/
public interface OAuth2Service {
OAuth2AccessTokenRespDTO createAccessToken(OAuth2CreateAccessTokenReqDTO createAccessTokenDTO);
OAuth2AccessTokenRespDTO checkAccessToken(String accessToken);
OAuth2AccessTokenRespDTO refreshAccessToken(OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO);
void removeToken(OAuth2RemoveTokenByUserReqDTO removeTokenDTO);
}
package cn.iocoder.mall.systemservice.service.oauth;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.util.StringUtils;
import cn.iocoder.mall.systemservice.config.SystemBizProperties;
import cn.iocoder.mall.systemservice.convert.oauth.OAuth2Convert;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2RefreshTokenDO;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.oauth.OAuth2AccessTokenMapper;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.oauth.OAuth2RefreshTokenMapper;
import cn.iocoder.mall.systemservice.dal.redis.dao.OAuth2AccessTokenRedisDAO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.*;
/**
* OAuth2.0 Service 实现类
*/
@Service
public class OAuth2ServiceImpl implements OAuth2Service {
@Autowired
private SystemBizProperties systemBizProperties;
@Autowired
private OAuth2AccessTokenMapper oauth2AccessTokenMapper;
@Autowired
private OAuth2RefreshTokenMapper oauth2RefreshTokenMapper;
@Autowired
private OAuth2AccessTokenRedisDAO oauth2AccessTokenRedisDAO;
@Override
@Transactional
public OAuth2AccessTokenRespDTO createAccessToken(OAuth2CreateAccessTokenReqDTO createAccessTokenDTO) {
// 创建刷新令牌 + 访问令牌
OAuth2RefreshTokenDO refreshTokenDO = createOAuth2RefreshToken(createAccessTokenDTO.getUserId(),
createAccessTokenDTO.getUserType(), createAccessTokenDTO.getCreateIp());
OAuth2AccessTokenDO accessTokenDO = createOAuth2AccessToken(refreshTokenDO, createAccessTokenDTO.getCreateIp());
// 返回访问令牌
return OAuth2Convert.INSTANCE.convert(accessTokenDO);
}
@Override
@Transactional
public OAuth2AccessTokenRespDTO checkAccessToken(String accessToken) {
OAuth2AccessTokenDO accessTokenDO = this.getOAuth2AccessToken(accessToken);
if (accessTokenDO == null) { // 不存在
throw ServiceExceptionUtil.exception(OAUTH2_ACCESS_TOKEN_NOT_FOUND);
}
if (accessTokenDO.getExpiresTime().getTime() < System.currentTimeMillis()) { // 已过期
throw ServiceExceptionUtil.exception(OAUTH2_ACCESS_TOKEN_TOKEN_EXPIRED);
}
// 返回访问令牌
return OAuth2Convert.INSTANCE.convert(accessTokenDO);
}
@Override
@Transactional
public OAuth2AccessTokenRespDTO refreshAccessToken(OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO) {
OAuth2RefreshTokenDO refreshTokenDO = oauth2RefreshTokenMapper.selectById(refreshAccessTokenDTO.getRefreshToken());
// 校验刷新令牌是否合法
if (refreshTokenDO == null) { // 不存在
throw ServiceExceptionUtil.exception(OAUTH2_REFRESH_TOKEN_NOT_FOUND);
}
if (refreshTokenDO.getExpiresTime().getTime() < System.currentTimeMillis()) { // 已过期
throw ServiceExceptionUtil.exception(OAUTH_REFRESH_TOKEN_EXPIRED);
}
// 标记 refreshToken 对应的 accessToken 都不合法
// 这块的实现,参考了 Spring Security OAuth2 的代码
List<OAuth2AccessTokenDO> accessTokenDOs = oauth2AccessTokenMapper.selectListByRefreshToken(refreshAccessTokenDTO.getRefreshToken());
accessTokenDOs.forEach(accessTokenDO -> deleteOAuth2AccessToken(accessTokenDO.getId()));
// 创建访问令牌
OAuth2AccessTokenDO oauth2AccessTokenDO = createOAuth2AccessToken(refreshTokenDO, refreshAccessTokenDTO.getCreateIp());
// 返回访问令牌
return OAuth2Convert.INSTANCE.convert(oauth2AccessTokenDO);
}
@Override
@Transactional
public void removeToken(OAuth2RemoveTokenByUserReqDTO removeTokenDTO) {
// 删除 Access Token
OAuth2AccessTokenDO accessTokenDO = oauth2AccessTokenMapper.selectByUserIdAndUserType(
removeTokenDTO.getUserId(), removeTokenDTO.getUserType());
if (accessTokenDO != null) {
this.deleteOAuth2AccessToken(accessTokenDO.getId());
}
// 删除 Refresh Token
oauth2RefreshTokenMapper.deleteByUserIdAndUserType(removeTokenDTO.getUserId(), removeTokenDTO.getUserType());
}
private OAuth2AccessTokenDO createOAuth2AccessToken(OAuth2RefreshTokenDO refreshTokenDO, String createIp) {
OAuth2AccessTokenDO accessToken = new OAuth2AccessTokenDO()
.setId(generateAccessToken())
.setUserId(refreshTokenDO.getUserId()).setUserType(refreshTokenDO.getUserType())
.setRefreshToken(refreshTokenDO.getId())
.setExpiresTime(new Date(System.currentTimeMillis() + systemBizProperties.getAccessTokenExpireTimeMillis()))
.setCreateIp(createIp);
oauth2AccessTokenMapper.insert(accessToken);
return accessToken;
}
private OAuth2RefreshTokenDO createOAuth2RefreshToken(Integer userId, Integer userType, String createIp) {
OAuth2RefreshTokenDO refreshToken = new OAuth2RefreshTokenDO()
.setId(generateRefreshToken())
.setUserId(userId).setUserType(userType)
.setExpiresTime(new Date(System.currentTimeMillis() + systemBizProperties.getRefreshTokenExpireTimeMillis()))
.setCreateIp(createIp);
oauth2RefreshTokenMapper.insert(refreshToken);
return refreshToken;
}
private OAuth2AccessTokenDO getOAuth2AccessToken(String accessToken) {
// 优先从 Redis 中获取
OAuth2AccessTokenDO accessTokenDO = oauth2AccessTokenRedisDAO.get(accessToken);
if (accessTokenDO != null) {
return accessTokenDO;
}
// 获取不到,从 MySQL 中获取
accessTokenDO = oauth2AccessTokenMapper.selectById(accessToken);
// 如果在 MySQL 存在,则往 Redis 中写入
if (accessTokenDO != null) {
oauth2AccessTokenRedisDAO.set(accessTokenDO);
}
return accessTokenDO;
}
/**
* 删除 accessToken 的 MySQL 与 Redis 的数据
*
* @param accessToken 访问令牌
*/
private void deleteOAuth2AccessToken(String accessToken) {
// 删除 MySQL
oauth2AccessTokenMapper.deleteById(accessToken);
// 删除 Redis
oauth2AccessTokenRedisDAO.delete(accessToken);
}
private static String generateAccessToken() {
return StringUtils.uuid(true);
}
private static String generateRefreshToken() {
return StringUtils.uuid(true);
}
}
package cn.iocoder.mall.systemservice.service.permission;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.common.framework.exception.GlobalException;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.AdminDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.AdminRoleDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.ResourceDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.RoleDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.RoleResourceDO;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.admin.AdminMapper;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.AdminRoleMapper;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.ResourceMapper;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.RoleMapper;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.RoleResourceMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.common.framework.exception.enums.GlobalErrorCodeConstants.FORBIDDEN;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.*;
/**
* 权限 Service
*/
@Service
@Slf4j
public class PermissionService {
@Autowired
private AdminMapper adminMapper;
@Autowired
private RoleMapper roleMapper;
@Autowired
private ResourceMapper resourceMapper;
@Autowired
private AdminRoleMapper adminRoleMapper;
@Autowired
private RoleResourceMapper roleResourceMapper;
/**
* 获得角色拥有的资源编号
*
* @param roleId 角色编号
* @return 资源编号列表
*/
public Set<Integer> listRoleResourceIds(Integer roleId) {
List<RoleResourceDO> roleResourceDOs = roleResourceMapper.selectListByRoleId(roleId);
return CollectionUtils.convertSet(roleResourceDOs, RoleResourceDO::getResourceId);
}
/**
* 赋予角色资源
*
* @param roleId 角色编号
* @param resourceIds 资源编号列表
*/
@Transactional
public void assignRoleResource(Integer roleId, Set<Integer> resourceIds) {
// 校验角色是否存在
if (roleMapper.selectById(roleId) == null) {
throw ServiceExceptionUtil.exception(ROLE_NOT_EXISTS);
}
// 校验是否有不存在的资源
if (!CollectionUtils.isEmpty(resourceIds)) {
int dbResourceSize = resourceMapper.selectCountByIdsAndType(resourceIds, null);
if (resourceIds.size() != dbResourceSize) {
throw ServiceExceptionUtil.exception(PERMISSION_ROLE_ASSIGN_RESOURCE_NOT_EXISTS);
}
}
// TODO 芋艿,这里先简单实现。即方式是,删除老的分配的资源关系,然后添加新的分配的资源关系
// 标记角色原资源关系都为删除
roleResourceMapper.deleteByRoleId(roleId);
// 创建 RoleResourceDO 数组,并插入到数据库
if (!CollectionUtils.isEmpty(resourceIds)) {
List<RoleResourceDO> roleResources = resourceIds.stream()
.map(resourceId -> new RoleResourceDO().setRoleId(roleId).setResourceId(resourceId)).collect(Collectors.toList());
roleResourceMapper.insertList(roleResources);
}
}
/**
* 赋予管理员角色
*
* @param adminId 管理员编号
* @param roleIds 角色编号列表
*/
@Transactional
public void assignAdminRole(Integer adminId, Set<Integer> roleIds) {
// 校验账号存在
AdminDO admin = adminMapper.selectById(adminId);
if (admin == null) {
throw ServiceExceptionUtil.exception(ADMIN_NOT_FOUND);
}
// 校验是否有不存在的角色
if (!CollectionUtils.isEmpty(roleIds)) {
List<RoleDO> roles = roleMapper.selectBatchIds(roleIds);
if (roles.size() != roleIds.size()) {
throw ServiceExceptionUtil.exception(ADMIN_ASSIGN_ROLE_NOT_EXISTS);
}
}
// TODO 芋艿,这里先简单实现。即方式是,删除老的分配的角色关系,然后添加新的分配的角色关系
// 标记管理员角色源关系都为删除
adminRoleMapper.deleteByAdminId(adminId);
// 创建 RoleResourceDO 数组,并插入到数据库
if (!CollectionUtil.isEmpty(roleIds)) {
List<AdminRoleDO> adminRoleDOs = roleIds.stream()
.map(roleId -> new AdminRoleDO().setAdminId(adminId).setRoleId(roleId)).collect(Collectors.toList());
adminRoleMapper.insertList(adminRoleDOs);
}
}
/**
* 获得管理员拥有的角色编号列表
*
* @param adminId 管理员编号
* @return 角色编号列表
*/
public Set<Integer> listAdminRoleIds(Integer adminId) {
List<AdminRoleDO> adminRoleDOs = adminRoleMapper.selectListByAdminId(adminId);
return CollectionUtils.convertSet(adminRoleDOs, AdminRoleDO::getRoleId);
}
/**
* 获得每个管理员拥有的角色编号
* 返回的结果,key 为管理员编号
*
* @param adminIds 管理员编号列表
* @return 每个管理员拥有的角色编号
*/
public Map<Integer, Set<Integer>> mapAdminRoleIds(Collection<Integer> adminIds) {
List<AdminRoleDO> adminRoleDOs = adminRoleMapper.selectListByAdminIds(adminIds);
if (CollectionUtils.isEmpty(adminRoleDOs)) {
return Collections.emptyMap();
}
return CollectionUtils.convertMultiMap2(adminRoleDOs, AdminRoleDO::getAdminId, AdminRoleDO::getRoleId);
}
public void checkPermission(Collection<Integer> roleIds, Collection<String> permissions) {
// 查询权限对应资源
List<ResourceDO> resourceBOs = resourceMapper.selectListByPermissions(permissions);
if (CollectionUtil.isEmpty(resourceBOs)) { // 无对应资源,则认为无需权限验证
log.warn("[checkPermission][permission({}) 未配置对应资源]", permissions);
return;
}
Set<Integer> permissionIds = CollectionUtils.convertSet(resourceBOs, ResourceDO::getId);
// 权限验证
List<RoleResourceDO> roleResourceDOs = roleResourceMapper.selectListByResourceIds(permissionIds);
if (CollectionUtil.isEmpty(roleResourceDOs)) { // 资源未授予任何角色,必然权限验证不通过
throw new GlobalException(FORBIDDEN);
}
Map<Integer, List<Integer>> resourceRoleMap = CollectionUtils.convertMultiMap(roleResourceDOs,
RoleResourceDO::getResourceId, RoleResourceDO::getRoleId);
for (Map.Entry<Integer, List<Integer>> entry : resourceRoleMap.entrySet()) {
if (!CollectionUtil.containsAny(roleIds, entry.getValue())) { // 所以有任一不满足,就验证失败,抛出异常
throw new GlobalException(FORBIDDEN);
}
}
}
}
package cn.iocoder.mall.systemservice.service.permission;
/**
* 资源 Service 接口
*/
public interface ResourceService {
}
package cn.iocoder.mall.systemservice.service.permission;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.mall.systemservice.convert.permission.ResourceConvert;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.ResourceDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.RoleResourceDO;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.ResourceMapper;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.RoleResourceMapper;
import cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants;
import cn.iocoder.mall.systemservice.enums.permission.ResourceIdEnum;
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
import cn.iocoder.mall.systemservice.service.permission.bo.ResourceBO;
import cn.iocoder.mall.systemservice.service.permission.bo.ResourceCreateBO;
import cn.iocoder.mall.systemservice.service.permission.bo.ResourceUpdateBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.*;
/**
* 资源 Service
*/
@Service
@Validated
public class ResourceServiceImpl implements ResourceService {
@Autowired
private ResourceMapper resourceMapper;
@Autowired
private RoleResourceMapper roleResourceMapper;
/**
* 创建资源
*
* @param createBO 创建资源 BO
* @return 资源
*/
public ResourceBO createResource(@Valid ResourceCreateBO createBO) {
// 校验父资源存在
checkParentResource(createBO.getPid(), null);
// 校验资源(自己)
checkResource(createBO.getPid(), createBO.getName(), null);
// 插入数据库
ResourceDO resourceDO = ResourceConvert.INSTANCE.convert(createBO);
initResourceProperty(resourceDO);
resourceMapper.insert(resourceDO);
// 返回
return ResourceConvert.INSTANCE.convert(resourceDO);
}
/**
* 更新资源
*
* @param updateBO 更新资源 BO
*/
public void updateResource(@Valid ResourceUpdateBO updateBO) {
// 校验更新的资源是否存在
if (resourceMapper.selectById(updateBO.getId()) == null) {
throw ServiceExceptionUtil.exception(RESOURCE_NOT_EXISTS);
}
// 校验父资源存在
checkParentResource(updateBO.getPid(), updateBO.getId());
// 校验资源(自己)
checkResource(updateBO.getPid(), updateBO.getName(), updateBO.getId());
// 更新到数据库
ResourceDO updateObject = ResourceConvert.INSTANCE.convert(updateBO);
initResourceProperty(updateObject);
resourceMapper.updateById(updateObject);
}
/**
* 删除资源
*
* @param resourceId 资源编号
*/
public void deleteResource(Integer resourceId) {
// 校验更新的资源是否存在
if (resourceMapper.selectById(resourceId) == null) {
throw ServiceExceptionUtil.exception(SystemErrorCodeConstants.RESOURCE_NOT_EXISTS);
}
// 校验是否还有子资源
if (resourceMapper.selectCountByPid(resourceId) > 0) {
throw ServiceExceptionUtil.exception(SystemErrorCodeConstants.RESOURCE_EXISTS_CHILDREN);
}
// 校验删除的资源是否存在
if (resourceMapper.selectById(resourceId) == null) {
throw ServiceExceptionUtil.exception(RESOURCE_NOT_EXISTS);
}
// 标记删除
resourceMapper.deleteById(resourceId);
// 删除授予给角色的权限
roleResourceMapper.deleteByResourceId(resourceId);
}
/**
* 获得资源
*
* @param resourceId 资源编号
* @return 资源
*/
public ResourceBO getResource(Integer resourceId) {
ResourceDO resourceDO = resourceMapper.selectById(resourceId);
return ResourceConvert.INSTANCE.convert(resourceDO);
}
/**
* 获得资源列表
*
* @param resourceIds 资源编号列表
* @return 资源列表
*/
public List<ResourceBO> listResources(List<Integer> resourceIds) {
List<ResourceDO> resourceDOs = resourceMapper.selectBatchIds(resourceIds);
return ResourceConvert.INSTANCE.convertList(resourceDOs);
}
/**
* 获得资源全列表
*
* @return 资源全列表
*/
public List<ResourceBO> listResources() {
List<ResourceDO> resourceDOs = resourceMapper.selectList(null);
return ResourceConvert.INSTANCE.convertList(resourceDOs);
}
/**
* 获得指定类型的资源列表
*
* @param type 资源类型,允许空
* @return 资源列表
*/
public List<ResourceBO> listResourcesByType(Integer type) {
List<ResourceDO> resourceDOs = resourceMapper.selectListByType(type);
return ResourceConvert.INSTANCE.convertList(resourceDOs);
}
/**
* 获得角色拥有的资源列表
*
* @param roleIds 角色编号
* @param type 资源类型,允许空
* @return 资源列表
*/
public List<ResourceBO> listRoleResourcesByType(Collection<Integer> roleIds, Integer type) {
List<RoleResourceDO> roleResourceDOs = roleResourceMapper.selectListByRoleIds(roleIds);
if (CollectionUtils.isEmpty(roleResourceDOs)) {
return Collections.emptyList();
}
List<ResourceDO> resourceDOs = resourceMapper.selectListByIdsAndType(
CollectionUtils.convertSet(roleResourceDOs, RoleResourceDO::getResourceId), type);
return ResourceConvert.INSTANCE.convertList(resourceDOs);
}
/**
* 校验父资源是否合法
*
* 1. 不能设置自己为父资源
* 2. 父资源不存在
* 3. 父资源必须是 {@link ResourceTypeEnum#MENU} 菜单类型
*
* @param pid 父资源编号
* @param childId 当前资源编号
*/
private void checkParentResource(Integer pid, Integer childId) {
if (pid == null || ResourceIdEnum.ROOT.getId().equals(pid)) {
return;
}
// 不能设置自己为父资源
if (pid.equals(childId)) {
throw ServiceExceptionUtil.exception(RESOURCE_PARENT_ERROR);
}
ResourceDO resource = resourceMapper.selectById(pid);
// 父资源不存在
if (resource == null) {
throw ServiceExceptionUtil.exception(RESOURCE_PARENT_NOT_EXISTS);
}
// 父资源必须是菜单类型
if (!ResourceTypeEnum.MENU.getType().equals(resource.getType())) {
throw ServiceExceptionUtil.exception(RESOURCE_PARENT_NOT_MENU);
}
}
/**
* 校验资源是否合法
*
* 1. 校验相同父资源编号下,是否存在相同的资源名
*
* @param name 资源名字
* @param pid 父资源编号
* @param id 资源编号
*/
private void checkResource(Integer pid, String name, Integer id) {
ResourceDO resource = resourceMapper.selectByPidAndName(pid, name);
if (resource == null) {
return;
}
// 如果 id 为空,说明不用比较是否为相同 id 的资源
if (id == null) {
throw ServiceExceptionUtil.exception(RESOURCE_NAME_DUPLICATE);
}
if (!resource.getId().equals(id)) {
throw ServiceExceptionUtil.exception(RESOURCE_NAME_DUPLICATE);
}
}
/**
* 初始化资源的通用属性。
*
* 例如说,只有菜单类型的资源,才设置 icon
*
* @param resource 资源
*/
private void initResourceProperty(ResourceDO resource) {
// 资源为按钮类型时,无需 route、icon、view 属性,进行置空
if (ResourceTypeEnum.BUTTON.getType().equals(resource.getType())) {
resource.setRoute(null);
resource.setIcon(null);
resource.setView(null);
}
}
}
package cn.iocoder.mall.systemservice.service.permission;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.convert.permission.RoleConvert;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.AdminRoleDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.RoleDO;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.AdminRoleMapper;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.RoleMapper;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.RoleResourceMapper;
import cn.iocoder.mall.systemservice.enums.permission.RoleCodeEnum;
import cn.iocoder.mall.systemservice.enums.permission.RoleTypeEnum;
import cn.iocoder.mall.systemservice.service.permission.bo.RoleBO;
import cn.iocoder.mall.systemservice.service.permission.bo.RoleCreateBO;
import cn.iocoder.mall.systemservice.service.permission.bo.RolePageBO;
import cn.iocoder.mall.systemservice.service.permission.bo.RoleUpdateBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.*;
/**
* 角色 Service
*/
@Service
@Validated
public class RoleService {
@Autowired
private RoleMapper roleMapper;
@Autowired
private AdminRoleMapper adminRoleMapper;
@Autowired
private RoleResourceMapper roleResourceMapper;
/**
* 创建角色
*
* @param createBO 创建角色 BO
* @return 角色
*/
public RoleBO createRole(@Valid RoleCreateBO createBO) {
// 校验角色
checkDuplicateRole(createBO.getName(), createBO.getCode(), null);
// 插入到数据库
RoleDO roleDO = RoleConvert.INSTANCE.convert(createBO);
roleDO.setType(RoleTypeEnum.CUSTOM.getType());
roleMapper.insert(roleDO);
// 返回
return RoleConvert.INSTANCE.convert(roleDO);
}
/**
* 更新角色
*
* @param updateBO 更新角色 BO
*/
public void updateRole(@Valid RoleUpdateBO updateBO) {
// 校验更新的角色是否存在
RoleDO roleDO = roleMapper.selectById(updateBO.getId());
if (roleMapper.selectById(updateBO.getId()) == null) {
throw ServiceExceptionUtil.exception(ROLE_NOT_EXISTS);
}
// 内置角色,不允许修改
if (RoleTypeEnum.SYSTEM.getType().equals(roleDO.getType())) {
throw ServiceExceptionUtil.exception(ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE);
}
// 校验角色的唯一字段是否重复
checkDuplicateRole(updateBO.getName(), updateBO.getCode(), updateBO.getId());
// 更新到数据库
RoleDO updateObject = RoleConvert.INSTANCE.convert(updateBO);
roleMapper.updateById(updateObject);
}
/**
* 删除角色
*
* @param roleId 角色编号
*/
public void deleteRole(Integer roleId) {
// 校验删除的角色是否存在
RoleDO roleDO = roleMapper.selectById(roleId);
if (roleMapper.selectById(roleId) == null) {
throw ServiceExceptionUtil.exception(ROLE_NOT_EXISTS);
}
// 内置角色,不允许删除
if (RoleTypeEnum.SYSTEM.getType().equals(roleDO.getType())) {
throw ServiceExceptionUtil.exception(ROLE_CAN_NOT_DELETE_SYSTEM_TYPE_ROLE);
}
// 标记删除
roleMapper.deleteById(roleId);
// 标记删除 RoleResource
roleResourceMapper.deleteByRoleId(roleId);
// 标记删除 AdminRole
adminRoleMapper.deleteByRoleId(roleId);
}
/**
* 获得角色
*
* @param roleId 角色编号
* @return 角色
*/
public RoleBO getRole(Integer roleId) {
RoleDO roleDO = roleMapper.selectById(roleId);
return RoleConvert.INSTANCE.convert(roleDO);
}
/**
* 获得所有角色
*
* @return 角色列表
*/
public List<RoleBO> listAllRole() {
List<RoleDO> roleDOs = roleMapper.selectList(null);
return RoleConvert.INSTANCE.convertList(roleDOs);
}
/**
* 获得角色列表
*
* @param roleIds 角色编号列表
* @return 角色列表
*/
public List<RoleBO> listRole(Collection<Integer> roleIds) {
List<RoleDO> roleDOs = roleMapper.selectBatchIds(roleIds);
return RoleConvert.INSTANCE.convertList(roleDOs);
}
/**
* 获得角色分页
*
* @param pageBO 角色分页查询
* @return 角色分页结果
*/
public PageResult<RoleBO> pageRole(RolePageBO pageBO) {
IPage<RoleDO> roleDOPage = roleMapper.selectPage(pageBO);
return RoleConvert.INSTANCE.convertPage(roleDOPage);
}
/**
* 校验角色的唯一字段是否重复
*
* 1. 是否存在相同名字的角色
* 2. 是否存在相同编码的角色
*
* @param name 角色名字
* @param code 角色额编码
* @param id 角色编号
*/
private void checkDuplicateRole(String name, String code, Integer id) {
// 1. 该 name 名字被其它角色所使用
RoleDO role = roleMapper.selectByName(name);
if (role != null && !role.getId().equals(id)) {
throw ServiceExceptionUtil.exception(ROLE_NAME_DUPLICATE, name);
}
// 2. 是否存在相同编码的角色
if (!StringUtils.hasText(code)) {
return;
}
// 该 code 编码被其它角色所使用
role = roleMapper.selectByCode(code);
if (role != null && !role.getId().equals(id)) {
throw ServiceExceptionUtil.exception(ROLE_CODE_DUPLICATE, name);
}
}
/**
* 获得管理员拥有的角色编号列表
*
* @param adminId 管理员编号
* @return 角色编号列表
*/
public Set<Integer> listAdminRoleIds(Integer adminId) {
List<AdminRoleDO> adminRoleDOs = adminRoleMapper.selectByAdminId(adminId);
return CollectionUtils.convertSet(adminRoleDOs, AdminRoleDO::getRoleId);
}
/**
* 判断角色是否有超级管理员
*
* @param roleIds 角色编号列表
* @return 是否有超级管理员
*/
public boolean hasSuperAdmin(Collection<Integer> roleIds) {
List<RoleDO> roleDOs = roleMapper.selectBatchIds(roleIds);
for (RoleDO roleDO : roleDOs) {
if (RoleCodeEnum.SUPER_ADMIN.getCode().equals(roleDO.getCode())) {
return true;
}
}
return false;
}
}
package cn.iocoder.mall.systemservice.service.permission.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
@Data
@Accessors(chain = true)
public class ResourceBO {
/**
* 资源编号
*/
private Integer id;
/**
* 菜单名
*/
private String name;
/**
* 权限标识
*/
private String permission;
/**
* 资源类型
*/
private Integer type;
/**
* 排序
*/
private Integer sort;
/**
* 父级资源编号
*/
private Integer pid;
/**
* 前端路由
*/
private String route;
/**
* 菜单图标
*/
private String icon;
/**
* 前端界面
*/
private String view;
/**
* 添加时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}
package cn.iocoder.mall.systemservice.service.permission.bo;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 资源创建 BO
*/
@Data
@Accessors(chain = true)
public class ResourceCreateBO {
/**
* 菜单名
*/
@NotEmpty(message = "菜单名不能为空")
private String name;
/**
* 权限标识
*/
private String permission;
/**
* 资源类型
*/
@NotNull(message = "资源类型不能为空")
@InEnum(value = ResourceTypeEnum.class, message = "资源类型必须是 {value}")
private Integer type;
/**
* 排序
*/
@NotNull(message = "排序不能为空")
private Integer sort;
/**
* 父级资源编号
*/
@NotNull(message = "父级资源编号不能为空")
private Integer pid;
/**
* 前端路由
*/
private String route;
/**
* 菜单图标
*/
private String icon;
/**
* 前端界面
*/
private String view;
/**
* 创建管理员编号
*/
@NotNull(message = "创建管理员编号不能为空")
private Integer createAdminId;
}
package cn.iocoder.mall.systemservice.service.permission.bo;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Data
@Accessors(chain = true)
public class ResourceUpdateBO {
/**
* 菜单编号
*/
@NotNull(message = "菜单编号不能为空")
private Integer id;
/**
* 菜单名
*/
@NotEmpty(message = "菜单名不能为空")
private String name;
/**
* 权限标识
*/
private String permission;
/**
* 资源类型
*/
@NotNull(message = "资源类型不能为空")
@InEnum(value = ResourceTypeEnum.class, message = "资源类型必须是 {value}")
private Integer type;
/**
* 排序
*/
@NotNull(message = "排序不能为空")
private Integer sort;
/**
* 父级资源编号
*/
@NotNull(message = "父级资源编号不能为空")
private Integer pid;
/**
* 前端路由
*/
private String route;
/**
* 菜单图标
*/
private String icon;
/**
* 前端界面
*/
private String view;
}
package cn.iocoder.mall.systemservice.service.permission.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 角色 BO
*/
@Data
@Accessors(chain = true)
public class RoleBO {
/**
* 角色编号
*/
private Integer id;
/**
* 角色名
*/
private String name;
/**
* 角色编码
*/
private String code;
/**
* 角色类型
*/
private Integer type;
/**
* 创建管理员编号
*/
private Integer createAdminId;
/**
* 创建时间
*/
private Date createTime;
}
package cn.iocoder.mall.systemservice.service.permission.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 角色创建 BO
*/
@Data
@Accessors(chain = true)
public class RoleCreateBO {
/**
* 角色名
*/
@NotEmpty(message = "角色名不能为空")
private String name;
/**
* 角色编码
*/
private String code;
/**
* 创建管理员编号
*/
@NotNull(message = "创建管理员编号不能为空")
private Integer createAdminId;
}
package cn.iocoder.mall.systemservice.service.permission.bo;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 角色分页 BO
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class RolePageBO extends PageParam {
/**
* 角色名,模糊匹配
*/
private String name;
}
package cn.iocoder.mall.systemservice.service.permission.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 角色更新 BO
*/
@Data
@Accessors(chain = true)
public class RoleUpdateBO {
/**
* 角色编号
*/
@NotNull(message = "角色编号不能为空")
private Integer id;
/**
* 角色名
*/
@NotEmpty(message = "角色名不能为空")
private String name;
/**
* 角色编码
*/
private String code;
}
package cn.iocoder.mall.systemservice.service.systemlog;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.convert.systemlog.SystemAccessLogConvert;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemAccessLogDO;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog.SystemAccessLogMapper;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogBO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogCreateBO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogPageBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 系统访问日志 Service
*/
@Service
public class SystemAccessLogService {
@Autowired
private SystemAccessLogMapper systemAccessLogMapper;
/**
* 创建系统访问日志
*
* @param createBO 创建系统访问日志 BO
*/
public void createSystemAccessLog(SystemAccessLogCreateBO createBO) {
SystemAccessLogDO logDO = SystemAccessLogConvert.INSTANCE.convert(createBO);
systemAccessLogMapper.insert(logDO);
}
/**
* 获得系统访问日志分页
*
* @param pageBO 系统访问日志分页查询
* @return 系统访问日志分页结果
*/
public PageResult<SystemAccessLogBO> pageSystemAccessLog(SystemAccessLogPageBO pageBO) {
IPage<SystemAccessLogDO> systemAccessLogDOPage = systemAccessLogMapper.selectPage(pageBO);
return SystemAccessLogConvert.INSTANCE.convertPage(systemAccessLogDOPage);
}
}
package cn.iocoder.mall.systemservice.service.systemlog;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.systemservice.convert.systemlog.SystemExceptionLogConvert;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemExceptionLogDO;
import cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog.SystemExceptionLogMapper;
import cn.iocoder.mall.systemservice.enums.systemlog.SystemExceptionLogProcessStatusEnum;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogBO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogCreateBO;
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogPageBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.SYSTEM_EXCEPTION_LOG_NOT_FOUND;
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.SYSTEM_EXCEPTION_LOG_PROCESSED;
/**
* 系统异常日志 Service
*/
@Service
public class SystemExceptionLogService {
@Autowired
private SystemExceptionLogMapper systemExceptionLogMapper;
/**
* 创建系统异常日志
*
* @param createBO 创建 BO
*/
public void createSystemExceptionLog(SystemExceptionLogCreateBO createBO) {
SystemExceptionLogDO logDO = SystemExceptionLogConvert.INSTANCE.convert(createBO);
logDO.setProcessStatus(SystemExceptionLogProcessStatusEnum.INIT.getStatus());
systemExceptionLogMapper.insert(logDO);
}
/**
* 处理系统异常日志
*
* @param logId 日志编号
* @param processAdminId 处理管理员编号
* @param processStatus 处理状态
*/
public void processSystemExceptionLog(Integer logId, Integer processAdminId, Integer processStatus) {
SystemExceptionLogDO logDO = systemExceptionLogMapper.selectById(logId);
if (logDO == null) {
throw ServiceExceptionUtil.exception(SYSTEM_EXCEPTION_LOG_NOT_FOUND);
}
if (!SystemExceptionLogProcessStatusEnum.INIT.getStatus().equals(logDO.getProcessStatus())) {
throw ServiceExceptionUtil.exception(SYSTEM_EXCEPTION_LOG_PROCESSED);
}
// 标记处理
SystemExceptionLogDO updateObj = new SystemExceptionLogDO().setId(logId)
.setProcessAdminId(processAdminId).setProcessStatus(processStatus);
systemExceptionLogMapper.updateById(updateObj);
}
/**
* 获得系统异常日志分页
*
* @param pageBO 系统异常日志分页查询
* @return 系统异常日志分页结果
*/
public PageResult<SystemExceptionLogBO> pageSystemExceptionLog(SystemExceptionLogPageBO pageBO) {
IPage<SystemExceptionLogDO> systemExceptionLogDOPage = systemExceptionLogMapper.selectPage(pageBO);
return SystemExceptionLogConvert.INSTANCE.convertPage(systemExceptionLogDOPage);
}
public SystemExceptionLogBO getSystemExceptionLog(Integer logId) {
SystemExceptionLogDO logDO = systemExceptionLogMapper.selectById(logId);
return SystemExceptionLogConvert.INSTANCE.convert(logDO);
}
}
package cn.iocoder.mall.systemservice.service.systemlog.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 系统访问日志 BO
*/
@Data
@Accessors(chain = true)
public class SystemAccessLogBO {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*/
private Integer userType;
/**
* 链路追踪编号
*/
private String traceId;
/**
* 应用名
*/
private String applicationName;
/**
* 访问地址
*/
private String uri;
/**
* 参数
*/
private String queryString;
/**
* http 方法
*/
private String method;
/**
* userAgent
*/
private String userAgent;
/**
* ip
*/
private String ip;
/**
* 请求时间
*/
private Date startTime;
/**
* 响应时长 -- 毫秒级
*/
private Integer responseTime;
/**
* 错误码
*/
private Integer errorCode;
/**
* 错误提示
*/
private String errorMessage;
/**
* 创建时间
*/
private Date createTime;
}
package cn.iocoder.mall.systemservice.service.systemlog.bo;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 访问日志添加 BO
*/
@Data
@Accessors(chain = true)
public class SystemAccessLogCreateBO {
/**
* 账号编号
*/
private Integer userId;
/**
* 用户类型
*
* 枚举 {@link UserTypeEnum}
*/
private Integer userType;
/**
* 链路编号
*/
private String traceId;
@NotNull(message = "应用名不能为空")
private String applicationName;
@NotNull(message = "访问地址不能为空")
private String uri;
@NotNull(message = "请求参数不能为空")
private String queryString;
@NotNull(message = "http 请求方法不能为空")
private String method;
@NotNull(message = "User-Agent 不能为空")
private String userAgent;
@NotNull(message = "ip 不能为空")
private String ip;
@NotNull(message = "请求时间不能为空")
private Date startTime;
@NotNull(message = "响应时长不能为空")
private Integer responseTime;
@NotNull(message = "错误码不能为空")
private Integer errorCode;
/**
* 错误提示
*/
private String errorMessage;
}
package cn.iocoder.mall.systemservice.service.systemlog.bo;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 系统访问日志分页 BO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SystemAccessLogPageBO extends PageParam {
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*/
private Integer userType;
/**
* 应用名
*/
private String applicationName;
}
package cn.iocoder.mall.systemservice.service.systemlog.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 系统异常日志 BO
*/
@Data
@Accessors(chain = true)
public class SystemExceptionLogBO {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*/
private Integer userType;
/**
* 链路追踪编号
*
* 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。
*/
private String traceId;
/**
* 应用名
*
* 目前读取 spring.application.name
*/
private String applicationName;
/**
* 访问地址
*/
private String uri;
/**
* 参数
*/
private String queryString;
/**
* http 方法
*/
private String method;
/**
* userAgent
*/
private String userAgent;
/**
* ip
*/
private String ip;
/**
* 异常发生时间
*/
private Date exceptionTime;
/**
* 异常名
*
* {@link Throwable#getClass()} 的类全名
*/
private String exceptionName;
/**
* 异常导致的消息
*
* {@link cn.iocoder.common.framework.util.ExceptionUtil#getMessage(Throwable)}
*/
private String exceptionMessage;
/**
* 异常导致的根消息
*
* {@link cn.iocoder.common.framework.util.ExceptionUtil#getRootCauseMessage(Throwable)}
*/
private String exceptionRootCauseMessage;
/**
* 异常的栈轨迹
*
* {@link cn.iocoder.common.framework.util.ExceptionUtil#getServiceException(Exception)}
*/
private String exceptionStackTrace;
/**
* 异常发生的类全名
*
* {@link StackTraceElement#getClassName()}
*/
private String exceptionClassName;
/**
* 异常发生的类文件
*
* {@link StackTraceElement#getFileName()}
*/
private String exceptionFileName;
/**
* 异常发生的方法名
*
* {@link StackTraceElement#getMethodName()}
*/
private String exceptionMethodName;
/**
* 异常发生的方法所在行
*
* {@link StackTraceElement#getLineNumber()}
*/
private Integer exceptionLineNumber;
/**
* 处理状态
*/
private Integer processStatus;
/**
* 处理时间
*/
private Date processTime;
/**
* 处理管理员编号
*/
private Integer processAdminId;
/**
* 创建时间
*/
private Date createTime;
}
package cn.iocoder.mall.systemservice.service.systemlog.bo;
import cn.iocoder.common.framework.enums.UserTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 系统异常日志添加 BO
*/
@Data
@Accessors(chain = true)
public class SystemExceptionLogCreateBO {
/**
* 账号编号
*/
private Integer userId;
/**
* 用户类型
*
* 枚举 {@link UserTypeEnum}
*/
private Integer userType;
/**
* 链路编号
*/
private String traceId;
@NotNull(message = "应用名不能为空")
private String applicationName;
@NotNull(message = "访问地址不能为空")
private String uri;
@NotNull(message = "请求参数不能为空")
private String queryString;
@NotNull(message = "http 请求方法不能为空")
private String method;
@NotNull(message = "User-Agent 不能为空")
private String userAgent;
@NotNull(message = "ip 不能为空")
private String ip;
@NotNull(message = "异常时间不能为空")
private Date exceptionTime;
@NotNull(message = "异常名不能为空")
private String exceptionName;
@NotNull(message = "异常发生的类全名不能为空")
private String exceptionClassName;
@NotNull(message = "异常发生的类文件不能为空")
private String exceptionFileName;
@NotNull(message = "异常发生的方法名不能为空")
private String exceptionMethodName;
@NotNull(message = "异常发生的方法所在行不能为空")
private Integer exceptionLineNumber;
@NotNull(message = "异常的栈轨迹不能为空")
private String exceptionStackTrace;
@NotNull(message = "异常导致的根消息不能为空")
private String exceptionRootCauseMessage;
@NotNull(message = "异常导致的消息不能为空")
private String exceptionMessage;
}
package cn.iocoder.mall.systemservice.service.systemlog.bo;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 系统异常日志分页 BO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SystemExceptionLogPageBO extends PageParam {
/**
* 用户编号
*/
private Integer userId;
/**
* 用户类型
*/
private Integer userType;
/**
* 应用名
*
* 目前读取 spring.application.name
*/
private String applicationName;
/**
* 处理状态
*/
private Integer processStatus;
}
spring:
# MySQL 配置项
datasource:
url: jdbc:mysql://localhost:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
password: zhuyang
# Redis 配置
redis:
host: localhost
port: 6379
database: 0
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
spring:
# MySQL 配置项
datasource:
url: jdbc:mysql://localhost:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
password: zhuyang
# Redis 配置
redis:
host: localhost
port: 6379
database: 0
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider:
tag: ${DUBBO_TAG} # Dubbo 路由分组
spring:
# Application 的配置项
application:
name: system-service
# Profile 的配置项
profiles:
active: local
# MyBatis Plus 配置项
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
global-config:
db-config:
id-type: auto
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
mapper-locations: classpath*:mapper/*.xml
type-aliases-package: cn.iocoder.mall.systemservice.dal.mysql.dataobject
# Dubbo 配置项
dubbo:
# Spring Cloud Alibaba Dubbo 专属配置
cloud:
subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用
# Dubbo 提供者的协议
protocol:
name: dubbo
port: -1
# Dubbo 提供服务的扫描基础包
scan:
base-packages: cn.iocoder.mall.systemservice.rpc
# Dubbo 服务提供者的配置
provider:
filter: -exception
validation: true # 开启 Provider 参数校验
version: 1.0.0 # 服务的版本号
AdminRpc:
version: 1.0.0
ResourceRpc:
version: 1.0.0
RoleRpc:
version: 1.0.0
PermissionRpc:
version: 1.0.0
DepartmentRpc:
version: 1.0.0
DataDictRpc:
version: 1.0.0
SystemExceptionLogRpc:
version: 1.0.0
SystemAccessLogRpc:
version: 1.0.0
ErrorCodeRpc:
version: 1.0.0
# Dubbo 服务消费者的配置
consumer:
ErrorCodeRpc:
version: 1.0.0
# Actuator 监控配置项
management:
server.port: 38080 # 独立端口,避免被暴露出去
endpoints.web.exposure.include: '*' # 暴露所有监控端点
server.port: ${management.server.port} # 设置使用 Actuator 的服务器端口,因为 RPC 服务不需要 Web 端口
# Mall 配置项
mall:
# 错误码配置项对应 ErrorCodeProperties 配置类
error-code:
group: ${spring.application.name}
constants-class: cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants
# 业务配置
biz:
access-token-expire-time-millis: 2880000
refresh-token-expire-time-millis: 43200000
<?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="cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.AdminRoleMapper">
<insert id="insertList">
INSERT INTO permission_admin_role (
admin_id, role_id
) VALUES
<foreach collection="adminRoleDOs" item="adminRole" separator=",">
(#{adminRole.adminId}, #{adminRole.roleId})
</foreach>
</insert>
</mapper>
<?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="cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.RoleResourceMapper">
<insert id="insertList">
INSERT INTO permission_role_resource (
resource_id, role_id
) VALUES
<foreach collection="roleResources" item="roleResource" separator=",">
(#{roleResource.resourceId}, #{roleResource.roleId})
</foreach>
</insert>
</mapper>
-- ----------------------------
-- Table data for admin
-- ----------------------------
INSERT INTO `mall_system`.`admin`(`id`, `name`, `avatar`, `department_id`, `status`, `username`, `password`, `password_salt`, `create_admin_id`, `create_ip`, `create_time`, `update_time`) VALUES (1, '管理员', '', NULL, 1, 'admin', '$2a$10$5sSIO3fq77iVvrnv4XjXwugz4D91D4gxIe7ClQzKsPySNPEZcr6za', '$2a$10$5sSIO3fq77iVvrnv4XjXwu', 0, '', '2020-04-17 19:20:14', '2020-07-04 21:33:30');
-- ----------------------------
-- Table data for admin_department
-- ----------------------------
INSERT INTO `mall_system`.`admin_department`(`id`, `name`, `sort`, `pid`, `create_time`, `update_time`, `deleted`) VALUES (1, '测试部门', 0, 0, '2020-07-14 13:19:40', '2020-07-14 13:19:40', b'0');
INSERT INTO `mall_system`.`admin_department`(`id`, `name`, `sort`, `pid`, `create_time`, `update_time`, `deleted`) VALUES (2, '技术部', 1, 0, '2020-07-14 13:51:02', '2020-07-14 13:51:02', b'0');
INSERT INTO `mall_system`.`admin_department`(`id`, `name`, `sort`, `pid`, `create_time`, `update_time`, `deleted`) VALUES (3, '测试小组10', 1, 1, '2020-07-14 13:51:09', '2020-07-14 13:51:30', b'0');
INSERT INTO `mall_system`.`admin_department`(`id`, `name`, `sort`, `pid`, `create_time`, `update_time`, `deleted`) VALUES (4, '测试小组2', 2, 1, '2020-07-14 13:51:14', '2020-07-14 13:51:14', b'0');
INSERT INTO `mall_system`.`admin_department`(`id`, `name`, `sort`, `pid`, `create_time`, `update_time`, `deleted`) VALUES (5, '测试小组3', 3, 1, '2020-07-14 13:51:21', '2020-07-14 13:51:21', b'0');
-- ----------------------------
-- Table data for permission_admin_role
-- ----------------------------
INSERT INTO `mall_system`.`permission_admin_role`(`id`, `admin_id`, `role_id`, `create_time`, `update_time`, `deleted`) VALUES (35, 1, 1, '2019-05-17 17:08:37', '2020-04-23 07:59:16', b'0');
-- ----------------------------
-- Table structure for oauth2_access_token
-- ----------------------------
INSERT INTO `mall_system`.`oauth2_access_token`(`id`, `user_id`, `user_type`, `refresh_token`, `expires_time`, `create_ip`, `create_time`, `update_time`, `deleted`) VALUES ('yudaoyuanma', 1, 2, '7fc104020a2f428abece37c2d3f91839', '2021-07-05 10:39:14', '127.0.0.1', '2020-07-05 22:51:13', '2020-07-07 17:15:10', b'0');
INSERT INTO `mall_system`.`oauth2_access_token`(`id`, `user_id`, `user_type`, `refresh_token`, `expires_time`, `create_ip`, `create_time`, `update_time`, `deleted`) VALUES ('yunai', 243, 1, 'yunai_refresh', '2055-07-03 21:24:01', '127.0.0.1', '2020-07-04 09:36:04', '2020-07-24 11:08:46', b'0');
-- ----------------------------
-- Table structure for oauth2_refresh_token
-- ----------------------------
-- ----------------------------
-- Table structure for permission_admin_role
-- ----------------------------
-- ----------------------------
-- Table data for permission_resource
-- ----------------------------
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (1, '管理员信息', NULL, 2, -1, 0, '/admin/admin/info', NULL, NULL, 0, '2019-02-24 09:07:43', '2019-05-15 22:57:30', b'1');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (13, '系统管理', '', 1, 8, 0, '/system', 'el-icon-s-tools', NULL, 0, '2019-03-10 03:59:07', '2020-07-11 16:53:17', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (14, '员工列表', 'system:admin:page', 1, 1, 13, 'admin-list', 'people', 'admin/admin/index', 0, '2019-03-10 03:59:29', '2020-07-14 13:31:15', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (15, '权限列表', 'system:resource:tree', 1, 4, 13, 'resource-list', 'el-icon-s-operation', 'permission/resource/index', 0, '2019-03-10 03:59:56', '2020-07-14 13:25:55', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (16, '角色列表', 'system:role:page', 1, 3, 13, 'role-list', 'peoples', 'permission/role/index', 0, '2019-03-10 04:00:35', '2020-07-14 13:25:59', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (19, '数据字典', 'system:data-dict:list', 1, 5, 13, 'data-dict-list', 'el-icon-reading', 'datadict/index', 0, '2019-03-15 19:10:30', '2020-07-15 10:58:48', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (20, '商品管理', '', 1, 4, 0, '/product', 'el-icon-potato-strips', NULL, 0, '2019-03-15 19:53:09', '2020-07-25 18:27:15', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (21, '商品列表', NULL, 1, 1, 20, 'product-spu-list', NULL, NULL, 0, '2019-03-15 19:55:22', '2020-07-10 12:24:49', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (22, '展示类目', 'product:category:tree', 1, 2, 20, 'product-category-list', 'el-icon-lollipop', 'product/category/list', 0, '2019-03-15 19:56:42', '2020-07-25 18:24:16', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (23, '营销管理', NULL, 1, 7, 0, 'promotion', NULL, NULL, 0, '2019-03-30 22:42:13', '2020-07-10 12:25:00', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (24, '首页广告', NULL, 1, 1, 23, 'banner-list', NULL, NULL, 0, '2019-03-30 22:54:57', '2020-07-10 12:25:04', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (25, '商品推荐', NULL, 1, 2, 23, 'product-recommend-list', NULL, NULL, 0, '2019-04-01 13:17:28', '2020-07-10 12:25:09', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (26, '优惠劵', NULL, 1, 3, 23, 'coupon-card-template-list', NULL, NULL, 0, '2019-04-04 16:02:14', '2020-07-10 12:25:14', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (27, '订单管理', NULL, 1, 5, 0, 'order', NULL, NULL, 0, '2019-04-06 12:53:55', '2020-07-10 12:25:17', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (28, '订单管理', NULL, 1, 1, 27, 'order-list', NULL, NULL, 0, '2019-04-06 12:57:17', '2020-07-10 12:25:21', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (29, '商品品牌', 'product:brand:page', 1, 3, 20, 'product-brand-list', 'el-icon-orange', 'product/brand/list', 0, '2019-04-09 17:58:36', '2020-07-25 23:40:02', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (30, '发布商品', NULL, 1, -99, 20, 'product-spu-add', NULL, NULL, 0, '2019-05-01 21:01:38', '2020-07-10 12:25:29', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (31, '概述', NULL, 1, 0, 0, '/home', NULL, NULL, 0, '2019-05-03 00:01:33', '2020-07-12 00:06:47', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (32, '数据分析', NULL, 1, 1, 0, '/statistic', NULL, NULL, 0, '2019-05-03 00:02:08', '2020-07-12 00:07:14', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (33, '店铺资产', '', 1, 2, 0, '/pay', 'money-collect', NULL, 0, '2019-05-03 00:02:57', '2020-07-12 00:25:41', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (34, '会员管理', NULL, 1, 6, 0, '/member', NULL, NULL, 0, '2019-05-03 00:03:55', '2020-07-23 07:11:42', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (41, '限时折扣', NULL, 1, 24, 23, 'time-limit-discount-list', NULL, NULL, 0, '2019-05-07 22:34:30', '2020-07-10 12:26:12', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (42, '满减送', NULL, 1, 25, 23, 'full-privilege-list', NULL, NULL, 0, '2019-05-08 00:05:20', '2020-07-10 12:26:24', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (43, '会员资料', NULL, 1, 1, 34, 'user-list', 'el-icon-user', 'user/user/index', 0, '2019-05-08 11:11:22', '2020-07-23 07:10:12', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (44, '支付单', NULL, 1, 1, 33, 'transaction-list', NULL, NULL, 0, '2019-05-08 14:17:15', '2020-07-10 12:25:47', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (45, '退款单', NULL, 1, 2, 33, 'refund-list', NULL, NULL, 0, '2019-05-08 16:58:05', '2020-07-10 12:25:51', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (46, '订单售后', NULL, 1, 1, 27, 'order-refunds', NULL, NULL, 0, '2019-05-09 19:57:23', '2020-07-10 12:25:57', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (47, '新建员工', 'system:admin:create', 2, 1, 14, '', NULL, NULL, 0, '2019-05-15 23:43:58', '2020-07-14 07:07:01', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (48, '新建字典', 'system:data-dict:create', 2, 1, 19, '', NULL, NULL, 0, '2019-05-16 16:00:57', '2020-07-15 10:50:09', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (49, '编辑字典', 'system:data-dict:update', 2, 2, 19, '', NULL, NULL, 0, '2019-05-16 16:01:18', '2020-07-15 10:50:20', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (50, '删除字典', 'system:data-dict:delete', 2, 3, 19, '', NULL, NULL, 0, '2019-05-16 16:01:36', '2020-07-15 10:50:45', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (51, '短信服务', '', 1, 3, 0, 'sms', 'user', NULL, 0, '2019-05-26 12:00:31', '2020-07-10 12:27:09', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (52, '短信签名', '', 1, 1, 51, 'sign-list', 'user', NULL, 0, '2019-05-26 12:01:56', '2020-07-10 12:26:08', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (53, '短信模板', '', 1, 2, 51, 'template-list', 'user', NULL, 0, '2019-05-26 12:02:19', '2020-07-10 11:37:10', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (54, '拼团购', '', 1, 6, 23, 'group-buy-list', ' ', NULL, 0, '2019-07-07 16:51:47', '2020-07-10 12:26:02', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (55, '新建权限', 'system:resource:create', 2, 1, 15, '', NULL, NULL, 0, '2020-04-27 15:45:21', '2020-07-14 07:06:52', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (56, '更新权限 ', 'system:resource:update', 2, 2, 15, '', NULL, NULL, 0, '2020-04-27 15:51:01', '2020-04-27 15:51:01', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (57, '删除权限', 'system:resource:delete', 2, 3, 15, '', NULL, NULL, 0, '2020-04-27 15:51:32', '2020-04-27 15:51:31', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (59, '新建角色', 'system:role:create', 2, 1, 16, '', NULL, NULL, 0, '2020-04-27 20:49:43', '2020-07-14 07:06:41', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (60, '更新角色', 'system:role:update', 2, 2, 16, '', NULL, NULL, 0, '2020-04-27 20:50:15', '2020-04-28 09:51:33', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (62, '分配管理员角色', 'assign-role-resource', 2, 4, 14, '', NULL, NULL, 0, '2020-04-29 18:41:08', '2020-07-13 22:44:22', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (69, '23', NULL, 2, 1, 31, NULL, NULL, NULL, 1, '2020-07-11 17:03:30', '2020-07-12 00:06:35', b'1');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (70, '123', NULL, 2, 1, 51, NULL, NULL, NULL, 1, '2020-07-11 17:31:30', '2020-07-11 17:31:30', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (71, '1', NULL, 2, 1, 31, NULL, NULL, NULL, 1, '2020-07-11 17:38:25', '2020-07-12 00:06:37', b'1');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (72, '测试菜单', NULL, 1, 1, 0, 'test', NULL, 'ooxx', 1, '2020-07-11 18:02:23', '2020-07-12 00:06:13', b'1');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (73, '测试按钮', NULL, 2, 1, 0, NULL, NULL, NULL, 1, '2020-07-11 23:56:45', '2020-07-12 00:06:08', b'1');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (74, 'biu', NULL, 1, 1, 0, '11', NULL, NULL, 1, '2020-07-12 00:05:51', '2020-07-12 00:06:06', b'1');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (75, '修改员工', 'system:admin:update', 2, 2, 14, NULL, NULL, NULL, 1, '2020-07-13 22:33:14', '2020-07-13 22:33:14', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (76, '开启或禁用员工', 'system:admin:update-status', 2, 3, 14, NULL, NULL, NULL, 1, '2020-07-13 22:33:35', '2020-07-13 22:33:35', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (77, '删除角色', 'system:role:delete', 2, 3, 16, NULL, NULL, NULL, 1, '2020-07-13 22:40:20', '2020-07-13 22:40:20', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (78, '部门列表', 'system:department:tree', 1, 2, 13, 'department-list', 'el-icon-refrigerator', 'admin/department/index', 1, '2020-07-14 13:36:04', '2020-07-14 13:36:04', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (79, '新建部门', 'system:department:create', 2, 1, 78, NULL, NULL, NULL, 1, '2020-07-14 13:44:32', '2020-07-14 13:44:32', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (80, '修改部门', 'system:department:update', 2, 2, 78, NULL, NULL, NULL, 1, '2020-07-14 13:45:15', '2020-07-14 13:45:15', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (81, '删除部门', 'system:department:delete', 2, 3, 78, NULL, NULL, NULL, 1, '2020-07-14 13:47:40', '2020-07-14 13:47:40', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (82, '日志管理', NULL, 1, 9, 0, '/system-log', 'el-icon-pear', NULL, 1, '2020-07-15 17:44:33', '2020-07-23 07:08:40', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (83, '访问日志', 'system:system-access-log:page', 1, 1, 82, 'system-access-log-list', 'el-icon-receiving', 'system-log/system-access-log/index', 1, '2020-07-15 17:47:08', '2020-07-16 14:31:10', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (84, '异常日志', 'system:system-exception-log:page', 1, 2, 82, 'system-exception-log-list', 'el-icon-collection', 'system-log/system-exception-log/index', 1, '2020-07-16 12:56:15', '2020-07-16 14:32:00', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (85, '处理异常', 'system:system-exception-log:process', 2, 1, 84, NULL, NULL, NULL, 1, '2020-07-16 14:32:42', '2020-07-16 14:32:42', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (86, '错误码', 'system:error-dict:page', 1, 6, 13, 'error-code-list', 'el-icon-picture-outline-round', 'errorCode/index.vue', 1, '2020-07-20 19:25:35', '2020-07-20 19:27:09', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (87, '新建错误码', 'system:error-code:create', 2, 1, 86, NULL, NULL, NULL, 1, '2020-07-20 20:27:47', '2020-07-20 20:27:47', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (88, '修改错误码', 'system:error-code:update', 2, 2, 86, NULL, NULL, NULL, 1, '2020-07-20 20:28:04', '2020-07-20 20:28:04', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (89, '删除错误码', 'system:error-code:delete', 2, 3, 86, NULL, NULL, NULL, 1, '2020-07-20 20:28:22', '2020-07-20 20:28:22', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (90, '会员地址', NULL, 1, 2, 34, 'user-address-list', NULL, NULL, 1, '2020-07-23 07:11:23', '2020-07-23 07:11:23', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (91, '新建类目', 'product:category:create', 2, 1, 22, NULL, NULL, NULL, 1, '2020-07-25 18:25:13', '2020-07-25 18:25:13', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (92, '修改类目', 'product:category:update', 2, 2, 22, NULL, NULL, NULL, 1, '2020-07-25 18:25:41', '2020-07-25 18:25:41', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (93, '删除类目', 'product:category:delete', 2, 3, 22, NULL, NULL, NULL, 1, '2020-07-25 18:26:02', '2020-07-25 18:26:02', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (94, '新建品牌', 'product:brand:create', 2, 1, 29, NULL, NULL, NULL, 1, '2020-07-25 23:40:47', '2020-07-25 23:40:47', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (95, '修改品牌', 'product:brand:update', 2, 2, 29, NULL, NULL, NULL, 1, '2020-07-25 23:41:01', '2020-07-25 23:41:01', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (96, '删除品牌', 'product:brand:delete', 2, 3, 29, NULL, NULL, NULL, 1, '2020-07-25 23:41:17', '2020-07-25 23:41:17', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (97, '商品规格', NULL, 1, 5, 20, 'product-attr-list', 'el-icon-dish', 'product/attr/list', 1, '2020-07-28 13:44:06', '2020-07-30 01:11:57', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (98, '规格键列表', 'product:attr-value:page', 2, 1, 97, NULL, NULL, NULL, 1, '2020-07-30 01:09:02', '2020-07-30 01:09:47', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (99, '新建规格键', 'product:attr-value:create', 2, 2, 97, NULL, NULL, NULL, 1, '2020-07-30 01:09:39', '2020-07-30 01:09:39', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (100, '修改规格键', 'product:attr-key:update', 2, 3, 97, NULL, NULL, NULL, 1, '2020-07-30 01:10:07', '2020-07-30 01:10:07', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (101, '规格值列表', 'product:attr-value:list', 2, 11, 97, NULL, NULL, NULL, 1, '2020-07-30 01:10:26', '2020-07-30 01:10:26', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (102, '新建规格值', 'product:attr-value:create', 2, 12, 97, NULL, NULL, NULL, 1, '2020-07-30 01:10:48', '2020-07-30 01:10:48', b'0');
INSERT INTO `mall_system`.`permission_resource`(`id`, `name`, `permission`, `type`, `sort`, `pid`, `route`, `icon`, `view`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (103, '修改规格值', 'product:attr-value:update', 2, 13, 97, NULL, NULL, NULL, 1, '2020-07-30 01:11:04', '2020-07-30 01:11:04', b'0');
-- ----------------------------
-- Table data for permission_role
-- ---------------------------
INSERT INTO `mall_system`.`permission_role`(`id`, `name`, `code`, `type`, `create_admin_id`, `create_time`, `update_time`, `deleted`) VALUES (1, '超级管理员', 'SUPER_ADMIN', 1, 0, '2019-02-24 09:03:51', '2020-04-30 16:53:38', b'0');
-- ----------------------------
-- Table data for permission_role_resource
-- ----------------------------
-- ----------------------------
-- Table structure for system_access_log
-- ----------------------------
-- ----------------------------
-- Table data for system_data_dict
-- ----------------------------
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (1, 'gender', '1', '男', 1, '性别 - 男(嗨)', '2019-03-03 13:03:46', '2019-03-15 16:51:45', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (2, 'gender', '2', '女', 2, '性别(女)', '2019-03-03 13:04:00', '2019-03-15 17:19:20', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (3, 'gender', '3', '未知', 10, NULL, '2019-03-02 23:09:19', '2019-03-03 13:11:47', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (4, 'common_status', '1', '开启', 1, '状态 - 开启', '2019-03-15 17:28:08', '2019-03-15 17:28:07', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (5, 'common_status', '2', '禁用', 2, '状态 - 禁用', '2019-03-15 17:28:54', '2019-03-15 17:28:54', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (6, 'test', '1', '测试', 1, '你猜', '2019-03-15 17:36:54', '2019-03-15 17:36:59', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (7, 'test', '1', '测试', 1, '1', '2019-03-15 17:37:13', '2019-03-15 18:46:21', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (8, 'delete_status', '0', '未删除', 0, '正常/未删除', '2019-03-22 21:20:59', '2019-03-22 21:20:59', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (9, 'delete_status', '1', '删除', 1, '删除', '2019-03-22 21:23:20', '2019-03-22 21:23:20', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (10, 'order_status', '1', '等待付款', 1, '订单状态', '2019-03-24 16:17:55', '2019-03-24 16:20:24', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (11, 'order_status', '2', '等待发货', 2, ' 等待发货', '2019-03-24 16:18:39', '2019-03-24 16:20:14', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (12, 'order_status', '3', '已发货', 3, '已发货', '2019-03-24 16:19:14', '2019-03-24 16:20:07', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (13, 'order_status', '4', '已完成', 4, ' 已完成', '2019-03-24 16:19:37', '2019-03-24 16:20:03', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (14, 'order_status', '5', '已关闭', 5, '已关闭', '2019-03-24 16:19:50', '2019-03-24 16:19:50', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (15, 'order_has_return_exchange', '1', '无退换货', 1, '.', '2019-03-24 16:51:27', '2019-03-24 16:51:26', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (16, 'order_has_return_exchange', '2', '退货', 2, '.', '2019-03-24 16:51:36', '2019-03-24 16:51:35', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (17, 'order_has_return_exchange', '3', '换货', 3, '.', '2019-03-24 16:51:45', '2019-03-24 16:51:44', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (18, 'order_has_return_exchange', '4', '退换货', 4, '。', '2019-03-24 16:52:01', '2019-03-24 16:52:00', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (19, 'order_cancel_reasons', '1', '无法联系上买家', 1, '.', '2019-03-30 15:19:18', '2019-03-30 15:19:17', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (20, 'order_cancel_reasons', '2', '买家误拍或重拍了', 2, ',', '2019-03-30 15:19:31', '2019-03-30 15:19:30', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (21, 'order_cancel_reasons', '3', '买家无诚意完成交易', 3, '.', '2019-03-30 15:19:42', '2019-03-30 15:19:41', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (22, 'order_cancel_reasons', '4', '已通过银行线下汇款', 4, '.', '2019-03-30 15:19:56', '2019-03-30 15:19:56', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (23, 'order_cancel_reasons', '5', '已通过同城见面交易', 5, '.', '2019-03-30 15:20:21', '2019-03-30 15:20:21', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (24, 'order_cancel_reasons', '6', '已通过货到付款交易', 6, '.', '2019-03-30 15:20:37', '2019-03-30 15:20:37', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (25, 'order_cancel_reasons', '7', '已通过网上银行直接汇款', 7, '.', '2019-03-30 15:20:48', '2019-03-30 15:20:47', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (26, 'order_cancel_reasons', '8', '已经缺货无法交易', 8, '.', '2019-03-30 15:21:01', '2019-03-30 15:21:01', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (27, 'order_cancel_reasons', '20', '其他', 20, '.', '2019-03-30 17:16:27', '2019-03-30 17:16:27', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (28, 'logistics_company', '1', '顺丰快递', 1, '.', '2019-04-05 16:26:22', '2019-04-05 16:26:22', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (29, 'logistics_company', '2', '顺风速运', 2, '.', '2019-04-05 16:26:40', '2019-04-05 16:27:48', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (30, 'logistics_company', '3', '圆通快递', 3, '.', '2019-04-05 16:26:57', '2019-04-05 16:26:56', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (31, 'logistics_company', '4', '申通快递', 4, '.', '2019-04-05 16:27:14', '2019-04-05 16:27:14', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (32, 'logistics_company', '5', 'EMS', 5, '.', '2019-04-05 16:28:00', '2019-04-05 16:28:00', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (33, 'logistics_company', '6', '申通快递', 6, '.', '2019-04-05 16:28:40', '2019-04-05 16:28:40', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (34, 'logistics_company', '7', '天天快递', 7, '.', '2019-04-05 16:28:51', '2019-04-05 16:28:51', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (35, 'logistics_company', '8', '环球速运', 8, '.', '2019-04-05 16:29:12', '2019-04-05 16:29:12', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (36, 'user_type', '1', '用户', 1, '用户类型 - 用户', '2019-04-11 17:48:29', '2020-07-15 18:46:42', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (37, 'order_return_reason', '0', '退货原因', 1, '退货原因', '2019-04-25 23:25:10', '2019-04-25 23:27:02', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (38, 'order_return_reason', '1', '不想要了', 1, '.', '2019-04-25 23:25:55', '2019-04-25 23:25:55', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (39, 'order_return_reason', '2', '多拍重拍', 2, '.', '2019-04-25 23:26:23', '2019-04-25 23:26:23', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (40, 'order_return_reason', '3', '少货', 3, '.', '2019-04-25 23:26:48', '2019-04-25 23:26:47', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (41, 'order_return_return_type', '-1', '订单退货类型', 1, '.', '2019-04-27 11:57:45', '2019-04-27 11:58:16', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (42, 'order_return_return_type', '1', '退货退款', 1, '.', '2019-04-27 11:58:05', '2019-04-27 12:12:01', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (43, 'order_return_return_type', '2', '退款', 2, '.', '2019-04-27 11:58:14', '2019-04-27 12:12:03', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (44, 'order_return_service_type', '1', '退货退款', 1, '.', '2019-04-27 12:12:26', '2019-04-27 12:12:25', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (45, 'order_return_service_type', '2', '退款', 2, '2', '2019-04-27 12:12:36', '2019-04-27 12:12:35', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (46, 'order_return_status', '1', '退货申请', 1, '1', '2019-05-06 22:50:06', '2019-05-06 22:50:05', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (47, 'order_return_status', '2', '2', 2, '2', '2019-05-06 22:50:46', '2019-05-06 22:51:57', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (48, 'order_return_status', '-1', '1', 1, '1', '2019-05-06 22:51:07', '2019-05-06 22:52:00', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (49, 'order_return_status', '0', '0', 0, '0', '2019-05-06 22:51:39', '2019-05-06 22:52:02', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (50, 'order_return_status', '2', '申请成功', 2, '.', '2019-05-06 22:52:13', '2019-05-06 22:52:12', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (51, 'order_return_status', '3', '申请失败', 3, '.', '2019-05-06 22:52:34', '2019-05-06 22:52:34', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (52, 'order_return_status', '4', '退货中', 4, '.', '2019-05-06 22:52:44', '2019-05-06 22:52:43', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (53, 'order_return_status', '5', '已收货', 5, '.', '2019-05-06 22:52:57', '2019-05-09 22:17:35', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (54, 'order_return_status', '6', '退款成功', 6, '.', '2019-05-09 22:17:52', '2019-05-09 22:17:51', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (55, 'sms_platform', '1', '云片', 1, '短信服务云片', '2019-05-26 15:09:37', '2019-05-26 15:09:37', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (56, 'sms_platform', '2', '阿里云', 2, '阿里云短信服务', '2019-05-26 15:09:56', '2019-05-26 15:09:56', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (57, 'sms_apply_status', '1', '审核中', 1, '审核中', '2019-05-26 15:11:27', '2019-05-26 15:11:27', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (58, 'sms_apply_status', '2', '审核成功', 2, '审核成功', '2019-05-26 15:11:40', '2019-05-26 15:11:40', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (59, 'sms_apply_status', '10', '审核失败', 10, '审核失败', '2019-05-26 15:12:10', '2019-05-26 15:12:10', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (60, 'sms_type', '1', '验证码', 1, '验证码', '2019-05-26 23:51:15', '2019-05-26 23:51:15', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (61, 'sms_type', '2', '通知', 2, '通知', '2019-05-26 23:51:29', '2019-05-26 23:51:28', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (62, 'sms_type', '3', '营销', 3, '营销', '2019-05-26 23:51:47', '2019-05-26 23:51:46', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (63, 'testOne', '2', '测试下', 1, '是冯绍峰是', '2020-07-15 11:27:34', '2020-07-15 11:27:57', b'1');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (64, 'user_type', '2', '管理员', 1, '用户类型 - 管理员', '2020-07-15 11:28:07', '2020-07-15 18:47:01', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (65, 'resource_type', '1', '菜单', 1, '资源类型 - 菜单', '2020-07-15 14:43:17', '2020-07-15 14:43:46', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (66, 'resource_type', '2', '按钮', 2, '资源类型 - 按钮', '2020-07-15 14:43:38', '2020-07-15 14:43:38', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (67, 'role_type', '1', '内置角色', 1, '角色类型 - 内置角色', '2020-07-15 15:04:04', '2020-07-15 15:04:04', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (68, 'role_type', '2', '自定义角色', 2, '角色类型 - 自定义角色', '2020-07-15 15:04:20', '2020-07-15 15:04:20', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (69, 'system_exception_log_process_status', '0', '未处理', 1, '系统异常日志的处理状态 - 未处理', '2020-07-16 13:34:56', '2020-07-16 13:40:03', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (70, 'system_exception_log_process_status', '1', '已处理', 2, '系统异常日志的处理状态 - 已处理', '2020-07-16 13:35:19', '2020-07-16 13:40:08', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (71, 'system_exception_log_process_status', '2', '已忽略', 3, '系统异常日志的处理状态 - 已忽略', '2020-07-16 13:35:31', '2020-07-16 13:40:11', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (72, 'error_code_type', '1', '自动生成', 1, '错误码的类型枚举 - 自动生成', '2020-07-20 19:49:23', '2020-07-20 19:50:45', b'0');
INSERT INTO `mall_system`.`system_data_dict`(`id`, `enum_value`, `value`, `display_name`, `sort`, `memo`, `create_time`, `update_time`, `deleted`) VALUES (73, 'error_code_type', '2', '手动编辑', 2, '错误码的类型枚举 - 手动编辑', '2020-07-20 19:50:00', '2020-07-20 19:50:51', b'0');
-- ----------------------------
-- Table structure for system_error_code
-- ----------------------------
-- ----------------------------
-- Table structure for system_exception_log
-- ----------------------------
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for admin
-- ----------------------------
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '管理员编号',
`name` varchar(10) NOT NULL COMMENT '真实名字',
`avatar` varchar(255) DEFAULT NULL COMMENT '头像',
`department_id` int(11) DEFAULT NULL COMMENT '部门id',
`status` tinyint(4) NOT NULL COMMENT '在职状态',
`username` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '登陆账号',
`password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '加密后的密码',
`password_salt` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '密码的盐',
`create_admin_id` int(11) NOT NULL COMMENT '创建管理员编号',
`create_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建 IP',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_username` (`username`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8mb4 COMMENT='管理员';
-- ----------------------------
-- Table structure for admin_department
-- ----------------------------
DROP TABLE IF EXISTS `admin_department`;
CREATE TABLE `admin_department` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '部门编号',
`name` varchar(100) COLLATE utf8mb4_bin NOT NULL COMMENT '部门名称',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序字段',
`pid` int(11) NOT NULL DEFAULT '0' COMMENT '父级部门编号',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除标记',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='部门';
-- ----------------------------
-- Table structure for oauth2_access_token
-- ----------------------------
DROP TABLE IF EXISTS `oauth2_access_token`;
CREATE TABLE `oauth2_access_token` (
`id` varchar(32) NOT NULL COMMENT '访问令牌',
`user_id` int(11) NOT NULL COMMENT '用户编号',
`user_type` tinyint(4) NOT NULL COMMENT '用户类型',
`refresh_token` varchar(32) NOT NULL COMMENT '刷新令牌',
`expires_time` datetime NOT NULL COMMENT '过期时间',
`create_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建 IP',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_userId` (`user_id`) USING BTREE,
KEY `idx_refreshToken` (`refresh_token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='访问令牌';
-- ----------------------------
-- Table structure for oauth2_refresh_token
-- ----------------------------
DROP TABLE IF EXISTS `oauth2_refresh_token`;
CREATE TABLE `oauth2_refresh_token` (
`id` varchar(32) NOT NULL COMMENT '编号,刷新令牌',
`user_id` int(11) NOT NULL COMMENT '用户编号',
`user_type` tinyint(4) NOT NULL COMMENT '用户类型',
`expires_time` datetime NOT NULL COMMENT '过期时间',
`create_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建 IP',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_userId` (`user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='刷新令牌';
-- ----------------------------
-- Table structure for permission_admin_role
-- ----------------------------
DROP TABLE IF EXISTS `permission_admin_role`;
CREATE TABLE `permission_admin_role` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
`admin_id` int(11) NOT NULL COMMENT '管理员编号',
`role_id` int(11) NOT NULL COMMENT '角色编号',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COMMENT='管理员角色';
-- ----------------------------
-- Table structure for permission_resource
-- ----------------------------
DROP TABLE IF EXISTS `permission_resource`;
CREATE TABLE `permission_resource` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '资源编号',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单名',
`permission` varchar(255) DEFAULT NULL COMMENT '权限标识',
`type` int(11) NOT NULL COMMENT '资源类型',
`sort` int(11) NOT NULL COMMENT '排序',
`pid` int(11) NOT NULL DEFAULT '0' COMMENT '父级资源编号(外键:{@link ResourceDO#id})',
`route` varchar(50) DEFAULT NULL COMMENT '前端路由',
`icon` varchar(50) DEFAULT NULL COMMENT '菜单图标',
`view` varchar(50) DEFAULT NULL COMMENT '前端界面',
`create_admin_id` int(11) NOT NULL COMMENT '创建管理员编号',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8mb4 COMMENT='资源';
-- ----------------------------
-- Table structure for permission_role
-- ----------------------------
DROP TABLE IF EXISTS `permission_role`;
CREATE TABLE `permission_role` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '角色编号',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '角色名',
`code` varchar(50) DEFAULT NULL COMMENT '角色编码',
`type` tinyint(4) NOT NULL COMMENT '角色类型',
`create_admin_id` int(11) NOT NULL COMMENT '创建管理员编号',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COMMENT='角色';
-- ----------------------------
-- Table structure for permission_role_resource
-- ----------------------------
DROP TABLE IF EXISTS `permission_role_resource`;
CREATE TABLE `permission_role_resource` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
`role_id` int(11) NOT NULL DEFAULT '-1' COMMENT '角色编号(外键:{@link RoleDO}',
`resource_id` int(11) NOT NULL DEFAULT '-1' COMMENT '资源编号',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=860 DEFAULT CHARSET=utf8mb4 COMMENT='角色资源';
-- ----------------------------
-- Table structure for system_access_log
-- ----------------------------
DROP TABLE IF EXISTS `system_access_log`;
CREATE TABLE `system_access_log` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
`user_id` int(11) DEFAULT NULL COMMENT '用户编号',
`user_type` tinyint(4) DEFAULT NULL COMMENT '用户类型',
`trace_id` varchar(64) DEFAULT NULL COMMENT '链路追踪编号',
`application_name` varchar(50) NOT NULL COMMENT '应用名',
`uri` varchar(4096) NOT NULL DEFAULT '' COMMENT '访问地址',
`query_string` varchar(4096) NOT NULL DEFAULT '' COMMENT '参数',
`method` varchar(50) NOT NULL DEFAULT '' COMMENT 'http 方法',
`user_agent` varchar(1024) NOT NULL DEFAULT '' COMMENT 'userAgent',
`ip` varchar(50) NOT NULL DEFAULT '' COMMENT 'ip',
`start_time` datetime NOT NULL COMMENT '请求时间',
`response_time` int(11) NOT NULL COMMENT '响应时长 -- 毫秒级',
`error_code` int(11) NOT NULL COMMENT '错误码',
`error_message` varchar(512) DEFAULT NULL COMMENT '错误提示',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=87141 DEFAULT CHARSET=utf8mb4 COMMENT='系统访问日志';
-- ----------------------------
-- Table structure for system_data_dict
-- ----------------------------
DROP TABLE IF EXISTS `system_data_dict`;
CREATE TABLE `system_data_dict` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
`enum_value` varchar(50) NOT NULL DEFAULT '' COMMENT '大类枚举值',
`value` varchar(50) NOT NULL DEFAULT '' COMMENT '小类数值',
`display_name` varchar(50) NOT NULL DEFAULT '' COMMENT '展示名',
`sort` int(11) NOT NULL DEFAULT '-1' COMMENT '排序值',
`memo` varchar(50) DEFAULT '' COMMENT '备注',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8mb4 COMMENT='数据字典';
-- ----------------------------
-- Table structure for system_error_code
-- ----------------------------
CREATE TABLE `system_error_code` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '错误码编号',
`code` int(11) NOT NULL DEFAULT '0' COMMENT '错误码编码',
`message` varchar(255) NOT NULL DEFAULT '' COMMENT '错误码错误提示',
`type` tinyint(4) NOT NULL COMMENT '错误码类型',
`group` varchar(64) NOT NULL COMMENT '错误码分组',
`memo` varchar(255) DEFAULT NULL COMMENT '错误码备注',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=350 DEFAULT CHARSET=utf8mb4 COMMENT='错误码';
-- ----------------------------
-- Table structure for system_exception_log
-- ----------------------------
DROP TABLE IF EXISTS `system_exception_log`;
CREATE TABLE `system_exception_log` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
`user_id` int(11) DEFAULT NULL COMMENT '用户编号',
`user_type` tinyint(4) DEFAULT NULL COMMENT '用户类型',
`trace_id` varchar(64) NOT NULL COMMENT '链路追踪编号\n *\n * 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。',
`application_name` varchar(50) NOT NULL COMMENT '应用名\n *\n * 目前读取 spring.application.name',
`uri` varchar(4096) NOT NULL COMMENT '访问地址',
`query_string` varchar(4096) NOT NULL COMMENT '参数',
`method` varchar(50) NOT NULL COMMENT 'http 方法',
`user_agent` varchar(1024) NOT NULL COMMENT 'userAgent',
`ip` varchar(50) NOT NULL COMMENT 'ip',
`exception_time` datetime NOT NULL COMMENT '异常发生时间',
`exception_name` varchar(128) NOT NULL DEFAULT '' COMMENT '异常名\n *\n * {@link Throwable#getClass()} 的类全名',
`exception_message` text NOT NULL COMMENT '异常导致的消息\n *\n * {@link cn.iocoder.common.framework.util.ExceptionUtil#getMessage(Throwable)}',
`exception_root_cause_message` text NOT NULL COMMENT '异常导致的根消息\n *\n * {@link cn.iocoder.common.framework.util.ExceptionUtil#getRootCauseMessage(Throwable)}',
`exception_stack_trace` text NOT NULL COMMENT '异常的栈轨迹\n *\n * {@link cn.iocoder.common.framework.util.ExceptionUtil#getServiceException(Exception)}',
`exception_class_name` varchar(512) NOT NULL COMMENT '异常发生的类全名\n *\n * {@link StackTraceElement#getClassName()}',
`exception_file_name` varchar(512) NOT NULL COMMENT '异常发生的类文件\n *\n * {@link StackTraceElement#getFileName()}',
`exception_method_name` varchar(512) NOT NULL COMMENT '异常发生的方法名\n *\n * {@link StackTraceElement#getMethodName()}',
`exception_line_number` int(11) NOT NULL COMMENT '异常发生的方法所在行\n *\n * {@link StackTraceElement#getLineNumber()}',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1012 DEFAULT CHARSET=utf8mb4 COMMENT='系统异常日志';
SET FOREIGN_KEY_CHECKS = 1;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论