| | |
| | | package com.panzhihua.service_grid.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | 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 com.panzhihua.service_grid.model.dos.*; |
| | | import com.panzhihua.service_grid.dao.ComActEasyPhotoMapper; |
| | | import com.panzhihua.service_grid.dao.ComActEasyPhotoTypeRelationMapper; |
| | | import com.panzhihua.service_grid.model.dos.ComActEasyPhotoDO; |
| | | import com.panzhihua.service_grid.model.dos.ComActEasyPhotoTypeRelationDO; |
| | | 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 org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @auther lyq |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComActEasyPhotoServiceImpl extends ServiceImpl<ComActEasyPhotoMapper, ComActEasyPhotoDO> implements ComActEasyPhotoService { |
| | | public class ComActEasyPhotoServiceImpl extends ServiceImpl<ComActEasyPhotoMapper, ComActEasyPhotoDO> |
| | | implements ComActEasyPhotoService { |
| | | |
| | | @Resource |
| | | private ComActEasyPhotoMapper comActEasyPhotoMapper; |
| | |
| | | private ComActEasyPhotoTypeRelationMapper comActEasyPhotoTypeRelationMapper; |
| | | @Resource |
| | | private ComActEasyPhotoTypeRelationService comActEasyPhotoTypeRelationService; |
| | | |
| | | /** |
| | | * 新增社区活动 》随手拍 |
| | | * |
| | | * @param comActEasyPhotoAddDTO |
| | | * @return 新增结果 |
| | | */ |
| | | public R add(ComActEasyPhotoAddDTO comActEasyPhotoAddDTO){ |
| | | public R add(ComActEasyPhotoAddDTO comActEasyPhotoAddDTO) { |
| | | ComActEasyPhotoDO comActEasyPhotoDO = new ComActEasyPhotoDO(); |
| | | BeanUtils.copyProperties(comActEasyPhotoAddDTO, comActEasyPhotoDO); |
| | | comActEasyPhotoDO.setCreateAt(new Date()); |
| | | if(comActEasyPhotoMapper.insert(comActEasyPhotoDO)>0){ |
| | | if (comActEasyPhotoMapper.insert(comActEasyPhotoDO) > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | |
| | | |
| | | /** |
| | | * 修改社区活动 》随手拍 |
| | | * |
| | | * @param comActEasyPhotoEditDTO |
| | | * @return 维护结果 |
| | | */ |
| | | public R edit(ComActEasyPhotoEditDTO comActEasyPhotoEditDTO){ |
| | | public R edit(ComActEasyPhotoEditDTO comActEasyPhotoEditDTO) { |
| | | ComActEasyPhotoDO comActEasyPhotoDO = new ComActEasyPhotoDO(); |
| | | BeanUtils.copyProperties(comActEasyPhotoEditDTO, comActEasyPhotoDO); |
| | | //comActEasyPhotoDO.setUpdateAt(new Date()); |
| | | if(comActEasyPhotoMapper.updateById(comActEasyPhotoDO)>0){ |
| | | // comActEasyPhotoDO.setUpdateAt(new Date()); |
| | | if (comActEasyPhotoMapper.updateById(comActEasyPhotoDO) > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | |
| | | |
| | | /** |
| | | * 分页查找社区活动 》随手拍 |
| | | * |
| | | * @param easyAppDTO |
| | | * @return 维护结果 |
| | | */ |
| | | public R<IPage<ComActEasyPhotoVO>> query(PageEasyAppDTO easyAppDTO){ |
| | | Page page = new Page(easyAppDTO.getPageNum(),easyAppDTO.getPageSize()); |
| | | if(easyAppDTO.getStatus() != null){ |
| | | switch (easyAppDTO.getStatus()){ |
| | | public R<IPage<ComActEasyPhotoVO>> query(PageEasyAppDTO easyAppDTO) { |
| | | Page page = new Page(easyAppDTO.getPageNum(), easyAppDTO.getPageSize()); |
| | | if (easyAppDTO.getStatus() != null) { |
| | | switch (easyAppDTO.getStatus()) { |
| | | case 1: |
| | | easyAppDTO.setHandleStatus(1); |
| | | break; |
| | |
| | | |
| | | /** |
| | | * 删除社区活动 》随手拍 |
| | | * |
| | | * @param ComActEasyPhotoDeleteDTO |
| | | * @return 平台用户信息 |
| | | */ |
| | | public R delete(ComActEasyPhotoDeleteDTO ComActEasyPhotoDeleteDTO){ |
| | | public R delete(ComActEasyPhotoDeleteDTO ComActEasyPhotoDeleteDTO) { |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 查询社区活动 》随手拍详细信息 |
| | | * @param id 社区活动 》随手拍 id |
| | | * |
| | | * @param id |
| | | * 社区活动 》随手拍 id |
| | | * @return 查找结果 |
| | | */ |
| | | public R<ComActEasyPhotoDetailsVO> comActEasyPhotoDetails(Long id){ |
| | | public R<ComActEasyPhotoDetailsVO> comActEasyPhotoDetails(Long id) { |
| | | ComActEasyPhotoDO comActEasyPhotoDO = comActEasyPhotoMapper.selectById(id); |
| | | if(comActEasyPhotoDO!=null) { |
| | | if (comActEasyPhotoDO != null) { |
| | | ComActEasyPhotoDetailsVO comActEasyPhotoDetailsVO = new ComActEasyPhotoDetailsVO(); |
| | | BeanUtils.copyProperties(comActEasyPhotoDO, comActEasyPhotoDetailsVO); |
| | | return R.ok(comActEasyPhotoDetailsVO); |
| | |
| | | |
| | | /** |
| | | * 根据随手拍id查询随手拍详情 |
| | | * @param easyId 随手拍id |
| | | * @return 随手拍详情 |
| | | * |
| | | * @param easyId |
| | | * 随手拍id |
| | | * @return 随手拍详情 |
| | | */ |
| | | @Override |
| | | public R detail(Long easyId){ |
| | | public R detail(Long easyId) { |
| | | ComActEasyPhotoVO easyPhotoVO = this.baseMapper.findByEaseId(easyId); |
| | | if(easyPhotoVO != null){ |
| | | //查询随手拍类型 |
| | | if (easyPhotoVO != null) { |
| | | // 查询随手拍类型 |
| | | List<String> typeRelationList = comActEasyPhotoTypeRelationMapper.getEasyPhotoTypeRelationByEasyId(easyId); |
| | | if(!typeRelationList.isEmpty()){ |
| | | if (!typeRelationList.isEmpty()) { |
| | | easyPhotoVO.setEasyPhotoList(typeRelationList); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 随手拍处理 |
| | | * @param photoHandleDTO 请求参数 |
| | | * @return 处理结果 |
| | | * |
| | | * @param photoHandleDTO |
| | | * 请求参数 |
| | | * @return 处理结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R easyHandle(ComActEasyPhotoHandleDTO photoHandleDTO){ |
| | | public R easyHandle(ComActEasyPhotoHandleDTO photoHandleDTO) { |
| | | ComActEasyPhotoDO easyPhotoDO = this.baseMapper.selectById(photoHandleDTO.getId()); |
| | | if(easyPhotoDO == null){ |
| | | if (easyPhotoDO == null) { |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | if(easyPhotoDO.getHandleStatus().equals(ComActEasyPhotoDO.handleStatus.yes)){ |
| | | if (easyPhotoDO.getHandleStatus().equals(ComActEasyPhotoDO.handleStatus.yes)) { |
| | | return R.fail("该随手拍已处理"); |
| | | } |
| | | BeanUtils.copyProperties(photoHandleDTO,easyPhotoDO); |
| | | BeanUtils.copyProperties(photoHandleDTO, easyPhotoDO); |
| | | easyPhotoDO.setHandleStatus(ComActEasyPhotoDO.handleStatus.yes); |
| | | easyPhotoDO.setFeedbackAt(new Date()); |
| | | //关联随手拍类型 |
| | | if(!photoHandleDTO.getEasyTypeIds().isEmpty()){ |
| | | // 关联随手拍类型 |
| | | if (!photoHandleDTO.getEasyTypeIds().isEmpty()) { |
| | | List<ComActEasyPhotoTypeRelationDO> typeRelationDOList = new ArrayList<>(); |
| | | photoHandleDTO.getEasyTypeIds().forEach(typeId -> { |
| | | ComActEasyPhotoTypeRelationDO typeRelationDO = new ComActEasyPhotoTypeRelationDO(); |
| | |
| | | }); |
| | | comActEasyPhotoTypeRelationService.saveBatch(typeRelationDOList); |
| | | } |
| | | if(this.baseMapper.updateById(easyPhotoDO) > 0){ |
| | | if (this.baseMapper.updateById(easyPhotoDO) > 0) { |
| | | return R.ok(); |
| | | }else{ |
| | | } else { |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 随手拍公示状态切换 |
| | | * @param photoHandleDTO 请求参数 |
| | | * @return 切换结果 |
| | | * |
| | | * @param photoHandleDTO |
| | | * 请求参数 |
| | | * @return 切换结果 |
| | | */ |
| | | @Override |
| | | public R easyPublicity(ComActEasyPhotoHandleDTO photoHandleDTO){ |
| | | public R easyPublicity(ComActEasyPhotoHandleDTO photoHandleDTO) { |
| | | |
| | | ComActEasyPhotoDO easyPhotoDO = this.baseMapper.selectById(photoHandleDTO.getId()); |
| | | if(easyPhotoDO == null){ |
| | | if (easyPhotoDO == null) { |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | easyPhotoDO.setIsPublicity(photoHandleDTO.getIsPublicity()); |
| | | if(this.baseMapper.updateById(easyPhotoDO) > 0){ |
| | | if (this.baseMapper.updateById(easyPhotoDO) > 0) { |
| | | return R.ok(); |
| | | }else{ |
| | | } else { |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 随手拍上报社区 |
| | | * @param photoHandleDTO 请求参数 |
| | | * @return 上报结果 |
| | | * |
| | | * @param photoHandleDTO |
| | | * 请求参数 |
| | | * @return 上报结果 |
| | | */ |
| | | @Override |
| | | public R easyReport(ComActEasyPhotoHandleDTO photoHandleDTO){ |
| | | public R easyReport(ComActEasyPhotoHandleDTO photoHandleDTO) { |
| | | ComActEasyPhotoDO easyPhotoDO = this.baseMapper.selectById(photoHandleDTO.getId()); |
| | | if(easyPhotoDO == null){ |
| | | if (easyPhotoDO == null) { |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | if(easyPhotoDO.getIsReport().equals(ComActEasyPhotoDO.isReport.yes)){ |
| | | if (easyPhotoDO.getIsReport().equals(ComActEasyPhotoDO.isReport.yes)) { |
| | | return R.fail("随手拍已上报"); |
| | | } |
| | | easyPhotoDO.setIsReport(ComActEasyPhotoDO.isReport.yes); |
| | | if(this.baseMapper.updateById(easyPhotoDO) > 0){ |
| | | if (this.baseMapper.updateById(easyPhotoDO) > 0) { |
| | | return R.ok(); |
| | | }else{ |
| | | } else { |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 后台管理-分页查询随手拍列表 |
| | | * @param easyAppDTO 请求参数 |
| | | * @return 随手拍列表 |
| | | * |
| | | * @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()){ |
| | | 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()){ |
| | | // 随手拍已处理,查询随手拍类型 |
| | | List<String> photoTypeList = |
| | | comActEasyPhotoTypeRelationMapper.getEasyPhotoTypeRelationByEasyId(photoAdmin.getId()); |
| | | if (!photoTypeList.isEmpty()) { |
| | | photoAdmin.setPhotoTypeList(photoTypeList); |
| | | } |
| | | }); |
| | |
| | | |
| | | /** |
| | | * 后台管理-随手拍详情 |
| | | * @param easyId 随手拍id |
| | | * @return 随手拍详情 |
| | | * |
| | | * @param easyId |
| | | * 随手拍id |
| | | * @return 随手拍详情 |
| | | */ |
| | | @Override |
| | | public R easyDetailByAdmin(Long easyId){ |
| | | public R easyDetailByAdmin(Long easyId) { |
| | | ComActEasyPhotoAdminVO photoAdminVO = this.baseMapper.easyDetailByAdmin(easyId); |
| | | if(photoAdminVO == null){ |
| | | if (photoAdminVO == null) { |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | if(photoAdminVO.getHandleStatus().equals(ComActEasyPhotoDO.handleStatus.yes)){ |
| | | //随手拍已处理,查询随手拍类型 |
| | | List<String> photoTypeList = comActEasyPhotoTypeRelationMapper.getEasyPhotoTypeRelationByEasyId(photoAdminVO.getId()); |
| | | if(!photoTypeList.isEmpty()){ |
| | | if (photoAdminVO.getHandleStatus().equals(ComActEasyPhotoDO.handleStatus.yes)) { |
| | | // 随手拍已处理,查询随手拍类型 |
| | | List<String> photoTypeList = |
| | | comActEasyPhotoTypeRelationMapper.getEasyPhotoTypeRelationByEasyId(photoAdminVO.getId()); |
| | | if (!photoTypeList.isEmpty()) { |
| | | photoAdminVO.setPhotoTypeList(photoTypeList); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 后台管理-随手拍处理 |
| | | * @param photoHandleDTO 请求参数 |
| | | * @return 处理结果 |
| | | * |
| | | * @param photoHandleDTO |
| | | * 请求参数 |
| | | * @return 处理结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R easyHandleByAdmin(ComActEasyPhotoHandleDTO photoHandleDTO){ |
| | | public R easyHandleByAdmin(ComActEasyPhotoHandleDTO photoHandleDTO) { |
| | | ComActEasyPhotoDO easyPhotoDO = this.baseMapper.selectById(photoHandleDTO.getId()); |
| | | if(easyPhotoDO == null){ |
| | | if (easyPhotoDO == null) { |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | if(easyPhotoDO.getIsReport().equals(ComActEasyPhotoDO.isReport.no)){ |
| | | if (easyPhotoDO.getIsReport().equals(ComActEasyPhotoDO.isReport.no)) { |
| | | return R.fail("该随手拍未上报,不可处理"); |
| | | } |
| | | if(easyPhotoDO.getHandleStatus().equals(ComActEasyPhotoDO.handleStatus.yes)){ |
| | | if (easyPhotoDO.getHandleStatus().equals(ComActEasyPhotoDO.handleStatus.yes)) { |
| | | return R.fail("该随手拍已处理"); |
| | | } |
| | | BeanUtils.copyProperties(photoHandleDTO,easyPhotoDO); |
| | | BeanUtils.copyProperties(photoHandleDTO, easyPhotoDO); |
| | | easyPhotoDO.setHandleStatus(ComActEasyPhotoDO.handleStatus.yes); |
| | | //关联随手拍类型 |
| | | if(!photoHandleDTO.getEasyTypeIds().isEmpty()){ |
| | | // 关联随手拍类型 |
| | | if (!photoHandleDTO.getEasyTypeIds().isEmpty()) { |
| | | List<ComActEasyPhotoTypeRelationDO> typeRelationDOList = new ArrayList<>(); |
| | | photoHandleDTO.getEasyTypeIds().forEach(typeId -> { |
| | | ComActEasyPhotoTypeRelationDO typeRelationDO = new ComActEasyPhotoTypeRelationDO(); |
| | |
| | | }); |
| | | comActEasyPhotoTypeRelationService.saveBatch(typeRelationDOList); |
| | | } |
| | | if(this.baseMapper.updateById(easyPhotoDO) > 0){ |
| | | if (this.baseMapper.updateById(easyPhotoDO) > 0) { |
| | | return R.ok(); |
| | | }else{ |
| | | } else { |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 后台管理-批量修改随手拍公示状态/删除随手拍 |
| | | * @param photoEditDTO 请求参数 |
| | | * @return 修改/删除结果 |
| | | * |
| | | * @param photoEditDTO |
| | | * 请求参数 |
| | | * @return 修改/删除结果 |
| | | */ |
| | | @Override |
| | | public R easyPublicityByAdmin(ComActEasyPhotoEditAdminDTO photoEditDTO){ |
| | | public R easyPublicityByAdmin(ComActEasyPhotoEditAdminDTO photoEditDTO) { |
| | | |
| | | if(photoEditDTO.getType().equals(1)){ |
| | | if (photoEditDTO.getType().equals(1)) { |
| | | Integer count = this.baseMapper.selectCount(new QueryWrapper<ComActEasyPhotoDO>().lambda() |
| | | .eq(ComActEasyPhotoDO::getHandleStatus,ComActEasyPhotoDO.handleStatus.no).in(ComActEasyPhotoDO::getId,photoEditDTO.getIds())); |
| | | if(count > 0){ |
| | | .eq(ComActEasyPhotoDO::getHandleStatus, ComActEasyPhotoDO.handleStatus.no) |
| | | .in(ComActEasyPhotoDO::getId, photoEditDTO.getIds())); |
| | | if (count > 0) { |
| | | return R.fail("您选择的有未处理的随手拍,不可进行操作"); |
| | | } |
| | | } |
| | | |
| | | if(this.baseMapper.easyPublicityByAdmin(photoEditDTO) > 0){ |
| | | if (this.baseMapper.easyPublicityByAdmin(photoEditDTO) > 0) { |
| | | return R.ok(); |
| | | }else{ |
| | | } else { |
| | | return R.fail(); |
| | | } |
| | | } |