101captain
2022-02-21 5a278a0965b417e7f39e8c209e2ff401f415066a
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
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.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.social.SocialProjectVO;
import com.panzhihua.service_community.entity.ComActSocialProject;
import com.panzhihua.service_community.dao.ComActSocialProjectDao;
import com.panzhihua.service_community.entity.ProjectRelationVO;
import com.panzhihua.service_community.service.ComActSocialProjectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
 
/**
 * 三社联动项目表(ComActSocialProject)表服务实现类
 *
 * @author makejava
 * @since 2021-12-22 14:02:48
 */
@Slf4j
@Service
public class ComActSocialProjectServiceImpl extends ServiceImpl<ComActSocialProjectDao, ComActSocialProject> implements ComActSocialProjectService {
 
    @Resource
    private ComActSocialProjectDao comActSocialProjectDao;
    @Override
    public R pageList(CommonPage commonPage) {
        return R.ok(comActSocialProjectDao.pageList(new Page(commonPage.getPage(),commonPage.getSize()),commonPage));
    }
 
    @Override
    public R getByApplet(Long id) {
        ComActSocialProject comActSocialProject=this.comActSocialProjectDao.selectById(id);
        comActSocialProject.setViews(comActSocialProject.getViews()+1);
        comActSocialProjectDao.updateById(comActSocialProject);
        return R.ok(comActSocialProjectDao.getByApplet(id));
    }
 
    @Override
    public R getByBackstage(Long id) {
        return R.ok(comActSocialProjectDao.getByApplet(id));
    }
 
    @Override
    public R getProject(CommonPage commonPage) {
        if(commonPage.getParamId()==null){
            return R.fail("数据异常");
        }
        ProjectRelationVO projectRelationVO=new ProjectRelationVO();
        ComActSocialProject comActSocialProject=this.comActSocialProjectDao.selectById(commonPage.getParamId());
        if(comActSocialProject.getLevel()==1){
            ComActSocialProject comActSocialProject1=this.comActSocialProjectDao.selectOne(new QueryWrapper<ComActSocialProject>().lambda().eq(ComActSocialProject::getId,comActSocialProject.getParentId()));
            if(comActSocialProject1!=null){
                SocialProjectVO socialProjectVO=new SocialProjectVO();
                BeanUtils.copyProperties(comActSocialProject1,socialProjectVO);
                projectRelationVO.setFatherProjectLevelOne(socialProjectVO);
            }
 
        }
        if(comActSocialProject.getLevel()==2){
            ComActSocialProject comActSocialProject1=this.comActSocialProjectDao.selectOne(new QueryWrapper<ComActSocialProject>().lambda().eq(ComActSocialProject::getId,comActSocialProject.getParentId()));
            if(comActSocialProject1!=null){
                SocialProjectVO socialProjectVO=new SocialProjectVO();
                BeanUtils.copyProperties(comActSocialProject1,socialProjectVO);
                projectRelationVO.setFatherProjectLevelTwo(socialProjectVO);
                ComActSocialProject comActSocialProject2=this.comActSocialProjectDao.selectOne(new QueryWrapper<ComActSocialProject>().lambda().eq(ComActSocialProject::getId,comActSocialProject1.getParentId()));
                if(comActSocialProject2!=null){
                    SocialProjectVO socialProjectVO1=new SocialProjectVO();
                    BeanUtils.copyProperties(comActSocialProject2,socialProjectVO1);
                    projectRelationVO.setFatherProjectLevelOne(socialProjectVO1);
                }
            }
        }
        IPage<SocialProjectVO> socialProjectVOIPage=this.comActSocialProjectDao.pageList(new Page(commonPage.getPage(),commonPage.getSize()),commonPage);
        projectRelationVO.setSocialProjectVOIPage(socialProjectVOIPage);
        return R.ok(projectRelationVO);
    }
}