package com.gkhy.safePlatform.account.rpc.test; import com.gkhy.safePlatform.account.entity.schedule.GroupInfoDO; import com.gkhy.safePlatform.account.enums.schedule.GroupStatusEnum; import com.gkhy.safePlatform.account.model.dto.resp.GroupInfoRespDTO; import com.gkhy.safePlatform.account.rpc.apimodel.AccountGroupService; import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.GroupRPCRespDTO; import com.gkhy.safePlatform.account.service.GroupService; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.exception.AusinessException; import com.gkhy.safePlatform.commons.exception.BusinessException; import com.gkhy.safePlatform.commons.vo.ResultVO; import org.apache.commons.collections.CollectionUtils; import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.factory.annotation.Autowired; import java.util.*; @DubboService public class AccountGroupServiceProvider implements AccountGroupService { @Autowired private GroupService groupService; @Override public ResultVO getGroupInfoByGroupId(Long groupId) { try { GroupInfoRespDTO groupInfo = groupService.getGroupInfoByGroupId(groupId); GroupRPCRespDTO result = null; if (groupInfo != null) { result = new GroupRPCRespDTO(); result.setGroupId(groupInfo.getGroupId()); result.setGroupName(groupInfo.getGroupName()); result.setGroupInfo(groupInfo.getGroupInfo()); result.setGroupStrategyId(groupInfo.getGroupStrategyId()); result.setStatus(groupInfo.getStatus()); result.setStatusDesc(groupInfo.getStatusDesc()); } return new ResultVO<>(ResultCodes.OK,result); } catch (AusinessException e) { return new ResultVO<>(e.getCode(),e.getMessage()); } catch (BusinessException e) { return new ResultVO<>(e.getCode(),e.getMessage()); } catch (Exception e) { // return new ResultVO<>(ResultCodes.SERVER_ERROR); ResultVO resultVO = new ResultVO<>(); resultVO.setCode(ResultCodes.SERVER_ERROR.getCode()); return resultVO; } } @Override public ResultVO> listGroupInfoByUid(Long uid) { try { List result = Collections.emptyList(); List groupInfoRespDTOS = groupService.listGroupInfoByUid(uid); if (groupInfoRespDTOS != null && !groupInfoRespDTOS.isEmpty()) { GroupRPCRespDTO rpcRespDTO; result = new ArrayList<>(groupInfoRespDTOS.size()); for (GroupInfoRespDTO respDTO : groupInfoRespDTOS) { rpcRespDTO = new GroupRPCRespDTO(); rpcRespDTO.setGroupId(respDTO.getGroupId()); rpcRespDTO.setGroupName(respDTO.getGroupName()); rpcRespDTO.setGroupInfo(respDTO.getGroupInfo()); rpcRespDTO.setGroupStrategyId(respDTO.getGroupStrategyId()); rpcRespDTO.setStatus(respDTO.getStatus()); rpcRespDTO.setStatusDesc(respDTO.getStatusDesc()); result.add(rpcRespDTO); } } return new ResultVO<>(ResultCodes.OK,result); } catch (AusinessException e) { return new ResultVO<>(e.getCode(),e.getMessage()); } catch (BusinessException e) { return new ResultVO<>(e.getCode(),e.getMessage()); } catch (Exception e) { // return new ResultVO<>(ResultCodes.SERVER_ERROR); ResultVO resultVO = new ResultVO<>(); resultVO.setCode(ResultCodes.SERVER_ERROR.getCode()); return resultVO; } } @Override public ResultVO getGroupInfoByUid(Long uid) { return null; } @Override public ResultVO> listGroupMapByGroupIds(Collection groupIds) { try { Map resultMap = null; if (groupIds != null && groupIds.size() != 0) { List groupInfoRespDTOS = groupService.listGroupInfoByGroupIds(groupIds); if (groupInfoRespDTOS.size() > 0) { resultMap = new HashMap<>(groupInfoRespDTOS.size()); GroupRPCRespDTO mapItem; for (GroupInfoRespDTO groupInfo : groupInfoRespDTOS) { mapItem = new GroupRPCRespDTO(); mapItem.setGroupId(groupInfo.getGroupId()); mapItem.setGroupName(groupInfo.getGroupName()); mapItem.setGroupInfo(groupInfo.getGroupInfo()); mapItem.setStatus(groupInfo.getStatus()); mapItem.setStatusDesc(groupInfo.getStatusDesc()); mapItem.setGroupStrategyId(groupInfo.getGroupStrategyId()); resultMap.put(groupInfo.getGroupId(), mapItem); } } } return new ResultVO<>(ResultCodes.OK, resultMap); } catch (AusinessException e) { return new ResultVO<>(e.getCode(),e.getMessage()); } catch (BusinessException e) { return new ResultVO<>(e.getCode(),e.getMessage()); } catch (Exception e) { // return new ResultVO<>(ResultCodes.SERVER_ERROR); ResultVO resultVO = new ResultVO<>(); resultVO.setCode(ResultCodes.SERVER_ERROR.getCode()); return resultVO; } } }