|
|
@ -26,6 +26,7 @@ import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.CustomerStaffConstant; |
|
|
|
import com.epmet.constant.UserConstant; |
|
|
|
import com.epmet.constant.UserRoleConstant; |
|
|
|
import com.epmet.dao.CustomerStaffDao; |
|
|
@ -49,9 +50,13 @@ import com.epmet.dto.result.StaffInitResultDTO; |
|
|
|
import com.epmet.dto.result.StaffRoleResultDTO; |
|
|
|
import com.epmet.entity.CustomerStaffEntity; |
|
|
|
import com.epmet.entity.GovStaffRoleEntity; |
|
|
|
import com.epmet.entity.StaffRoleEntity; |
|
|
|
import com.epmet.entity.UserEntity; |
|
|
|
import com.epmet.redis.CustomerStaffRedis; |
|
|
|
import com.epmet.service.CustomerStaffService; |
|
|
|
import com.epmet.service.GovStaffRoleService; |
|
|
|
import com.epmet.service.StaffRoleService; |
|
|
|
import com.epmet.service.UserService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
@ -79,7 +84,10 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao, |
|
|
|
private CustomerStaffRedis customerStaffRedis; |
|
|
|
@Autowired |
|
|
|
private GovStaffRoleService govStaffRoleService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserService userService; |
|
|
|
@Autowired |
|
|
|
private StaffRoleService staffRoleService; |
|
|
|
@Override |
|
|
|
public PageData<CustomerStaffDTO> page(Map<String, Object> params) { |
|
|
|
IPage<CustomerStaffEntity> page = baseDao.selectPage( |
|
|
@ -240,23 +248,94 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao, |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result addStaff(StaffSubmitFromDTO fromDTO) { |
|
|
|
return null; |
|
|
|
//USER表插入数据
|
|
|
|
UserEntity userEntity = new UserEntity(); |
|
|
|
userEntity.setFromApp(fromDTO.getApp()); |
|
|
|
userEntity.setFromClient(fromDTO.getClient()); |
|
|
|
userService.insert(userEntity); |
|
|
|
//Customer_Staff表插入数据
|
|
|
|
CustomerStaffEntity staffEntity = new CustomerStaffEntity(); |
|
|
|
staffEntity.setUserId(userEntity.getId()); |
|
|
|
staffEntity.setRealName(fromDTO.getName()); |
|
|
|
staffEntity.setMobile(fromDTO.getMobile()); |
|
|
|
staffEntity.setActiveFlag(CustomerStaffConstant.INACTIVE); |
|
|
|
staffEntity.setGender(fromDTO.getGender()); |
|
|
|
staffEntity.setWorkType(fromDTO.getWorkType()); |
|
|
|
staffEntity.setEnableFlag(CustomerStaffConstant.ENABLE); |
|
|
|
baseDao.insert(staffEntity); |
|
|
|
|
|
|
|
//工作人员角色关联表
|
|
|
|
fromDTO.getRoles().forEach(role -> { |
|
|
|
StaffRoleEntity staffRoleEntity = new StaffRoleEntity(); |
|
|
|
staffRoleEntity.setStaffId(userEntity.getId()); |
|
|
|
staffRoleEntity.setRoleId(role); |
|
|
|
staffRoleEntity.setOrgId(fromDTO.getAgencyId()); |
|
|
|
staffRoleService.insert(staffRoleEntity); |
|
|
|
}); |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result editStaff(StaffSubmitFromDTO fromDTO) { |
|
|
|
return null; |
|
|
|
CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId()); |
|
|
|
//Customer_Staff表插入数据
|
|
|
|
CustomerStaffEntity staffEntity = new CustomerStaffEntity(); |
|
|
|
staffEntity.setId(customerStaffEntity.getId()); |
|
|
|
staffEntity.setRealName(fromDTO.getName()); |
|
|
|
staffEntity.setMobile(fromDTO.getMobile()); |
|
|
|
staffEntity.setGender(fromDTO.getGender()); |
|
|
|
staffEntity.setWorkType(fromDTO.getWorkType()); |
|
|
|
baseDao.updateById(staffEntity); |
|
|
|
|
|
|
|
//清空权限关联
|
|
|
|
StaffRoleDTO staffRoleDTO = new StaffRoleDTO(); |
|
|
|
staffRoleDTO.setStaffId(fromDTO.getStaffId()); |
|
|
|
staffRoleDTO.setOrgId(fromDTO.getAgencyId()); |
|
|
|
staffRoleService.clearStaffRoles(staffRoleDTO); |
|
|
|
//重新添加角色关联
|
|
|
|
fromDTO.getRoles().forEach(role -> { |
|
|
|
StaffRoleEntity staffRoleEntity = new StaffRoleEntity(); |
|
|
|
staffRoleEntity.setStaffId(fromDTO.getStaffId()); |
|
|
|
staffRoleEntity.setRoleId(role); |
|
|
|
staffRoleEntity.setOrgId(fromDTO.getAgencyId()); |
|
|
|
staffRoleService.insert(staffRoleEntity); |
|
|
|
}); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO) { |
|
|
|
return null; |
|
|
|
StaffDetailResultDTO resultDTO = new StaffDetailResultDTO(); |
|
|
|
//获取工作人员信息
|
|
|
|
CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfo(fromDTO); |
|
|
|
resultDTO.setStaffId(customerStaffDTO.getUserId()); |
|
|
|
resultDTO.setName(customerStaffDTO.getRealName()); |
|
|
|
resultDTO.setMobile(customerStaffDTO.getMobile()); |
|
|
|
resultDTO.setHeadPhoto(customerStaffDTO.getHeadPhoto()); |
|
|
|
resultDTO.setGender(customerStaffDTO.getGender()); |
|
|
|
resultDTO.setActiveFlag(customerStaffDTO.getActiveFlag()); |
|
|
|
resultDTO.setActiveTime(customerStaffDTO.getActiveTime()); |
|
|
|
resultDTO.setEnableFlag(customerStaffDTO.getEnableFlag()); |
|
|
|
|
|
|
|
//获取工作人员角色
|
|
|
|
List<GovStaffRoleEntity> staffRoles = govStaffRoleService.listRolesByStaffId(fromDTO.getStaffId(), fromDTO.getAgencyId()); |
|
|
|
List<String> roles = staffRoles.stream().map(GovStaffRoleEntity::getRoleName).collect(Collectors.toList()); |
|
|
|
resultDTO.setRoles(roles); |
|
|
|
return new Result<StaffDetailResultDTO>().ok(resultDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result disabledStaff(StaffInfoFromDTO fromDTO) { |
|
|
|
return null; |
|
|
|
CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId()); |
|
|
|
CustomerStaffEntity staffEntity = new CustomerStaffEntity(); |
|
|
|
staffEntity.setId(customerStaffEntity.getId()); |
|
|
|
staffEntity.setEnableFlag(CustomerStaffConstant.DISABLED); |
|
|
|
baseDao.updateById(staffEntity); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|