AppUpdateController.java
13.7 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/*
package com.brframework.webapppatch.web;
import com.brframework.commoncms.annatotion.AdminMenu;
import com.brframework.commoncms.annatotion.layout.EditAlertLayout;
import com.brframework.commoncms.annatotion.layout.EditLayout;
import com.brframework.commoncms.annatotion.layout.PageLayout;
import com.brframework.commoncms.annatotion.layout.ViewLayout;
import com.brframework.commoncms.annatotion.option.CmsOption;
import com.brframework.commoncms.core.Icons;
import com.brframework.commonweb.json.JSONResult;
import com.brframework.commonweb.json.Page;
import com.brframework.commonweb.json.PageParam;
import com.brframework.commonwebadmin.aop.annotation.AOLog;
import com.brframework.webapppatch.domain.AppPatchConfig;
import com.brframework.webapppatch.entity.AppVersion;
import com.brframework.webapppatch.entity.PatchBranch;
import com.brframework.webapppatch.entity.PatchGrayUser;
import com.brframework.webapppatch.entity.PatchVersion;
import com.brframework.webapppatch.json.*;
import com.brframework.webapppatch.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.time.LocalDateTime;
import static com.brframework.commondb.core.ControllerPageHandle.jpaPageConvertToPage;
import static com.brframework.commondb.core.ControllerPageHandle.jpaPageToPage;
*/
/**
* APP热更新
*
* @author xu
* @date 2019/11/14 10:36
*//*
@RestController
@Api(tags = "APP更新")
@RequestMapping("/admin/access")
@AdminMenu(menuName = "APP更新", icon = Icons.DEVELOPMENT_FIX, order = Integer.MIN_VALUE + 200)
public class AppUpdateController {
@Autowired
AppVersionService appVersionService;
@Autowired
PatchBranchService patchBranchService;
@Autowired
PatchGrayUserService patchGrayUserService;
@Autowired
PatchVersionService patchVersionService;
@Autowired
PatchConfigService patchConfigService;
@ApiOperation(value = "APP版本列表", notes = "APP版本列表")
@GetMapping("v1/app/version/list")
@PageLayout(
options = {
@CmsOption(name = "发布", uriMappingMethod = "appVersionCreate")
},
columnOptions = {
@CmsOption(name = "查看", uriMappingMethod = "appVersionGet"),
@CmsOption(name = "灰度", condition = "{updateStatus}==1", uriMappingMethod = "appVersionGray", alert = "您确定要进行灰度发布吗?"),
@CmsOption(name = "发布", condition = "{updateStatus}==2", uriMappingMethod = "appVersionRelease", alert = "您确定要正式发布吗?"),
@CmsOption(name = "失败", condition = "{updateStatus}==2", uriMappingMethod = "appVersionDefeated", alert = "您确定要失败吗?")
}
)
@PreAuthorize("hasRole('app-version-list')")
@AdminMenu(menuName = "APP版本管理", order = 5)
@AOLog
public JSONResult<Page<AppVersionListSimpleResult>> appVersionList(@Valid PageParam page, AppVersionListParam param) {
return JSONResult.ok(jpaPageConvertToPage(
appVersionService.page(page, param),
page, AppVersionListSimpleResult.class
));
}
@ApiOperation(value = "发布版本", notes = "新增版本")
@PutMapping("v1/app/version")
@EditAlertLayout
@PreAuthorize("hasRole('app-version-create')")
@AOLog
public JSONResult appVersionCreate(
@Valid @RequestBody AppVersionUpdateParam param) {
appVersionService.createVersion(param.getOs(), param.getVersion(), param.getVersionName(), param.getVersionMessage(),
param.getVersionUrl(), param.getUpdateType());
return JSONResult.ok();
}
@ApiOperation(value = "查看版本信息", notes = "查看版本信息")
@GetMapping("v1/app/version/{id}")
@ViewLayout(
paddingMappingMethod = "appVersionGet"
)
@PreAuthorize("hasRole('app-version-get')")
@AOLog
public JSONResult<AppVersion> appVersionGet(@PathVariable Long id) {
return JSONResult.ok(appVersionService.accessObject(id));
}
@ApiOperation(value = "版本进入灰度", notes = "版本进入灰度")
@PostMapping("v1/app/version/gray/{id}")
@PreAuthorize("hasRole('app-version-gray')")
@AOLog
public JSONResult appVersionGray(@PathVariable Long id) {
appVersionService.setVersionGray(id);
return JSONResult.ok();
}
@ApiOperation(value = "版本发布", notes = "版本发布")
@PostMapping("v1/app/version/release/{id}")
@PreAuthorize("hasRole('app-version-release')")
@AOLog
public JSONResult appVersionRelease(@PathVariable Long id) {
appVersionService.setVersionRelease(id);
return JSONResult.ok();
}
@ApiOperation(value = "版本失败", notes = "版本失败")
@DeleteMapping("v1/app/version/defeated/{id}")
@PreAuthorize("hasRole('app-version-defeated')")
@AOLog
public JSONResult appVersionDefeated(@PathVariable Long id) {
appVersionService.setVersionDefeated(id);
return JSONResult.ok();
}
@ApiOperation(value = "热更新分支列表", notes = "热更新分支列表")
@GetMapping("v1/app-patch/branch/list")
@PageLayout(
options = {
@CmsOption(name = "添加分支", uriMappingMethod = "appPatchBranchCreate")
},
columnOptions = {
@CmsOption(name = "查看", uriMappingMethod = "appPatchBranchGet"),
//@CmsOption(name = "修改信息", uriMappingMethod = "appPatchBranchEdit"),
@CmsOption(name = "删除", uriMappingMethod = "appPatchBranchDel", alert = "您确定要删除该数据吗?"),
@CmsOption(name = "清除分支版本", uriMappingMethod = "appPatchBranchVersion", alert = "您确定清除该分支下的所有版本吗?这是一个危险并不可逆的操作,如果您对该功能不了解或不完全了解不要进行该操作!")
}
)
@PreAuthorize("hasRole('app-patch-branch-list')")
@AdminMenu(menuName = "热更新分支管理", order = 20)
@AOLog
public JSONResult<Page<AppPatchBranchSimpleResult>> appPatchBranchList(@Valid PageParam page) {
return JSONResult.ok(jpaPageConvertToPage(
patchBranchService.page(page, null),
page, AppPatchBranchSimpleResult.class
));
}
@ApiOperation(value = "分支信息", notes = "分支信息")
@GetMapping("v1/app-patch/branch/{id}")
@ViewLayout(paddingMappingMethod = "appPatchBranchGet")
@PreAuthorize("hasRole('app-patch-branch-list')")
@AOLog
public JSONResult<PatchBranch> appPatchBranchGet(@PathVariable Long id) {
return JSONResult.ok(
patchBranchService.accessObject(id)
);
}
@ApiOperation(value = "更新分支", notes = "更新分支")
@PostMapping("v1/app-patch/branch/{id}")
@EditAlertLayout(
paddingMappingMethod = "appPatchBranchGet"
)
@PreAuthorize("hasRole('app-patch-branch-edit')")
@AOLog
public JSONResult appPatchBranchEdit(
@PathVariable Long id,
@Valid @RequestBody AppPatchBranchUpdateParam param) {
patchBranchService.updateBranch(id, param.getOs(), param.getBranchName(), param.getBranchDetail());
return JSONResult.ok();
}
@ApiOperation(value = "清除分支版本", notes = "清除分支版本")
@DeleteMapping("v1/app-patch/branch/version/{id}")
@PreAuthorize("hasRole('app-patch-branch-version')")
public JSONResult appPatchBranchVersion(@PathVariable Long id) {
PatchBranch patchBranch = patchBranchService.accessObject(id);
patchVersionService.removeByBranch(patchBranch.getBranchName());
return JSONResult.ok();
}
@ApiOperation(value = "添加分支", notes = "添加分支")
@PutMapping("v1/app-patch/branch")
@EditAlertLayout
@PreAuthorize("hasRole('app-patch-branch-create')")
@AOLog
public JSONResult appPatchBranchCreate(
@Valid @RequestBody AppPatchBranchUpdateParam param) {
patchBranchService.createBranch(param.getOs(), param.getBranchName(), param.getBranchDetail());
return JSONResult.ok();
}
@ApiOperation(value = "删除分支", notes = "删除分支")
@DeleteMapping("v1/app-patch/branch/{id}")
@PreAuthorize("hasRole('app-patch-branch-del')")
public JSONResult appPatchBranchDel(@PathVariable Long id) {
patchBranchService.removeById(id);
return JSONResult.ok();
}
@ApiOperation(value = "灰度用户列表", notes = "灰度用户列表")
@GetMapping("v1/app-patch/gray-user/list")
@PageLayout(
options = {
@CmsOption(name = "添加灰度用户", uriMappingMethod = "appPatchGrayUserCreate")
},
columnOptions = {
@CmsOption(name = "删除", uriMappingMethod = "appPatchGrayUserDel", alert = "您确定要删除该数据吗?")
}
)
@PreAuthorize("hasRole('app-patch-gray-user-list')")
@AdminMenu(menuName = "灰度用户管理", order = 30)
@AOLog
public JSONResult<Page<PatchGrayUser>> appPatchGrayUserList(@Valid PageParam page,
AppPatchGrayUserListQueryParam param) {
return JSONResult.ok(jpaPageToPage(
patchGrayUserService.page(page, param),
page
));
}
@ApiOperation(value = "添加灰度用户", notes = "添加灰度用户")
@PutMapping("v1/app-patch/gray-user")
@EditAlertLayout
@PreAuthorize("hasRole('app-patch-gray-user-create')")
@AOLog
public JSONResult appPatchGrayUserCreate(
@Valid @RequestBody AppPatchGrayUserUpdateParam param) {
patchGrayUserService.createGrayUser(param.getUsername());
return JSONResult.ok();
}
@ApiOperation(value = "删除灰度用户", notes = "删除灰度用户")
@DeleteMapping("v1/app-patch/gray-user/{id}")
@PreAuthorize("hasRole('app-patch-gray-user-del')")
@AOLog
public JSONResult appPatchGrayUserDel(@PathVariable Long id) {
patchGrayUserService.removeById(id);
return JSONResult.ok();
}
@ApiOperation(value = "热更新版本列表", notes = "热更新版本列表")
@GetMapping("v1/app-patch/version/list")
@PageLayout(
columnOptions = {
@CmsOption(name = "查看", uriMappingMethod = "appPatchVersionGet"),
@CmsOption(name = "灰度", condition = "{updateStatus}==1", uriMappingMethod = "appPatchVersionGray", alert = "您确定要进行灰度发布吗?"),
@CmsOption(name = "发布", condition = "{updateStatus}==2", uriMappingMethod = "appPatchVersionRelease", alert = "您确定要正式发布吗?"),
@CmsOption(name = "失败", condition = "{updateStatus}==2", uriMappingMethod = "appPatchVersionDefeated", alert = "您确定要失败吗?")
}
)
@PreAuthorize("hasRole('app-patch-version-list')")
@AdminMenu(menuName = "热更新版本管理", order = 10)
@AOLog
public JSONResult<Page<AppPatchVersionListSimpleResult>> appPatchVersionList(@Valid PageParam page, AppPatchVersionListParam param) {
return JSONResult.ok(jpaPageConvertToPage(
patchVersionService.page(page, param),
page, AppPatchVersionListSimpleResult.class
));
}
@ApiOperation(value = "查看版本信息", notes = "查看版本信息")
@GetMapping("v1/app-patch/version/{id}")
@ViewLayout(
paddingMappingMethod = "appPatchVersionGet"
)
@PreAuthorize("hasRole('app-patch-version-get')")
@AOLog
public JSONResult<PatchVersion> appPatchVersionGet(@PathVariable Long id) {
return JSONResult.ok(patchVersionService.accessObject(id));
}
@ApiOperation(value = "版本进入灰度", notes = "版本进入灰度")
@PostMapping("v1/app-patch/version/gray/{id}")
@PreAuthorize("hasRole('app-patch-version-gray')")
@AOLog
public JSONResult appPatchVersionGray(@PathVariable Long id) {
patchVersionService.setVersionGray(id);
return JSONResult.ok();
}
@ApiOperation(value = "版本发布", notes = "版本发布")
@PostMapping("v1/app-patch/version/release/{id}")
@PreAuthorize("hasRole('app-patch-version-release')")
@AOLog
public JSONResult appPatchVersionRelease(@PathVariable Long id) {
patchVersionService.setVersionRelease(id);
return JSONResult.ok();
}
@ApiOperation(value = "版本失败", notes = "版本失败")
@DeleteMapping("v1/app-patch/version/defeated/{id}")
@PreAuthorize("hasRole('app-patch-version-defeated')")
@AOLog
public JSONResult appPatchVersionDefeated(@PathVariable Long id) {
patchVersionService.setVersionDefeated(id);
return JSONResult.ok();
}
@ApiOperation(value = "热更新配置", notes = "热更新配置")
@PostMapping("/v1/app-patch/config")
@EditLayout(paddingMappingMethod = "appPatchConfigGet")
@PreAuthorize("hasRole('app-patch-config')")
@AdminMenu(menuName = "热更新配置", order = 50)
@AOLog
public JSONResult appPatchConfigSet(@RequestBody AppPatchConfig param) {
patchConfigService.set(param);
return JSONResult.ok();
}
@ApiOperation(value = "获取热更新配置", notes = "获取热更新配置")
@GetMapping("/v1/app-patch/config")
@PreAuthorize("hasRole('app-patch-config')")
@AOLog
public JSONResult<AppPatchConfig> appPatchConfigGet() {
return JSONResult.ok(patchConfigService.get());
}
}
*/