|
|
@@ -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;
|
|
|
}
|