Bläddra i källkod

中康养新需求

lishuangjiang@potevio.com 1 år sedan
förälder
incheckning
015d0d765b

+ 8 - 0
sso-framework/sso-spring-boot-starter-security/src/main/java/com/poteviohealth/cgp/sso/framework/operatelog/core/service/LogRecordServiceImpl.java

@@ -1,5 +1,6 @@
 package com.poteviohealth.cgp.sso.framework.operatelog.core.service;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.poteviohealth.cgp.sso.framework.common.util.monitor.TracerUtils;
 import com.poteviohealth.cgp.sso.framework.common.util.servlet.ServletUtils;
 import com.poteviohealth.cgp.sso.framework.security.core.LoginUser;
@@ -13,6 +14,8 @@ import lombok.extern.slf4j.Slf4j;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * 操作日志 ILogRecordService 实现类
@@ -51,6 +54,11 @@ public class LogRecordServiceImpl implements ILogRecordService {
         }
         reqDTO.setUserId(loginUser.getId());
         reqDTO.setUserType(loginUser.getUserType());
+        Map<String, String> info = loginUser.getInfo();
+        if(CollectionUtil.isNotEmpty(info)){
+            reqDTO.setDeptId(Objects.nonNull(info.get("deptId"))?Long.parseLong(info.get("deptId")):null);
+        }
+
     }
 
     public static void fillModuleFields(OperateLogCreateReqDTO reqDTO, LogRecord logRecord) {

+ 5 - 0
sso-module-system/sso-module-system-api/src/main/java/com/poteviohealth/cgp/sso/module/system/api/logger/dto/OperateLogCreateReqDTO.java

@@ -82,4 +82,9 @@ public class OperateLogCreateReqDTO {
     @NotEmpty(message = "浏览器 UA 不能为空")
     private String userAgent;
 
+    /**
+     * 机构ID
+     */
+    private Long deptId;
+
 }

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

@@ -4,10 +4,8 @@ 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.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.DeptRespVO;
-import com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
-import com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept.DeptSimpleRespVO;
+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;
 import com.poteviohealth.cgp.sso.module.system.service.dept.DeptService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -92,4 +90,12 @@ public class DeptController {
         return success(BeanUtils.toBean(dept, DeptRespVO.class));
     }
 
+    @PutMapping("/update-status")
+    @Operation(summary = "修改部门状态")
+    @PreAuthorize("@ss.hasPermission('system:dept:update')")
+    public CommonResult<Boolean> updateUserStatus(@Valid @RequestBody DeptUpdateStatusReqVO reqVO) {
+        deptService.updateUserStatus(reqVO.getId(), reqVO.getStatus());
+        return success(true);
+    }
+
 }

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

@@ -82,4 +82,6 @@ public class OperateLogDO 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/service/dept/DeptService.java

@@ -100,4 +100,6 @@ public interface DeptService {
     void validateDeptList(Collection<Long> ids);
 
     List<DeptDO> selectDeptByIds(Set<Long> deptIds);
+
+    void updateUserStatus(Long id, Integer status);
 }

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

@@ -11,11 +11,13 @@ import com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept.Dep
 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;
+import com.poteviohealth.cgp.sso.module.system.dal.dataobject.user.AdminUserDO;
 import com.poteviohealth.cgp.sso.module.system.dal.mysql.dept.DeptMapper;
 import com.poteviohealth.cgp.sso.module.system.dal.mysql.sequence.SequenceMapper;
 import com.poteviohealth.cgp.sso.module.system.dal.mysql.user.AdminUserMapper;
 import com.poteviohealth.cgp.sso.module.system.dal.redis.RedisKeyConstants;
 import com.google.common.annotations.VisibleForTesting;
+import com.poteviohealth.cgp.sso.module.system.enums.permission.RoleTypeEnum;
 import com.poteviohealth.cgp.sso.module.system.service.user.AdminUserService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -193,14 +195,15 @@ public class DeptServiceImpl implements DeptService {
     }
 
     @VisibleForTesting
-    void validateDeptExists(Long id) {
+    DeptDO validateDeptExists(Long id) {
         if (id == null) {
-            return;
+            return null;
         }
         DeptDO dept = deptMapper.selectById(id);
         if (dept == null) {
             throw exception(DEPT_NOT_FOUND);
         }
+        return dept;
     }
 
     @VisibleForTesting
@@ -326,4 +329,15 @@ public class DeptServiceImpl implements DeptService {
         }
         return deptMapper.selectDeptByIds(ids);
     }
+
+    @Override
+    public void updateUserStatus(Long id, Integer status) {
+        // 校验用户存在
+        DeptDO deptDO = validateDeptExists(id);
+        // 更新状态
+        DeptDO updateObj = new DeptDO();
+        updateObj.setId(id);
+        updateObj.setStatus(status);
+        deptMapper.updateById(updateObj);
+    }
 }