AppVersionServiceImpl.java
4.73 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
133
134
135
136
137
138
139
140
141
package com.zteits.pay.biz;
import com.github.pagehelper.PageInfo;
import com.xiaoleilu.hutool.util.BeanUtil;
import com.zteits.clouds.api.apibase.bean.BizResult;
import com.zteits.clouds.api.apibase.bean.PageBean;
import com.zteits.clouds.api.apibase.constants.ErrorType;
import com.zteits.clouds.api.apibase.exception.BizException;
import com.zteits.clouds.api.dto.pay.AppVersionDTO;
import com.zteits.clouds.api.dto.pay.param.AppVersionQueryForPageReq;
import com.zteits.clouds.api.dto.pay.param.AppVersionRequest;
import com.zteits.clouds.api.dto.pay.param.AppVersionSaveReq;
import com.zteits.clouds.api.dto.pay.param.AppVersionUpdateByIdReq;
import com.zteits.clouds.api.service.pay.AppVersionService;
import com.zteits.pay.dao.AppVersionDao;
import com.zteits.pay.domain.AppVersion;
import com.zteits.pay.pagepager.PageBeanUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@Component
public class AppVersionServiceImpl implements AppVersionService {
@Autowired
private AppVersionDao appVersionDao;
@Override
public BizResult<AppVersionDTO> checkAppVersion(AppVersionRequest appVersionRequest) {
AppVersionDTO appVersionDTO = null;
AppVersion appVersion = appVersionDao.checkVersionByAppType(Integer.parseInt(appVersionRequest.getAppType()));
if (appVersion != null) {
appVersionDTO = new AppVersionDTO();
BeanUtil.copyProperties(appVersion, appVersionDTO);
}
return new BizResult<AppVersionDTO>(appVersionDTO);
}
@Override
public BizResult<Integer> saveAppVersion(AppVersionSaveReq req) {
if (null == req.getData()) {
throw new BizException(ErrorType.PARAMM_NULL, "待保存数据");
}
if (null == req.getData().getAppName()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP名称");
}
if (null == req.getData().getAppType()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP类型");
}
if (null == req.getData().getAppUrl()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP发布URL");
}
if (null == req.getData().getDownType()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP更新类型");
}
if (null == req.getData().getVersion()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP版本号");
}
if (null == req.getData().getRemark()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP发布内容");
}
AppVersion appVersion = new AppVersion();
BeanUtils.copyProperties(req.getData(), appVersion);
Integer num = appVersionDao.saveAppVersion(appVersion);
return new BizResult<>(num);
}
@Override
public BizResult<Integer> updateAppVersionById(AppVersionUpdateByIdReq req) {
if (null == req.getData()) {
throw new BizException(ErrorType.PARAMM_NULL, "待保存数据");
}
if (null == req.getData().getId()) {
throw new BizException(ErrorType.PARAMM_NULL, "主键ID");
}
if (null == req.getData().getAppName()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP名称");
}
if (null == req.getData().getAppType()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP类型");
}
if (null == req.getData().getAppUrl()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP发布URL");
}
if (null == req.getData().getDownType()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP更新类型");
}
if (null == req.getData().getVersion()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP版本号");
}
if (null == req.getData().getRemark()) {
throw new BizException(ErrorType.PARAMM_NULL, "APP发布内容");
}
AppVersion appVersion = new AppVersion();
BeanUtils.copyProperties(req.getData(), appVersion);
Integer num = appVersionDao.updateAppVersionById(appVersion);
return new BizResult<>(num);
}
@Override
public BizResult<PageBean<AppVersionDTO>> queryAppVersionForPage(AppVersionQueryForPageReq req) {
if (CollectionUtils.isEmpty(req.getAppTypes())) {
throw new BizException(ErrorType.PARAMM_NULL, "APP类型");
}
PageInfo<AppVersion> pageInfo = appVersionDao.queryAppVersionForPage(req);
PageBean<AppVersionDTO> pageBean = new PageBean<>();
PageBeanUtil.copyProperties(pageInfo, pageBean, AppVersionDTO.class);
return new BizResult<>(pageBean);
}
}