Browse Source

Merge remote-tracking branch 'origin/dev_grid_patrol' into dev_grid_patrol

master
jianjun 4 years ago
parent
commit
bcf337a086
  1. 32
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

32
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -51,6 +51,7 @@ import com.epmet.feign.AuthFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.redis.CustomerStaffRedis;
import com.epmet.redis.StaffRoleRedis;
import com.epmet.service.CustomerStaffService;
import com.epmet.service.GovStaffRoleService;
import com.epmet.service.StaffRoleService;
@ -66,10 +67,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -104,6 +102,8 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
private GovStaffRoleDao govStaffRoleDao;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Autowired
private StaffRoleRedis staffRoleRedis;
@Override
public PageData<CustomerStaffDTO> page(Map<String, Object> params) {
@ -327,6 +327,18 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
staffRoleService.insert(staffRoleEntity);
});
// 角色放缓存
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
List<RoleKeyValueResultDTO> roleKeyValue = govStaffRoleDao.selectRoleKeyName(fromDTO.getRoles());
dto.setCustomerId(fromDTO.getCustomerId());
dto.setStaffId(userEntity.getId());
dto.setAgencyId(fromDTO.getAgencyId());
Map m = new HashMap(16);
roleKeyValue.forEach(r -> {
m.put(r.getRoleKey(),r.getRoleName());
});
dto.setRoles(m.toString());
staffRoleRedis.setRole(dto.getCustomerId(), dto.getStaffId(),dto);
return new Result<CustomerStaffDTO>().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class));
}
@ -388,6 +400,18 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
logger.error("修改用户信息:修改用户已缓存的角色列表异常:{}", ExceptionUtils.getErrorStackTrace(e));;
}
// 角色放缓存
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
List<RoleKeyValueResultDTO> roleKeyValue = govStaffRoleDao.selectRoleKeyName(fromDTO.getRoles());
dto.setCustomerId(fromDTO.getCustomerId());
dto.setStaffId(fromDTO.getStaffId());
dto.setAgencyId(fromDTO.getAgencyId());
Map m = new HashMap(16);
roleKeyValue.forEach(r -> {
m.put(r.getRoleKey(),r.getRoleName());
});
dto.setRoles(m.toString());
staffRoleRedis.setRole(dto.getCustomerId(), dto.getStaffId(),dto);
return new Result();
}

Loading…
Cancel
Save