diff --git a/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminDemoInterceptor.java b/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminDemoInterceptor.java index ec6618ee..741fc644 100644 --- a/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminDemoInterceptor.java +++ b/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminDemoInterceptor.java @@ -22,7 +22,7 @@ public class AdminDemoInterceptor extends HandlerInterceptorAdapter { // 当 Admin 编号等于 0 时,约定为演示账号 if (Objects.equals(AdminSecurityContextHolder.getAdminId(), 0) && request.getMethod().equalsIgnoreCase(HttpMethod.POST.toString())) { - throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.AUTHORIZATION_DEMO_PERMISSION_DENY); + throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.PERMISSION_DEMO_PERMISSION_DENY); } return true; } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemExceptionLogController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemExceptionLogController.java new file mode 100644 index 00000000..6c8d5d1c --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemExceptionLogController.java @@ -0,0 +1,46 @@ +package cn.iocoder.mall.managementweb.controller.systemlog; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemExceptionLogPageDTO; +import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemExceptionLogDetailVO; +import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemExceptionLogVO; +import cn.iocoder.mall.managementweb.manager.systemlog.SystemExceptionLogManager; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +/** +* 系统异常日志 Controller +*/ +@RestController +@RequestMapping("/system-exception-log") +@Api(tags = "系统异常日志") +@Validated +public class SystemExceptionLogController { + + @Autowired + private SystemExceptionLogManager systemExceptionLogManager; + + @GetMapping("/get") + @ApiOperation("获得系统异常日志明细") + @ApiImplicitParam(name = "logId", value = "系统异常日志编号", required = true) + public CommonResult getSystemExceptionLogDetail(@RequestParam("logId") Integer logId) { + return success(systemExceptionLogManager.getSystemExceptionLogDetail(logId)); + } + + @GetMapping("/page") + @ApiOperation("获得系统异常日志分页") + public CommonResult> pageSystemExceptionLog(SystemExceptionLogPageDTO pageDTO) { + return success(systemExceptionLogManager.pageSystemExceptionLog(pageDTO)); + } + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/dto/SystemAccessLogPageDTO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/dto/SystemAccessLogPageDTO.java index ab2d4c2d..e224a3be 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/dto/SystemAccessLogPageDTO.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/dto/SystemAccessLogPageDTO.java @@ -9,11 +9,11 @@ import lombok.Data; @Data public class SystemAccessLogPageDTO extends PageParam { - @ApiModelProperty(value = "用户编号") + @ApiModelProperty(value = "用户编号", example = "1") private Integer userId; - @ApiModelProperty(value = "用户类型") + @ApiModelProperty(value = "用户类型", example = "2") private Integer userType; - @ApiModelProperty(value = "应用名", required = true) + @ApiModelProperty(value = "应用名", example = "xxx-service-application") private String applicationName; } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/dto/SystemExceptionLogPageDTO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/dto/SystemExceptionLogPageDTO.java new file mode 100644 index 00000000..37675883 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/dto/SystemExceptionLogPageDTO.java @@ -0,0 +1,21 @@ +package cn.iocoder.mall.managementweb.controller.systemlog.dto; + +import cn.iocoder.common.framework.vo.PageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@ApiModel("系统异常日志分页 DTO") +@Data +public class SystemExceptionLogPageDTO extends PageParam { + + @ApiModelProperty(value = "用户编号", example = "1") + private Integer userId; + @ApiModelProperty(value = "用户类型", example = "2") + private Integer userType; + @ApiModelProperty(value = "应用名", example = "xxx-service-application") + private String applicationName; + @ApiModelProperty(value = "处理状态", notes = "对应 SystemExceptionLogProcessStatusEnum 枚举类", example = "1") + private Integer processStatus; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/vo/SystemExceptionLogDetailVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/vo/SystemExceptionLogDetailVO.java new file mode 100644 index 00000000..7a4037e2 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/vo/SystemExceptionLogDetailVO.java @@ -0,0 +1,4 @@ +package cn.iocoder.mall.managementweb.controller.systemlog.vo; + +public class SystemExceptionLogDetailVO { +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/vo/SystemExceptionLogVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/vo/SystemExceptionLogVO.java new file mode 100644 index 00000000..5c05eca5 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/vo/SystemExceptionLogVO.java @@ -0,0 +1,58 @@ +package cn.iocoder.mall.managementweb.controller.systemlog.vo; + +import lombok.*; +import io.swagger.annotations.*; +import java.util.*; + +@ApiModel("系统异常日志 VO") +@Data +public class SystemExceptionLogVO { + + @ApiModelProperty(value = "编号", required = true) + private Integer id; + @ApiModelProperty(value = "用户编号") + private Integer userId; + @ApiModelProperty(value = "用户类型") + private Integer userType; + @ApiModelProperty(value = "链路追踪编", required = true) + private String traceId; + @ApiModelProperty(value = "应用名", required = true, example = "user-shop-application") + private String applicationName; + @ApiModelProperty(value = "访问地址", required = true, example = "/management-api/system-access-log/page") + private String uri; + @ApiModelProperty(value = "参数", required = true, example = "pageNo=1&pageSize=10") + private String queryString; + @ApiModelProperty(value = "http 方法", required = true, example = "GET") + private String method; + @ApiModelProperty(value = "userAgent", required = true, example = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0") + private String userAgent; + @ApiModelProperty(value = "ip", required = true, example = "127.0.0.1") + private String ip; + @ApiModelProperty(value = "异常发生时间", required = true) + private Date exceptionTime; + @ApiModelProperty(value = "异常名, {@link Throwable#getClass()} 的类全名", required = true) + private String exceptionName; + @ApiModelProperty(value = "异常导致的消息, {@link cn.iocoder.common.framework.util.ExceptionUtil#getMessage(Throwable)}", required = true) + private String exceptionMessage; + @ApiModelProperty(value = "异常导致的根消息, {@link cn.iocoder.common.framework.util.ExceptionUtil#getRootCauseMessage(Throwable)}", required = true) + private String exceptionRootCauseMessage; + @ApiModelProperty(value = "异常的栈轨迹, {@link cn.iocoder.common.framework.util.ExceptionUtil#getServiceException(Exception)}", required = true) + private String exceptionStackTrace; + @ApiModelProperty(value = "异常发生的类全名, {@link StackTraceElement#getClassName()}", required = true) + private String exceptionClassName; + @ApiModelProperty(value = "异常发生的类文件, {@link StackTraceElement#getFileName()}", required = true) + private String exceptionFileName; + @ApiModelProperty(value = "异常发生的方法名, {@link StackTraceElement#getMethodName()}", required = true) + private String exceptionMethodName; + @ApiModelProperty(value = "异常发生的方法所在行, {@link StackTraceElement#getLineNumber()}", required = true) + private Integer exceptionLineNumber; + @ApiModelProperty(value = "处理状态", required = true, notes = "对应 SystemExceptionLogProcessStatusEnum 枚举类", example = "1") + private Integer processStatus; + @ApiModelProperty(value = "处理时间") + private Date processTime; + @ApiModelProperty(value = "处理管理员编号", example = "1024") + private Integer processAdminId; + @ApiModelProperty(value = "创建时间", required = true) + private Date createTime; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/systemlog/SystemExceptionLogConvert.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/systemlog/SystemExceptionLogConvert.java new file mode 100644 index 00000000..e52d96e8 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/systemlog/SystemExceptionLogConvert.java @@ -0,0 +1,18 @@ +package cn.iocoder.mall.managementweb.convert.systemlog; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemExceptionLogVO; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogPageDTO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface SystemExceptionLogConvert { + + SystemExceptionLogConvert INSTANCE = Mappers.getMapper(SystemExceptionLogConvert.class); + + SystemExceptionLogPageDTO convert(cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemExceptionLogPageDTO bean); + + PageResult convertPage(PageResult page); + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemExceptionLogManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemExceptionLogManager.java new file mode 100644 index 00000000..05f4bab6 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemExceptionLogManager.java @@ -0,0 +1,49 @@ +package cn.iocoder.mall.managementweb.manager.systemlog; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemExceptionLogPageDTO; +import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemExceptionLogDetailVO; +import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemExceptionLogVO; +import cn.iocoder.mall.managementweb.convert.systemlog.SystemExceptionLogConvert; +import cn.iocoder.mall.systemservice.rpc.systemlog.SystemExceptionLogRpc; +import org.apache.dubbo.config.annotation.Reference; +import org.springframework.stereotype.Service; + +/** +* 系统异常日志 Manager +*/ +@Service +public class SystemExceptionLogManager { + + @Reference(version = "$ {dubbo.consumer.SystemExceptionLogRpc.version}", validation = "false") + private SystemExceptionLogRpc systemExceptionLogRpc; + + /** + * 获得系统异常日志 + * + * @param systemExceptionLogId 系统异常日志编号 + * @return 系统异常日志 + */ + public SystemExceptionLogDetailVO getSystemExceptionLogDetail(Integer systemExceptionLogId) { + CommonResult getSystemExceptionLogResult + = systemExceptionLogRpc.getSystemExceptionLog(systemExceptionLogId); + getSystemExceptionLogResult.checkError(); +// return SystemExceptionLogConvert.INSTANCE.convert(getSystemExceptionLogResult.getData()); + return null; + } + + /** + * 获得系统异常日志分页 + * + * @param pageDTO 系统异常日志分页查询 + * @return 系统异常日志分页结果 + */ + public PageResult pageSystemExceptionLog(SystemExceptionLogPageDTO pageDTO) { + CommonResult> pageSystemExceptionLogResult + = systemExceptionLogRpc.pageSystemExceptionLog(SystemExceptionLogConvert.INSTANCE.convert(pageDTO)); + pageSystemExceptionLogResult.checkError(); + return SystemExceptionLogConvert.INSTANCE.convertPage(pageSystemExceptionLogResult.getData()); + } + +} diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java index 9271387f..945f25f0 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java @@ -69,15 +69,20 @@ public enum SystemErrorCodeEnum implements ServiceExceptionUtil.Enumerable createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO); + /** + * 获得系统异常日志 + * + * @param systemExceptionLogId 系统异常日志编号 + * @return 系统异常日志 + */ + CommonResult getSystemExceptionLog(Integer systemExceptionLogId); + + /** + * 获得系统异常日志分页 + * + * @param pageDTO 系统异常日志分页查询 + * @return 系统异常日志分页结果 + */ + CommonResult> pageSystemExceptionLog(SystemExceptionLogPageDTO pageDTO); + + /** + * 处理系统异常日志,完成或者忽略 + * + * @param processDTO 处理 DTO + * @return 成功 + */ + CommonResult processSystemExceptionLog(SystemExceptionLogProcessDTO processDTO); + } diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemExceptionLogPageDTO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemExceptionLogPageDTO.java new file mode 100644 index 00000000..ee326cca --- /dev/null +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemExceptionLogPageDTO.java @@ -0,0 +1,35 @@ +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; + +} diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemExceptionLogProcessDTO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemExceptionLogProcessDTO.java new file mode 100644 index 00000000..c2a7b7fe --- /dev/null +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemExceptionLogProcessDTO.java @@ -0,0 +1,29 @@ +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 SystemExceptionLogProcessDTO extends PageParam { + + /** + * 系统异常日志编号 + */ + private Integer logId; + /** + * 处理状态 + */ + private Integer processStatus; + /** + * 处理管理员编号 + */ + private Integer processAdminId; + +} diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/vo/SystemExceptionLogVO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/vo/SystemExceptionLogVO.java new file mode 100644 index 00000000..f9f932aa --- /dev/null +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/vo/SystemExceptionLogVO.java @@ -0,0 +1,125 @@ +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; + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemExceptionLogConvert.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemExceptionLogConvert.java index cb2fb491..0ceafbc8 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemExceptionLogConvert.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemExceptionLogConvert.java @@ -1,8 +1,14 @@ 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.factory.Mappers; @@ -15,4 +21,14 @@ public interface SystemExceptionLogConvert { SystemExceptionLogCreateBO convert(SystemExceptionLogCreateDTO bean); + PageResult convertPage(IPage page); + + SystemExceptionLogBO convert(SystemExceptionLogDO bean); + + SystemExceptionLogVO convert(SystemExceptionLogBO bean); + + SystemExceptionLogPageBO convert(SystemExceptionLogPageDTO bean); + + PageResult convertPage(PageResult page); + } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/SystemExceptionLogDO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/SystemExceptionLogDO.java index daebe6e9..05bc6d87 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/SystemExceptionLogDO.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/SystemExceptionLogDO.java @@ -2,6 +2,8 @@ package cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog; import cn.iocoder.common.framework.enums.UserTypeEnum; import cn.iocoder.mall.mybatis.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; @@ -117,4 +119,21 @@ public class SystemExceptionLogDO extends BaseDO { */ private Integer exceptionLineNumber; + /** + * 处理状态 + * + * 外键 {@link SystemExceptionLogProcessStatusEnum} + */ + private Integer processStatus; + /** + * 处理时间 + */ + private Date processTime; + /** + * 处理管理员编号 + * + * 外键 {@link AdminDO#getId()} + */ + private Integer processAdminId; + } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/SystemExceptionLogMapper.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/SystemExceptionLogMapper.java index 6217139c..04aa9561 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/SystemExceptionLogMapper.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/SystemExceptionLogMapper.java @@ -1,10 +1,24 @@ package cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog; +import cn.iocoder.mall.mybatis.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 { + default IPage selectPage(SystemExceptionLogPageBO pageBO) { + return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()), + new QueryWrapperX() + .eqIfPresent("user_id", pageBO.getUserId()) + .eqIfPresent("user_type", pageBO.getUserType()) + .eqIfPresent("application_name", pageBO.getApplicationName()) + .eqIfPresent("processStatus", pageBO.getProcessStatus()) + .orderByDesc("start_time")); + } + } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/permission/PermissionManager.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/permission/PermissionManager.java index c115dfa1..7a2f4182 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/permission/PermissionManager.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/permission/PermissionManager.java @@ -18,7 +18,7 @@ import java.util.Collections; import java.util.Map; import java.util.Set; -import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeEnum.AUTHORIZATION_PERMISSION_DENY; +import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeEnum.PERMISSION_DENY; /** * 权限 Manager @@ -98,7 +98,7 @@ public class PermissionManager { // 查询管理员拥有的角色关联数据 Set roleIds = permissionService.listAdminRoleIds(checkDTO.getAdminId()); if (CollectionUtil.isEmpty(roleIds)) { // 如果没有角色,默认无法访问 - throw ServiceExceptionUtil.exception(AUTHORIZATION_PERMISSION_DENY); + throw ServiceExceptionUtil.exception(PERMISSION_DENY); } // 判断是否为超管。若是超管,默认有所有权限 if (roleService.hasSuperAdmin(roleIds)) { diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemExceptionLogManager.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemExceptionLogManager.java index cca39291..a23de489 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemExceptionLogManager.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemExceptionLogManager.java @@ -1,8 +1,13 @@ 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; @@ -13,10 +18,47 @@ import org.springframework.stereotype.Service; public class SystemExceptionLogManager { @Autowired - private SystemExceptionLogService systemLogService; + private SystemExceptionLogService systemExceptionLogService; + /** + * 创建系统异常日志 + * + * @param createDTO 创建系统异常日志 DTO + */ public void createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO) { - systemLogService.createSystemExceptionLog(SystemExceptionLogConvert.INSTANCE.convert(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 pageSystemExceptionLog(SystemExceptionLogPageDTO pageDTO) { + PageResult 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()); } } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemExceptionLogRpcImpl.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemExceptionLogRpcImpl.java index 4781274a..81647f7f 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemExceptionLogRpcImpl.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemExceptionLogRpcImpl.java @@ -1,11 +1,17 @@ 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.manager.systemlog.SystemExceptionLogManager; 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.apache.dubbo.config.annotation.Service; import org.springframework.beans.factory.annotation.Autowired; +import static cn.iocoder.common.framework.vo.CommonResult.success; + @Service(version = "${dubbo.provider.SystemExceptionLogRpc.version}", validation = "false") public class SystemExceptionLogRpcImpl implements SystemExceptionLogRpc { @@ -15,6 +21,22 @@ public class SystemExceptionLogRpcImpl implements SystemExceptionLogRpc { @Override public CommonResult createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO) { systemExceptionLogManager.createSystemExceptionLog(createDTO); + return success(true); + } + + @Override + public CommonResult getSystemExceptionLog(Integer systemExceptionLogId) { + return success(systemExceptionLogManager.getSystemExceptionLog(systemExceptionLogId)); + } + + @Override + public CommonResult> pageSystemExceptionLog(SystemExceptionLogPageDTO pageDTO) { + return success(systemExceptionLogManager.pageSystemExceptionLog(pageDTO)); + } + + @Override + public CommonResult processSystemExceptionLog(SystemExceptionLogProcessDTO processDTO) { + systemExceptionLogManager.processSystemExceptionLog(processDTO); return CommonResult.success(true); } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/permission/PermissionService.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/permission/PermissionService.java index 527ec16f..c054bb57 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/permission/PermissionService.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/permission/PermissionService.java @@ -68,7 +68,7 @@ public class PermissionService { if (!CollectionUtils.isEmpty(resourceIds)) { int dbResourceSize = resourceMapper.selectCountByIdsAndType(resourceIds, null); if (resourceIds.size() != dbResourceSize) { - throw ServiceExceptionUtil.exception(AUTHORIZATION_ROLE_ASSIGN_RESOURCE_NOT_EXISTS); + throw ServiceExceptionUtil.exception(PERMISSION_ROLE_ASSIGN_RESOURCE_NOT_EXISTS); } } // TODO 芋艿,这里先简单实现。即方式是,删除老的分配的资源关系,然后添加新的分配的资源关系 @@ -150,13 +150,13 @@ public class PermissionService { // 权限验证 List roleResourceDOs = roleResourceMapper.selectListByResourceIds(permissionIds); if (CollectionUtil.isEmpty(roleResourceDOs)) { // 资源未授予任何角色,必然权限验证不通过 - throw ServiceExceptionUtil.exception(AUTHORIZATION_PERMISSION_DENY); + throw ServiceExceptionUtil.exception(PERMISSION_DENY); } Map> resourceRoleMap = CollectionUtils.convertMultiMap(roleResourceDOs, RoleResourceDO::getResourceId, RoleResourceDO::getRoleId); for (Map.Entry> entry : resourceRoleMap.entrySet()) { if (!CollectionUtil.containsAny(roleIds, entry.getValue())) { // 所以有任一不满足,就验证失败,抛出异常 - throw ServiceExceptionUtil.exception(AUTHORIZATION_PERMISSION_DENY); + throw ServiceExceptionUtil.exception(PERMISSION_DENY); } } } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemExceptionLogService.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemExceptionLogService.java index af7e7f28..849e3b94 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemExceptionLogService.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemExceptionLogService.java @@ -1,12 +1,21 @@ package cn.iocoder.mall.systemservice.service.systemlog; +import cn.iocoder.common.framework.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.SystemErrorCodeEnum.SYSTEM_EXCEPTION_LOG_NOT_FOUND; +import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeEnum.SYSTEM_EXCEPTION_LOG_PROCESSED; + /** * 系统异常日志 Service */ @@ -16,9 +25,51 @@ 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 pageSystemExceptionLog(SystemExceptionLogPageBO pageBO) { + IPage systemExceptionLogDOPage = systemExceptionLogMapper.selectPage(pageBO); + return SystemExceptionLogConvert.INSTANCE.convertPage(systemExceptionLogDOPage); + } + + public SystemExceptionLogBO getSystemExceptionLog(Integer logId) { + SystemExceptionLogDO logDO = systemExceptionLogMapper.selectById(logId); + return SystemExceptionLogConvert.INSTANCE.convert(logDO); + } } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemExceptionLogBO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemExceptionLogBO.java new file mode 100644 index 00000000..02b50225 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemExceptionLogBO.java @@ -0,0 +1,128 @@ +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; + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemExceptionLogPageBO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemExceptionLogPageBO.java new file mode 100644 index 00000000..ac95d52b --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemExceptionLogPageBO.java @@ -0,0 +1,35 @@ +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; + +} diff --git a/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/bo/systemlog/AccessLogBO.java b/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/bo/systemlog/AccessLogBO.java deleted file mode 100644 index 87ac846f..00000000 --- a/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/bo/systemlog/AccessLogBO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.mall.system.api.bo.systemlog; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; - -/** - * @author:ycjx - * @descriptio - * @create:2019-06-23 17:26 - */ -@Data -@Accessors(chain = true) -public class AccessLogBO implements Serializable { - - private String traceId; - - private Integer userId; - - private Integer userType; - - private String applicationName; - - private String uri; - - private String queryString; - - private String method; - - private String userAgent; - - private String ip; - - private Date startTime; - - private Integer responseTime; - - private Integer errorCode; -} diff --git a/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/bo/systemlog/AccessLogPageBO.java b/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/bo/systemlog/AccessLogPageBO.java deleted file mode 100644 index ec7618fd..00000000 --- a/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/bo/systemlog/AccessLogPageBO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.mall.system.api.bo.systemlog; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.List; - -/** - * @author:ycjx - * @descriptio - * @create:2019-06-23 17:26 - */ -@Data -@Accessors(chain = true) -public class AccessLogPageBO implements Serializable { - - /** - * 日志数组 - */ - private List list; - /** - * 总量 - */ - private Integer total; - -} diff --git a/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/dto/datadict/DataDictAddDTO.java b/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/dto/datadict/DataDictAddDTO.java deleted file mode 100644 index c22f0309..00000000 --- a/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/dto/datadict/DataDictAddDTO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.mall.system.api.dto.datadict; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -@ApiModel("数据字典添加 DTO") -@Data -@Accessors(chain = true) -public class DataDictAddDTO implements Serializable { - - @ApiModelProperty(value = "大类枚举值", required = true, example = "gender") - @NotEmpty(message = "大类枚举值不能为空") - private String enumValue; - - @ApiModelProperty(value = "小类数值", required = true, example = "1") - @NotEmpty(message = "小类数值不能为空") - private String value; - - @ApiModelProperty(value = "展示名", required = true, example = "男") - @NotEmpty(message = "展示名不能为空") - private String displayName; - - @ApiModelProperty(required = true, value = "排序值", example = "123") - @NotNull(message = "排序值不能为空") - private Integer sort; - - @ApiModelProperty(value = "备注", example = "你猜我猜不猜") - private String memo; - -} diff --git a/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/dto/datadict/DataDictUpdateDTO.java b/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/dto/datadict/DataDictUpdateDTO.java deleted file mode 100644 index 351075fb..00000000 --- a/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/dto/datadict/DataDictUpdateDTO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.mall.system.api.dto.datadict; - -import io.swagger.annotations.ApiModelProperty; -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 { - - @ApiModelProperty(value = "数据字典编号", required = true, example = "1") - @NotNull(message = "数据字典编号不能为空") - private Integer id; - - @ApiModelProperty(value = "大类枚举值", required = true, example = "gender") - @NotEmpty(message = "大类枚举值不能为空") - private String enumValue; - - @ApiModelProperty(value = "小类数值", required = true, example = "1") - @NotEmpty(message = "小类数值不能为空") - private String value; - - @ApiModelProperty(value = "展示名", required = true, example = "男") - @NotEmpty(message = "展示名不能为空") - private String displayName; - - @ApiModelProperty(required = true, value = "排序值", example = "123") - @NotNull(message = "排序值不能为空") - private Integer sort; - - @ApiModelProperty(value = "备注", example = "你猜我猜不猜") - private String memo; - -} diff --git a/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/dto/systemlog/AccessLogPageDTO.java b/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/dto/systemlog/AccessLogPageDTO.java deleted file mode 100644 index 37f30e9e..00000000 --- a/system/system-service-api/src/main/java/cn/iocoder/mall/system/api/dto/systemlog/AccessLogPageDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.system.api.dto.systemlog; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; - -/** - * @author:ycjx - * @descriptio - * @create:2019-06-23 16:53 - */ -@Data -@Accessors(chain = true) -public class AccessLogPageDTO { - - - /** - * 用户id - */ - private Integer userId; - - @NotNull(message = "页码不能为空") - private Integer pageNo; - @NotNull(message = "每页条数不能为空") - private Integer pageSize; - -} diff --git a/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/convert/AccessLogConvert.java b/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/convert/AccessLogConvert.java deleted file mode 100644 index 4e8fdafe..00000000 --- a/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/convert/AccessLogConvert.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.mall.admin.convert; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.api.bo.systemlog.AccessLogBO; -import cn.iocoder.mall.system.api.dto.systemlog.AccessLogAddDTO; -import cn.iocoder.mall.system.api.dto.systemlog.ExceptionLogAddDTO; -import cn.iocoder.mall.admin.dataobject.AccessLogDO; -import cn.iocoder.mall.admin.dataobject.ExceptionLogDO; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface AccessLogConvert { - - AccessLogConvert INSTANCE = Mappers.getMapper(AccessLogConvert.class); - - @Mappings({}) - AccessLogDO convert(AccessLogAddDTO accessLogAddDTO); - - @Mappings({}) - ExceptionLogDO convert(ExceptionLogAddDTO exceptionLogAddDTO); - - @Mappings({ - @Mapping(source = "records", target = "list"), - }) - PageResult convert(IPage page); - -} diff --git a/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/convert/DataDictConvert.java b/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/convert/DataDictConvert.java deleted file mode 100644 index c8f2a29e..00000000 --- a/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/convert/DataDictConvert.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.mall.admin.convert; - -import cn.iocoder.mall.system.api.bo.datadict.DataDictBO; -import cn.iocoder.mall.system.api.dto.datadict.DataDictAddDTO; -import cn.iocoder.mall.system.api.dto.datadict.DataDictUpdateDTO; -import cn.iocoder.mall.admin.dataobject.DataDictDO; -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(DataDictAddDTO dataDictAddDTO); - - DataDictDO convert(DataDictUpdateDTO dataDictUpdateDTO); - - DataDictBO convert(DataDictDO dataDictDO); - - List convert(List dataDictDOs); - -} diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/SystemApplication.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/SystemApplication.java deleted file mode 100644 index 4b4f647c..00000000 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/SystemApplication.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.mall.system.application; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.scheduling.annotation.EnableAsync; - -@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.system"}) -@EnableAsync(proxyTargetClass = true) -public class SystemApplication { - - public static void main(String[] args) { - SpringApplication.run(SystemApplication.class, args); - } - -} diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/config/QiniuConfiguration.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/config/QiniuConfiguration.java deleted file mode 100644 index 0d3626de..00000000 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/config/QiniuConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.mall.system.application.config; - -import com.qiniu.util.Auth; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class QiniuConfiguration { - - @Value("${qiniu.access-key}") - private String accessKey; - @Value("${qiniu.secret-key}") - private String secretKey; - - @Bean - public Auth auth() { - return Auth.create(accessKey, secretKey); - } - -} diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/DeptmentController.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/DeptmentController.java deleted file mode 100644 index 4923366b..00000000 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/DeptmentController.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.mall.system.application.controller.admins; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.api.DeptmentService; -import cn.iocoder.mall.system.api.bo.deptment.DeptmentBO; -import cn.iocoder.mall.system.api.constant.ResourceConstants; -import cn.iocoder.mall.system.api.dto.depetment.DeptmentAddDTO; -import cn.iocoder.mall.system.api.dto.depetment.DeptmentPageDTO; -import cn.iocoder.mall.system.api.dto.depetment.DeptmentUpdateDTO; -import cn.iocoder.mall.system.application.convert.DeptmentConvert; -import cn.iocoder.mall.system.application.vo.deptment.DeptmentVO; -import cn.iocoder.mall.system.sdk.context.AdminSecurityContextHolder; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -/** - * Description: - * - * @author: zhenxianyimeng - * @date: 2019-06-14 - * @time: 19:07 - */ -@RestController -@RequestMapping("admins/dept") -@Api("部门模块") -public class DeptmentController { - - @Autowired - private DeptmentService deptmentService; - - @GetMapping("tree/all") - @ApiOperation(value = "根部门的部门树") - public CommonResult> treeAll(){ - List list = deptmentService.getAllDeptments(); - List voList = DeptmentConvert.INSTANCE.convert(list); - Map nodeMap = calcNodeMap(voList); - // 获得到所有的根节点 - List rootNodes = nodeMap.values().stream() - .filter(node -> node.getPid().equals(ResourceConstants.PID_ROOT)) - .collect(Collectors.toList()); - return success(rootNodes); - } - - @GetMapping("tree/page") - @ApiOperation(value = "根部门分页的部门树") - public CommonResult> treePage(@Validated DeptmentPageDTO deptmentPageDTO){ - PageResult pageResult = deptmentService.getPageRootDeptment(deptmentPageDTO); - PageResult voPageResult = DeptmentConvert.INSTANCE.convert(pageResult); - List list = deptmentService.getAllDeptments(); - List voList = DeptmentConvert.INSTANCE.convert(list); - Map nodeMap = calcNodeMap(voList); - voPageResult.getList().forEach(d->{ - d.setChildren(nodeMap.get(d.getId()).getChildren()); - }); - return success(voPageResult); - } - - @PostMapping("add") - @ApiOperation(value = "新增部门", notes = "选择部门名称,父级部门") - public CommonResult add(@RequestBody DeptmentAddDTO deptmentAddDTO){ - return success(deptmentService.addDeptment( - AdminSecurityContextHolder.getContext().getAdminId(), deptmentAddDTO)); - - } - - @PostMapping("delete") - @ApiOperation(value = "删除部门") - @ApiImplicitParam(name = "id", value = "部门id", required = true, example = "1") - public CommonResult delete(@RequestParam("id") Integer id){ - - return success(deptmentService.deleteDeptment( - AdminSecurityContextHolder.getContext().getAdminId(), id - )); - } - - @PostMapping("update") - @ApiOperation(value = "更新部门") - public CommonResult update(@RequestBody DeptmentUpdateDTO deptmentUpdateDTO){ - return success(deptmentService.updateDeptment( - AdminSecurityContextHolder.getContext().getAdminId(), deptmentUpdateDTO - )); - } - - private Map calcNodeMap(List voList){ - Map nodeMap = voList.stream().collect(Collectors.toMap(e->e.getId(), e->e)); - - nodeMap.values().stream() - .filter(node -> !node.getPid().equals(ResourceConstants.PID_ROOT)) - .forEach((childNode) -> { - // 获得父节点 - DeptmentVO parentNode = nodeMap.get(childNode.getPid()); - if (parentNode.getChildren() == null) { // 初始化 children 数组 - parentNode.setChildren(new ArrayList<>()); - } - // 将自己添加到父节点中 - parentNode.getChildren().add(childNode); - }); - return nodeMap; - } - - -} diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/vo/datadict/DataDictEnumVO.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/vo/datadict/DataDictEnumVO.java deleted file mode 100644 index fb769c78..00000000 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/vo/datadict/DataDictEnumVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.mall.system.application.vo.datadict; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -@ApiModel("数据字典枚举 VO") -@Data -@Accessors(chain = true) -public class DataDictEnumVO { - - @ApiModelProperty(value = "大类枚举值", required = true, example = "gender") - private String enumValue; - - @ApiModelProperty(value = "小类数值数组", required = true) - private List values; - - @ApiModel("数据字典枚举值 VO") - @Data - @Accessors(chain = true) - public static class Value { - - @ApiModelProperty(value = "小类数值", required = true, example = "1") - private String value; - - @ApiModelProperty(value = "展示名", required = true, example = "男") - private String displayName; - - } - -}