diff --git a/chushang-common/chushang-common-core/src/main/java/com/chushang/common/core/util/CommonParam.java b/chushang-common/chushang-common-core/src/main/java/com/chushang/common/core/util/CommonParam.java deleted file mode 100644 index 0c26387..0000000 --- a/chushang-common/chushang-common-core/src/main/java/com/chushang/common/core/util/CommonParam.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.chushang.common.core.util; - -import lombok.Data; - -import java.io.Serial; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -/** - * by zhaowenyuan create 2021/11/5 14:53 - * 公共 请求 query - */ -@Data -public class CommonParam implements Serializable { - - @Serial - private static final long serialVersionUID = 1L; - - /** - * 当前页码 - */ - private Integer page = 1; - /** - * 页面大小 - */ - private Integer limit = 10; - /** - * 排序字段: 排序方式 -- 为 null 时, 没有排序 - */ - private String sortStr; - /** - * 额外分组选项 - */ - private String groupStr; - - /** - * 内部使用 sql 查询, 仅用于 角色权限所需查询, 前端不能传递 - */ - private Map sqlParam; - - public Map getSqlParam() - { - if (sqlParam == null) - { - sqlParam = new HashMap<>(); - } - return sqlParam; - } -} diff --git a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/annotation/SysLog.java b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/annotation/SysLog.java index 30affd8..17e8267 100644 --- a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/annotation/SysLog.java +++ b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/annotation/SysLog.java @@ -8,6 +8,8 @@ package com.chushang.common.log.annotation; +import com.chushang.common.log.enums.BusinessType; + import java.lang.annotation.*; /** @@ -23,12 +25,15 @@ public @interface SysLog { String value() default ""; /** + * 请求参数 * 判断参数下标 -- 需要与 参数下标一一对应 - * -2 代表删除 - * -1 代表默认 * 0 - Integer.MAX_VALUE 代表 参数下标 */ int index() default -1; + /** + * 操作类型 + */ + BusinessType businessType() default BusinessType.OTHER; boolean export() default false; diff --git a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/aspect/SysLogAspect.java b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/aspect/SysLogAspect.java index 692e7dd..aa70e7a 100644 --- a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/aspect/SysLogAspect.java +++ b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/aspect/SysLogAspect.java @@ -1,8 +1,8 @@ /** * Copyright (c) 2016-2019 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ @@ -15,6 +15,7 @@ import com.chushang.common.core.util.IPUtils; import com.chushang.common.core.util.ServletUtils; import com.chushang.common.log.annotation.SysLog; import com.chushang.common.log.entity.SysLogEntity; +import com.chushang.common.log.enums.BusinessType; import com.chushang.common.log.enums.LogTypeEnum; import com.chushang.common.log.service.SysLogService; import com.chushang.security.utils.SecurityUtils; @@ -50,129 +51,117 @@ import java.util.stream.Collectors; @RequiredArgsConstructor(onConstructor_ = @Autowired) public class SysLogAspect { - final SysLogService sysLogService; + final SysLogService sysLogService; - @Pointcut("@annotation(com.chushang.common.log.annotation.SysLog)") - public void logPointCut() { - } + @Pointcut("@annotation(com.chushang.common.log.annotation.SysLog)") + public void logPointCut() { + } - /** - * 不主动拦截get 请求 - */ - @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)" + - "|| @annotation(org.springframework.web.bind.annotation.PostMapping)" + - "|| @annotation(org.springframework.web.bind.annotation.DeleteMapping)" + - "|| @annotation(org.springframework.web.bind.annotation.PutMapping)") - public void exceptionLogPointCut() { - } + /** + * 不主动拦截get 请求 + */ + @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)" + + "|| @annotation(org.springframework.web.bind.annotation.PostMapping)" + + "|| @annotation(org.springframework.web.bind.annotation.DeleteMapping)" + + "|| @annotation(org.springframework.web.bind.annotation.PutMapping)") + public void exceptionLogPointCut() { + } - @AfterReturning("logPointCut()") - public void around(JoinPoint point) { - long beginTime = System.currentTimeMillis(); - //执行时长(毫秒) - long time = System.currentTimeMillis() - beginTime; - //保存日志 - saveSysLog(point, time, LogTypeEnum.NORMAL, null); - } + @AfterReturning("logPointCut()") + public void around(JoinPoint point) { + long beginTime = System.currentTimeMillis(); + //执行时长(毫秒) + long time = System.currentTimeMillis() - beginTime; + //保存日志 + saveSysLog(point, time, LogTypeEnum.NORMAL, null); + } - /** - * 异常返回通知,用于拦截异常日志信息 连接点抛出异常后执行 - * --> 未执行, 因为 有全局捕捉一长 - * @param joinPoint 切入点 - * @param ex 异常信息 - */ - @AfterThrowing(pointcut = "exceptionLogPointCut()", throwing = "ex") - public void saveExceptionLog(JoinPoint joinPoint, Throwable ex) - { - long beginTime = System.currentTimeMillis(); - //执行时长(毫秒) - long time = System.currentTimeMillis() - beginTime; + /** + * 异常返回通知,用于拦截异常日志信息 连接点抛出异常后执行 + * --> 未执行, 因为 有全局捕捉一长 + * @param joinPoint 切入点 + * @param ex 异常信息 + */ + @AfterThrowing(pointcut = "exceptionLogPointCut()", throwing = "ex") + public void saveExceptionLog(JoinPoint joinPoint, Throwable ex) { + long beginTime = System.currentTimeMillis(); + //执行时长(毫秒) + long time = System.currentTimeMillis() - beginTime; - saveSysLog(joinPoint, time, LogTypeEnum.ERROR, ex.getMessage()); - } + saveSysLog(joinPoint, time, LogTypeEnum.ERROR, ex.getMessage()); + } - private void saveSysLog(JoinPoint joinPoint, long time, LogTypeEnum type, String ex) { - try { - MethodSignature signature = (MethodSignature) joinPoint.getSignature(); - Method method = signature.getMethod(); + private void saveSysLog(JoinPoint joinPoint, long time, LogTypeEnum type, String ex) { + try { + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); - // 获取到的所有参数 - Object[] args = joinPoint.getArgs(); + // 获取到的所有参数 + Object[] args = joinPoint.getArgs(); + SysLogEntity sysLogEntity = new SysLogEntity(); + SysLog syslog = + method.getAnnotation(SysLog.class); + if (syslog != null) { + String value = syslog.value(); + BusinessType businessType = syslog.businessType(); + if (null != businessType){ + value += businessType.getDesc(); + sysLogEntity.setOperationType(businessType.getCode()); + } + sysLogEntity.setOperation(value); + if (null != args && args.length > 0) { + // 将导出的response 过滤掉 + List argList = + Arrays.stream(args) + .filter(arg -> !(arg instanceof HttpServletResponse) && !(arg instanceof HttpServletRequest)) + .collect(Collectors.toList()); + sysLogEntity.setParams(JacksonUtils.toJSONString(argList)); + } + } - SysLogEntity sysLogEntity = new SysLogEntity(); - SysLog syslog = - method.getAnnotation(SysLog.class); + //获取request + HttpServletRequest request = ServletUtils.getRequest(); + String ipAddr = IPUtils.clientIp(request); + //请求的方法名 + String className = joinPoint.getTarget().getClass().getName(); + String methodName = signature.getName(); + sysLogEntity.setMethod(className + "." + methodName + "()"); + //设置IP地址 + sysLogEntity.setRemoteAddr(ipAddr); + // 请求uri + sysLogEntity.setRequestUri(URLUtil.getPath(request.getRequestURI())); + // 请求代理 + sysLogEntity.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT)); - if(syslog != null){ - String value = syslog.value(); - int index = syslog.index(); - if (index != -1){ - if (index >= 0){ - String id = args[index] + ""; - if ("0".equals(id)){ - value += "新增 "; - }else { - value += "修改 "; - } - }else if (index == -2){ - value += "删除 "; - } - } - sysLogEntity.setOperation(value); - if (null != args && args.length > 0){ - // 将导出的response 过滤掉 - List argList = - Arrays.stream(args) - .filter(arg -> !(arg instanceof HttpServletResponse)) - .collect(Collectors.toList()); - sysLogEntity.setParams(JacksonUtils.toJSONString(argList)); - } - } - - //获取request - HttpServletRequest request = ServletUtils.getRequest(); - String ipAddr = IPUtils.clientIp(request); - //请求的方法名 - String className = joinPoint.getTarget().getClass().getName(); - String methodName = signature.getName(); - sysLogEntity.setMethod(className + "." + methodName + "()"); - //设置IP地址 - sysLogEntity.setRemoteAddr(ipAddr); - // 请求uri - sysLogEntity.setRequestUri(URLUtil.getPath(request.getRequestURI())); - // 请求代理 - sysLogEntity.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT)); - - LoginUser loginUser = SecurityUtils.getLoginUser(); - // 请求账号信息 - if (null != loginUser){ - Integer userId = loginUser.getUserId(); - //用户名 - sysLogEntity.setUserId(userId); - String username = loginUser.getUsername(); - sysLogEntity.setUsername(username); - //保存系统日志 - } - else { - if (!ipAddr.equals("localhost") && !ipAddr.equals("127.0.0.1")){ - throw new ResultException("没有权限"); - } - sysLogEntity.setUserId(1); - sysLogEntity.setUsername("error"); - } - // 执行时间 - sysLogEntity.setTime(time); - // 日志类型 - sysLogEntity.setType(type); - sysLogEntity.setException(ex); - sysLogService.save(sysLogEntity); - }catch (Exception e){ - HttpServletRequest request = ServletUtils.getRequest(); - // 保存日志失败 不应当影响 正常的操作 - log.error("uri : {}, save log error",URLUtil.getPath(request.getRequestURI()),e); - } - } + LoginUser loginUser = SecurityUtils.getLoginUser(); + // 请求账号信息 + if (null != loginUser) { + Integer userId = loginUser.getUserId(); + //用户名 + sysLogEntity.setUserId(userId); + String username = loginUser.getUsername(); + sysLogEntity.setUsername(username); + //保存系统日志 + } else { + if (!ipAddr.equals("localhost") && !ipAddr.equals("127.0.0.1")) { + throw new ResultException("没有权限"); + } + sysLogEntity.setUserId(1); + sysLogEntity.setUsername("error"); + } + // 执行时间 + sysLogEntity.setTime(time); + // 日志类型 + sysLogEntity.setType(type); + sysLogEntity.setException(ex); + sysLogService.save(sysLogEntity); + } catch (Exception e) { + HttpServletRequest request = ServletUtils.getRequest(); + // 保存日志失败 不应当影响 正常的操作 + log.error("uri : {}, save log error", URLUtil.getPath(request.getRequestURI()), e); + } + } } diff --git a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/controller/SysLogController.java b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/controller/SysLogController.java index 65d5004..e9419ed 100644 --- a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/controller/SysLogController.java +++ b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/controller/SysLogController.java @@ -8,10 +8,10 @@ package com.chushang.common.log.controller; +import com.chushang.common.core.web.AjaxResult; import com.chushang.common.log.entity.dto.ListLogDTO; -import com.chushang.common.core.web.Result; import com.chushang.common.log.service.SysLogService; -import com.chushang.common.mybatis.utils.PageUtils; +import com.chushang.common.mybatis.utils.PageResult; import com.chushang.security.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -30,16 +30,16 @@ import org.springframework.web.bind.annotation.ResponseBody; public class SysLogController { @Autowired private SysLogService sysLogService; - + /** * 列表 */ @ResponseBody @GetMapping("/list") @RequiresPermissions("sys:log:list") - public Result list(ListLogDTO params){ - PageUtils page = sysLogService.queryPage(params); - return Result.ok(page); + public AjaxResult list(ListLogDTO params){ + PageResult page = sysLogService.queryPage(params); + return AjaxResult.success(page); } - + } diff --git a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/entity/SysLogEntity.java b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/entity/SysLogEntity.java index c99bf0e..2618c69 100644 --- a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/entity/SysLogEntity.java +++ b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/entity/SysLogEntity.java @@ -2,6 +2,7 @@ package com.chushang.common.log.entity; import cn.hutool.core.date.DatePattern; import com.baomidou.mybatisplus.annotation.*; +import com.chushang.common.log.enums.BusinessType; import com.chushang.common.log.enums.LogTypeEnum; import com.chushang.common.mybatis.base.BaseEntity; import com.fasterxml.jackson.annotation.JsonFormat; @@ -84,6 +85,11 @@ public class SysLogEntity { */ @TableField(value = "operation") private String operation; + /** + * 用户操作 类型 + */ + @TableField(value = "operation_type") + private Integer operationType; /** * 创建时间 @@ -103,4 +109,4 @@ public class SysLogEntity { @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE, updateStrategy = FieldStrategy.NOT_NULL) @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) private LocalDateTime updateTime; -} \ No newline at end of file +} diff --git a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/entity/dto/ListLogDTO.java b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/entity/dto/ListLogDTO.java index 117192c..5123dc3 100644 --- a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/entity/dto/ListLogDTO.java +++ b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/entity/dto/ListLogDTO.java @@ -1,6 +1,6 @@ package com.chushang.common.log.entity.dto; -import com.chushang.common.core.util.CommonParam; +import com.chushang.common.mybatis.page.CommonParam; import lombok.Data; import lombok.EqualsAndHashCode; @@ -12,5 +12,6 @@ import lombok.EqualsAndHashCode; public class ListLogDTO extends CommonParam { private String title; + private String operType; } diff --git a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/enums/BusinessType.java b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/enums/BusinessType.java new file mode 100644 index 0000000..760137a --- /dev/null +++ b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/enums/BusinessType.java @@ -0,0 +1,67 @@ +package com.chushang.common.log.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 业务操作类型 + * + * @author ruoyi + */ +@AllArgsConstructor +@Getter +public enum BusinessType +{ + /** + * 其它 + */ + OTHER(1,"其他"), + + /** + * 新增 + */ + INSERT(2,"新增"), + + /** + * 修改 + */ + UPDATE(3,"修改"), + + /** + * 删除 + */ + DELETE(4,"删除"), + + /** + * 授权 + */ + GRANT(5,"授权"), + + /** + * 导出 + */ + EXPORT(6,"导出"), + + /** + * 导入 + */ + IMPORT(7,"导入"), + + /** + * 强退 + */ + FORCE(8,"强退"), + + /** + * 生成代码 + */ + GENCODE(9,"生成代码"), + + /** + * 清空数据 + */ + CLEAN(10,"清空数据"), + ; + private final Integer code; + private final String desc; +} diff --git a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/service/SysLogService.java b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/service/SysLogService.java index 3bab416..0843785 100644 --- a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/service/SysLogService.java +++ b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/service/SysLogService.java @@ -1,30 +1,32 @@ package com.chushang.common.log.service; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.chushang.common.log.entity.SysLogEntity; import com.chushang.common.log.entity.dto.ListLogDTO; -import com.chushang.common.mybatis.utils.PageUtils; +import com.chushang.common.mybatis.utils.PageResult; import org.apache.commons.lang3.StringUtils; +import java.util.Arrays; + /** * by zhaowenyuan create 2022/3/16 15:35 */ public interface SysLogService extends IService { - default PageUtils queryPage(ListLogDTO params){ + default PageResult queryPage(ListLogDTO params){ String key = params.getTitle(); - IPage page = this.page( - new Page<>(params.getPage(), params.getLimit()), - new LambdaQueryWrapper() + new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(params.getPage(), params.getLimit()), + new QueryWrapper() + .orderBy(true, "asc".equals(params.getIsAsc()), params.getOrderBy()) + .lambda() .like(StringUtils.isNotBlank(key),SysLogEntity::getUsername, key) .or() .like(StringUtils.isNotEmpty(key), SysLogEntity::getOperation, key) - .orderByDesc(SysLogEntity::getCreateTime) + .in(StringUtils.isNotEmpty(params.getOperType()), SysLogEntity::getOperationType, Arrays.asList(params.getOperType().split(","))) ); - return new PageUtils(page); + return new PageResult(page); } } diff --git a/chushang-common/chushang-common-log/src/main/resources/mapper/SysLogMapper.xml b/chushang-common/chushang-common-log/src/main/resources/mapper/SysLogMapper.xml deleted file mode 100644 index a7f7c85..0000000 --- a/chushang-common/chushang-common-log/src/main/resources/mapper/SysLogMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/chushang-common/chushang-common-mybatis/pom.xml b/chushang-common/chushang-common-mybatis/pom.xml index 8a45bca..66a05df 100644 --- a/chushang-common/chushang-common-mybatis/pom.xml +++ b/chushang-common/chushang-common-mybatis/pom.xml @@ -36,6 +36,15 @@ com.github.jsqlparser jsqlparser + + + com.github.pagehelper + pagehelper-spring-boot-starter + + + com.chushang + chushang-common-core + diff --git a/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/page/CommonParam.java b/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/page/CommonParam.java new file mode 100644 index 0000000..973fbf6 --- /dev/null +++ b/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/page/CommonParam.java @@ -0,0 +1,136 @@ +package com.chushang.common.mybatis.page; + +import com.chushang.common.core.exception.utils.AssertUtil; +import com.chushang.common.core.text.Convert; +import com.chushang.common.core.util.ServletUtils; +import com.chushang.common.core.util.StringUtils; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +/** + * by zhaowenyuan create 2021/11/5 14:53 + * 公共 请求 query + */ +@Data +public class CommonParam implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 当前页码 + */ + private Integer page = 1; + /** + * 页面大小 + */ + private Integer limit = 10; + /** + * 排序字段: 排序方式 -- 为 null 时, 没有排序 + * 默认创建时间倒叙 + */ + private String orderBy = "create_time"; + /** + * 额外分组选项 + */ + private String groupStr; + /** + * 排序方式 + */ + private String isAsc = "asc"; + /** + * 是否查询全部数据 + */ + private Boolean isAll = false; + /** + * 内部使用 sql 查询, 仅用于 角色权限所需查询, 前端不能传递 + */ + private Map sqlParam; + + public Map getSqlParam() + { + if (sqlParam == null) + { + sqlParam = new HashMap<>(); + } + return sqlParam; + } + public String getOrderBy() + { + if (StringUtils.isEmpty(orderBy)) + { + return ""; + } + return StringUtils.toUnderScoreCase(orderBy); + } + + public void setIsAsc(String isAsc) + { + if (StringUtils.isNotEmpty(isAsc)) + { + // 兼容前端排序类型 + if ("ascending".equals(isAsc)) + { + isAsc = "asc"; + } + else if ("descending".equals(isAsc)) + { + isAsc = "desc"; + } + this.isAsc = isAsc; + } + } + + /** + * 当前记录起始索引 + */ + private static final String PAGE_NUM = "page"; + /** + * 每页显示记录数 + */ + private static final String PAGE_SIZE = "limit"; + /** + * 排序列 + */ + private static final String ORDER_BY_COLUMN = "orderBy"; + /** + * 排序的方向 "desc" 或者 "asc". + */ + private static final String IS_ASC = "isAsc"; + + private static final String GROUP_STR = "groupStr"; + /** + * 封装分页对象 + */ + private static CommonParam getPageParam() + { + CommonParam pageDomain = new CommonParam(); + pageDomain.setPage(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1)); + pageDomain.setLimit(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10)); + pageDomain.setOrderBy(ServletUtils.getParameter(ORDER_BY_COLUMN)); + pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC)); + pageDomain.setGroupStr(ServletUtils.getParameter(GROUP_STR)); + return pageDomain; + } + + public static CommonParam buildPageRequest() + { + return getPageParam(); + } + + /** + * 用于查询所有数据 + */ + public static CommonParam buildAllRequest() + { + CommonParam commonParam = new CommonParam(); + commonParam.setLimit(null); + commonParam.setPage(null); + commonParam.setIsAll(true); + return commonParam; + } +} diff --git a/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/utils/PageUtils.java b/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/utils/PageResult.java similarity index 63% rename from chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/utils/PageUtils.java rename to chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/utils/PageResult.java index d6e30fa..250dbf3 100644 --- a/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/utils/PageUtils.java +++ b/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/utils/PageResult.java @@ -8,7 +8,9 @@ package com.chushang.common.mybatis.utils; import com.baomidou.mybatisplus.core.metadata.IPage; +import lombok.Data; +import java.io.Serial; import java.io.Serializable; import java.util.List; @@ -17,7 +19,9 @@ import java.util.List; * * @author Mark sunlightcs@gmail.com */ -public class PageUtils implements Serializable { +@Data +public class PageResult implements Serializable { + @Serial private static final long serialVersionUID = 1L; /** * 总记录数 @@ -39,7 +43,7 @@ public class PageUtils implements Serializable { * 列表数据 */ private List list; - + /** * 分页 * @param list 列表数据 @@ -47,14 +51,14 @@ public class PageUtils implements Serializable { * @param pageSize 每页记录数 * @param currPage 当前页数 */ - public PageUtils(List list, long totalCount, long pageSize, long currPage) { + public PageResult(List list, long totalCount, long pageSize, long currPage) { this.list = list; this.totalCount = (int)totalCount; this.pageSize = (int)pageSize; this.currPage = (int)currPage; this.totalPage = (int)Math.ceil((double)totalCount/pageSize); } - public PageUtils(List list, IPage page) { + public PageResult(List list, IPage page) { this.list = list; if (null != page){ this.totalCount = (int)page.getTotal(); @@ -67,7 +71,7 @@ public class PageUtils implements Serializable { /** * 分页 */ - public PageUtils(IPage page) { + public PageResult(IPage page) { this.list = page.getRecords(); this.totalCount = (int)page.getTotal(); this.pageSize = (int)page.getSize(); @@ -75,44 +79,4 @@ public class PageUtils implements Serializable { this.totalPage = (int)page.getPages(); } - public int getTotalCount() { - return totalCount; - } - - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - public int getPageSize() { - return pageSize; - } - - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } - - public int getTotalPage() { - return totalPage; - } - - public void setTotalPage(int totalPage) { - this.totalPage = totalPage; - } - - public int getCurrPage() { - return currPage; - } - - public void setCurrPage(int currPage) { - this.currPage = currPage; - } - - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } - } diff --git a/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/utils/SqlUtil.java b/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/utils/SqlUtil.java new file mode 100644 index 0000000..289524c --- /dev/null +++ b/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/utils/SqlUtil.java @@ -0,0 +1,70 @@ +package com.chushang.common.mybatis.utils; + +import cn.hutool.core.exceptions.UtilException; +import com.chushang.common.core.util.StringUtils; + +/** + * sql操作工具类 + * + * @author ruoyi + */ +public class SqlUtil +{ + /** + * 定义常用的 sql关键字 + */ + public static String SQL_REGEX = "and |extractvalue|updatexml|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |+|user()"; + + /** + * 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序) + */ + public static String SQL_PATTERN = "[a-zA-Z0-9_ ,.]+"; + + /** + * 限制orderBy最大长度 + */ + private static final int ORDER_BY_MAX_LENGTH = 500; + + /** + * 检查字符,防止注入绕过 + */ + public static String escapeOrderBySql(String value) + { + if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) + { + throw new UtilException("参数不符合规范,不能进行查询"); + } + if (StringUtils.length(value) > ORDER_BY_MAX_LENGTH) + { + throw new UtilException("参数已超过最大限制,不能进行查询"); + } + return value; + } + + /** + * 验证 order by 语法是否符合规范 + */ + public static boolean isValidOrderBySql(String value) + { + return value.matches(SQL_PATTERN); + } + + /** + * SQL关键字检查 + */ + public static void filterKeyword(String value) + { + if (StringUtils.isEmpty(value)) + { + return; + } + String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|"); + for (String sqlKeyword : sqlKeywords) + { + if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) + { + throw new UtilException("参数存在SQL注入风险"); + } + } + } +} diff --git a/chushang-modules/chushang-module-auth/auth-service/src/main/resources/logback-nacos.xml b/chushang-modules/chushang-module-auth/auth-service/src/main/resources/logback-nacos.xml index 74bb510..9515ba1 100644 --- a/chushang-modules/chushang-module-auth/auth-service/src/main/resources/logback-nacos.xml +++ b/chushang-modules/chushang-module-auth/auth-service/src/main/resources/logback-nacos.xml @@ -7,11 +7,15 @@ - + + + + + @@ -91,6 +95,8 @@ + + diff --git a/chushang-modules/chushang-module-gateway/src/main/resources/logback-nacos.xml b/chushang-modules/chushang-module-gateway/src/main/resources/logback-nacos.xml index 74bb510..9515ba1 100644 --- a/chushang-modules/chushang-module-gateway/src/main/resources/logback-nacos.xml +++ b/chushang-modules/chushang-module-gateway/src/main/resources/logback-nacos.xml @@ -7,11 +7,15 @@ - + + + + + @@ -91,6 +95,8 @@ + + diff --git a/chushang-modules/chushang-module-system/system-feign/pom.xml b/chushang-modules/chushang-module-system/system-feign/pom.xml index 7d7e606..c07a03e 100644 --- a/chushang-modules/chushang-module-system/system-feign/pom.xml +++ b/chushang-modules/chushang-module-system/system-feign/pom.xml @@ -29,5 +29,9 @@ com.chushang chushang-common-security + + com.chushang + chushang-common-excel + diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListDeptDTO.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListDeptDTO.java index 2d5c7b7..d7aeda3 100644 --- a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListDeptDTO.java +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListDeptDTO.java @@ -1,6 +1,6 @@ package com.chushang.system.entity.dto; -import com.chushang.common.core.util.CommonParam; +import com.chushang.common.mybatis.page.CommonParam; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListDictDTO.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListDictDTO.java new file mode 100644 index 0000000..20bbea1 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListDictDTO.java @@ -0,0 +1,41 @@ +package com.chushang.system.entity.dto; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +/** + * @auther: zhao + * @date: 2024/5/9 17:09 + */ +@Data +public class ListDictDTO { + /** + * 字典编码 + */ + private Integer dictCode; + /** + * 字典类型 + */ + private String dictType; + + /** + * 样式属性(其他样式扩展) + */ + private String cssClass; + + /** + * 表格字典样式 + */ + private String listClass; + + /** + * 是否默认(Y是 N否) + */ + private String isDefault; + + /** + * 状态(0正常 1停用) + */ + private String status; +} diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListMenuDTO.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListMenuDTO.java index cab854c..5c88135 100644 --- a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListMenuDTO.java +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListMenuDTO.java @@ -1,6 +1,6 @@ package com.chushang.system.entity.dto; -import com.chushang.common.core.util.CommonParam; +import com.chushang.common.mybatis.page.CommonParam; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListRoleDTO.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListRoleDTO.java index 9bc666b..9fdb48a 100644 --- a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListRoleDTO.java +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListRoleDTO.java @@ -1,6 +1,6 @@ package com.chushang.system.entity.dto; -import com.chushang.common.core.util.CommonParam; +import com.chushang.common.mybatis.page.CommonParam; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListUserDTO.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListUserDTO.java index 37fa83e..c1d8b05 100644 --- a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListUserDTO.java +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/dto/ListUserDTO.java @@ -1,6 +1,6 @@ package com.chushang.system.entity.dto; -import com.chushang.common.core.util.CommonParam; +import com.chushang.common.mybatis.page.CommonParam; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysConfig.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysConfig.java new file mode 100644 index 0000000..2dfb97d --- /dev/null +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysConfig.java @@ -0,0 +1,73 @@ +package com.chushang.system.entity.po; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.baomidou.mybatisplus.annotation.*; +import com.chushang.common.mybatis.base.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Setter; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.io.Serial; + +/** + * 参数配置表 sys_config + * + * @author ruoyi + */ +@Setter +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("sys_config") +public class SysConfig extends BaseEntity +{ + @Serial + private static final long serialVersionUID = 1L; + + /** 参数主键 */ + @TableId(value = "config_id", type = IdType.AUTO) + @ExcelProperty(value = "参数主键", index = 0) + private Long configId; + + /** 参数名称 */ + @ExcelProperty(value = "参数名称", index = 1) + private String configName; + + /** 参数键名 */ + @ExcelProperty(value = "参数键名", index = 2) + private String configKey; + + /** 参数键值 */ + @ExcelProperty(value = "参数键值", index = 3) + private String configValue; + + /** 系统内置(Y是 N否) */ + @ExcelProperty(value = "系统内置", index = 4) + private String configType; + + + /** + * 创建人 + */ + @TableField( + value = "create_by", + updateStrategy = FieldStrategy.NEVER + ) + @ExcelProperty(value = "创建人", index = 5) + protected String createBy; + /** + * 修改人 + */ + @TableField( + value = "update_by", + insertStrategy = FieldStrategy.NEVER + ) + @ExcelProperty(value = "修改人", index = 6) + protected String updateBy; +} diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysDictData.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysDictData.java index 007a88d..35477c5 100644 --- a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysDictData.java +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysDictData.java @@ -1,8 +1,9 @@ package com.chushang.system.entity.po; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.alibaba.excel.annotation.ExcelProperty; +import com.baomidou.mybatisplus.annotation.*; +import com.chushang.common.excel.utils.ExcelUtils; +import com.chushang.common.mybatis.base.BaseEntity; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -14,7 +15,7 @@ import java.io.Serializable; @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("sys_dict_data") -public class SysDictData implements Serializable { +public class SysDictData extends BaseEntity { @Serial private static final long serialVersionUID = 1L; @@ -22,46 +23,72 @@ public class SysDictData implements Serializable { * 字典编码 */ @TableId(value = "dict_code", type = IdType.AUTO) + @ExcelProperty(value = "字典编码", index = 0) private Integer dictCode; /** * 字典排序 */ + @ExcelProperty(value = "字典排序", index = 1) private Integer dictSort; /** * 字典标签 */ + @ExcelProperty(value = "字典标签", index = 2) private String dictLabel; /** * 字典键值 */ + @ExcelProperty(value = "字典键值", index = 3) private String dictValue; /** * 字典类型 */ + @ExcelProperty(value = "字典键值", index = 4) private String dictType; /** * 样式属性(其他样式扩展) */ + @ExcelProperty(value = "样式属性(其他样式扩展)", index = 5) private String cssClass; /** * 表格字典样式 */ + @ExcelProperty(value = "表格字典样式", index = 6) private String listClass; /** * 是否默认(Y是 N否) */ + @ExcelProperty(value = "是否默认", index = 7) private String isDefault; /** * 状态(0正常 1停用) */ + @ExcelProperty(value = "状态", index = 8) private String status; -} \ No newline at end of file + /** + * 创建人 + */ + @TableField( + value = "create_by", + updateStrategy = FieldStrategy.NEVER + ) + protected String createBy; + /** + * 修改人 + */ + @TableField( + value = "update_by", + insertStrategy = FieldStrategy.NEVER + ) + protected String updateBy; + +} diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysDictType.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysDictType.java new file mode 100644 index 0000000..debc96f --- /dev/null +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysDictType.java @@ -0,0 +1,69 @@ +package com.chushang.system.entity.po; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.baomidou.mybatisplus.annotation.*; +import com.chushang.common.mybatis.base.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.io.Serial; + +/** + * 字典类型表 sys_dict_type + * + * @author ruoyi + */ +@Setter +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("sys_dict_type") +public class SysDictType extends BaseEntity +{ + @Serial + private static final long serialVersionUID = 1L; + + /** 字典主键 */ + @TableId(value = "dict_id", type = IdType.AUTO) + @ExcelProperty(value = "字典主键", index = 0) + private Long dictId; + + /** 字典名称 */ + @ExcelProperty(value = "字典名称", index = 1) + private String dictName; + + /** 字典类型 */ + @ExcelProperty(value = "字典类型", index = 2) + private String dictType; + + /** 状态(0正常 1停用) */ + @ExcelProperty(value = "状态", index = 3) + private String status; + /** + * 创建人 + */ + @TableField( + value = "create_by", + updateStrategy = FieldStrategy.NEVER + ) + @ExcelProperty(value = "创建人", index = 4) + protected String createBy; + /** + * 修改人 + */ + @TableField( + value = "update_by", + insertStrategy = FieldStrategy.NEVER + ) + @ExcelProperty(value = "修改人", index = 5) + protected String updateBy; +} diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysMenu.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysMenu.java index ca86ea1..a64fa08 100644 --- a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysMenu.java +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysMenu.java @@ -11,7 +11,7 @@ import java.util.List; /** *

- * + * *

* * @author author @@ -57,21 +57,21 @@ public class SysMenu extends BaseEntity { private String query; /** - * 是否 外链 true 不为外链, false 为外链 + * 是否 外链 1 为内链, 0 为外链 */ - private boolean frame; + private String frame; - /** 是否缓存(false不缓存 true缓存) */ - private boolean cache; + /** 是否缓存(1缓存 0不缓存) */ + private String cache; /** - * 是否隐藏 true 隐藏 + * 是否显示 1 显示 */ - private boolean visible; + private String visible; /** - * 状态 true 停用 + * 状态 0 停用 */ - private boolean status; + private String status; /** * 拥有权限 diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysPost.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysPost.java new file mode 100644 index 0000000..2ee9049 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysPost.java @@ -0,0 +1,77 @@ +package com.chushang.system.entity.po; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.baomidou.mybatisplus.annotation.*; +import com.chushang.common.mybatis.base.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.io.Serial; + +/** + * 岗位表 sys_post + * + * @author ruoyi + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("sys_post") +public class SysPost extends BaseEntity +{ + @Serial + private static final long serialVersionUID = 1L; + + /** 岗位序号 */ + @TableId(value = "post_id", type = IdType.AUTO) + @ExcelProperty(value = "岗位序号", index = 0) + private Long postId; + + /** 岗位编码 */ + @ExcelProperty(value = "岗位编码", index = 1) + private String postCode; + + /** 岗位名称 */ + @ExcelProperty(value = "岗位名称", index = 2) + private String postName; + + /** 岗位排序 */ + @ExcelProperty(value = "岗位排序", index = 3) + private Integer postSort; + + /** 状态(0正常 1停用) */ + @ExcelProperty(value = "状态", index = 4) + private String status; + + /** + * 创建人 + */ + @TableField( + value = "create_by", + updateStrategy = FieldStrategy.NEVER + ) + @ExcelProperty(value = "创建人", index = 4) + protected String createBy; + /** + * 修改人 + */ + @TableField( + value = "update_by", + insertStrategy = FieldStrategy.NEVER + ) + @ExcelProperty(value = "修改人", index = 5) + protected String updateBy; + + /** 用户是否存在此岗位标识 默认不存在 */ + @TableField(exist = false) + private boolean flag = false; +} diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysRoleDept.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysRoleDept.java index b01cfeb..5e7a616 100644 --- a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysRoleDept.java +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysRoleDept.java @@ -21,13 +21,6 @@ public class SysRoleDept implements Serializable { @Serial private static final long serialVersionUID = 1L; - - /** - * 自增Id - */ - @TableId(value = "id", type = IdType.AUTO) - private Integer id; - /** * 角色Id */ diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysRoleMenu.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysRoleMenu.java index 3a42248..4861baa 100644 --- a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysRoleMenu.java +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysRoleMenu.java @@ -11,7 +11,7 @@ import java.io.Serializable; /** *

- * + * *

* * @author author @@ -24,13 +24,6 @@ import java.io.Serializable; public class SysRoleMenu implements Serializable { private static final long serialVersionUID = 1L; - - /** - * 自增Id - */ - @TableId(value = "id", type = IdType.AUTO) - private Integer id; - /** * 角色Id */ diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysUserPost.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysUserPost.java index ceaecd3..f4a4ea1 100644 --- a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysUserPost.java +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysUserPost.java @@ -12,7 +12,7 @@ import java.io.Serializable; /** *

- * + * *

* * @author author @@ -27,12 +27,6 @@ public class SysUserPost implements Serializable { @Serial private static final long serialVersionUID = 1L; - /** - * 自增主键Id - */ - @TableId(value = "id", type = IdType.AUTO) - private Integer id; - /** * 岗位Id */ diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysUserRole.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysUserRole.java index 829a417..a9d5a06 100644 --- a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysUserRole.java +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/po/SysUserRole.java @@ -12,7 +12,7 @@ import java.io.Serializable; /** *

- * + * *

* * @author author @@ -27,12 +27,6 @@ public class SysUserRole implements Serializable { @Serial private static final long serialVersionUID = 1L; - /** - * 自增Id - */ - @TableId(value = "id", type = IdType.AUTO) - private Integer id; - /** * 角色id */ diff --git a/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/vo/SysUserOnline.java b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/vo/SysUserOnline.java new file mode 100644 index 0000000..337ed9a --- /dev/null +++ b/chushang-modules/chushang-module-system/system-feign/src/main/java/com/chushang/system/entity/vo/SysUserOnline.java @@ -0,0 +1,36 @@ +package com.chushang.system.entity.vo; + +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +/** + * 当前在线会话 + * + * @author ruoyi + */ +@Data +public class SysUserOnline +{ + /** 会话编号 */ + private String tokenId; + + /** 用户名称 */ + private String userName; + + /** 登录IP地址 */ + private String ipaddr; + + /** 登录地址 */ + private String loginLocation; + + /** 浏览器类型 */ + private String browser; + + /** 操作系统 */ + private String os; + + /** 登录时间 */ + private Long loginTime; + +} diff --git a/chushang-modules/chushang-module-system/system-service/pom.xml b/chushang-modules/chushang-module-system/system-service/pom.xml index 8cffcf8..2d4b47b 100644 --- a/chushang-modules/chushang-module-system/system-service/pom.xml +++ b/chushang-modules/chushang-module-system/system-service/pom.xml @@ -37,4 +37,4 @@ - \ No newline at end of file + diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/aspect/DataScopeAspect.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/aspect/DataScopeAspect.java index b56723e..3f6924f 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/aspect/DataScopeAspect.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/aspect/DataScopeAspect.java @@ -2,7 +2,7 @@ package com.chushang.system.aspect; import cn.hutool.core.collection.CollectionUtil; import com.chushang.common.core.text.Convert; -import com.chushang.common.core.util.CommonParam; +import com.chushang.common.mybatis.page.CommonParam; import com.chushang.common.core.util.StringUtils; import com.chushang.common.mybatis.base.BaseEntity; import com.chushang.security.context.SecurityContextHolder; diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/DictController.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/DictController.java index 27f1aa9..e07518c 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/DictController.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/DictController.java @@ -1,12 +1,25 @@ package com.chushang.system.controller; import com.chushang.common.core.web.AjaxResult; +import com.chushang.common.excel.utils.ExcelUtils; +import com.chushang.common.log.annotation.SysLog; +import com.chushang.common.log.enums.BusinessType; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.security.annotation.RequiresPermissions; +import com.chushang.security.utils.SecurityUtils; +import com.chushang.system.entity.dto.ListDictDTO; +import com.chushang.system.entity.po.SysDictData; +import com.chushang.system.service.ISysDictTypeService; import com.chushang.system.service.SysDictDataService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.aspectj.weaver.loadtime.Aj; +import org.checkerframework.checker.units.qual.A; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.List; /** * @author by zhaowenyuan create 2022/8/26 11:43 @@ -16,15 +29,83 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping(value = "/dict/data") public class DictController { - @Autowired + @Resource SysDictDataService dictDataService; + @Resource + ISysDictTypeService dictTypeService; /** * 获取字典数据值 */ @GetMapping(value = "/type/{dictType}") public AjaxResult getInfo(@PathVariable String dictType) { - return dictDataService.selectDictDataByType(dictType); + return AjaxResult.success(dictDataService.selectDictDataByType(dictType)); + } + + @RequiresPermissions("system:dict:list") + @GetMapping("/list") + public AjaxResult list(ListDictDTO dictData) + { + CommonParam pageParam = CommonParam.buildPageRequest(); + return AjaxResult.success(dictDataService.pageDictDataList(dictData, pageParam)); + } + + @SysLog(value = "导出字典数据") + @RequiresPermissions("system:dict:export") + @PostMapping("/export") + public void export(HttpServletResponse response, ListDictDTO dictData) + { + CommonParam commonParam = CommonParam.buildAllRequest(); + List list = dictDataService.allDictDataList(dictData,commonParam); + ExcelUtils.exportList(response, SysDictData.class, list, "导出字典数据"); + } + + /** + * 查询字典数据详细 + */ + @RequiresPermissions("system:dict:query") + @GetMapping(value = "/{dictCode}") + public AjaxResult getInfo(@PathVariable Long dictCode) + { + return AjaxResult.success(dictDataService.getById(dictCode)); + } + + /** + * 新增字典类型 + */ + @RequiresPermissions("system:dict:add") + @SysLog(value = "字典数据", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysDictData dict) + { + dict.setCreateBy(SecurityUtils.getUsername()); + dictDataService.saveOrUpdate(dict); + return AjaxResult.success(); + } + + /** + * 修改保存字典类型 + */ + @RequiresPermissions("system:dict:edit") + @SysLog(value = "字典数据", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysDictData dict) + { + dict.setUpdateBy(SecurityUtils.getUsername()); + dictDataService.saveOrUpdate(dict); + return AjaxResult.success(); + } + + /** + * 删除字典类型 + */ + @RequiresPermissions("system:dict:remove") + @SysLog(value = "字典类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{dictCodes}") + public AjaxResult remove(@PathVariable Long[] dictCodes) + { + dictDataService.removeBatchByIds(Arrays.asList(dictCodes)); + return AjaxResult.success(); } } diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/DictTypeController.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/DictTypeController.java new file mode 100644 index 0000000..9da6eb1 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/DictTypeController.java @@ -0,0 +1,131 @@ +package com.chushang.system.controller; + +import com.chushang.common.core.exception.utils.AssertUtil; +import com.chushang.common.core.web.AjaxResult; +import com.chushang.common.excel.utils.ExcelUtils; +import com.chushang.common.log.annotation.SysLog; +import com.chushang.common.log.enums.BusinessType; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.security.annotation.RequiresPermissions; +import com.chushang.security.utils.SecurityUtils; +import com.chushang.system.entity.po.SysDictType; +import com.chushang.system.service.ISysDictTypeService; +import lombok.extern.java.Log; +import org.aspectj.weaver.loadtime.Aj; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.List; + +/** + * @auther: zhao + * @date: 2024/5/9 15:54 + */ +@RestController +@RequestMapping(value = "/dict/type") +public class DictTypeController { + @Resource + ISysDictTypeService dictTypeService; + + @RequiresPermissions("system:dict:list") + @GetMapping("/list") + public AjaxResult list(SysDictType dictType) + { + CommonParam commonParam = CommonParam.buildPageRequest(); + PageResult pageResult = dictTypeService.pageDictTypeList(dictType, commonParam); + return AjaxResult.success(pageResult); + } + + @SysLog(value = "字典类型", businessType = BusinessType.EXPORT) + @RequiresPermissions("system:dict:export") + @PostMapping("/export") + public void export(HttpServletResponse response, SysDictType dictType) + { + CommonParam commonParam = CommonParam.buildAllRequest(); + List list = dictTypeService.allDictTypeList(dictType, commonParam); + ExcelUtils.exportList(response, SysDictType.class, list, "导出字典类型数据"); + } + + /** + * 查询字典类型详细 + */ + @RequiresPermissions("system:dict:query") + @GetMapping(value = "/{dictId}") + public AjaxResult getInfo(@PathVariable Long dictId) + { + return AjaxResult.success(dictTypeService.getById(dictId)); + } + + /** + * 新增字典类型 + */ + @RequiresPermissions("system:dict:add") + @SysLog(value = "字典类型", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysDictType dict) + { + CommonParam commonParam = CommonParam.buildAllRequest(); + + AssertUtil.invalidate(dictTypeService.checkDictTypeUnique(dict, commonParam),"新增字典'" + dict.getDictName() + "'失败,字典类型已存在" ); + + dict.setCreateBy(SecurityUtils.getUsername()); + dictTypeService.saveOrUpdate(dict); + return AjaxResult.success(); + } + + /** + * 修改字典类型 + */ + @RequiresPermissions("system:dict:edit") + @SysLog(value = "字典类型", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysDictType dict) + { + CommonParam commonParam = CommonParam.buildAllRequest(); + + AssertUtil.invalidate(dictTypeService.checkDictTypeUnique(dict, commonParam),"修改字典'" + dict.getDictName() + "'失败,字典类型已存在" ); + + dict.setUpdateBy(SecurityUtils.getUsername()); + dictTypeService.saveOrUpdate(dict); + return AjaxResult.success(); + } + + /** + * 删除字典类型 + */ + @RequiresPermissions("system:dict:remove") + @SysLog(value = "字典类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{dictIds}") + public AjaxResult remove(@PathVariable Long[] dictIds) + { + dictTypeService.removeBatchByIds(Arrays.asList(dictIds)); + return AjaxResult.success(); + } + + /** + * 刷新字典缓存 TODO + */ + @RequiresPermissions("system:dict:remove") + @SysLog(value = "字典类型", businessType = BusinessType.CLEAN) + @DeleteMapping("/refreshCache") + public AjaxResult refreshCache() + { + dictTypeService.resetDictCache(); + return AjaxResult.success(); + } + + /** + * 获取字典选择框列表 + */ + @GetMapping("/option/select") + public AjaxResult optionSelect() + { + CommonParam commonParam = CommonParam.buildAllRequest(); + List list = dictTypeService.allDictTypeList(new SysDictType(), commonParam); + return AjaxResult.success(list); + } +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/MenuController.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/MenuController.java index 87cb941..cce8e74 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/MenuController.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/MenuController.java @@ -86,7 +86,8 @@ public class MenuController { { return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); } - else if (!menu.isFrame() && ! StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) + // 外链 + else if ("0".equals(menu.getFrame()) && ! StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) { return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); } @@ -109,7 +110,8 @@ public class MenuController { { return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); } - else if (!menu.isFrame() && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) + // 外链 + else if ("0".equals(menu.getFrame()) && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) { return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); } diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/PostController.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/PostController.java new file mode 100644 index 0000000..1014ef4 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/PostController.java @@ -0,0 +1,131 @@ +package com.chushang.system.controller; + +import com.chushang.common.core.exception.utils.AssertUtil; +import com.chushang.common.core.web.AjaxResult; +import com.chushang.common.excel.utils.ExcelUtils; +import com.chushang.common.log.annotation.SysLog; +import com.chushang.common.log.enums.BusinessType; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.security.annotation.RequiresPermissions; +import com.chushang.security.utils.SecurityUtils; +import com.chushang.system.entity.po.SysPost; +import com.chushang.system.service.ISysPostService; +import lombok.extern.java.Log; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.List; + +/** + * @auther: zhao + * @date: 2024/5/9 15:54 + */ +@RestController +@RequestMapping("/post") +public class PostController { + + @Resource + ISysPostService postService; + + /** + * 获取岗位列表 + */ + @RequiresPermissions("system:post:list") + @GetMapping("/list") + public AjaxResult list(SysPost post) + { + CommonParam commonParam = CommonParam.buildPageRequest(); + PageResult pageResult = postService.pagePostList(post, commonParam); + return AjaxResult.success(pageResult); + } + + @SysLog(value = "岗位管理", businessType = BusinessType.EXPORT) + @RequiresPermissions("system:post:export") + @PostMapping("/export") + public void export(HttpServletResponse response, SysPost post) + { + CommonParam commonParam = CommonParam.buildAllRequest(); + List list = postService.allPostList(post, commonParam); + ExcelUtils.exportList(response, SysPost.class,list, "岗位数据"); + } + + /** + * 根据岗位编号获取详细信息 + */ + @RequiresPermissions("system:post:query") + @GetMapping(value = "/{postId}") + public AjaxResult getInfo(@PathVariable Long postId) + { + return AjaxResult.success(postService.getById(postId)); + } + + /** + * 新增岗位 + */ + @RequiresPermissions("system:post:add") + @SysLog(value = "岗位管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysPost post) + { + CommonParam commonParam = CommonParam.buildAllRequest(); + SysPost postName = new SysPost(); + postName.setPostName(post.getPostName()); + postName.setPostCode(null); + AssertUtil.invalidate(postService.checkPostCodeUnique(postName, commonParam), "新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); + postName.setPostCode(post.getPostCode()); + postName.setPostName(null); + AssertUtil.invalidate(postService.checkPostCodeUnique(postName, commonParam), "新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + post.setCreateBy(SecurityUtils.getUsername()); + postService.saveOrUpdate(post); + return AjaxResult.success(); + } + + /** + * 修改岗位 + */ + @RequiresPermissions("system:post:edit") + @SysLog(value = "岗位管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysPost post) + { + CommonParam commonParam = CommonParam.buildAllRequest(); + SysPost postName = new SysPost(); + postName.setPostName(post.getPostName()); + postName.setPostCode(null); + AssertUtil.invalidate(postService.checkPostCodeUnique(postName, commonParam), "修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); + postName.setPostCode(post.getPostCode()); + postName.setPostName(null); + AssertUtil.invalidate(postService.checkPostCodeUnique(postName, commonParam), "修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + post.setCreateBy(SecurityUtils.getUsername()); + postService.saveOrUpdate(post); + return AjaxResult.success(); + } + + /** + * 删除岗位 + */ + @RequiresPermissions("system:post:remove") + @SysLog(value = "岗位管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{postIds}") + public AjaxResult remove(@PathVariable Long[] postIds) + { + postService.removeBatchByIds(Arrays.asList(postIds)); + return AjaxResult.success(); + } + + /** + * 获取岗位选择框列表 + */ + @GetMapping("/option/select") + public AjaxResult optionselect() + { + CommonParam commonParam = CommonParam.buildAllRequest(); + List list = postService.allPostList(new SysPost(), commonParam); + return AjaxResult.success(list); + } + +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/SysConfigController.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/SysConfigController.java new file mode 100644 index 0000000..4c638c9 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/SysConfigController.java @@ -0,0 +1,124 @@ +package com.chushang.system.controller; + +import com.chushang.common.core.web.AjaxResult; +import com.chushang.common.excel.utils.ExcelUtils; +import com.chushang.common.log.annotation.SysLog; +import com.chushang.common.log.enums.BusinessType; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.security.annotation.RequiresPermissions; +import com.chushang.security.utils.SecurityUtils; +import com.chushang.system.entity.po.SysConfig; +import com.chushang.system.entity.po.SysDictType; +import com.chushang.system.service.ISysConfigService; +import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.List; + +/** + * 参数配置 信息操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/config") +public class SysConfigController +{ + @Resource + private ISysConfigService configService; + + /** + * 获取参数配置列表 + */ + @RequiresPermissions("system:config:list") + @GetMapping("/list") + public AjaxResult list(SysConfig config) + { + CommonParam commonParam = CommonParam.buildPageRequest(); + PageResult pageResult = configService.pageConfigList(config, commonParam); + return AjaxResult.success(pageResult); + } + + @SysLog(value = "参数管理", businessType = BusinessType.EXPORT) + @RequiresPermissions("system:config:export") + @PostMapping("/export") + public void export(HttpServletResponse response, SysConfig config) + { + CommonParam commonParam = CommonParam.buildAllRequest(); + List list = configService.allConfigList(config, commonParam); + ExcelUtils.exportList(response, SysConfig.class, list, "参数数据"); + } + + /** + * 根据参数编号获取详细信息 + */ + @GetMapping(value = "/{configId}") + public AjaxResult getInfo(@PathVariable Long configId) + { + return AjaxResult.success(configService.getById(configId)); + } + + /** + * 根据参数键名查询参数值 + */ + @GetMapping(value = "/configKey/{configKey}") + public AjaxResult getConfigKey(@PathVariable String configKey) + { + SysConfig config = new SysConfig(); + config.setConfigKey(configKey); + CommonParam commonParam = CommonParam.buildPageRequest(); + return AjaxResult.success(configService.getOne(configService.buildWrapper(config, commonParam))); + } + + /** + * 新增参数配置 + */ + @RequiresPermissions("system:config:add") + @SysLog(value = "参数管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysConfig config) + { + if (configService.checkConfigKeyUnique(config, CommonParam.buildAllRequest())) + { + return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); + } + config.setCreateBy(SecurityUtils.getUsername()); + configService.saveOrUpdate(config); + return AjaxResult.success(); + } + + /** + * 修改参数配置 + */ + @RequiresPermissions("system:config:edit") + @SysLog(value = "参数管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysConfig config) + { + if (configService.checkConfigKeyUnique(config, CommonParam.buildAllRequest())) + { + return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); + } + config.setUpdateBy(SecurityUtils.getUsername()); + configService.saveOrUpdate(config); + return AjaxResult.success(); + } + + /** + * 删除参数配置 + */ + @RequiresPermissions("system:config:remove") + @SysLog(value = "参数管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{configIds}") + public AjaxResult remove(@PathVariable Long[] configIds) + { + configService.removeBatchByIds(Arrays.asList(configIds)); + return AjaxResult.success(); + } +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/SysUserOnlineController.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/SysUserOnlineController.java new file mode 100644 index 0000000..a6e659f --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/SysUserOnlineController.java @@ -0,0 +1,53 @@ +//package com.chushang.system.controller; +// +//import java.util.ArrayList; +//import java.util.Collection; +//import java.util.Collections; +//import java.util.List; +// +//import com.chushang.common.core.constant.CacheConstants; +//import com.chushang.common.core.web.AjaxResult; +//import com.chushang.security.annotation.RequiresPermissions; +//import com.chushang.security.entity.vo.LoginUser; +//import com.chushang.system.entity.vo.SysUserOnline; +//import com.chushang.system.service.ISysUserOnlineService; +//import lombok.extern.java.Log; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.bind.annotation.DeleteMapping; +//import org.springframework.web.bind.annotation.GetMapping; +//import org.springframework.web.bind.annotation.PathVariable; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RestController; +// +///** +// * 在线用户监控 +// * +// * @author ruoyi +// */ +//@RestController +//@RequestMapping("/online") +//public class SysUserOnlineController +//{ +// @Autowired +// private ISysUserOnlineService userOnlineService; +// +// @RequiresPermissions("monitor:online:list") +// @GetMapping("/list") +// public TableDataInfo list(String ipaddr, String userName) +// { +// +// return getDataTable(userOnlineList); +// } +// +// /** +// * 强退用户 +// */ +// @RequiresPermissions("monitor:online:forceLogout") +// @Log(title = "在线用户", businessType = BusinessType.FORCE) +// @DeleteMapping("/{tokenId}") +// public AjaxResult forceLogout(@PathVariable String tokenId) +// { +// redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId); +// return success(); +// } +//} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/UserController.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/UserController.java index 23cff0b..402e061 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/UserController.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/controller/UserController.java @@ -73,8 +73,6 @@ public class UserController implements RemoteUserService { Set permissions = permissionService.getMenuPermission(sysUser); AjaxResult ajax = AjaxResult.success(); - sysUser.setPassword(""); - sysUser.setSalt(""); ajax.put("user", sysUser); ajax.put("roles", roles); ajax.put("permissions", permissions); diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/mapper/SysConfigMapper.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/mapper/SysConfigMapper.java new file mode 100644 index 0000000..7d2f247 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/mapper/SysConfigMapper.java @@ -0,0 +1,11 @@ +package com.chushang.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chushang.system.entity.po.SysConfig; + +/** + * @auther: zhao + * @date: 2024/5/9 15:48 + */ +public interface SysConfigMapper extends BaseMapper { +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/mapper/SysDictTypeMapper.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/mapper/SysDictTypeMapper.java new file mode 100644 index 0000000..ae2a738 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/mapper/SysDictTypeMapper.java @@ -0,0 +1,11 @@ +package com.chushang.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chushang.system.entity.po.SysDictData; +import com.chushang.system.entity.po.SysDictType; + +/** + * @author by zhaowenyuan create 2022/8/26 11:40 + */ +public interface SysDictTypeMapper extends BaseMapper { +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/mapper/SysPostMapper.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/mapper/SysPostMapper.java new file mode 100644 index 0000000..9e0a778 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/mapper/SysPostMapper.java @@ -0,0 +1,11 @@ +package com.chushang.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chushang.system.entity.po.SysPost; + +/** + * @auther: zhao + * @date: 2024/5/9 15:49 + */ +public interface SysPostMapper extends BaseMapper { +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysConfigService.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysConfigService.java new file mode 100644 index 0000000..e4c6a5f --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysConfigService.java @@ -0,0 +1,31 @@ +package com.chushang.system.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.system.entity.po.SysConfig; + +import java.util.List; + +/** + * @auther: zhao + * @date: 2024/5/9 15:53 + */ +public interface ISysConfigService extends IService { + default PageResult pageConfigList(SysConfig config, CommonParam commonParam){ + return new PageResult(this.page(new Page<>(commonParam.getPage(), commonParam.getLimit()), + buildWrapper(config, commonParam) + )); + } + LambdaQueryWrapper buildWrapper(SysConfig sysConfig, CommonParam commonParam); + + default List allConfigList(SysConfig config, CommonParam commonParam){ + return this.list(this.buildWrapper(config, commonParam)); + } + + default boolean checkConfigKeyUnique(SysConfig config, CommonParam commonParam){ + return this.count(buildWrapper(config, commonParam)) > 0; + } +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysDictTypeService.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysDictTypeService.java new file mode 100644 index 0000000..b833841 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysDictTypeService.java @@ -0,0 +1,29 @@ +package com.chushang.system.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.system.entity.po.SysDictType; + +import java.util.List; + +/** + * @auther: zhao + * @date: 2024/5/9 15:53 + */ +public interface ISysDictTypeService extends IService { + PageResult pageDictTypeList(SysDictType dictType, CommonParam commonParam); + default List allDictTypeList(SysDictType dictType, CommonParam commonParam){ + return this.list(buildWrapper(dictType, commonParam)); + } + + LambdaQueryWrapper buildWrapper(SysDictType dictType, CommonParam commonParam); + + default boolean checkDictTypeUnique(SysDictType dictType, CommonParam commonParam){ + return this.count(buildWrapper(dictType, commonParam)) > 0; + } + // todo + default void resetDictCache(){} + +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysPostService.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysPostService.java new file mode 100644 index 0000000..f8daca7 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysPostService.java @@ -0,0 +1,34 @@ +package com.chushang.system.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.system.entity.po.SysPost; + +import java.util.List; + +/** + * @auther: zhao + * @date: 2024/5/9 15:53 + */ +public interface ISysPostService extends IService { + default PageResult pagePostList(SysPost sysPost, CommonParam commonParam){ + IPage page = this.page( + new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(commonParam.getPage(), commonParam.getLimit()), + buildWrapper(sysPost, commonParam) + ); + return new PageResult(page); + } + LambdaQueryWrapper buildWrapper(SysPost sysPost, CommonParam commonParam); + + default List allPostList(SysPost post, CommonParam commonParam){ + return this.list(buildWrapper(post, commonParam)); + } + + + default boolean checkPostCodeUnique(SysPost sysPost, CommonParam commonParam){ + return this.count(buildWrapper(sysPost, commonParam)) > 0; + } +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysRoleDeptService.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysRoleDeptService.java index d3ac5f4..8e84757 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysRoleDeptService.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysRoleDeptService.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; import com.chushang.system.entity.po.SysRoleDept; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -17,7 +18,7 @@ import java.util.List; * @since 2022-08-18 */ public interface ISysRoleDeptService extends IService { - + @Transactional default void saveBatch(Integer roleId, Integer[] deptIds){ remove(new LambdaQueryWrapper().eq(SysRoleDept::getRoleId, roleId)); @@ -31,18 +32,18 @@ public interface ISysRoleDeptService extends IService { rd.setDeptId(deptId); list.add(rd); } - if (list.size() > 0) + if (!list.isEmpty()) { saveBatch(list); } } - + @Transactional default void deleteRoleDept(List roleIds){ if (CollectionUtil.isNotEmpty(roleIds)){ roleIds.forEach(this::removeByRoleId); } } - + @Transactional default void removeByRoleId(Integer roleId){ remove(new LambdaQueryWrapper().eq(SysRoleDept::getRoleId, roleId)); } diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysRoleMenuService.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysRoleMenuService.java index a748abc..3b472c6 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysRoleMenuService.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysRoleMenuService.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; import com.chushang.system.entity.po.SysRoleMenu; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; @@ -18,7 +19,7 @@ import java.util.List; * @since 2022-08-18 */ public interface ISysRoleMenuService extends IService { - + @Transactional default void saveBatch(Integer roleId, Integer[] menuIds){ // 先删除 对应的角色菜单 remove(new LambdaQueryWrapper() @@ -34,13 +35,13 @@ public interface ISysRoleMenuService extends IService { saveBatch(list); } } - + @Transactional default void deleteRoleMenu(Collection roleIds){ if (CollectionUtil.isNotEmpty(roleIds)){ roleIds.forEach(this::removeByRoleId); } } - + @Transactional default void removeByRoleId(Integer roleId){ remove(new LambdaQueryWrapper().eq(SysRoleMenu::getRoleId, roleId)); } diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserOnlineService.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserOnlineService.java new file mode 100644 index 0000000..cd0fd84 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserOnlineService.java @@ -0,0 +1,132 @@ +//package com.chushang.system.service; +// +//import com.chushang.common.core.constant.CacheConstants; +//import com.chushang.common.core.util.StringUtils; +//import com.chushang.security.entity.vo.LoginUser; +//import com.chushang.system.entity.vo.SysUserOnline; +//import lombok.extern.slf4j.Slf4j; +//import org.redisson.api.RKeys; +//import org.redisson.api.RedissonClient; +//import org.springframework.stereotype.Service; +// +//import javax.annotation.Resource; +//import java.util.ArrayList; +//import java.util.Collection; +//import java.util.Collections; +//import java.util.List; +// +///** +// * 在线用户 服务层 +// * +// * @author ruoyi +// */ +//@Slf4j +//@Service +//public class ISysUserOnlineService +//{ +// +// @Resource +// RedissonClient redissonClient; +// +// public SysUserOnline selectOnlineByIpaddr(){ +// +// Collection keys = new ArrayList<>(); +// redissonClient.getKeys().getKeys().forEach(key-> { +// if (key.startsWith(CacheConstants.LOGIN_TOKEN_KEY)){ +// keys.add(key); +// } +// }); +// List userOnlineList = new ArrayList(); +// for (String key : keys) +// { +// LoginUser user = redisService.getCacheObject(key); +// if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) +// { +// userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); +// } +// else if (StringUtils.isNotEmpty(ipaddr)) +// { +// userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); +// } +// else if (StringUtils.isNotEmpty(userName)) +// { +// userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); +// } +// else +// { +// userOnlineList.add(userOnlineService.loginUserToUserOnline(user)); +// } +// } +// Collections.reverse(userOnlineList); +// userOnlineList.removeAll(Collections.singleton(null)); +// } +// +// /** +// * 通过登录地址查询信息 +// * +// * @param ipaddr 登录地址 +// * @param user 用户信息 +// * @return 在线用户信息 +// */ +// public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) +// { +// if (StringUtils.equals(ipaddr, user.getIpaddr())) +// { +// return loginUserToUserOnline(user); +// } +// return null; +// } +// +// /** +// * 通过用户名称查询信息 +// * +// * @param userName 用户名称 +// * @param user 用户信息 +// * @return 在线用户信息 +// */ +// public SysUserOnline selectOnlineByUserName(String userName, LoginUser user) +// { +// if (StringUtils.equals(userName, user.getUsername())) +// { +// return loginUserToUserOnline(user); +// } +// return null; +// } +// +// /** +// * 通过登录地址/用户名称查询信息 +// * +// * @param ipaddr 登录地址 +// * @param userName 用户名称 +// * @param user 用户信息 +// * @return 在线用户信息 +// */ +// public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user) +// { +// if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) +// { +// return loginUserToUserOnline(user); +// } +// return null; +// } +// +// /** +// * 设置在线用户信息 +// * +// * @param user 用户信息 +// * @return 在线用户 +// */ +// public SysUserOnline loginUserToUserOnline(LoginUser user) +// { +// if (StringUtils.isNull(user)) +// { +// return null; +// } +// SysUserOnline sysUserOnline = new SysUserOnline(); +// sysUserOnline.setTokenId(user.getToken()); +// sysUserOnline.setUserName(user.getUsername()); +// sysUserOnline.setIpaddr(user.getIpaddr()); +// sysUserOnline.setLoginTime(user.getLoginTime()); +// return sysUserOnline; +// } +//} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserPostService.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserPostService.java index 92a38ed..5d72fbd 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserPostService.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserPostService.java @@ -3,6 +3,7 @@ package com.chushang.system.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; import com.chushang.system.entity.po.SysUserPost; +import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; @@ -12,7 +13,7 @@ import java.util.stream.Collectors; * @author by zhaowenyuan create 2022/8/19 11:49 */ public interface ISysUserPostService extends IService { - + @Transactional default void saveOrUpdate(Integer userId, Integer[] roleIdList){ //先删除用户与岗位 this.remove(new LambdaQueryWrapper() diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserRoleService.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserRoleService.java index 1658d0b..b8e3ead 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserRoleService.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/ISysUserRoleService.java @@ -3,6 +3,7 @@ package com.chushang.system.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; import com.chushang.system.entity.po.SysUserRole; +import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.Collection; @@ -18,6 +19,7 @@ import java.util.stream.Collectors; */ public interface ISysUserRoleService extends IService { + @Transactional default void saveOrUpdate(Integer userId, Integer[] roleIdList){ //先删除用户与角色关系 this.remove(new LambdaQueryWrapper() @@ -32,7 +34,7 @@ public interface ISysUserRoleService extends IService { return sysUserRoleEntity; }).collect(Collectors.toList())); } - + @Transactional default void saveOrUpdate(Integer[] userIdList, Integer roleId){ //先删除用户与角色关系 this.remove(new LambdaQueryWrapper() diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/SysDictDataService.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/SysDictDataService.java index a4897df..6bc28e2 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/SysDictDataService.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/SysDictDataService.java @@ -2,12 +2,22 @@ package com.chushang.system.service; import com.baomidou.mybatisplus.extension.service.IService; import com.chushang.common.core.web.AjaxResult; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.security.utils.SecurityUtils; +import com.chushang.system.entity.dto.ListDictDTO; import com.chushang.system.entity.po.SysDictData; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; /** * @author by zhaowenyuan create 2022/8/26 11:42 */ public interface SysDictDataService extends IService { - AjaxResult selectDictDataByType(String dictType); + List selectDictDataByType(String dictType); + + PageResult pageDictDataList(ListDictDTO dictData, CommonParam commonParam); + List allDictDataList(ListDictDTO dictData, CommonParam commonParam); } diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysConfigServiceImpl.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysConfigServiceImpl.java new file mode 100644 index 0000000..7b5b42f --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysConfigServiceImpl.java @@ -0,0 +1,31 @@ +package com.chushang.system.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.system.entity.po.SysConfig; +import com.chushang.system.entity.po.SysDictType; +import com.chushang.system.mapper.SysConfigMapper; +import com.chushang.system.service.ISysConfigService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +/** + * @auther: zhao + * @date: 2024/5/9 18:47 + */ +@Slf4j +@Service +public class SysConfigServiceImpl extends ServiceImpl implements ISysConfigService { + public LambdaQueryWrapper buildWrapper(SysConfig sysConfig, CommonParam commonParam) { + return new QueryWrapper() + .orderBy(true, "asc".equals(commonParam.getIsAsc()), commonParam.getOrderBy()) + .lambda() + .eq(null != sysConfig.getConfigId(), SysConfig::getConfigId, sysConfig.getConfigId()) + .eq(StringUtils.isNotEmpty(sysConfig.getConfigName()), SysConfig::getConfigName, sysConfig.getConfigName()) + .eq(StringUtils.isNotEmpty(sysConfig.getConfigKey()), SysConfig::getConfigKey, sysConfig.getConfigKey()) + .eq(StringUtils.isNotEmpty(sysConfig.getConfigType()), SysConfig::getConfigType, sysConfig.getConfigType()); + } +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysDictDataServiceImpl.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysDictDataServiceImpl.java index cbcdb5b..398c844 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysDictDataServiceImpl.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysDictDataServiceImpl.java @@ -2,12 +2,19 @@ package com.chushang.system.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.chushang.common.core.web.AjaxResult; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.system.entity.dto.ListDictDTO; import com.chushang.system.entity.po.SysDictData; import com.chushang.system.mapper.SysDictDataMapper; import com.chushang.system.service.SysDictDataService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.redisson.api.RBucket; import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; @@ -28,24 +35,52 @@ public class SysDictDataServiceImpl extends ServiceImpl selectDictDataByType(String dictType) { RBucket> bucket = redissonClient.getBucket(getCacheKey(dictType)); List dictDataList = bucket.get(); - if (CollectionUtil.isNotEmpty(dictDataList)){ - return AjaxResult.success(dictDataList); + if (CollectionUtil.isNotEmpty(dictDataList)) { + return dictDataList; } List list = list(new LambdaQueryWrapper() .eq(SysDictData::getDictType, dictType) .eq(SysDictData::getStatus, "0") .orderByAsc(SysDictData::getDictSort) ); - if (CollectionUtil.isNotEmpty(list)){ + if (CollectionUtil.isNotEmpty(list)) { bucket.set(list); } - return AjaxResult.success(list); + return list; } - private String getCacheKey(String cacheKey){ + @Override + public PageResult pageDictDataList(ListDictDTO dictData, CommonParam commonParam) { + IPage page = this.page( + new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(commonParam.getPage(), commonParam.getLimit()), + buildWrapper(dictData, commonParam) + ); + return new PageResult(page); + } + + @Override + public List allDictDataList(ListDictDTO dictData, CommonParam commonParam) { + return this.list(buildWrapper(dictData, commonParam)); + } + + + private String getCacheKey(String cacheKey) { return SYS_DICT_KEY + cacheKey; } + + private LambdaQueryWrapper buildWrapper(ListDictDTO dictData, CommonParam commonParam) { + return new QueryWrapper() + .orderBy(true, "asc".equals(commonParam.getIsAsc()), commonParam.getOrderBy()) + .lambda() + .eq(null != dictData.getDictCode(), SysDictData::getDictCode, dictData.getDictCode()) + .eq(StringUtils.isNotEmpty(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) + .eq(StringUtils.isNotEmpty(dictData.getCssClass()), SysDictData::getCssClass, dictData.getCssClass()) + .eq(StringUtils.isNotEmpty(dictData.getListClass()), SysDictData::getListClass, dictData.getListClass()) + .eq(StringUtils.isNotEmpty(dictData.getIsDefault()), SysDictData::getIsDefault, dictData.getIsDefault()) + .eq(StringUtils.isNotEmpty(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()); + } + } diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysDictTypeServiceImpl.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysDictTypeServiceImpl.java new file mode 100644 index 0000000..9c5a847 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysDictTypeServiceImpl.java @@ -0,0 +1,45 @@ +package com.chushang.system.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.system.entity.dto.ListDictDTO; +import com.chushang.system.entity.po.SysDictData; +import com.chushang.system.entity.po.SysDictType; +import com.chushang.system.mapper.SysDictTypeMapper; +import com.chushang.system.service.ISysDictTypeService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @auther: zhao + * @date: 2024/5/9 17:57 + */ +@Slf4j +@Service +public class SysDictTypeServiceImpl extends ServiceImpl implements ISysDictTypeService { + @Override + public PageResult pageDictTypeList(SysDictType dictType, CommonParam commonParam) { + IPage page = this.page( + new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(commonParam.getPage(), commonParam.getLimit()), + buildWrapper(dictType, commonParam) + ); + return new PageResult(page); + } + + public LambdaQueryWrapper buildWrapper(SysDictType dictType, CommonParam commonParam) { + return new QueryWrapper() + .orderBy(true, "asc".equals(commonParam.getIsAsc()), commonParam.getOrderBy()) + .lambda() + .eq(null != dictType.getDictId(), SysDictType::getDictId, dictType.getDictId()) + .eq(StringUtils.isNotEmpty(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) + .eq(StringUtils.isNotEmpty(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) + .eq(StringUtils.isNotEmpty(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()); + } +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysMenuServiceImpl.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysMenuServiceImpl.java index 95ccbbf..86f64bd 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysMenuServiceImpl.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysMenuServiceImpl.java @@ -105,12 +105,13 @@ public class SysMenuServiceImpl extends ServiceImpl impl for (SysMenu menu : menus) { RouterVo router = new RouterVo(); - router.setHidden(menu.isVisible()); + // visible 为1 代表显示路由 + router.setHidden("0".equals(menu.getVisible())); router.setName(getRouteName(menu)); router.setPath(getRouterPath(menu)); router.setComponent(getComponent(menu)); router.setQuery(menu.getQuery()); - router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.isCache(), menu.getPath())); + router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), "0".equals(menu.getCache()), menu.getPath())); List cMenus = menu.getChildren(); if (!cMenus.isEmpty() && MenuTypeEnum.CATALOG.equals(menu.getMenuType())) { @@ -126,7 +127,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl children.setPath(menu.getPath()); children.setComponent(menu.getComponent()); children.setName(StringUtils.capitalize(menu.getPath())); - children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.isCache(), menu.getPath())); + children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), "0".equals(menu.getCache()), menu.getPath())); children.setQuery(menu.getQuery()); childrenList.add(children); router.setChildren(childrenList); @@ -175,7 +176,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl */ public boolean isMenuFrame(SysMenu menu) { - return menu.getParentId() == 0 && MenuTypeEnum.MENU.equals(menu.getMenuType()) && menu.isFrame(); + return menu.getParentId() == 0 && MenuTypeEnum.MENU.equals(menu.getMenuType()) && "1".equals(menu.getFrame()); } /** @@ -194,7 +195,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl } // 非外链并且是一级目录(类型为目录) if (0 == menu.getParentId() && MenuTypeEnum.CATALOG.equals(menu.getMenuType()) - && menu.isFrame()) + && "1".equals(menu.getFrame())) { routerPath = "/" + menu.getPath(); } @@ -213,10 +214,10 @@ public class SysMenuServiceImpl extends ServiceImpl impl menu.setMenuName("系统管理"); menu.setPath("system"); menu.setMenuType(MenuTypeEnum.CATALOG); - menu.setFrame(false); - menu.setCache(false); - menu.setVisible(false); - menu.setStatus(false); + menu.setFrame("1"); + menu.setCache("1"); + menu.setVisible("1"); + menu.setStatus("1"); String routerPath = sysMenuService.getRouterPath(menu); System.out.println(routerPath); } @@ -229,7 +230,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl */ public boolean isInnerLink(SysMenu menu) { - return !menu.isFrame() && StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS); + return "1".equals(menu.getFrame()) && StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS); } /** diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysPostServiceImpl.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysPostServiceImpl.java new file mode 100644 index 0000000..af789c2 --- /dev/null +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysPostServiceImpl.java @@ -0,0 +1,33 @@ +package com.chushang.system.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chushang.common.mybatis.page.CommonParam; +import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.system.entity.po.SysDictType; +import com.chushang.system.entity.po.SysPost; +import com.chushang.system.mapper.SysPostMapper; +import com.chushang.system.service.ISysPostService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +/** + * @auther: zhao + * @date: 2024/5/9 18:33 + */ +@Slf4j +@Service +public class SysPostServiceImpl extends ServiceImpl implements ISysPostService { + + public LambdaQueryWrapper buildWrapper(SysPost sysPost, CommonParam commonParam) { + return new QueryWrapper() + .orderBy(true, "asc".equals(commonParam.getIsAsc()), commonParam.getOrderBy()) + .lambda() + .eq(null != sysPost.getPostId(), SysPost::getPostId, sysPost.getPostId()) + .eq(StringUtils.isNotEmpty(sysPost.getPostCode()), SysPost::getPostCode, sysPost.getPostCode()) + .eq(StringUtils.isNotEmpty(sysPost.getPostName()), SysPost::getPostName, sysPost.getPostName()) + .eq(StringUtils.isNotEmpty(sysPost.getStatus()), SysPost::getStatus, sysPost.getStatus()); + } +} diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysRoleServiceImpl.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysRoleServiceImpl.java index e5774c2..d6390c6 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysRoleServiceImpl.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysRoleServiceImpl.java @@ -1,13 +1,12 @@ package com.chushang.system.service.impl; import cn.hutool.core.collection.CollectionUtil; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.chushang.common.core.exception.ResultException; import com.chushang.common.core.util.SpringUtils; import com.chushang.common.core.util.StringUtils; import com.chushang.common.core.web.AjaxResult; -import com.chushang.common.mybatis.utils.PageUtils; +import com.chushang.common.mybatis.utils.PageResult; import com.chushang.security.utils.SecurityUtils; import com.chushang.system.annotation.DataScope; import com.chushang.system.mapper.SysRoleMapper; @@ -76,10 +75,10 @@ public class SysRoleServiceImpl extends ServiceImpl impl @Override @DataScope(deptAlias = "d") public AjaxResult selectRoleList(ListRoleDTO listRole) { - Page page = new Page<>(listRole.getPage(), listRole.getLimit()); + com.baomidou.mybatisplus.extension.plugins.pagination.Page page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(listRole.getPage(), listRole.getLimit()); List listAfDataVOList = baseMapper.listRole(listRole, page); - return AjaxResult.success(new PageUtils( + return AjaxResult.success(new PageResult( listAfDataVOList, page.getTotal(), page.getPages(), diff --git a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysUserServiceImpl.java b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysUserServiceImpl.java index 6b58e47..65e37a9 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysUserServiceImpl.java +++ b/chushang-modules/chushang-module-system/system-service/src/main/java/com/chushang/system/service/impl/SysUserServiceImpl.java @@ -2,13 +2,12 @@ package com.chushang.system.service.impl; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.chushang.common.core.exception.ResultException; import com.chushang.common.core.util.IdUtils; import com.chushang.common.core.util.SpringUtils; import com.chushang.common.core.web.AjaxResult; -import com.chushang.common.mybatis.utils.PageUtils; +import com.chushang.common.mybatis.utils.PageResult; import com.chushang.security.service.TokenService; import com.chushang.security.utils.SecurityUtils; import com.chushang.system.annotation.DataScope; @@ -54,11 +53,11 @@ public class SysUserServiceImpl extends ServiceImpl impl @Override @DataScope(deptAlias = "d", userAlias = "u") public AjaxResult listUser(ListUserDTO listUser) { - Page page = new Page<>(listUser.getPage(),listUser.getLimit()); + com.baomidou.mybatisplus.extension.plugins.pagination.Page page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(listUser.getPage(),listUser.getLimit()); List listAfDataVOList = baseMapper.listUser(listUser, page); - return AjaxResult.success(new PageUtils( + return AjaxResult.success(new PageResult( listAfDataVOList, page.getTotal(), page.getPages(), @@ -164,11 +163,11 @@ public class SysUserServiceImpl extends ServiceImpl impl @Override @DataScope(deptAlias = "d", userAlias = "u") public AjaxResult selectAllocatedList(ListUserDTO listUser) { - Page page = new Page<>(listUser.getPage(),listUser.getLimit()); - + com.baomidou.mybatisplus.extension.plugins.pagination.Page page = + new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(listUser.getPage(),listUser.getLimit()); List userList = baseMapper.selectAllocatedList(listUser, page); - return AjaxResult.success(new PageUtils( + return AjaxResult.success(new PageResult( userList, page.getTotal(), page.getPages(), @@ -178,11 +177,11 @@ public class SysUserServiceImpl extends ServiceImpl impl @Override @DataScope(deptAlias = "d", userAlias = "u") public AjaxResult selectUnallocatedList(ListUserDTO listUser) { - Page page = new Page<>(listUser.getPage(),listUser.getLimit()); + com.baomidou.mybatisplus.extension.plugins.pagination.Page page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(listUser.getPage(),listUser.getLimit()); List userList = baseMapper.selectUnallocatedList(listUser, page); - return AjaxResult.success(new PageUtils( + return AjaxResult.success(new PageResult( userList, page.getTotal(), page.getPages(), diff --git a/chushang-modules/chushang-module-system/system-service/src/main/resources/logback-nacos.xml b/chushang-modules/chushang-module-system/system-service/src/main/resources/logback-nacos.xml index 74bb510..9515ba1 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/resources/logback-nacos.xml +++ b/chushang-modules/chushang-module-system/system-service/src/main/resources/logback-nacos.xml @@ -7,11 +7,15 @@ - + + + + + @@ -91,6 +95,8 @@ + + diff --git a/chushang-modules/chushang-module-system/system-service/src/main/resources/mapper/SysMenuMapper.xml b/chushang-modules/chushang-module-system/system-service/src/main/resources/mapper/SysMenuMapper.xml index 6669cd9..de15737 100644 --- a/chushang-modules/chushang-module-system/system-service/src/main/resources/mapper/SysMenuMapper.xml +++ b/chushang-modules/chushang-module-system/system-service/src/main/resources/mapper/SysMenuMapper.xml @@ -139,7 +139,7 @@ from sys_menu m where m.del_state = FALSE AND m.menu_type in ('M', 'C') - and m.status = 0 + and m.status = 1 order by m.parent_id, m.order_num @@ -176,6 +176,6 @@ FROM sys_menu m LEFT JOIN sys_role_menu rm ON m.menu_id = rm.menu_id JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( m.perms ) - LENGTH( REPLACE ( m.perms, ',', '' ) ) + 1 ) - WHERE m.STATUS = '0' AND rm.role_id = #{roleId} + WHERE m.STATUS = 1 AND rm.role_id = #{roleId} diff --git a/pom.xml b/pom.xml index 3674d26..23d7282 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,8 @@ 0.4.20 3.14.1 4.3 + 2.0.0 + 2.0.0-beta8 7.14.0 3.6.7 @@ -525,6 +527,12 @@ jsqlparser ${jsqparser.version} + + + com.github.pagehelper + pagehelper-spring-boot-starter + ${pagehelper.boot.version} + org.elasticsearch.client @@ -606,4 +614,4 @@ - \ No newline at end of file +