no
DESKTOP-71BH0QO\L、ming
2021-04-28 f114009511545cc291e5c368474558a241fe90f0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.panzhihua.service_community.service.impl;
import java.util.Date;
 
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.neighbor.ComActNeighborCircleAdminDTO;
import com.panzhihua.common.model.dtos.neighbor.ComActNeighborCircleAppDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.neighbor.AddNeighborCircleAdminVO;
import com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAdminVO;
import com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAppVO;
import com.panzhihua.common.model.vos.neighbor.EditNeighborCircleAdminVO;
import com.panzhihua.common.model.vos.user.AdministratorsUserVO;
import com.panzhihua.service_community.dao.ComActNeighborCircleDAO;
import com.panzhihua.service_community.model.dos.ComActNeighborCircleDO;
import com.panzhihua.service_community.service.ComActNeighborCircleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
/**
 * @auther lyq
 * @create 2021-04-28 09:20:49
 * @describe 邻里圈表服务实现类
 */
@Slf4j
@Service
public abstract class ComActNeighborCircleServiceImpl extends ServiceImpl<ComActNeighborCircleDAO, ComActNeighborCircleDO> implements ComActNeighborCircleService {
 
    /**
     * 分页查询邻里圈列表
     * @param neighborCircleAppDTO  请求参数
     * @return  邻里圈列表
     */
    public R pageNeighborByApp(ComActNeighborCircleAppDTO neighborCircleAppDTO){
        Page userPage = new Page(neighborCircleAppDTO.getPageNum(), neighborCircleAppDTO.getPageSize());
        IPage<ComActNeighborCircleAppVO> doPager = this.baseMapper.pageNeighborByApp(userPage, neighborCircleAppDTO);
        return R.ok(doPager);
    }
 
    @Override
    public R pageNeighborByAdmin(ComActNeighborCircleAdminDTO neighborCircleAdminDTO) {
        Page page = new Page(neighborCircleAdminDTO.getPageNum(), neighborCircleAdminDTO.getPageSize());
        IPage<ComActNeighborCircleAdminVO> doPager = this.baseMapper.pageNeighborByAdmin(page, neighborCircleAdminDTO);
        return R.ok(doPager);
    }
 
    @Override
    public R addNeighborByAdmin(AddNeighborCircleAdminVO addVO) {
        ComActNeighborCircleDO comActNeighborCircleDO = new ComActNeighborCircleDO();
        AdministratorsUserVO adminUser = this.baseMapper.selectUserByUserId(addVO.getUserId());
        if(adminUser==null){
            return R.fail("请登录重试");
        }
        comActNeighborCircleDO.setReleaseId(addVO.getUserId());
        comActNeighborCircleDO.setReleasePhone(adminUser.getPhone());
        comActNeighborCircleDO.setCommunityId(adminUser.getCommunityId());
        comActNeighborCircleDO.setReleaseContent(addVO.getReleaseContent());
        comActNeighborCircleDO.setReleaseImages(addVO.getReleaseImages());
        comActNeighborCircleDO.setStatus(1);
        comActNeighborCircleDO.setCommentNum(0);
        comActNeighborCircleDO.setFabulousNum(0);
        comActNeighborCircleDO.setForwardNum(0);
        comActNeighborCircleDO.setViewsNum(0);
        comActNeighborCircleDO.setIsBoutique(2);
        comActNeighborCircleDO.setCreateAt(new Date());
        comActNeighborCircleDO.setLastCommentNum(0);
        comActNeighborCircleDO.setLastFabulousNum(0);
        comActNeighborCircleDO.setLastViewsNum(0);
        this.baseMapper.insert(comActNeighborCircleDO);
        return R.ok();
    }
 
    @Override
    public R changeStatusByAdmin(EditNeighborCircleAdminVO editVO) {
        ComActNeighborCircleDO neighborCircleDO = this.baseMapper.selectById(editVO.getId());
        if(neighborCircleDO==null){
            return R.fail("id有误!");
        }
        neighborCircleDO.setStatus(editVO.getStatus());
        neighborCircleDO.setRefuseReason(editVO.getRefuseReason());
        this.baseMapper.updateById(neighborCircleDO);
        return R.ok();
    }
}