101captain
2022-07-20 c40f8e3d2e08e108780091776437242528bf61d6
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
86
87
88
89
90
91
92
93
94
package com.panzhihua.service_community.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.community.social.PageSocialOrgHatchDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.social.SocialOrgHatchVO;
import com.panzhihua.service_community.dao.ComActSocialOrgHatchAuditDAO;
import com.panzhihua.service_community.dao.ComActSocialOrgHatchAuditScheduleDAO;
import com.panzhihua.service_community.dao.ComActSocialOrgHatchDAO;
import com.panzhihua.service_community.entity.ComActSocialOrgHatch;
import com.panzhihua.service_community.entity.ComActSocialOrgHatchAudit;
import com.panzhihua.service_community.entity.ComActSocialOrgHatchAuditSchedule;
import com.panzhihua.service_community.service.ComActSocialOrgHatchService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
 
import static java.util.Objects.nonNull;
 
/**
 * 社会组织孵化表(ComActSocialOrgHatch)表服务实现类
 *
 * @author makejava
 * @since 2022-04-18 14:09:53
 */
@Service("comActSocialOrgHatchService")
public class ComActSocialOrgHatchServiceImpl extends ServiceImpl<ComActSocialOrgHatchDAO, ComActSocialOrgHatch> implements ComActSocialOrgHatchService {
 
    @Resource
    private ComActSocialOrgHatchAuditDAO comActSocialOrgHatchAuditDAO;
    @Resource
    private ComActSocialOrgHatchAuditScheduleDAO comActSocialOrgHatchAuditScheduleDAO;
 
    /**
     * 分页查询孵化数据
     * @param pageHatchDTO
     * @return
     */
    @Override
    public R pageOrgHatch(PageSocialOrgHatchDTO pageHatchDTO) {
        Page page = new Page<>();
        page.setSize(pageHatchDTO.getPageSize());
        page.setCurrent(pageHatchDTO.getPageNum());
        return R.ok(this.baseMapper.pageOrgHatch(page, pageHatchDTO));
    }
 
    /**
     * 查看孵化数据详情
     * @param id
     * @return
     */
    @Override
    public R detailOrgHatch(Long id) {
        return R.ok(this.baseMapper.detailOrgHatch(id));
    }
 
    /**
     * 修改孵化状态
     * @param id
     * @param status
     * @return
     */
    @Override
    public R updateOrgHatchStatus(Long id, Integer status) {
        ComActSocialOrgHatch socialOrgHatch = new ComActSocialOrgHatch();
        socialOrgHatch.setStatus(status);
        int result = this.baseMapper.update(socialOrgHatch, new LambdaQueryWrapper<ComActSocialOrgHatch>().eq(ComActSocialOrgHatch::getId, id));
        return result > 0 ? R.ok() : R.fail("操作失败,请重新尝试");
    }
 
    /**
     * 删除孵化数据
     * @param id
     * @return
     */
    @Override
    public R deleteOrgHatch(Long id) {
        ComActSocialOrgHatch orgHatch = this.baseMapper.selectById(id);
        Long auditId = orgHatch.getAuditId();
        if (nonNull(orgHatch)) {
            int result = this.baseMapper.deleteById(id);
            if (result > 0) {
                comActSocialOrgHatchAuditDAO.delete(new LambdaQueryWrapper<ComActSocialOrgHatchAudit>()
                        .eq(ComActSocialOrgHatchAudit::getId, auditId));
                comActSocialOrgHatchAuditScheduleDAO.delete(new LambdaQueryWrapper<ComActSocialOrgHatchAuditSchedule>()
                        .eq(ComActSocialOrgHatchAuditSchedule::getAuditId, auditId));
            }
        }
        return R.ok();
    }
}