CustomerCarInfoDaoImpl.java
5.2 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.zteits.pay.dao.impl;
import com.clouds.common.constants.pagequery.PageSizeEnum;
import com.clouds.common.utils.page.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.dto.pay.dto.CustomerCarInfoDTO;
import com.zteits.clouds.api.dto.pay.dto.CustomerInfoDTO;
import com.zteits.clouds.api.dto.pay.param.CheckCustomerCarInfoRequest;
import com.zteits.clouds.api.dto.pay.param.CustomerCarInfoRequest;
import com.zteits.pay.dao.CustomerCarInfoDao;
import com.zteits.pay.domain.TdClCustomerCarInfo;
import com.zteits.pay.domain.TdClCustomerCarInfoExample;
import com.zteits.pay.mapper.TdClCustomerCarInfoMapper;
import com.zteits.pay.mapper.smapper.TdClCustomerCarInfoSMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
@Component
public class CustomerCarInfoDaoImpl implements CustomerCarInfoDao {
@Autowired
private TdClCustomerCarInfoMapper tdClCustomerCarInfoMapper;
@Autowired
private TdClCustomerCarInfoSMapper tdClCustomerCarInfoSMapper;
@Override
public PageInfo<CustomerCarInfoDTO> queryCustomerCarInfo(CustomerCarInfoRequest request) {
List<CustomerCarInfoDTO> dtoList = new ArrayList<>();
TdClCustomerCarInfoExample example = new TdClCustomerCarInfoExample();
TdClCustomerCarInfoExample.Criteria sql = example.createCriteria();
if(!StringUtils.isEmpty(request.getCustomerNo())){
sql.andCustomerNoEqualTo(request.getCustomerNo());
}
if(!StringUtils.isEmpty(request.getCustomerName())){
sql.andCustomerNameLike("%"+request.getCustomerName()+"%");
}
if(!StringUtils.isEmpty(request.getCarNo())){
sql.andCarNoLike("%"+request.getCarNo()+"%");
}
sql.andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
// 1.设置分页信息
PageUtil.pageSizeValidate(PageSizeEnum.PAGE_SIZE_BASE,request);
PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
// List<TdClCustomerCarInfo> customerCarInfoList = tdClCustomerCarInfoMapper.selectByExample(example);
// ListCopyUtil.listCopyProperties(customerCarInfoList,dtoList, CustomerCarInfoDTO.class);
List<CustomerCarInfoDTO> dto = tdClCustomerCarInfoMapper.selectDtoByExample(example);
return new PageInfo<>(dto);
}
@Override
public int insertSelective(TdClCustomerCarInfo record) {
if (record == null) {
return 0;
}
if (record.getDataStatus() == null) {
record.setDataStatus(DataStatusEnum.DATA_STATUS_NO_VALID.value());
}
return tdClCustomerCarInfoMapper.insertSelective(record);
}
@Override
public int updateSelective(TdClCustomerCarInfo record) {
if (record == null) {
return 0;
}
if (record.getDataStatus() == null) {
record.setDataStatus(DataStatusEnum.DATA_STATUS_NO_VALID.value());
}
return tdClCustomerCarInfoMapper.updateByPrimaryKeySelective(record);
}
@Override
public int deleteCustomerCarInfo(TdClCustomerCarInfo record) {
if (record == null) {
return 0;
}
if (record.getDataStatus() == null) {
record.setDataStatus(DataStatusEnum.DATA_STATUS_NO_VALID.value());
}
return tdClCustomerCarInfoMapper.updateByPrimaryKeySelective(record);
}
/**
* 根据车牌号码获取绑定的客户信息
*
* @Author: zegnqc
* @Date: 2020-12-28
*/
@Override
public CustomerInfoDTO queryCustomerInfoByCarNo(CustomerCarInfoRequest request) {
return tdClCustomerCarInfoSMapper.queryCustomerInfoByCarNo(request.getCarNo());
}
@Override
public Long checkCustomerManageCar(CheckCustomerCarInfoRequest request) {
TdClCustomerCarInfoExample example = new TdClCustomerCarInfoExample();
example.createCriteria().andCarNoEqualTo(request.getCarNo()).andDataStatusEqualTo(1);
// List<TdClCustomerCarInfo> list = tdClCustomerCarInfoMapper.selectByExample(example);
Long count = tdClCustomerCarInfoMapper.countByExample(example);
return count;
}
@Override
public List<CustomerCarInfoDTO> queryCustomerCarList(CustomerCarInfoRequest request) {
TdClCustomerCarInfoExample example = new TdClCustomerCarInfoExample();
example.createCriteria().andDataStatusEqualTo(1).andCustomerNoEqualTo(request.getCustomerNo());
List<CustomerCarInfoDTO> dtoList = tdClCustomerCarInfoMapper.selectDtoByExample(example);
return dtoList;
}
@Override
public int deleteCustomerManageRelCarInfo(TdClCustomerCarInfo customerCarInfo) {
if (customerCarInfo == null) {
return 0;
}
TdClCustomerCarInfoExample example = new TdClCustomerCarInfoExample();
example.createCriteria().andCustomerNoEqualTo(customerCarInfo.getCustomerNo());
return tdClCustomerCarInfoMapper.updateByExampleSelective(customerCarInfo,example);
}
}