lishuangjiang@potevio.com пре 1 година
родитељ
комит
a60042680e
30 измењених фајлова са 141 додато и 37 уклоњено
  1. 1 1
      sso-module-infra/sso-module-infra-biz/src/main/java/com/poteviohealth/cgp/sso/module/infra/controller/admin/job/JobController.java
  2. 4 2
      sso-module-system/sso-module-system-api/src/main/java/com/poteviohealth/cgp/sso/module/system/api/logger/dto/LoginLogCreateReqDTO.java
  3. 4 0
      sso-module-system/sso-module-system-api/src/main/java/com/poteviohealth/cgp/sso/module/system/enums/DictTypeConstants.java
  4. 2 2
      sso-module-system/sso-module-system-api/src/main/java/com/poteviohealth/cgp/sso/module/system/enums/ErrorCodeConstants.java
  5. 1 1
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/auth/vo/AuthLoginReqVO.java
  6. 17 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/dept/DeptController.java
  7. 19 6
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/dept/vo/dept/DeptRespVO.java
  8. 6 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/logger/LoginLogController.java
  9. 6 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/logger/OperateLogController.java
  10. 2 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/logger/vo/loginlog/LoginLogPageReqVO.java
  11. 2 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/logger/vo/operatelog/OperateLogPageReqVO.java
  12. 1 1
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java
  13. 3 3
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/UserController.java
  14. 2 2
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/profile/UserProfileUpdatePasswordReqVO.java
  15. 3 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/user/UserPageReqVO.java
  16. 3 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/user/UserRespVO.java
  17. 3 2
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/user/UserSaveReqVO.java
  18. 3 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/user/UserSimpleRespVO.java
  19. 1 1
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/user/UserUpdatePasswordReqVO.java
  20. 10 1
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/userclient/UserClientController.java
  21. 3 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/userclient/vo/UserSsoVo.java
  22. 3 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/dal/dataobject/logger/LoginLogDO.java
  23. 2 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/dal/dataobject/user/AdminUserDO.java
  24. 2 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/dal/mysql/logger/LoginLogMapper.java
  25. 2 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/dal/mysql/logger/OperateLogMapper.java
  26. 4 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/framework/datapermission/config/DataPermissionConfiguration.java
  27. 15 13
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/service/auth/AdminAuthServiceImpl.java
  28. 6 0
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/service/dept/DeptService.java
  29. 7 1
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/service/dept/DeptServiceImpl.java
  30. 4 1
      sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/service/user/AdminUserServiceImpl.java

+ 1 - 1
sso-module-infra/sso-module-infra-biz/src/main/java/com/poteviohealth/cgp/sso/module/infra/controller/admin/job/JobController.java

@@ -116,7 +116,7 @@ public class JobController {
     }
 
     @GetMapping("/export-excel")
-    @Operation(summary = "导出定时任务 Excel")
+    @Operation(summary = "·导出定时任务 Excel")
     @PreAuthorize("@ss.hasPermission('infra:job:export')")
     @ApiAccessLog(operateType = EXPORT)
     public void exportJobExcel(@Valid JobPageReqVO exportReqVO,

+ 4 - 2
sso-module-system/sso-module-system-api/src/main/java/com/poteviohealth/cgp/sso/module/system/api/logger/dto/LoginLogCreateReqDTO.java

@@ -36,7 +36,7 @@ public class LoginLogCreateReqDTO {
     private Integer userType;
     /**
      * 用户账号
-     *
+     * <p>
      * 不再强制校验 username 非空,因为 Member 社交登录时,此时暂时没有 username(mobile)!
      */
     private String username;
@@ -54,9 +54,11 @@ public class LoginLogCreateReqDTO {
     private String userIp;
     /**
      * 浏览器 UserAgent
-     *
+     * <p>
      * 允许空,原因:Job 过期登出时,是无法传递 UserAgent 的
      */
     private String userAgent;
 
+    private Long deptId;
+
 }

+ 4 - 0
sso-module-system/sso-module-system-api/src/main/java/com/poteviohealth/cgp/sso/module/system/enums/DictTypeConstants.java

@@ -10,6 +10,10 @@ public interface DictTypeConstants {
     String USER_TYPE = "user_type"; // 用户类型
     String COMMON_STATUS = "common_status"; // 系统状态
 
+    String ORG_STATUS = "org_status"; // 机构状态
+
+    String BUSINESS_PATTERN = "business_pattern"; // 机构状态
+
     String APPLICATION_STATUS = "application_status"; //应用状态
 
     String SYNC_USER_STATUS = "sync_user_status"; // 用户同步状态

+ 2 - 2
sso-module-system/sso-module-system-api/src/main/java/com/poteviohealth/cgp/sso/module/system/enums/ErrorCodeConstants.java

@@ -40,7 +40,7 @@ public interface ErrorCodeConstants {
     ErrorCode USER_NOT_EXISTS = new ErrorCode(1_002_003_003, "用户不存在");
     ErrorCode USER_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_002_003_004, "导入用户数据不能为空!");
     ErrorCode USER_PASSWORD_FAILED = new ErrorCode(1_002_003_005, "用户密码校验失败");
-    ErrorCode USER_IS_DISABLE = new ErrorCode(1_002_003_006, "名字为【{}】的用户已被禁用");
+    ErrorCode USER_IS_DISABLE = new ErrorCode(1_002_003_006, "用户【{}】已被禁用");
     ErrorCode USER_COUNT_MAX = new ErrorCode(1_002_003_008, "创建用户失败,原因:超过租户最大租户配额({})!");
 
     ErrorCode USER_CLIENT_NOT_EXISTS = new ErrorCode(1_002_003_009, "用户应用关联不存在");
@@ -67,7 +67,7 @@ public interface ErrorCodeConstants {
 
     ErrorCode USER_SYNC_ERROR = new ErrorCode(1_002_003_019, "用户同步错误({})");
 
-    ErrorCode USER_CLIENT_LINK_AUTH_ERROR = new ErrorCode(1_002_003_020, "无权限");
+    ErrorCode USER_CLIENT_LINK_AUTH_ERROR = new ErrorCode(1_002_003_020, "无该系统权限,请联系系统管理员申请开通");
 
     // ========== 部门模块 1-002-004-000 ==========
     ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "已经存在该名字的部门");

+ 1 - 1
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/auth/vo/AuthLoginReqVO.java

@@ -29,7 +29,7 @@ public class AuthLoginReqVO {
 
     @Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
     @NotEmpty(message = "密码不能为空")
-    @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
+    @Length(min = 6, max = 16, message = "密码长度为 6-16 位")
     private String password;
 
     // ========== 图片验证码相关 ==========

+ 17 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/dept/DeptController.java

@@ -1,9 +1,12 @@
 package com.poteviohealth.cgp.sso.module.system.controller.admin.dept;
 
+import com.poteviohealth.cgp.sso.framework.apilog.core.annotation.ApiAccessLog;
 import com.poteviohealth.cgp.sso.framework.common.enums.CommonStatusEnum;
 import com.poteviohealth.cgp.sso.framework.common.pojo.CommonResult;
+import com.poteviohealth.cgp.sso.framework.common.pojo.PageParam;
 import com.poteviohealth.cgp.sso.framework.common.util.object.BeanUtils;
 import com.poteviohealth.cgp.sso.framework.datapermission.core.annotation.DataPermission;
+import com.poteviohealth.cgp.sso.framework.excel.core.util.ExcelUtils;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept.*;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.user.vo.user.UserUpdateStatusReqVO;
 import com.poteviohealth.cgp.sso.module.system.dal.dataobject.dept.DeptDO;
@@ -16,9 +19,12 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
+import java.io.IOException;
 import java.util.List;
 
+import static com.poteviohealth.cgp.sso.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static com.poteviohealth.cgp.sso.framework.common.pojo.CommonResult.success;
 
 @Tag(name = "管理后台 - 部门")
@@ -98,4 +104,15 @@ public class DeptController {
         return success(true);
     }
 
+    @GetMapping("/export")
+    @Operation(summary = "机构管理")
+    @PreAuthorize("@ss.hasPermission('system:dept:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void export(HttpServletResponse response, @Validated DeptListReqVO reqVO) throws IOException {
+//        reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+//        List<DeptDO> list = deptService.getPostPage(reqVO).getList();
+        List<DeptDO> list = deptService.getDeptList(reqVO);
+        List<DeptRespVO> deptRespVOs = BeanUtils.toBean(list, DeptRespVO.class);
+        ExcelUtils.write(response, "机构数据.xls", "机构列表", DeptRespVO.class, deptRespVOs);
+    }
 }

+ 19 - 6
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/dept/vo/dept/DeptRespVO.java

@@ -1,6 +1,11 @@
 package com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept;
 
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.poteviohealth.cgp.sso.framework.excel.core.annotations.DictFormat;
+import com.poteviohealth.cgp.sso.framework.excel.core.convert.DictConvert;
+import com.poteviohealth.cgp.sso.module.system.enums.DictTypeConstants;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -9,14 +14,20 @@ import java.util.Set;
 
 @Schema(description = "管理后台 - 部门信息 Response VO")
 @Data
+@ExcelIgnoreUnannotated
 public class DeptRespVO {
 
     @Schema(description = "部门编号", example = "1024")
     private Long id;
 
     @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "中康科")
+    @ExcelProperty("机构名称")
     private String name;
 
+    @Schema(description = "部门编码", example = "1")
+    @ExcelProperty("编码")
+    private String code;
+
     @Schema(description = "父部门 ID", example = "1024")
     private Long parentId;
 
@@ -32,16 +43,21 @@ public class DeptRespVO {
     @Schema(description = "邮箱", example = "sso@iocoder.cn")
     private String email;
 
+    @Schema(description = "经营方式", example = " 0")
+    @ExcelProperty(value = "经营方式", converter = DictConvert.class)
+    @DictFormat(DictTypeConstants.BUSINESS_PATTERN)
+    private Integer businessPattern;
+
     @Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @ExcelProperty(value = "状态", converter = DictConvert.class)
+    @DictFormat(DictTypeConstants.ORG_STATUS)
     private Integer status;
 
     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
+    @ExcelProperty("创建时间")
     private LocalDateTime createTime;
 
 
-    @Schema(description = "部门编码", example = "1")
-    private String code;
-
     @Schema(description = "所在地编号", example = "101010")
     private Long areaId;
 
@@ -76,9 +92,6 @@ public class DeptRespVO {
     @Schema(description = "机构性质", example = "[机构,旅居]")
     private Set<Long> propertypes;
 
-    @Schema(description = "经营方式", example = " 0")
-    private Integer businessPattern;
-
     @Schema(description = "经营状态", example = "0")
     private Integer businessStatus;
 

+ 6 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/logger/LoginLogController.java

@@ -6,6 +6,7 @@ import com.poteviohealth.cgp.sso.framework.common.pojo.PageParam;
 import com.poteviohealth.cgp.sso.framework.common.pojo.PageResult;
 import com.poteviohealth.cgp.sso.framework.common.util.object.BeanUtils;
 import com.poteviohealth.cgp.sso.framework.excel.core.util.ExcelUtils;
+import com.poteviohealth.cgp.sso.framework.security.core.util.SecurityFrameworkUtils;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.logger.vo.loginlog.LoginLogRespVO;
 import com.poteviohealth.cgp.sso.module.system.dal.dataobject.logger.LoginLogDO;
@@ -23,6 +24,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
 import java.util.List;
+import java.util.Optional;
 
 import static com.poteviohealth.cgp.sso.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static com.poteviohealth.cgp.sso.framework.common.pojo.CommonResult.success;
@@ -40,6 +42,10 @@ public class LoginLogController {
     @Operation(summary = "获得登录日志分页列表")
     @PreAuthorize("@ss.hasPermission('system:login-log:query')")
     public CommonResult<PageResult<LoginLogRespVO>> getLoginLogPage(@Valid LoginLogPageReqVO pageReqVO) {
+        Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
+        if(Optional.ofNullable(loginUserId).orElse(0L)!=1L){
+            pageReqVO.setHideId(1L);
+        }
         PageResult<LoginLogDO> pageResult = loginLogService.getLoginLogPage(pageReqVO);
         return success(BeanUtils.toBean(pageResult, LoginLogRespVO.class));
     }

+ 6 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/logger/OperateLogController.java

@@ -6,6 +6,7 @@ import com.poteviohealth.cgp.sso.framework.common.pojo.PageParam;
 import com.poteviohealth.cgp.sso.framework.common.pojo.PageResult;
 import com.poteviohealth.cgp.sso.framework.common.util.object.BeanUtils;
 import com.poteviohealth.cgp.sso.framework.excel.core.util.ExcelUtils;
+import com.poteviohealth.cgp.sso.framework.security.core.util.SecurityFrameworkUtils;
 import com.poteviohealth.cgp.sso.framework.translate.core.TranslateUtils;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.logger.vo.operatelog.OperateLogRespVO;
@@ -24,6 +25,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
 import java.util.List;
+import java.util.Optional;
 
 import static com.poteviohealth.cgp.sso.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static com.poteviohealth.cgp.sso.framework.common.pojo.CommonResult.success;
@@ -41,6 +43,10 @@ public class OperateLogController {
     @Operation(summary = "查看操作日志分页列表")
     @PreAuthorize("@ss.hasPermission('system:operate-log:query')")
     public CommonResult<PageResult<OperateLogRespVO>> pageOperateLog(@Valid OperateLogPageReqVO pageReqVO) {
+        Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
+        if(Optional.ofNullable(loginUserId).orElse(0L)!=1L){
+            pageReqVO.setHideId(1L);
+        }
         PageResult<OperateLogDO> pageResult = operateLogService.getOperateLogPage(pageReqVO);
         return success(BeanUtils.toBean(pageResult, OperateLogRespVO.class));
     }

+ 2 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/logger/vo/loginlog/LoginLogPageReqVO.java

@@ -28,4 +28,6 @@ public class LoginLogPageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
 
+    private Long hideId;
+
 }

+ 2 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/logger/vo/operatelog/OperateLogPageReqVO.java

@@ -32,4 +32,6 @@ public class OperateLogPageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
 
+    private Long hideId;
+
 }

+ 1 - 1
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java

@@ -57,7 +57,7 @@ public class TenantSaveReqVO {
     private String username;
 
     @Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
-    @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
+    @Length(min = 6, max = 16, message = "密码长度为 6-16 位")
     private String password;
 
     @AssertTrue(message = "用户账号、密码不能为空")

+ 3 - 3
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/UserController.java

@@ -291,7 +291,7 @@ public class UserController {
             } else {
                 if (user.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) {
                     log.error(USER_IS_DISABLE.getMsg(), user.getUsername());
-                    throw exception(USER_CLIENT_LINK_AUTH_ERROR);
+                    throw exception(USER_IS_DISABLE,SecurityFrameworkUtils.getLoginUserName());
                 }
                 if (!user.getAssociatedSystem().contains(linkId)) {
                     log.error(USER_CLIENT_NOT_EXISTS.getMsg());
@@ -309,11 +309,11 @@ public class UserController {
                 }
                 if (userClient.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) {
                     log.error(USER_CLIENT_STOP.getMsg());
-                    throw exception(USER_CLIENT_LINK_AUTH_ERROR);
+                    throw exception(USER_CLIENT_STOP);
                 }
                 if (userClient.getSyncStatus() == 0 || userClient.getSyncStatus() == 2) {
                     log.error(USER_NO_SYNC.getMsg());
-                    throw exception(USER_CLIENT_LINK_AUTH_ERROR);
+                    throw exception(USER_NO_SYNC);
                 }
                 // 拼接数据
                 url = constructLinkUrl(userClient, oAuth2Client, refreshToken, user);

+ 2 - 2
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/profile/UserProfileUpdatePasswordReqVO.java

@@ -12,12 +12,12 @@ public class UserProfileUpdatePasswordReqVO {
 
     @Schema(description = "旧密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
     @NotEmpty(message = "旧密码不能为空")
-    @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
+    @Length(min = 6, max = 16, message = "密码长度为 6-16 位")
     private String oldPassword;
 
     @Schema(description = "新密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "654321")
     @NotEmpty(message = "新密码不能为空")
-    @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
+    @Length(min = 6, max = 16, message = "密码长度为 6-16 位")
     private String newPassword;
 
 }

+ 3 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/user/UserPageReqVO.java

@@ -45,4 +45,7 @@ public class UserPageReqVO extends PageParam {
 
     private Integer roleType;
 
+    @Schema(description = "业务角色", example = "0/1")
+    private Integer businessRole;
+
 }

+ 3 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/user/UserRespVO.java

@@ -95,5 +95,8 @@ public class UserRespVO{
     @Schema(description = "角色类型", example = "0/1")
     private Integer roleType;
 
+    @Schema(description = "业务角色", example = "0/1")
+    private Integer businessRole;
+
     private String creator;
 }

+ 3 - 2
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/user/UserSaveReqVO.java

@@ -69,7 +69,7 @@ public class UserSaveReqVO {
     // ========== 仅【创建】时,需要传递的字段 ==========
 
     @Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
-    @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
+    @Length(min = 6, max = 16, message = "密码长度为 16-16 位")
     private String password;
 
     @Schema(description = "姓名", example = "sso")
@@ -93,7 +93,8 @@ public class UserSaveReqVO {
     @Schema(description = "角色类型", example = "0/1")
     private Integer roleType;
 
-
+    @Schema(description = "业务角色", example = "0/1")
+    private Integer businessRole;
 
     @AssertTrue(message = "密码不能为空")
     @JsonIgnore

+ 3 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/user/UserSimpleRespVO.java

@@ -50,4 +50,7 @@ public class UserSimpleRespVO {
     @Schema(description = "角色类型", example = "0/1")
     private Integer roleType;
 
+    @Schema(description = "业务角色", example = "0/1")
+    private Integer businessRole;
+
 }

+ 1 - 1
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/user/vo/user/UserUpdatePasswordReqVO.java

@@ -17,7 +17,7 @@ public class UserUpdatePasswordReqVO {
 
     @Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
     @NotEmpty(message = "密码不能为空")
-    @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
+    @Length(min = 6, max = 16, message = "密码长度为 6-16 位")
     private String password;
 
 }

+ 10 - 1
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/userclient/UserClientController.java

@@ -270,7 +270,16 @@ public class UserClientController {
         headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
         headers.set(HEADER, Objects.nonNull(oAuth2Client.getAppId())? oAuth2Client.getAppId(): oAuth2Client.getClientId());
         HttpEntity<UserSsoVo> httpEntity = new HttpEntity<>(new UserSsoVo(user.getUsername()
-                , user.getNickname(), user.getIdNumber(), user.getMobile(), null, companyName,companyCode, deptName,deptName,deptCode),
+                , user.getNickname(),
+                user.getIdNumber(),
+                user.getMobile(),
+                null,
+                companyName,
+                companyCode,
+                deptName,
+                deptName,
+                deptCode,
+                user.getBusinessRole()),
                 headers);
         ResponseEntity exchange;
         try{

+ 3 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/userclient/vo/UserSsoVo.java

@@ -69,4 +69,7 @@ public class UserSsoVo {
      */
     @Schema(description = "机构编码", name = "orgCode", required = false)
     private String  instCode;
+
+    @Schema(description = "业务角色", example = "0/1")
+    private Integer businessRole;
 }

+ 3 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/dal/dataobject/logger/LoginLogDO.java

@@ -69,4 +69,7 @@ public class LoginLogDO extends BaseDO {
      */
     private String userAgent;
 
+
+    private Long deptId;
+
 }

+ 2 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/dal/dataobject/user/AdminUserDO.java

@@ -124,4 +124,6 @@ public class AdminUserDO extends TenantBaseDO {
     private Set<Long> authorizationSystem;
 
     private Integer roleType;
+
+    private Integer businessRole;
 }

+ 2 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/dal/mysql/logger/LoginLogMapper.java

@@ -5,6 +5,7 @@ import com.poteviohealth.cgp.sso.framework.mybatis.core.mapper.BaseMapperX;
 import com.poteviohealth.cgp.sso.framework.mybatis.core.query.LambdaQueryWrapperX;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO;
 import com.poteviohealth.cgp.sso.module.system.dal.dataobject.logger.LoginLogDO;
+import com.poteviohealth.cgp.sso.module.system.dal.dataobject.user.AdminUserDO;
 import com.poteviohealth.cgp.sso.module.system.enums.logger.LoginResultEnum;
 import org.apache.ibatis.annotations.Mapper;
 
@@ -13,6 +14,7 @@ public interface LoginLogMapper extends BaseMapperX<LoginLogDO> {
 
     default PageResult<LoginLogDO> selectPage(LoginLogPageReqVO reqVO) {
         LambdaQueryWrapperX<LoginLogDO> query = new LambdaQueryWrapperX<LoginLogDO>()
+                .neIfPresent(LoginLogDO::getUserId,reqVO.getHideId())
                 .likeIfPresent(LoginLogDO::getUserIp, reqVO.getUserIp())
                 .likeIfPresent(LoginLogDO::getUsername, reqVO.getUsername())
                 .betweenIfPresent(LoginLogDO::getCreateTime, reqVO.getCreateTime());

+ 2 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/dal/mysql/logger/OperateLogMapper.java

@@ -5,6 +5,7 @@ import com.poteviohealth.cgp.sso.framework.mybatis.core.mapper.BaseMapperX;
 import com.poteviohealth.cgp.sso.framework.mybatis.core.query.LambdaQueryWrapperX;
 import com.poteviohealth.cgp.sso.module.system.api.logger.dto.OperateLogPageReqDTO;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO;
+import com.poteviohealth.cgp.sso.module.system.dal.dataobject.logger.LoginLogDO;
 import com.poteviohealth.cgp.sso.module.system.dal.dataobject.logger.OperateLogDO;
 import org.apache.ibatis.annotations.Mapper;
 
@@ -13,6 +14,7 @@ public interface OperateLogMapper extends BaseMapperX<OperateLogDO> {
 
     default PageResult<OperateLogDO> selectPage(OperateLogPageReqVO pageReqDTO) {
         return selectPage(pageReqDTO, new LambdaQueryWrapperX<OperateLogDO>()
+                .neIfPresent(OperateLogDO::getUserId,pageReqDTO.getHideId())
                 .eqIfPresent(OperateLogDO::getUserId, pageReqDTO.getUserId())
                 .eqIfPresent(OperateLogDO::getBizId, pageReqDTO.getBizId())
                 .likeIfPresent(OperateLogDO::getType, pageReqDTO.getType())

+ 4 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/framework/datapermission/config/DataPermissionConfiguration.java

@@ -1,6 +1,8 @@
 package com.poteviohealth.cgp.sso.module.system.framework.datapermission.config;
 
 import com.poteviohealth.cgp.sso.module.system.dal.dataobject.dept.DeptDO;
+import com.poteviohealth.cgp.sso.module.system.dal.dataobject.logger.LoginLogDO;
+import com.poteviohealth.cgp.sso.module.system.dal.dataobject.logger.OperateLogDO;
 import com.poteviohealth.cgp.sso.module.system.dal.dataobject.user.AdminUserDO;
 import com.poteviohealth.cgp.sso.framework.datapermission.core.rule.dept.DeptDataPermissionRuleCustomizer;
 import org.springframework.context.annotation.Bean;
@@ -20,6 +22,8 @@ public class DataPermissionConfiguration {
             // dept
             rule.addDeptColumn(AdminUserDO.class);
             rule.addDeptColumn(DeptDO.class, "id");
+            rule.addDeptColumn(LoginLogDO.class);
+            rule.addDeptColumn(OperateLogDO.class);
             // user
             rule.addUserColumn(AdminUserDO.class, "id");
         };

+ 15 - 13
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/service/auth/AdminAuthServiceImpl.java

@@ -78,16 +78,16 @@ public class AdminAuthServiceImpl implements AdminAuthService {
         // 校验账号是否存在
         AdminUserDO user = userService.getUserByUsername(username);
         if (user == null) {
-            createLoginLog(null, username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
+            createLoginLog(null, username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS,user.getDeptId());
             throw exception(AUTH_LOGIN_BAD_CREDENTIALS);
         }
         if (!userService.isPasswordMatch(password, user.getPassword())) {
-            createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
+            createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS,user.getDeptId());
             throw exception(AUTH_LOGIN_BAD_CREDENTIALS);
         }
         // 校验是否禁用
         if (CommonStatusEnum.isDisable(user.getStatus())) {
-            createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_DISABLED);
+            createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_DISABLED,user.getDeptId());
             throw exception(AUTH_LOGIN_USER_DISABLED);
         }
         return user;
@@ -95,19 +95,20 @@ public class AdminAuthServiceImpl implements AdminAuthService {
 
     @Override
     public AuthLoginRespVO login(AuthLoginReqVO reqVO) {
-        // 校验验证码
-        validateCaptcha(reqVO);
 
         // 使用账号密码,进行登录
         AdminUserDO user = authenticate(reqVO.getUsername(), reqVO.getPassword());
 
+        // 校验验证码
+        validateCaptcha(reqVO,user);
+
         // 如果 socialType 非空,说明需要绑定社交用户
         if (reqVO.getSocialType() != null) {
             socialUserService.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(),
                     reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState()));
         }
         // 创建 Token 令牌,记录登录日志
-        return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(),user.getLoginDate(),LoginLogTypeEnum.LOGIN_USERNAME);
+        return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(),user.getLoginDate(),LoginLogTypeEnum.LOGIN_USERNAME,user.getDeptId());
     }
 
     @Override
@@ -132,11 +133,11 @@ public class AdminAuthServiceImpl implements AdminAuthService {
         }
 
         // 创建 Token 令牌,记录登录日志
-        return createTokenAfterLoginSuccess(user.getId(), reqVO.getMobile(),user.getLoginDate(), LoginLogTypeEnum.LOGIN_MOBILE);
+        return createTokenAfterLoginSuccess(user.getId(), reqVO.getMobile(),user.getLoginDate(), LoginLogTypeEnum.LOGIN_MOBILE,user.getDeptId());
     }
 
     private void createLoginLog(Long userId, String username,
-                                LoginLogTypeEnum logTypeEnum, LoginResultEnum loginResult) {
+                                LoginLogTypeEnum logTypeEnum, LoginResultEnum loginResult,Long deptId) {
         // 插入登录日志
         LoginLogCreateReqDTO reqDTO = new LoginLogCreateReqDTO();
         reqDTO.setLogType(logTypeEnum.getType());
@@ -147,6 +148,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
         reqDTO.setUserAgent(ServletUtils.getUserAgent());
         reqDTO.setUserIp(ServletUtils.getClientIP());
         reqDTO.setResult(loginResult.getResult());
+        reqDTO.setDeptId(deptId);
         loginLogService.createLoginLog(reqDTO);
         // 更新最后登录时间
         if (userId != null && Objects.equals(LoginResultEnum.SUCCESS.getResult(), loginResult.getResult())) {
@@ -170,11 +172,11 @@ public class AdminAuthServiceImpl implements AdminAuthService {
         }
 
         // 创建 Token 令牌,记录登录日志
-        return createTokenAfterLoginSuccess(user.getId(), user.getUsername(),user.getLoginDate(),LoginLogTypeEnum.LOGIN_SOCIAL);
+        return createTokenAfterLoginSuccess(user.getId(), user.getUsername(),user.getLoginDate(),LoginLogTypeEnum.LOGIN_SOCIAL,user.getDeptId());
     }
 
     @VisibleForTesting
-    void validateCaptcha(AuthLoginReqVO reqVO) {
+    void validateCaptcha(AuthLoginReqVO reqVO,AdminUserDO user) {
         // 如果验证码关闭,则不进行校验
         if (!captchaEnable) {
             return;
@@ -187,14 +189,14 @@ public class AdminAuthServiceImpl implements AdminAuthService {
         // 验证不通过
         if (!response.isSuccess()) {
             // 创建登录失败日志(验证码不正确)
-            createLoginLog(null, reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME, LoginResultEnum.CAPTCHA_CODE_ERROR);
+            createLoginLog(null, reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME, LoginResultEnum.CAPTCHA_CODE_ERROR,user.getDeptId());
             throw exception(AUTH_LOGIN_CAPTCHA_CODE_ERROR, response.getRepMsg());
         }
     }
 
-    private AuthLoginRespVO createTokenAfterLoginSuccess(Long userId, String username, LocalDateTime loginDate,LoginLogTypeEnum logType) {
+    private AuthLoginRespVO createTokenAfterLoginSuccess(Long userId, String username, LocalDateTime loginDate,LoginLogTypeEnum logType,Long deptId) {
         // 插入登陆日志
-        createLoginLog(userId, username, logType, LoginResultEnum.SUCCESS);
+        createLoginLog(userId, username, logType, LoginResultEnum.SUCCESS,deptId);
         // 创建访问令牌
         OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.createAccessToken(userId, getUserType().getValue(),
                 OAuth2ClientConstants.CLIENT_ID_DEFAULT, null);

+ 6 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/service/dept/DeptService.java

@@ -1,9 +1,13 @@
 package com.poteviohealth.cgp.sso.module.system.service.dept;
 
+import com.poteviohealth.cgp.sso.framework.common.pojo.PageResult;
 import com.poteviohealth.cgp.sso.framework.common.util.collection.CollectionUtils;
+import com.poteviohealth.cgp.sso.framework.common.util.collection.MapUtils;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
+import com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept.DeptPageReqVO;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
 import com.poteviohealth.cgp.sso.module.system.dal.dataobject.dept.DeptDO;
+import com.poteviohealth.cgp.sso.module.system.dal.dataobject.dept.PostDO;
 
 import java.util.Collection;
 import java.util.List;
@@ -102,4 +106,6 @@ public interface DeptService {
     List<DeptDO> selectDeptByIds(Set<Long> deptIds);
 
     void updateUserStatus(Long id, Integer status);
+
+    PageResult<DeptDO> getPostPage(DeptPageReqVO reqVO);
 }

+ 7 - 1
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/service/dept/DeptServiceImpl.java

@@ -5,9 +5,11 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.poteviohealth.cgp.sso.framework.common.enums.CommonStatusEnum;
+import com.poteviohealth.cgp.sso.framework.common.pojo.PageResult;
 import com.poteviohealth.cgp.sso.framework.common.util.object.BeanUtils;
 import com.poteviohealth.cgp.sso.framework.datapermission.core.annotation.DataPermission;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
+import com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept.DeptPageReqVO;
 import com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
 import com.poteviohealth.cgp.sso.module.system.dal.dataobject.dept.DeptDO;
 import com.poteviohealth.cgp.sso.module.system.dal.dataobject.sequence.SequenceDO;
@@ -45,7 +47,6 @@ import static com.poteviohealth.cgp.sso.module.system.enums.ErrorCodeConstants.*
 @Validated
 @Slf4j
 public class DeptServiceImpl implements DeptService {
-
     @Resource
     private DeptMapper deptMapper;
     @Resource
@@ -340,4 +341,9 @@ public class DeptServiceImpl implements DeptService {
         updateObj.setStatus(status);
         deptMapper.updateById(updateObj);
     }
+
+    @Override
+    public PageResult<DeptDO> getPostPage(DeptPageReqVO reqVO) {
+        return null;
+    }
 }

+ 4 - 1
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/service/user/AdminUserServiceImpl.java

@@ -125,7 +125,7 @@ public class AdminUserServiceImpl implements AdminUserService {
             success = SYSTEM_USER_UPDATE_SUCCESS)
     public void updateUser(UserSaveReqVO updateReqVO) {
         updateReqVO.setPassword(null); // 特殊:此处不更新密码
-        updateReqVO.setUsername(null); //不更新用户名
+        updateReqVO.setUsername(null); // 不更新用户名
         // 1. 校验正确性
         AdminUserDO oldUser = validateUserForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getUsername(),
                 updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds());
@@ -139,6 +139,9 @@ public class AdminUserServiceImpl implements AdminUserService {
         updateUserPost(updateReqVO, updateObj);
 
         // 3. 记录操作日志上下文
+        //日志适配
+        oldUser.setUsername(null);
+        oldUser.setPassword(null);
         LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldUser, UserSaveReqVO.class));
         LogRecordContext.putVariable("user", oldUser);
     }