czt
9 天以前 db67639449287bcec461916a7dca6003ee5dd03c
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
package com.fzzy.igds.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzzy.igds.data.BaseResp;
import com.fzzy.igds.data.IgdsBaseParam;
import com.fzzy.igds.domain.PledgeContract;
import com.fzzy.igds.mapper.PledgeContractMapper;
import com.fzzy.igds.utils.ContextUtil;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
@Slf4j
@Service
public class PledgeContractService {
 
    @Resource
    private PledgeContractMapper pledgeContractMapper;
 
    public List<PledgeContract> listAll(IgdsBaseParam param) {
 
        if (null == param)
            return pledgeContractMapper.selectList(null);
 
        QueryWrapper<PledgeContract> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(param.getName())) {
            queryWrapper.like("name", param.getName());
        }
        return pledgeContractMapper.selectList(queryWrapper);
    }
 
    public BaseResp addData(PledgeContract pledgeContract) {
        if(StringUtils.isEmpty(pledgeContract.getId())){
            pledgeContract.setId(ContextUtil.generateOrderId("PC"));
        }
        pledgeContract.setCompanyId(ContextUtil.getCompanyId());
        pledgeContract.setUpdateBy(ContextUtil.getLoginUserName());
        pledgeContract.setUpdateTime(new Date());
        pledgeContract.setCreateBy(ContextUtil.getLoginUserName());
        pledgeContract.setCreateTime(new Date());
        return pledgeContractMapper.insert(pledgeContract) > 0 ? BaseResp.success() : BaseResp.error("添加失败");
    }
 
    public BaseResp updateData(PledgeContract pledgeContract) {
        pledgeContract.setUpdateBy(ContextUtil.getLoginUserName());
        pledgeContract.setUpdateTime(new Date());
        return pledgeContractMapper.updateById(pledgeContract) > 0 ? BaseResp.success() : BaseResp.error("更新失败");
    }
 
    public BaseResp deleteData(PledgeContract pledgeContract) {
        return pledgeContractMapper.deleteById(pledgeContract) > 0 ? BaseResp.success() : BaseResp.error("删除失败");
    }
 
}