CustPersonCreditDaoImpl.java
4.42 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.zteits.pay.dao.impl;
import org.apache.commons.collections4.CollectionUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zteits.pay.domain.CustPersonCredit;
import com.zteits.pay.domain.CustPersonCreditExample;
import com.zteits.clouds.api.dto.pay.param.CustPersonCreditRequest;
import com.zteits.pay.dao.CustPersonCreditDao;
import com.zteits.pay.mapper.CustPersonCreditMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Component
public class CustPersonCreditDaoImpl implements CustPersonCreditDao {
@Autowired
private CustPersonCreditMapper custPersonCreditMapper;
@Override
public int saveCustPersonCredit(CustPersonCredit custPersonCredit) {
if(custPersonCredit.getCreateDate()==null){
custPersonCredit.setCreateDate(new Date());
}
return custPersonCreditMapper.insertSelective(custPersonCredit);
}
@Override
public int updateByExampleSelective(CustPersonCredit record, CustPersonCreditExample example) {
return custPersonCreditMapper.updateByExampleSelective(record,example);
}
@Override
public int updateByPrimaryKeySelective(CustPersonCredit record) {
return custPersonCreditMapper.updateByPrimaryKeySelective(record);
}
@Override
public List<CustPersonCredit> selectByExample(CustPersonCreditExample example) {
return custPersonCreditMapper.selectByExample(example);
}
@Override
public CustPersonCredit queryByPrimaryKey(Long id) {
return custPersonCreditMapper.selectByPrimaryKey(id);
}
@Override
public List<CustPersonCredit> queryCustPersonCredit(CustPersonCreditRequest request) {
CustPersonCreditExample example = new CustPersonCreditExample();
CustPersonCreditExample.Criteria sql = example.createCriteria();
if (!StringUtils.isEmpty(request.getCustName())) {
sql.andCustNameLike(request.getUserPhone() + "%");
}
if (!StringUtils.isEmpty(request.getUserPhone())) {
sql.andUserPhoneLike(request.getUserPhone() + "%");
}
if (!StringUtils.isEmpty(request.getExamineState())) {
sql.andExamineStateEqualTo(request.getExamineState());
}
if (!StringUtils.isEmpty(request.getCustId())) {
sql.andCustIdEqualTo(request.getCustId());
}
if (!StringUtils.isEmpty(request.getDataState())) {
sql.andDataStateEqualTo(request.getDataState());
}
List<CustPersonCredit> list = custPersonCreditMapper.selectByExample(example);
return list;
}
@Override
public int batchDeleteCustPersonCreditByPrimaryKey(List<Long> ids, String opId, String opName) {
CustPersonCredit record = new CustPersonCredit();
// record.setModifyEmpId(opId);
// record.setModifyEmpName(opName);
// record.setModifyTime(new Date());
record.setDataState(DataStatusEnum.DATA_STATUS_NO_VALID.value());
CustPersonCreditExample example = new CustPersonCreditExample();
example.createCriteria().andIdIn(ids);
return custPersonCreditMapper.updateByExampleSelective(record,example);
}
@Override
public PageInfo<CustPersonCredit> queryCustPersonCreditForPage(CustPersonCreditRequest request) {
PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
CustPersonCreditExample example = new CustPersonCreditExample();
CustPersonCreditExample.Criteria sql = example.createCriteria();
if (!StringUtils.isEmpty(request.getCustName())) {
sql.andCustNameLike(request.getUserPhone() + "%");
}
if (!StringUtils.isEmpty(request.getUserPhone())) {
sql.andUserPhoneLike(request.getUserPhone() + "%");
}
if (!StringUtils.isEmpty(request.getExamineState())) {
sql.andExamineStateEqualTo(request.getExamineState());
}
List<CustPersonCredit> list = custPersonCreditMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(list)) {
return new PageInfo<CustPersonCredit>(list);
}
return new PageInfo<CustPersonCredit>(new ArrayList<CustPersonCredit>());
}
}