AppVersionDaoImpl.java
2.81 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
package com.zteits.pay.dao.impl;
import java.util.Date;
import java.util.List;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.apibase.constants.ErrorType;
import com.zteits.clouds.api.apibase.exception.BizException;
import com.zteits.clouds.api.dto.pay.param.AppVersionQueryForPageReq;
import com.zteits.pay.dao.AppVersionDao;
import com.zteits.pay.domain.AppVersion;
import com.zteits.pay.domain.AppVersionExample;
import com.zteits.pay.domain.AppVersionExample.Criteria;
import com.zteits.pay.mapper.AppVersionMapper;
import com.zteits.pay.mapper.smapper.AppVersionSMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class AppVersionDaoImpl implements AppVersionDao {
@Autowired
private AppVersionSMapper appVersionSMapper;
@Autowired
private AppVersionMapper appVersionMapper;
@Override
public AppVersion checkVersionByAppType(Integer appType) {
return appVersionSMapper.checkVersionByAppType(appType);
}
@Override
public int saveAppVersion(AppVersion appVersion) {
AppVersionExample example = new AppVersionExample();
example.createCriteria().andAppTypeEqualTo(appVersion.getAppType());
AppVersion updateVersion = new AppVersion();
updateVersion.setDataState(DataStatusEnum.DATA_STATUS_NO_VALID.value());
updateVersion.setModfiyDate(new Date());
updateVersion.setModfiyEmpid(appVersion.getCreateEmpid());
appVersionMapper.updateByExampleSelective(updateVersion, example);
return appVersionMapper.insertSelective(appVersion);
}
@Override
public int updateAppVersionById(AppVersion appVersion) {
if (null == appVersion.getId()) {
throw new BizException(ErrorType.PARAMM_NULL, "主键ID");
}
appVersion.setModfiyDate(new Date());
return appVersionMapper.updateByPrimaryKeySelective(appVersion);
}
@Override
public PageInfo<AppVersion> queryAppVersionForPage(AppVersionQueryForPageReq req) {
AppVersionExample example = new AppVersionExample();
example.setOrderByClause(" create_date desc");
Criteria sql = example.createCriteria().andAppTypeIn(req.getAppTypes());
if (null != req.getCreateDateStart()) {
sql.andCreateDateGreaterThanOrEqualTo(req.getCreateDateStart());
}
if (null != req.getCreateDateEnd()) {
sql.andCreateDateLessThanOrEqualTo(req.getCreateDateEnd());
}
PageHelper.startPage(req.getBaseRequest().getPageNum(), req.getBaseRequest().getPageSize());
List<AppVersion> list = appVersionMapper.selectByExample(example);
return new PageInfo<>(list);
}
}