| | |
| | | import com.panzhihua.service_grid.dao.*; |
| | | import com.panzhihua.service_grid.model.dos.*; |
| | | import com.panzhihua.service_grid.service.ComActEasyPhotoService; |
| | | import com.panzhihua.service_grid.service.ComActEasyPhotoTypeRelationService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.beans.BeanUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | private ComActEasyPhotoMapper comActEasyPhotoMapper; |
| | | @Resource |
| | | private ComActEasyPhotoTypeRelationMapper comActEasyPhotoTypeRelationMapper; |
| | | @Resource |
| | | private ComActEasyPhotoTypeRelationService comActEasyPhotoTypeRelationService; |
| | | /** |
| | | * 新增社区活动 》随手拍 |
| | | * @param comActEasyPhotoAddDTO |
| | |
| | | return R.ok(easyPhotoVO); |
| | | } |
| | | |
| | | /** |
| | | * 随手拍处理 |
| | | * @param photoHandleDTO 请求参数 |
| | | * @return 处理结果 |
| | | */ |
| | | @Override |
| | | |
| | | public R easyHandle(ComActEasyPhotoHandleDTO photoHandleDTO){ |
| | | ComActEasyPhotoDO easyPhotoDO = this.baseMapper.selectById(photoHandleDTO.getId()); |
| | | if(easyPhotoDO == null){ |
| | | 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 photoHandleDTO 请求参数 |
| | | * @return 切换结果 |
| | | */ |
| | | @Override |
| | | public R easyPublicity(ComActEasyPhotoHandleDTO photoHandleDTO){ |
| | | |
| | | ComActEasyPhotoDO easyPhotoDO = this.baseMapper.selectById(photoHandleDTO.getId()); |
| | | if(easyPhotoDO == null){ |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | easyPhotoDO.setIsPublicity(photoHandleDTO.getIsPublicity()); |
| | | if(this.baseMapper.updateById(easyPhotoDO) > 0){ |
| | | return R.ok(); |
| | | }else{ |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 随手拍上报社区 |
| | | * @param photoHandleDTO 请求参数 |
| | | * @return 上报结果 |
| | | */ |
| | | @Override |
| | | public R easyReport(ComActEasyPhotoHandleDTO photoHandleDTO){ |
| | | ComActEasyPhotoDO easyPhotoDO = this.baseMapper.selectById(photoHandleDTO.getId()); |
| | | if(easyPhotoDO == null){ |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | if(easyPhotoDO.getIsReport().equals(ComActEasyPhotoDO.isReport.yes)){ |
| | | return R.fail("随手拍已上报"); |
| | | } |
| | | easyPhotoDO.setIsReport(ComActEasyPhotoDO.isReport.yes); |
| | | if(this.baseMapper.updateById(easyPhotoDO) > 0){ |
| | | return R.ok(); |
| | | }else{ |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | } |