kimi
2020-05-27 c007f0ca1785db093d48f4846cda82fe8e955765
src/main/java/com/highdatas/mdm/service/act/impl/IdentityServiceImpl.java
@@ -39,11 +39,27 @@
   @Autowired
   RedisClient redisClient;
   /**
    *
    * @description:  启动流程
    * @param businessId 业务id
    * @param key 流程key
    * @return: 实例id
    *
    */
    @Override
   public String startProcess(String businessId, String key) {
      return startProcess(businessId, key, null, null);
   }
   /**
    *
    * @description:  启动流程
    * @param businessId 业务id
    * @param key 流程key
    * @param variables 额外参数
    * @return: 实例id
    *
    */
    @Override
   public String startProcess(String businessId, String key, String workflowStall, HashMap<String, Object> variables) {
       TUser user = getOnlineUser();
@@ -104,6 +120,13 @@
       }
   }
   /**
    *
    * @description:  添加工作流用户
    * @param id 用户id
    * @return: 添加结果
    *
    */
   @Override
   @Transactional(rollbackFor = {RuntimeException.class, Error.class})
   public Result addUser(String id) {
@@ -113,9 +136,6 @@
      }
      try {
         User user = identityService.newUser(id);
         identityService.saveUser(user);
         user.setFirstName("");
         identityService.saveUser(user);
         return Result.success(null);
      }catch (Exception e){
@@ -125,6 +145,13 @@
   }
   /**
    *
    * @description:  添加工作流角色
    * @param id 角色id
    * @return: 添加结果
    *
    */
   @Override
   @Transactional(rollbackFor = {RuntimeException.class, Error.class})
   public Result addRole(String id) {
@@ -135,8 +162,6 @@
      try {
         Group group = identityService.newGroup(id);
         identityService.saveGroup(group);
         group.setName("");
         identityService.saveGroup(group);
         return Result.success(null);
      }catch (Exception e){
         e.printStackTrace();
@@ -144,6 +169,14 @@
      }
   }
   /**
    *
    * @description:  添加工作流用户,角色关联
    * @param roleId 觉得id
    * @param userId 用户id
    * @return: 添加结果
    *
    */
   @Override
   @Transactional(rollbackFor = {RuntimeException.class, Error.class})
   public Result addUserRole(String roleId, String userId) {
@@ -152,16 +185,11 @@
         if (user == null) {
            return Result.error(new CodeMsg(3001, "当前用户不存在,请先创建用户"));
         }
         Group group = identityService.createGroupQuery().groupId(roleId).singleResult();
         if (group == null) {
            return Result.error(new CodeMsg(3001, "当前角色不存在,请先创建用户"));
         }
         Map<String, String> memberShip = tableInfoMapper.selectActMemberShip(userId, roleId);
            Map<String, String> memberShip = tableInfoMapper.selectActMemberShip(userId, roleId);
         if (memberShip != null) {
                return Result.success(null);
            }
            identityService.createMembership(userId,roleId);
         return Result.success(null);
      }
@@ -170,7 +198,13 @@
         return Result.error(new CodeMsg(3002, e.getMessage()));
      }
   }
   /**
    *
    * @description:  删除工作流用户
    * @param id 用户id
    * @return: 删除结果
    *
    */
   @Override
   @Transactional(rollbackFor = {RuntimeException.class, Error.class})
   public Result deleteUser(String id) {
@@ -197,7 +231,13 @@
      }
   }
   /**
    *
    * @description:  删除工作流角色
    * @param id 角色id
    * @return: 删除结果
    *
    */
   @Override
   @Transactional(rollbackFor = {RuntimeException.class, Error.class})
   public Result deleteRole(String id) {
@@ -224,11 +264,19 @@
      }
   }
   /**
    *
    * @description:  删除工作流用户 角色关联
    * @param userId 用户id
    * @param roleId 角色id
    * @return: 删除结果
    *
    */
   @Override
   @Transactional(rollbackFor = {RuntimeException.class, Error.class})
   public Result deleteUserRole(String roleId, String userId) {
      try {
            Map<String, String> memberShip = tableInfoMapper.selectActMemberShip(userId, roleId);
            if (memberShip == null) {
                return Result.success(null);
@@ -242,7 +290,13 @@
         return Result.error(new CodeMsg(3002, e.getMessage()));
      }
   }
   /**
    *
    * @description:  通过user获取关联的角色
    * @param userId 用户id
    * @return: 角色id列表
    *
    */
   @Override
   public List<String> getRoleByUser(String userId) {
      List<Group> list = identityService.createGroupQuery().groupMember(userId).list();