Jelajahi Sumber

加入申请接口调整

chenw 7 tahun lalu
induk
melakukan
54210bc386

+ 9 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/dto/AddApplyDTO.java

@@ -15,6 +15,7 @@ public class AddApplyDTO extends CommonBaseDTO implements Serializable {
     private String username;
     private String mobile;
     private String roles;
+    private String roleNames;
     /**
      * 审批状态:  2.待处理  0.不同意   1.同意
      */
@@ -22,6 +23,14 @@ public class AddApplyDTO extends CommonBaseDTO implements Serializable {
     private Long creatorId;
     private Long companyId;
 
+    public String getRoleNames() {
+        return roleNames;
+    }
+
+    public void setRoleNames(String roleNames) {
+        this.roleNames = roleNames;
+    }
+
     public Long getCompanyId() {
         return companyId;
     }

+ 1 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java

@@ -69,6 +69,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     PRODUCT_ISCLOSE(79506, "物料已关闭"),
     CUSTOMER_ISCLOSE(79507, "客户资料已关闭"),
     REQUIREDFIELD_NULL(79508,"存在必填字段为空"),
+    USER_EXIST(79509, ""),
 
     //采购 70000-71999
     PURCCHECKIN_POST_ERROR(70000,""),

+ 29 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/SystemRemindServiceImpl.java

@@ -3,13 +3,19 @@ package com.usoftchina.saas.commons.service.impl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.account.api.AccountApi;
+import com.usoftchina.saas.account.api.CompanyApi;
 import com.usoftchina.saas.account.dto.AccountDTO;
+import com.usoftchina.saas.account.dto.CompanyDTO;
+import com.usoftchina.saas.account.dto.RoleBaseDTO;
 import com.usoftchina.saas.commons.dto.AddApplyDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.mapper.SystemRemindMapper;
 import com.usoftchina.saas.commons.po.AddApply;
 import com.usoftchina.saas.commons.service.SystemRemindService;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.exception.BizException;
+import com.usoftchina.saas.exception.ExceptionCode;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.BeanMapper;
 import com.usoftchina.saas.utils.ObjectUtils;
@@ -31,9 +37,17 @@ public class SystemRemindServiceImpl implements SystemRemindService {
     private SystemRemindMapper systemRemindMapper;
     @Autowired
     private AccountApi accountApi;
+    @Autowired
+    private CompanyApi companyApi;
 
     @Override
     public void save(AddApplyDTO addApplyDTO) {
+        //校验这个人是否已经在此企业
+        AccountDTO accountDTO = accountApi.getAccount(addApplyDTO.getMobile()).getData();
+        CompanyDTO companyDTO = companyApi.getCompanyByName(addApplyDTO.getCompanyName()).getData();
+        if (!ObjectUtils.isEmpty(accountDTO.getCompany(companyDTO.getId()))){
+            throw new BizException(ExceptionCode.USER_COMPANY_EXIST);
+        }
         addApplyDTO.setCreateTime(new Date());
         AddApply addApply = BeanMapper.map(addApplyDTO, AddApply.class);
         addApply.setCreatorId(BaseContextHolder.getUserId());
@@ -43,9 +57,24 @@ public class SystemRemindServiceImpl implements SystemRemindService {
 
     @Override
     public PageInfo<AddApplyDTO> getApplyList(PageRequest pageRequest, ListReqDTO listReqDTO) {
+        Long companyId = BaseContextHolder.getCompanyId();
+        StringBuilder roles = new StringBuilder();
+        StringBuilder roleNames = new StringBuilder();
         PageHelper.startPage(pageRequest.getNumber(), pageRequest.getSize());
         String condition = listReqDTO.getFinalCondition();
         List<AddApplyDTO> addApplyDTOList = systemRemindMapper.getApplyList(condition, BaseContextHolder.getCompanyId());
+        for (AddApplyDTO addapplyDTO : addApplyDTOList) {
+            AccountDTO accountDTO = accountApi.getAccount(addapplyDTO.getMobile()).getData();
+            List<RoleBaseDTO> roleBaseDTOList = accountDTO.getRolesMap().get(companyId);
+            for (RoleBaseDTO roleBaseDTO : roleBaseDTOList){
+                roles.append(roleBaseDTO.getId() + ",");
+                roleNames.append(roleBaseDTO.getName() + ",");
+            }
+            addapplyDTO.setRoles(roles.substring(0, roles.length() - 1));
+            addapplyDTO.setRoleNames(roleNames.substring(0, roleNames.length() - 1));
+            roles.setLength(0);
+            roleNames.setLength(0);
+        }
         PageInfo<AddApplyDTO> pageInfo = new PageInfo<AddApplyDTO>(addApplyDTOList);
         return pageInfo;
     }

+ 2 - 2
applications/commons/commons-server/src/main/resources/mapper/SystemRemindMapper.xml

@@ -20,10 +20,10 @@
               AND COMPANYID = #{companyId}
           </if>
       </where>
-      ORDER RE_STATUS DESC,RE_ID DESC
+      ORDER BY RE_STATUS DESC,RE_ID DESC
     </select>
     <update id="confirmApply">
-        UPDATE REMIND SET STATUS = #{status}, updateTime = now(), updaterId = #{updaterId}
+        UPDATE REMIND SET RE_STATUS = #{status}, updateTime = now(), updaterId = #{updaterId}
         where re_id = #{id}
     </update>
     <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.AddApply">