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 ;
|
}
|
}
|