New file |
| | |
| | | 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.*; |
| | | import com.panzhihua.common.model.vos.R; |
| | | 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 javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @auther lyq |
| | | * @create 2021-04-14 15:03:01 |
| | | * @describe 订单表服务实现类 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComActEasyPhotoServiceImpl extends ServiceImpl<ComActEasyPhotoMapper, ComActEasyPhotoDO> implements ComActEasyPhotoService { |
| | | |
| | | @Resource |
| | | private ComActEasyPhotoMapper comActEasyPhotoMapper; |
| | | @Resource |
| | | private ComActEasyPhotoTypeRelationMapper comActEasyPhotoTypeRelationMapper; |
| | | @Resource |
| | | private ComActEasyPhotoTypeRelationService comActEasyPhotoTypeRelationService; |
| | | /** |
| | | * 新增社区活动 》随手拍 |
| | | * @param comActEasyPhotoAddDTO |
| | | * @return 新增结果 |
| | | */ |
| | | public R add(ComActEasyPhotoAddDTO comActEasyPhotoAddDTO){ |
| | | ComActEasyPhotoDO comActEasyPhotoDO = new ComActEasyPhotoDO(); |
| | | BeanUtils.copyProperties(comActEasyPhotoAddDTO, comActEasyPhotoDO); |
| | | comActEasyPhotoDO.setCreateAt(new Date()); |
| | | if(comActEasyPhotoMapper.insert(comActEasyPhotoDO)>0){ |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 修改社区活动 》随手拍 |
| | | * @param comActEasyPhotoEditDTO |
| | | * @return 维护结果 |
| | | */ |
| | | public R edit(ComActEasyPhotoEditDTO comActEasyPhotoEditDTO){ |
| | | ComActEasyPhotoDO comActEasyPhotoDO = new ComActEasyPhotoDO(); |
| | | BeanUtils.copyProperties(comActEasyPhotoEditDTO, comActEasyPhotoDO); |
| | | //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()){ |
| | | 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; |
| | | } |
| | | } |
| | | return R.ok(comActEasyPhotoMapper.findByPage(page, easyAppDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 删除社区活动 》随手拍 |
| | | * @param ComActEasyPhotoDeleteDTO |
| | | * @return 平台用户信息 |
| | | */ |
| | | public R delete(ComActEasyPhotoDeleteDTO ComActEasyPhotoDeleteDTO){ |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 查询社区活动 》随手拍详细信息 |
| | | * @param id 社区活动 》随手拍 id |
| | | * @return 查找结果 |
| | | */ |
| | | public R<ComActEasyPhotoDetailsVO> comActEasyPhotoDetails(Long id){ |
| | | ComActEasyPhotoDO comActEasyPhotoDO = comActEasyPhotoMapper.selectById(id); |
| | | if(comActEasyPhotoDO!=null) { |
| | | ComActEasyPhotoDetailsVO comActEasyPhotoDetailsVO = new ComActEasyPhotoDetailsVO(); |
| | | BeanUtils.copyProperties(comActEasyPhotoDO, comActEasyPhotoDetailsVO); |
| | | return R.ok(comActEasyPhotoDetailsVO); |
| | | } |
| | | 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 |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | } |