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> listCamerasByDepId(CameraRpcQuery rpcQuery) { CameraQuery query = new CameraQuery(); BeanUtils.copyProperties(rpcQuery,query); SearchResultVO> srs = cameraManageService.listCamerasByDepId(query); SearchResultVO> resultVO = new SearchResultVO<>(); BeanUtils.copyProperties(srs,resultVO); resultVO.setData(toRpcDtoList((List) srs.getData())); return resultVO; } @Override public SearchResultVO> listCamerasByUserId(Long userId) { SearchResultVO> srs = cameraManageService.listAccessCamerasByUserId(userId); SearchResultVO> resultVO = new SearchResultVO<>(); BeanUtils.copyProperties(srs,resultVO); resultVO.setData(toRpcDtoList((List) srs.getData())); return resultVO; } @Override public SearchResultVO findCameraById(Long cameraId) { SearchResultVO srs = cameraManageService.findByCameraId(cameraId); SearchResultVO resultVO = new SearchResultVO<>(); BeanUtils.copyProperties(srs,resultVO); resultVO.setData(toRpcDto((CameraRespDTO) srs.getData())); return resultVO; } @Override public SearchResultVO> findCamerasByCondition(CameraRpcQuery rpcQuery) { CameraQuery query = new CameraQuery(); BeanUtils.copyProperties(rpcQuery,query); SearchResultVO> srs = cameraManageService.listCamerasByCondition(query); SearchResultVO> resultVO = new SearchResultVO<>(); BeanUtils.copyProperties(srs,resultVO); resultVO.setData(toRpcDtoList((List) srs.getData())); return resultVO; } @Override public SearchResultVO> listByCameraIdList(List cameraIdList) { SearchResultVO> resultVO = new SearchResultVO<>(); resultVO.setCode(ResultCodes.OK); List respDTOList = cameraManageService.listByCameraIdList(cameraIdList); List rpcRespDTOS = toRpcDtoList(respDTOList); if(respDTOList != null) resultVO.setCount(rpcRespDTOS.size()); else resultVO.setCount(0); resultVO.setData(rpcRespDTOS); return resultVO; } private List toRpcDtoList(List respDTOList){ if(respDTOList == null || respDTOList.isEmpty()) return null; List rpcRespDTOS = new ArrayList<>(); for(int i=0;i