liuxm
2024-06-04 eeee3d8fa04aff41db6ee2418468e7371ecad57d
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
package com.dy.pmsProduct.taskPlan;
 
import com.dy.common.webFilter.UserTokenContext;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.daoPr.PrDevOpsPlanMapper;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.dy.pmsGlobal.pojoPr.PrDevOpsPlan;
import com.dy.pmsGlobal.util.UserUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
import java.util.Map;
 
@Slf4j
@Service
public class DevOpsSv {
    private PrDevOpsPlanMapper devOpsDao;
    private UserUtil userUtil;
 
    @Autowired
    public void setDevOpsDao(PrDevOpsPlanMapper devOpsDao) {
        this.devOpsDao = devOpsDao;
    }
    @Autowired
    public void setUserUtil(UserUtil userUtil) {
        this.userUtil = userUtil;
    }
    public PrDevOpsPlan selectById(Long id) {
        return devOpsDao.selectByPrimaryKey(id);
    }
 
    @Transactional
    public int save(PrDevOpsPlan plan) {
        if(devOpsDao.exists(plan.name,plan.id)){
            throw new RuntimeException("计划名不能重复");
        }
        BaUser loginUser = userUtil.getUser(UserTokenContext.get());
        if(loginUser!=null){
            plan.creator = loginUser.id;
        }
        plan.deleted = false;
        return devOpsDao.insertSelective(plan);
    }
    @Transactional
    public int update(PrDevOpsPlan plan) {
        if(devOpsDao.exists(plan.name,plan.id)){
            throw new RuntimeException("计划名不能重复");
        }
        return devOpsDao.updateByPrimaryKeySelective(plan);
    }
    public QueryResultVo<List<PrDevOpsPlan>> selectSome(QueryVo queryVo) {
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
        //查询符合条件的记录总数
        Long itemTotal = devOpsDao.selectSomeCount(params);
        QueryResultVo<List<PrDevOpsPlan>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
        //计算分页等信息
        rsVo.calculateAndSet(itemTotal, params);
        //查询符合条件的记录
        rsVo.obj = devOpsDao.selectSome(params);
        return rsVo ;
    }
}