| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.grid.*; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.grid.ComActEasyPhotoAdminVO; |
| | | import com.panzhihua.common.model.vos.grid.ComActEasyPhotoDetailsVO; |
| | | import com.panzhihua.common.model.vos.grid.ComActEasyPhotoVO; |
| | | import com.panzhihua.service_grid.dao.*; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | |
| | | * @return 处理结果 |
| | | */ |
| | | @Override |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R easyHandle(ComActEasyPhotoHandleDTO photoHandleDTO){ |
| | | ComActEasyPhotoDO easyPhotoDO = this.baseMapper.selectById(photoHandleDTO.getId()); |
| | | if(easyPhotoDO == null){ |
| | |
| | | } |
| | | BeanUtils.copyProperties(photoHandleDTO,easyPhotoDO); |
| | | easyPhotoDO.setHandleStatus(ComActEasyPhotoDO.handleStatus.yes); |
| | | easyPhotoDO.setFeedbackAt(new Date()); |
| | | //关联随手拍类型 |
| | | if(!photoHandleDTO.getEasyTypeIds().isEmpty()){ |
| | | List<ComActEasyPhotoTypeRelationDO> typeRelationDOList = new ArrayList<>(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 后台管理-分页查询随手拍列表 |
| | | * @param easyAppDTO 请求参数 |
| | | * @return 随手拍列表 |
| | | */ |
| | | @Override |
| | | public R easyListByAdmin(PageEasyAdminDTO easyAppDTO){ |
| | | IPage<ComActEasyPhotoAdminVO> photoAdminVOIPage = this.baseMapper.easyListByAdmin(new Page(easyAppDTO.getPageNum(),easyAppDTO.getPageSize()), easyAppDTO); |
| | | if(!photoAdminVOIPage.getRecords().isEmpty()){ |
| | | photoAdminVOIPage.getRecords().forEach(photoAdmin -> { |
| | | //随手拍已处理,查询随手拍类型 |
| | | List<String> photoTypeList = comActEasyPhotoTypeRelationMapper.getEasyPhotoTypeRelationByEasyId(photoAdmin.getId()); |
| | | if(!photoTypeList.isEmpty()){ |
| | | photoAdmin.setPhotoTypeList(photoTypeList); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(photoAdminVOIPage); |
| | | } |
| | | |
| | | /** |
| | | * 后台管理-随手拍详情 |
| | | * @param easyId 随手拍id |
| | | * @return 随手拍详情 |
| | | */ |
| | | @Override |
| | | public R easyDetailByAdmin(Long easyId){ |
| | | ComActEasyPhotoAdminVO photoAdminVO = this.baseMapper.easyDetailByAdmin(easyId); |
| | | if(photoAdminVO == null){ |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | if(photoAdminVO.getHandleStatus().equals(ComActEasyPhotoDO.handleStatus.yes)){ |
| | | //随手拍已处理,查询随手拍类型 |
| | | List<String> photoTypeList = comActEasyPhotoTypeRelationMapper.getEasyPhotoTypeRelationByEasyId(photoAdminVO.getId()); |
| | | if(!photoTypeList.isEmpty()){ |
| | | photoAdminVO.setPhotoTypeList(photoTypeList); |
| | | } |
| | | } |
| | | return R.ok(photoAdminVO); |
| | | } |
| | | |
| | | /** |
| | | * 后台管理-随手拍处理 |
| | | * @param photoHandleDTO 请求参数 |
| | | * @return 处理结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R easyHandleByAdmin(ComActEasyPhotoHandleDTO photoHandleDTO){ |
| | | ComActEasyPhotoDO easyPhotoDO = this.baseMapper.selectById(photoHandleDTO.getId()); |
| | | if(easyPhotoDO == null){ |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | if(easyPhotoDO.getIsReport().equals(ComActEasyPhotoDO.isReport.no)){ |
| | | return R.fail("该随手拍未上报,不可处理"); |
| | | } |
| | | if(easyPhotoDO.getHandleStatus().equals(ComActEasyPhotoDO.handleStatus.yes)){ |
| | | return R.fail("该随手拍已处理"); |
| | | } |
| | | BeanUtils.copyProperties(photoHandleDTO,easyPhotoDO); |
| | | easyPhotoDO.setHandleStatus(ComActEasyPhotoDO.handleStatus.yes); |
| | | //关联随手拍类型 |
| | | if(!photoHandleDTO.getEasyTypeIds().isEmpty()){ |
| | | List<ComActEasyPhotoTypeRelationDO> typeRelationDOList = new ArrayList<>(); |
| | | photoHandleDTO.getEasyTypeIds().forEach(typeId -> { |
| | | ComActEasyPhotoTypeRelationDO typeRelationDO = new ComActEasyPhotoTypeRelationDO(); |
| | | typeRelationDO.setEasyId(easyPhotoDO.getId()); |
| | | typeRelationDO.setEasyTypeId(typeId); |
| | | typeRelationDO.setCreateAt(new Date()); |
| | | typeRelationDOList.add(typeRelationDO); |
| | | }); |
| | | comActEasyPhotoTypeRelationService.saveBatch(typeRelationDOList); |
| | | } |
| | | if(this.baseMapper.updateById(easyPhotoDO) > 0){ |
| | | return R.ok(); |
| | | }else{ |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 后台管理-批量修改随手拍公示状态/删除随手拍 |
| | | * @param photoEditDTO 请求参数 |
| | | * @return 修改/删除结果 |
| | | */ |
| | | @Override |
| | | public R easyPublicityByAdmin(ComActEasyPhotoEditAdminDTO photoEditDTO){ |
| | | if(this.baseMapper.easyPublicityByAdmin(photoEditDTO) > 0){ |
| | | return R.ok(); |
| | | }else{ |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | } |