New file |
| | |
| | | package com.panzhihua.service_community.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.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO; |
| | | import com.panzhihua.common.model.vos.community.TodoEventsVO; |
| | | import com.panzhihua.service_community.dao.ComActEasyPhotoDAO; |
| | | import com.panzhihua.service_community.dao.ComActEasyPhotoUserDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActEasyPhotoDO; |
| | | import com.panzhihua.service_community.model.dos.ComActEasyPhotoUserDO; |
| | | import com.panzhihua.service_community.service.ComActEasyPhotoService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | | * @description: 随手拍 |
| | | * @author: huang.hongfa weixin hhf9596 qq 959656820 |
| | | * @create: 2020-12-07 14:31 |
| | | **/ |
| | | @Service |
| | | public class ComActEasyPhotoServiceImpl extends ServiceImpl<ComActEasyPhotoDAO, ComActEasyPhotoDO> implements ComActEasyPhotoService { |
| | | @Resource |
| | | private ComActEasyPhotoDAO comActEasyPhotoDAO; |
| | | @Resource |
| | | private ComActEasyPhotoUserDAO comActEasyPhotoUserDAO; |
| | | /** |
| | | * 分页查询随手拍 |
| | | * |
| | | * @param comActEasyPhotoVO 查询参数 |
| | | * @return 心愿列表 |
| | | */ |
| | | @Override |
| | | public R pageEasyPhoto(ComActEasyPhotoVO comActEasyPhotoVO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = comActEasyPhotoVO.getPageNum(); |
| | | Long pageSize = comActEasyPhotoVO.getPageSize(); |
| | | Long userId = comActEasyPhotoVO.getLogInUserId(); |
| | | if (null==pageNum||0==pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (null==pageSize||0==pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<ComActEasyPhotoVO> iPage = comActEasyPhotoDAO.pageEasyPhoto(page, comActEasyPhotoVO); |
| | | List<ComActEasyPhotoVO> records = iPage.getRecords(); |
| | | if (!ObjectUtils.isEmpty(records)) { |
| | | records.forEach(comActEasyPhotoVO1 -> { |
| | | Long id = comActEasyPhotoVO1.getId(); |
| | | ComActEasyPhotoUserDO comActEasyPhotoUserDO = comActEasyPhotoUserDAO.selectOne(new QueryWrapper<ComActEasyPhotoUserDO>().lambda().eq(ComActEasyPhotoUserDO::getEasyPhotoId, id).eq(ComActEasyPhotoUserDO::getUserId, userId)); |
| | | if (ObjectUtils.isEmpty(comActEasyPhotoUserDO)) { |
| | | comActEasyPhotoVO1.setHaveGiveThumbsUp(0); |
| | | }else { |
| | | comActEasyPhotoVO1.setHaveGiveThumbsUp(1); |
| | | } |
| | | }); |
| | | iPage.setRecords(records); |
| | | } |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | /** |
| | | * 随手拍详情 |
| | | * |
| | | * @param id 随手拍主键 |
| | | * @param userId |
| | | * @return 详情内容 |
| | | */ |
| | | @Override |
| | | public R detailEasyPhoto(Long id, Long userId) { |
| | | ComActEasyPhotoVO comActEasyPhotoVO=comActEasyPhotoDAO.detailEasyPhoto(id); |
| | | if (ObjectUtils.isEmpty(comActEasyPhotoVO)||null==comActEasyPhotoVO.getStatus()) { |
| | | return R.fail("随手拍不存在"); |
| | | } |
| | | ComActEasyPhotoUserDO comActEasyPhotoUserDO = comActEasyPhotoUserDAO.selectOne(new QueryWrapper<ComActEasyPhotoUserDO>().lambda().eq(ComActEasyPhotoUserDO::getEasyPhotoId, id).eq(ComActEasyPhotoUserDO::getUserId, userId)); |
| | | if (ObjectUtils.isEmpty(comActEasyPhotoUserDO)) { |
| | | comActEasyPhotoVO.setHaveGiveThumbsUp(0); |
| | | } else { |
| | | comActEasyPhotoVO.setHaveGiveThumbsUp(1); |
| | | } |
| | | return R.ok(comActEasyPhotoVO); |
| | | } |
| | | |
| | | /** |
| | | * 上传随手拍 |
| | | * |
| | | * @param comActEasyPhotoVO 上传数据 |
| | | * @return 上传结果 |
| | | */ |
| | | @Override |
| | | public R addEasyPhoto(ComActEasyPhotoVO comActEasyPhotoVO) { |
| | | ComActEasyPhotoDO comActEasyPhotoDO=new ComActEasyPhotoDO(); |
| | | BeanUtils.copyProperties(comActEasyPhotoVO,comActEasyPhotoDO); |
| | | int insert = comActEasyPhotoDAO.insert(comActEasyPhotoDO); |
| | | if (insert>0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 点赞/取消点赞随手拍 |
| | | * |
| | | * @param comActEasyPhotoVO 操作参数 |
| | | * @return 操作结果 |
| | | */ |
| | | @Override |
| | | public R putEasyPhoto(ComActEasyPhotoVO comActEasyPhotoVO) { |
| | | Integer haveGiveThumbsUp = comActEasyPhotoVO.getHaveGiveThumbsUp(); |
| | | Long userId = comActEasyPhotoVO.getSponsorId(); |
| | | Long easyPhotoId = comActEasyPhotoVO.getId(); |
| | | ComActEasyPhotoUserDO comActEasyPhotoUserDO = comActEasyPhotoUserDAO.selectOne(new QueryWrapper<ComActEasyPhotoUserDO>().lambda().eq(ComActEasyPhotoUserDO::getUserId, userId).eq(ComActEasyPhotoUserDO::getEasyPhotoId, easyPhotoId)); |
| | | boolean empty = ObjectUtils.isEmpty(comActEasyPhotoUserDO); |
| | | int num=0; |
| | | if (haveGiveThumbsUp.intValue()==1) { |
| | | if(empty){ |
| | | ComActEasyPhotoUserDO comActEasyPhotoUserDO1=new ComActEasyPhotoUserDO(); |
| | | comActEasyPhotoUserDO1.setEasyPhotoId(easyPhotoId); |
| | | comActEasyPhotoUserDO1.setUserId(userId); |
| | | num=comActEasyPhotoUserDAO.insert(comActEasyPhotoUserDO1); |
| | | }else{ |
| | | return R.ok(); |
| | | } |
| | | }else{ |
| | | if(empty){ |
| | | return R.ok(); |
| | | }else{ |
| | | num=comActEasyPhotoUserDAO.deleteById(comActEasyPhotoUserDO.getId()); |
| | | } |
| | | } |
| | | if (num>0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 审核反馈随手拍 |
| | | * |
| | | * @param comActEasyPhotoVO 操作参数 |
| | | * @return 操作结果 |
| | | */ |
| | | @Override |
| | | public R putEasypHotoStatus(ComActEasyPhotoVO comActEasyPhotoVO) { |
| | | Integer type = comActEasyPhotoVO.getType(); |
| | | // 操作类型 1审核通过 2驳回 3反馈 |
| | | ComActEasyPhotoDO cmActEasyPhotoDO=new ComActEasyPhotoDO(); |
| | | cmActEasyPhotoDO.setId(comActEasyPhotoVO.getId()); |
| | | cmActEasyPhotoDO.setHandlerId(comActEasyPhotoVO.getUserId()); |
| | | Date date = new Date(); |
| | | switch (type){ |
| | | case 1: |
| | | int isNeedFeedBack = comActEasyPhotoVO.getIsNeedFeedBack().intValue(); |
| | | if (isNeedFeedBack==1) { |
| | | cmActEasyPhotoDO.setStatus(2);//进行中 |
| | | cmActEasyPhotoDO.setIsNeedFeedBack(1); |
| | | }else{ |
| | | cmActEasyPhotoDO.setStatus(4);//已完成 |
| | | } |
| | | cmActEasyPhotoDO.setExamineAt(date); |
| | | break; |
| | | case 2: |
| | | cmActEasyPhotoDO.setStatus(3);//已驳回 |
| | | cmActEasyPhotoDO.setExamineAt(date); |
| | | cmActEasyPhotoDO.setRejectReason(comActEasyPhotoVO.getRejectReason()); |
| | | break; |
| | | case 3: |
| | | cmActEasyPhotoDO.setHandleResult(comActEasyPhotoVO.getHandleResult()); |
| | | cmActEasyPhotoDO.setHandlePhotoList(comActEasyPhotoVO.getHandlePhotoList()); |
| | | cmActEasyPhotoDO.setStatus(4);//已完成 |
| | | cmActEasyPhotoDO.setFeedbackAt(date); |
| | | break; |
| | | default:break; |
| | | } |
| | | int update = comActEasyPhotoDAO.updateById(cmActEasyPhotoDO); |
| | | if (update>0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 随手拍是否有待审核和带反馈的事件 |
| | | * |
| | | * @param communityId 社区id |
| | | * @param userId 登录用户id |
| | | * @return 待处理事件集合 |
| | | */ |
| | | @Override |
| | | public List<TodoEventsVO> selectNeedToDo(Long communityId, Long userId) { |
| | | List<TodoEventsVO> todoEventsVOS=comActEasyPhotoDAO.selectNeedToDo(communityId,userId); |
| | | return todoEventsVOS; |
| | | } |
| | | } |