| | |
| | | package com.panzhihua.service_grid.service.impl; |
| | | |
| | | 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.grid.ComActEasyPhotoAddDTO; |
| | | import com.panzhihua.common.model.dtos.grid.ComActEasyPhotoDeleteDTO; |
| | | import com.panzhihua.common.model.dtos.grid.ComActEasyPhotoEditDTO; |
| | | import com.panzhihua.common.model.dtos.grid.PageComActEasyPhotoDTO; |
| | | 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 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 org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @auther lyq |
| | |
| | | |
| | | @Resource |
| | | private ComActEasyPhotoMapper comActEasyPhotoMapper; |
| | | @Resource |
| | | private ComActEasyPhotoTypeRelationMapper comActEasyPhotoTypeRelationMapper; |
| | | @Resource |
| | | private ComActEasyPhotoTypeRelationService comActEasyPhotoTypeRelationService; |
| | | /** |
| | | * 新增社区活动 》随手拍 |
| | | * @param comActEasyPhotoAddDTO |
| | |
| | | |
| | | /** |
| | | * 分页查找社区活动 》随手拍 |
| | | * @param pageComActEasyPhotoDTO |
| | | * @param easyAppDTO |
| | | * @return 维护结果 |
| | | */ |
| | | public R<IPage<ComActEasyPhotoVO>> query(PageComActEasyPhotoDTO pageComActEasyPhotoDTO){ |
| | | Page page = new Page(1,10); |
| | | if(pageComActEasyPhotoDTO.getPageNum()!=null) { |
| | | page.setCurrent(pageComActEasyPhotoDTO.getPageNum()); |
| | | 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; |
| | | case 2: |
| | | easyAppDTO.setIsReport(1); |
| | | break; |
| | | case 3: |
| | | easyAppDTO.setIsPublicity(1); |
| | | break; |
| | | case 4: |
| | | easyAppDTO.setIsPublicity(0); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | if(pageComActEasyPhotoDTO.getPageSize()!=null) { |
| | | page.setSize(pageComActEasyPhotoDTO.getPageSize()); |
| | | } |
| | | return R.ok(comActEasyPhotoMapper.findByPage(page, pageComActEasyPhotoDTO)); |
| | | return R.ok(comActEasyPhotoMapper.findByPage(page, easyAppDTO)); |
| | | } |
| | | |
| | | /** |
| | |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 根据随手拍id查询随手拍详情 |
| | | * @param easyId 随手拍id |
| | | * @return 随手拍详情 |
| | | */ |
| | | @Override |
| | | public R detail(Long easyId){ |
| | | ComActEasyPhotoVO easyPhotoVO = this.baseMapper.findByEaseId(easyId); |
| | | if(easyPhotoVO != null){ |
| | | //查询随手拍类型 |
| | | List<String> typeRelationList = comActEasyPhotoTypeRelationMapper.getEasyPhotoTypeRelationByEasyId(easyId); |
| | | if(!typeRelationList.isEmpty()){ |
| | | easyPhotoVO.setEasyPhotoList(typeRelationList); |
| | | } |
| | | } |
| | | return R.ok(easyPhotoVO); |
| | | } |
| | | |
| | | /** |
| | | * 随手拍处理 |
| | | * @param photoHandleDTO 请求参数 |
| | | * @return 处理结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 后台管理-分页查询随手拍列表 |
| | | * @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(); |
| | | } |
| | | } |
| | | |
| | | } |