43 changed files with 801 additions and 36 deletions
@ -0,0 +1,39 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Data |
||||
|
public class StaffPermCacheFormDTO { |
||||
|
|
||||
|
/** |
||||
|
* 更新权限缓存分组 |
||||
|
*/ |
||||
|
public interface UpdatePermissionCache {} |
||||
|
|
||||
|
/** |
||||
|
* 工作人员 id |
||||
|
*/ |
||||
|
@NotBlank(message = "工作人员ID不能为空", groups = {UpdatePermissionCache.class}) |
||||
|
private String staffId; |
||||
|
|
||||
|
/** |
||||
|
* 登录头信息app |
||||
|
*/ |
||||
|
@NotBlank(message = "登录头信息app不能为空", groups = {UpdatePermissionCache.class}) |
||||
|
private String app; |
||||
|
|
||||
|
/** |
||||
|
* 登录头信息client |
||||
|
*/ |
||||
|
@NotBlank(message = "登录头信息client不能为空", groups = {UpdatePermissionCache.class}) |
||||
|
private String client; |
||||
|
|
||||
|
/** |
||||
|
* 权限列表 |
||||
|
*/ |
||||
|
private List<String> permissions; |
||||
|
|
||||
|
} |
@ -0,0 +1,43 @@ |
|||||
|
package com.epmet.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
||||
|
import com.epmet.dto.form.StaffPermCacheFormDTO; |
||||
|
import com.epmet.service.AccessService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 权限相关Api |
||||
|
* @Author wxz |
||||
|
* @Description |
||||
|
* @Date 2020/4/23 17:54 |
||||
|
**/ |
||||
|
@RestController |
||||
|
@RequestMapping("access") |
||||
|
public class AccessController { |
||||
|
|
||||
|
@Autowired |
||||
|
private AccessService accessService; |
||||
|
|
||||
|
/** |
||||
|
* 更新工作人员权限缓存 |
||||
|
* @param staffPermCacheFormDTO |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("updatepermissioncache") |
||||
|
public Result updatePermissionCache(@RequestBody StaffPermCacheFormDTO staffPermCacheFormDTO) { |
||||
|
ValidatorUtils.validateEntity(staffPermCacheFormDTO, StaffPermCacheFormDTO.UpdatePermissionCache.class); |
||||
|
String staffId = staffPermCacheFormDTO.getStaffId(); |
||||
|
String app = staffPermCacheFormDTO.getApp(); |
||||
|
String client = staffPermCacheFormDTO.getClient(); |
||||
|
List<String> permissions = staffPermCacheFormDTO.getPermissions(); |
||||
|
accessService.updatePermissionCache(staffId, app, client, permissions); |
||||
|
return new Result(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface AccessService { |
||||
|
/** |
||||
|
* 更新权限缓存 |
||||
|
* @param staffId |
||||
|
* @param permissions |
||||
|
*/ |
||||
|
void updatePermissionCache(String staffId, String app, String client, List<String> permissions); |
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.security.dto.GovTokenDto; |
||||
|
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
||||
|
import com.epmet.service.AccessService; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class AccessServiceImpl implements AccessService { |
||||
|
|
||||
|
private static Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class); |
||||
|
|
||||
|
@Autowired |
||||
|
private CpUserDetailRedis cpUserDetailRedis; |
||||
|
|
||||
|
/** |
||||
|
* 更新权限缓存 |
||||
|
* @param staffId |
||||
|
* @param permissions |
||||
|
*/ |
||||
|
@Override |
||||
|
public void updatePermissionCache(String staffId, String app, String client, List<String> permissions) { |
||||
|
GovTokenDto govTokenDto = cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class); |
||||
|
if (govTokenDto == null) { |
||||
|
logger.warn("更新[{}]用户缓存:Redis中不存在该用户TokenDto缓存信息", staffId); |
||||
|
return ; |
||||
|
} |
||||
|
govTokenDto.setPermissions(permissions); |
||||
|
|
||||
|
// 将新的TokenDto更新到redis中
|
||||
|
long expire = cpUserDetailRedis.getExpire(app, client, staffId); |
||||
|
cpUserDetailRedis.set(govTokenDto, expire); |
||||
|
logger.warn("更新[{}]用户缓存成功。", staffId); |
||||
|
} |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/4/23 15:45 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class StaffsInAgencyFromDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
/** |
||||
|
* 客户ID |
||||
|
*/ |
||||
|
private String customerId; |
||||
|
/** |
||||
|
* 机关ID |
||||
|
*/ |
||||
|
private String agencyId; |
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private List<String> staffList; |
||||
|
} |
@ -0,0 +1,38 @@ |
|||||
|
package com.epmet.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/4/23 16:08 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class StaffInfoResultDTO implements Serializable { |
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private String staffId; |
||||
|
/** |
||||
|
* 用户姓名 |
||||
|
*/ |
||||
|
private String staffName; |
||||
|
/** |
||||
|
* 头像 |
||||
|
*/ |
||||
|
private String staffHeadPhoto; |
||||
|
/** |
||||
|
* 性别 |
||||
|
*/ |
||||
|
private Integer gender; |
||||
|
/** |
||||
|
* 是否禁用(未禁用enable,已禁用disabled) |
||||
|
*/ |
||||
|
private String enableFlag; |
||||
|
/** |
||||
|
* 权限名 |
||||
|
*/ |
||||
|
private String roleName; |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.epmet.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/4/23 15:58 |
||||
|
*/ |
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public class StaffsInAgencyResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
/** |
||||
|
* 人员总数 |
||||
|
*/ |
||||
|
private Integer staffCount; |
||||
|
/** |
||||
|
* 人员列表 |
||||
|
*/ |
||||
|
private List<StaffInfoResultDTO> staffList; |
||||
|
|
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.epmet.controller; |
||||
|
|
||||
|
|
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.dto.form.StaffsInAgencyFromDTO; |
||||
|
import com.epmet.dto.result.StaffInfoResultDTO; |
||||
|
import com.epmet.dto.result.StaffsInAgencyResultDTO; |
||||
|
import com.epmet.service.StaffService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 组织结构-工作人员 |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/4/23 17:59 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("staff") |
||||
|
public class StaffController { |
||||
|
@Autowired |
||||
|
private StaffService staffService; |
||||
|
/** |
||||
|
* 组织首页-工作人员列表 |
||||
|
* @param fromDTO |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("staffsinagency") |
||||
|
public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { |
||||
|
return staffService.getStaffInfoForHome(fromDTO); |
||||
|
} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.dto.form.StaffsInAgencyFromDTO; |
||||
|
import com.epmet.dto.result.StaffsInAgencyResultDTO; |
||||
|
|
||||
|
/** |
||||
|
* 组织结构-工作人员 |
||||
|
* |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/4/23 18:00 |
||||
|
*/ |
||||
|
public interface StaffService { |
||||
|
/** |
||||
|
* 组织首页-工作人员列表 |
||||
|
* |
||||
|
* @param fromDTO 参数 |
||||
|
* @return Result<StaffsInAgencyResultDTO> |
||||
|
* @author zhaoqifeng |
||||
|
*/ |
||||
|
Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); |
||||
|
} |
@ -0,0 +1,54 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.dto.CustomerStaffAgencyDTO; |
||||
|
import com.epmet.dto.form.StaffsInAgencyFromDTO; |
||||
|
import com.epmet.dto.result.StaffInfoResultDTO; |
||||
|
import com.epmet.dto.result.StaffsInAgencyResultDTO; |
||||
|
import com.epmet.entity.CustomerAgencyEntity; |
||||
|
import com.epmet.feign.EpmetUserFeignClient; |
||||
|
import com.epmet.feign.OperCrmFeignClient; |
||||
|
import com.epmet.service.CustomerAgencyService; |
||||
|
import com.epmet.service.CustomerStaffAgencyService; |
||||
|
import com.epmet.service.StaffService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/4/23 18:05 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class StaffServiceImpl implements StaffService { |
||||
|
@Autowired |
||||
|
private EpmetUserFeignClient epmetUserFeignClient; |
||||
|
@Autowired |
||||
|
private OperCrmFeignClient operCrmFeignClient; |
||||
|
@Autowired |
||||
|
private CustomerAgencyService customerAgencyService; |
||||
|
@Autowired |
||||
|
private CustomerStaffAgencyService customerStaffAgencyService; |
||||
|
@Override |
||||
|
public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { |
||||
|
StaffsInAgencyResultDTO resultDTO = new StaffsInAgencyResultDTO(); |
||||
|
//获取机关所在客户ID和人员总数
|
||||
|
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); |
||||
|
resultDTO.setStaffCount(customerAgencyEntity.getTotalUser()); |
||||
|
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); |
||||
|
List<CustomerStaffAgencyDTO> customerStaffAgencyList = customerStaffAgencyService.getCustomerStaffAgencyList(fromDTO).getData(); |
||||
|
if (null == customerStaffAgencyList || customerStaffAgencyList.size() == 0) { |
||||
|
return new Result<StaffsInAgencyResultDTO>().ok(null); |
||||
|
} |
||||
|
//提取所有userID
|
||||
|
List<String> staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList()); |
||||
|
fromDTO.setStaffList(staffIds); |
||||
|
//获取用户信息
|
||||
|
Result<List<StaffInfoResultDTO>> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO); |
||||
|
resultDTO.setStaffList(staffInfoListResult.getData()); |
||||
|
return new Result<StaffsInAgencyResultDTO>().ok(resultDTO); |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Description 根据客户id查询客户信息 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/4/24 9:09 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class CustomerFormDTO implements Serializable { |
||||
|
/** |
||||
|
* 客户id集合 |
||||
|
* */ |
||||
|
private List<String> customerIdList; |
||||
|
} |
||||
|
|
Loading…
Reference in new issue