package com.gkhy.safePlatform.account.rpc.test;
|
|
import com.gkhy.safePlatform.account.model.dto.req.CameraQuery;
|
import com.gkhy.safePlatform.account.model.dto.resp.CameraRespDTO;
|
import com.gkhy.safePlatform.account.rpc.apimodel.CameraService;
|
import com.gkhy.safePlatform.account.rpc.apimodel.model.req.query.CameraRpcQuery;
|
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.CameraRpcRespDTO;
|
import com.gkhy.safePlatform.account.service.CameraManageService;
|
import com.gkhy.safePlatform.commons.enums.ResultCodes;
|
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
|
import org.apache.dubbo.config.annotation.DubboService;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
@DubboService
|
public class CameraServiceProvider implements CameraService {
|
|
@Autowired
|
private CameraManageService cameraManageService;
|
|
@Override
|
public SearchResultVO<List<CameraRpcRespDTO>> listCamerasByDepId(CameraRpcQuery rpcQuery) {
|
CameraQuery query = new CameraQuery();
|
BeanUtils.copyProperties(rpcQuery,query);
|
SearchResultVO<List<CameraRespDTO>> srs = cameraManageService.listCamerasByDepId(query);
|
SearchResultVO<List<CameraRpcRespDTO>> resultVO = new SearchResultVO<>();
|
BeanUtils.copyProperties(srs,resultVO);
|
resultVO.setData(toRpcDtoList((List<CameraRespDTO>) srs.getData()));
|
return resultVO;
|
}
|
|
@Override
|
public SearchResultVO<List<CameraRpcRespDTO>> listCamerasByUserId(Long userId) {
|
SearchResultVO<List<CameraRespDTO>> srs = cameraManageService.listAccessCamerasByUserId(userId);
|
SearchResultVO<List<CameraRpcRespDTO>> resultVO = new SearchResultVO<>();
|
BeanUtils.copyProperties(srs,resultVO);
|
resultVO.setData(toRpcDtoList((List<CameraRespDTO>) srs.getData()));
|
return resultVO;
|
}
|
|
@Override
|
public SearchResultVO<CameraRpcRespDTO> findCameraById(Long cameraId) {
|
SearchResultVO<CameraRespDTO> srs = cameraManageService.findByCameraId(cameraId);
|
SearchResultVO<CameraRpcRespDTO> resultVO = new SearchResultVO<>();
|
BeanUtils.copyProperties(srs,resultVO);
|
resultVO.setData(toRpcDto((CameraRespDTO) srs.getData()));
|
return resultVO;
|
}
|
|
@Override
|
public SearchResultVO<List<CameraRpcRespDTO>> findCamerasByCondition(CameraRpcQuery rpcQuery) {
|
CameraQuery query = new CameraQuery();
|
BeanUtils.copyProperties(rpcQuery,query);
|
SearchResultVO<List<CameraRespDTO>> srs = cameraManageService.listCamerasByCondition(query);
|
SearchResultVO<List<CameraRpcRespDTO>> resultVO = new SearchResultVO<>();
|
BeanUtils.copyProperties(srs,resultVO);
|
resultVO.setData(toRpcDtoList((List<CameraRespDTO>) srs.getData()));
|
return resultVO;
|
}
|
|
@Override
|
public SearchResultVO<List<CameraRpcRespDTO>> listByCameraIdList(List<Long> cameraIdList) {
|
SearchResultVO<List<CameraRpcRespDTO>> resultVO = new SearchResultVO<>();
|
resultVO.setCode(ResultCodes.OK);
|
List<CameraRespDTO> respDTOList = cameraManageService.listByCameraIdList(cameraIdList);
|
List<CameraRpcRespDTO> rpcRespDTOS = toRpcDtoList(respDTOList);
|
if(respDTOList != null)
|
resultVO.setCount(rpcRespDTOS.size());
|
else
|
resultVO.setCount(0);
|
resultVO.setData(rpcRespDTOS);
|
return resultVO;
|
}
|
|
private List<CameraRpcRespDTO> toRpcDtoList(List<CameraRespDTO> respDTOList){
|
if(respDTOList == null || respDTOList.isEmpty())
|
return null;
|
List<CameraRpcRespDTO> rpcRespDTOS = new ArrayList<>();
|
for(int i=0;i<respDTOList.size();i++){
|
rpcRespDTOS.add(toRpcDto(respDTOList.get(i)));
|
}
|
return rpcRespDTOS;
|
}
|
|
private CameraRpcRespDTO toRpcDto(CameraRespDTO respDTO){
|
if(respDTO == null)
|
return null;
|
CameraRpcRespDTO rpcDto = new CameraRpcRespDTO();
|
BeanUtils.copyProperties(respDTO,rpcDto);
|
return rpcDto;
|
}
|
}
|