소스 검색

test translator

lixing 4 년 전
부모
커밋
c655ba406a

+ 6 - 5
fm-person/src/main/java/com/persagy/fm/department/controller/DepartmentController.java

@@ -16,6 +16,7 @@ import com.persagy.fm.depproject.service.IDepProjectService;
 import com.persagy.fm.saas.project.model.vo.ProjectTreeItemVO;
 import com.persagy.fm.translate.model.Trans;
 import com.persagy.fm.translate.model.TransType;
+import com.persagy.fm.translate.model.Transes;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
@@ -62,14 +63,14 @@ public class DepartmentController {
     @ApiOperation(value = "部门详情")
     @PostMapping("/get")
     // TODO: 2021/3/24 使用翻译器
-//    @Transes({
-//            @Trans(source = "com.persagy.fm.person.service.IPersonTransBatchHandler",
-//                    type = TransType.SERVICE, result = "name", batch = true,
-//                    condition = "id", parameter = "managers", target = "managersShowName"),
+    @Transes({
+            @Trans(source = "personNameTranslator",
+                    type = TransType.SERVICE, batch = true,
+                    parameter = "managers", target = "managersShowName"),
 //            @Trans(source = "com.persagy.fm.person.service.IPersonTransBatchHandler",
 //                    type = TransType.SERVICE, result = "name", batch = true,
 //                    condition = "id", parameter = "projectIds", target = "projectsShowName")
-//    })
+    })
     @Trans(type = TransType.SERVICE, batch = true, source = "personNameTranslator", parameter = "managers", target = "managerShowName")
     public CommonResult<ResponseDepartmentItemVO> queryDepartmentDetail(
             @Valid @RequestBody QueryDepartmentDetailDTO queryDepartmentDetailDTO) {

+ 24 - 4
fm-person/src/main/java/com/persagy/fm/department/service/impl/DepTreeServiceImpl.java

@@ -37,9 +37,18 @@ public class DepTreeServiceImpl implements IDepTreeService {
      * @version V1.0 2021/3/12 11:58 上午
      */
     private Map<Integer, List<Department>> initTreeData(QueryDepartmentTreeDTO queryDepartmentTreeDTO) {
-        if (queryDepartmentTreeDTO.getCheckedId() != null) {
-            // TODO: 2021/3/9
-            return null;
+        Long checkedId = queryDepartmentTreeDTO.getCheckedId();
+        if (checkedId != null) {
+            Department checkedDep = departmentService.queryDepartmentDetail(checkedId);
+            // 获取部门全路径,计算部门所在层级
+            String fullPath = checkedDep.getFullPath();
+            String separator = "-";
+            String[] paths = fullPath.split(separator);
+            int defaultShowLevel = getDefaultShowLevel();
+            int showLevel = Math.max(paths.length, defaultShowLevel);
+            // 拼装树时会用到queryDepartmentTreeDTO中的showLevel
+            queryDepartmentTreeDTO.setShowLevel(showLevel);
+            return initDefaultTreeData(showLevel);
         } else {
             return initDefaultTreeData(getShowLevel(queryDepartmentTreeDTO));
         }
@@ -54,12 +63,23 @@ public class DepTreeServiceImpl implements IDepTreeService {
     private int getShowLevel(QueryDepartmentTreeDTO queryDepartmentTreeDTO) {
         Integer showLevel = queryDepartmentTreeDTO.getShowLevel();
         if (showLevel == null) {
-            showLevel = 2;
+            showLevel = getDefaultShowLevel();
         }
         return showLevel;
     }
 
     /**
+     * 获取默认展示的层级数
+     *
+     * @return 默认展示的层级数
+     * @author lixing
+     * @version V1.0 2021/3/26 10:36 上午
+     */
+    private int getDefaultShowLevel() {
+        return 2;
+    }
+
+    /**
      * 初始化默认树
      *
      * @return 需要展示的每一层级的部门:level -> depList

+ 8 - 0
fm-person/src/main/java/com/persagy/fm/person/controller/PersonController.java

@@ -109,6 +109,14 @@ public class PersonController {
         return ResultHelper.single(new FmResponseUpsertVO(deletePersonDTO.getId()));
     }
 
+    @ApiOperation(value = "解禁人员")
+    @PostMapping("/enable")
+    public CommonResult<FmResponseUpsertVO> enablePerson(
+            @Valid @RequestBody DeletePersonDTO deletePersonDTO) {
+        personService.enablePerson(deletePersonDTO.getId());
+        return ResultHelper.single(new FmResponseUpsertVO(deletePersonDTO.getId()));
+    }
+
     @ApiOperation(value = "离职人员")
     @PostMapping("/dismiss")
     public CommonResult<FmResponseUpsertVO> dismissPerson(

+ 9 - 0
fm-person/src/main/java/com/persagy/fm/person/service/IPersonService.java

@@ -124,4 +124,13 @@ public interface IPersonService {
      * @version V1.0 2021/3/22 7:57 下午
      */
     List<Person> nameQuickSearch(NameQuickSearchDTO nameQuickSearchDTO);
+
+    /**
+     * 解禁人员
+     *
+     * @param personId 人员id
+     * @author lixing
+     * @version V1.0 2021/3/22 10:39 上午
+     */
+    void enablePerson(Long personId);
 }

+ 0 - 10
fm-person/src/main/java/com/persagy/fm/person/service/IPersonTransBatchHandler.java

@@ -1,10 +0,0 @@
-package com.persagy.fm.person.service;
-
-/**
- * 人员翻译器
- *
- * @author lixing
- * @version V1.0 2021/3/24 11:21 上午
- **/
-public interface IPersonTransBatchHandler{
-}

+ 69 - 7
fm-person/src/main/java/com/persagy/fm/person/service/impl/PersonServiceImpl.java

@@ -20,11 +20,16 @@ import com.persagy.fm.saas.account.constant.enums.AccountTypeEnum;
 import com.persagy.fm.saas.account.model.dto.AddSaasAccountDTO;
 import com.persagy.fm.saas.account.model.dto.PageQuerySaasAccountDTO;
 import com.persagy.fm.saas.account.model.vo.SaasAccountListItemVO;
+import com.persagy.fm.saas.accountrole.client.SaasAccountRoleClient;
+import com.persagy.fm.saas.accountrole.constant.enums.AccountRoleTypeEnum;
+import com.persagy.fm.saas.accountrole.model.dto.AddSaasAccountRoleDTO;
 import com.persagy.fm.workresume.model.dto.AddWorkResumeDTO;
 import com.persagy.fm.workresume.service.IWorkResumeService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.util.Date;
 import java.util.List;
@@ -44,6 +49,8 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
     private SaasAccountClient saasAccountClient;
     @Autowired
     private PersonMapper personMapper;
+    @Autowired
+    private SaasAccountRoleClient saasAccountRoleClient;
 
     /**
      * 创建人员
@@ -66,15 +73,65 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
         // 账号关联项目
         // TODO: 2021/3/23
         // 账号关联角色
-        // TODO: 2021/3/23
+        saveAccountRole(accountId, addPersonDTO.getMainDuty(),
+                addPersonDTO.getOtherDuties(), addPersonDTO.getOtherRoles());
         return person.getId();
     }
 
     /**
+     * 账号关联角色
+     *
+     * @param accountId 账号id
+     * @param mainDuty 主岗id
+     * @param otherDuties 副岗id列表
+     * @param otherRoles 其他角色列表
+     * @author lixing
+     * @version V1.0 2021/3/26 11:41 上午
+     */
+    private void saveAccountRole(
+            String accountId, String mainDuty,
+            List<String> otherDuties, List<String> otherRoles) {
+        // 保存主岗
+        if (StringUtils.isNotBlank(mainDuty)) {
+            saveAccountRole(accountId, mainDuty, AccountRoleTypeEnum.MAIN_DUTY.getType());
+        }
+        // 保存副岗
+        if (!CollectionUtils.isEmpty(otherDuties)) {
+            for (String otherDuty : otherDuties) {
+                saveAccountRole(accountId, otherDuty, AccountRoleTypeEnum.OTHER_DUTY.getType());
+            }
+        }
+        // 保存其他角色
+        if (!CollectionUtils.isEmpty(otherRoles)) {
+            for (String otherRole : otherRoles) {
+                saveAccountRole(accountId, otherRole, AccountRoleTypeEnum.SYS_ROLE.getType());
+            }
+        }
+    }
+
+    /**
+     * 账号关联角色
+     *
+     * @param accountId 账号id
+     * @param roleId 角色id
+     * @param accountRoleType 关联类型
+     * @author lixing
+     * @version V1.0 2021/3/26 11:42 上午
+     */
+    private void saveAccountRole(String accountId, String roleId, String accountRoleType) {
+        AddSaasAccountRoleDTO mainDutyDTO = new AddSaasAccountRoleDTO();
+        mainDutyDTO.setDefaultValue();
+        mainDutyDTO.setAccountId(accountId);
+        mainDutyDTO.setRoleId(roleId);
+        mainDutyDTO.setCasType(accountRoleType);
+        saasAccountRoleClient.createSaasAccountRole(mainDutyDTO);
+    }
+
+    /**
      * 保存人员的工作信息
      *
      * @param addPersonDTO 创建人员入参
-     * @param personId 人员id
+     * @param personId     人员id
      * @author lixing
      * @version V1.0 2021/3/23 4:23 下午
      */
@@ -92,7 +149,7 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
      * 保存人员信息到数据库
      *
      * @param addPersonDTO 创建人员入参
-     * @param accountId 账号id
+     * @param accountId    账号id
      * @return 保存后的人员对象
      * @author lixing
      * @version V1.0 2021/3/23 4:06 下午
@@ -155,7 +212,7 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
      *
      * @param addPersonDTO
      * @return void
-     * @exception
+     * @throws
      * @author lixing
      * @version V1.0 2021/3/22 9:53 上午
      */
@@ -261,9 +318,9 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
         return result;
     }
 
-//    @Override
-//    public void resetPassWord(Long personId) {
-//    }
+    //    @Override
+    //    public void resetPassWord(Long personId) {
+    //    }
 
     @Override
     public void disablePerson(Long personId) {
@@ -290,4 +347,9 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
         // TODO: 2021/3/22 快速查询人名
         return null;
     }
+
+    @Override
+    public void enablePerson(Long personId) {
+        // TODO: 2021/3/26 解禁人员
+    }
 }

+ 0 - 12
fm-person/src/main/java/com/persagy/fm/person/service/impl/PersonTransBatchHandlerImpl.java

@@ -1,12 +0,0 @@
-package com.persagy.fm.person.service.impl;
-
-import com.persagy.fm.person.service.IPersonTransBatchHandler;
-
-/**
- * 人员翻译器
- *
- * @author lixing
- * @version V1.0 2021/3/24 11:22 上午
- **/
-public class PersonTransBatchHandlerImpl implements IPersonTransBatchHandler  {
-}

+ 2 - 1
fm-person/src/main/java/com/persagy/fm/saas/accountrole/constant/enums/AccountRoleTypeEnum.java

@@ -14,7 +14,8 @@ public enum AccountRoleTypeEnum {
      * 账号角色关联类型
      */
     MAIN_DUTY("0", "主岗"),
-    OTHER_DUTY("1", "副岗");
+    OTHER_DUTY("1", "副岗"),
+    SYS_ROLE("2", "系统角色");
 
     @Setter
     @Getter

+ 13 - 0
fm-person/src/main/java/com/persagy/fm/saas/accountrole/model/dto/AddSaasAccountRoleDTO.java

@@ -1,5 +1,7 @@
 package com.persagy.fm.saas.accountrole.model.dto;
 
+import com.persagy.fm.common.context.DefaultAppContext;
+import com.persagy.fm.saas.account.constant.enums.AccountBelongEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -41,4 +43,15 @@ public class AddSaasAccountRoleDTO {
     @NotNull(message = "关联类型不能为空")
     private String casType;
 
+    /**
+     * 设置默认的属性
+     *
+     * @author lixing
+     * @version V1.0 2021/3/26 11:32 上午
+     */
+    public void setDefaultValue() {
+        this.setAccountBelong(AccountBelongEnum.BUSINESS.getType());
+        this.setGroupCode(DefaultAppContext.getContext().getGroupCode());
+        this.setAppId(DefaultAppContext.getContext().getAppId());
+    }
 }