AppPushController.java
5.4 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
/*
package com.brframework.commonapppush.web;
import com.brframework.commonapppush.domain.UPushConfig;
import com.brframework.commonapppush.entity.PushClientInfo;
import com.brframework.commonapppush.entity.PushLog;
import com.brframework.commonapppush.json.AppUPushSendBroadcastParam;
import com.brframework.commonapppush.json.AppUPushSendUnicastParam;
import com.brframework.commonapppush.json.PushLogSimpleResult;
import com.brframework.commonapppush.service.AppPushService;
import com.brframework.commonapppush.service.PushClientInfoService;
import com.brframework.commonapppush.service.PushLogService;
import com.brframework.commonapppush.service.UPushConfigService;
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 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 static com.brframework.commondb.core.ControllerPageHandle.jpaPageConvertToPage;
import static com.brframework.commondb.core.ControllerPageHandle.jpaPageToPage;
*/
/**
* @author xu
* @date 2019/11/18 20:16
*//*
@RestController
@Api(tags = "APP推送")
@RequestMapping("/admin/access")
@AdminMenu(menuName = "APP推送", icon = Icons.DEVELOPMENT_LAPTOP, order = Integer.MIN_VALUE + 201)
public class AppPushController {
@Autowired
PushLogService pushLogService;
@Autowired
PushClientInfoService pushClientInfoService;
@Autowired
AppPushService appPushService;
@Autowired
UPushConfigService uPushConfigService;
@ApiOperation(value = "推送管理", notes = "推送管理")
@GetMapping("v1/app/push/list")
@PageLayout(
options = {
@CmsOption(name = "发送单播", uriMappingMethod = "appUPushSendUnicast"),
@CmsOption(name = "发送广播", uriMappingMethod = "appUPushSendBroadcast")
},
columnOptions = {
@CmsOption(name = "查看", uriMappingMethod = "appPushGet")
}
)
@PreAuthorize("hasRole('app-push-list')")
@AdminMenu(menuName = "推送管理", order = 0)
public JSONResult<Page<PushLogSimpleResult>> appPushList(@Valid PageParam page) {
return JSONResult.ok(jpaPageConvertToPage(
pushLogService.page(page, null),
page, PushLogSimpleResult.class
));
}
@ApiOperation(value = "推送详情", notes = "推送详情")
@GetMapping("v1/app/push/get/{id}")
@ViewLayout(paddingMappingMethod = "appPushGet")
@PreAuthorize("hasRole('app-push-list')")
public JSONResult<PushLog> appPushGet(@PathVariable Long id) {
return JSONResult.ok(pushLogService.accessObject(id));
}
@ApiOperation(value = "发送单播", notes = "发送单播")
@PostMapping("/v1/app/upush/send/unicast")
@EditAlertLayout
@PreAuthorize("hasRole('app-upush-send-unicast')")
public JSONResult appUPushSendUnicast(@RequestBody AppUPushSendUnicastParam param) {
appPushService.sendUnicastNotification(param.getUserTokens(), param.getTitle(),
param.getText(), param.getUri(), param.getDescription());
return JSONResult.ok();
}
@ApiOperation(value = "发送广播", notes = "发送广播")
@PostMapping("/v1/app/upush/send/broadcast")
@EditAlertLayout
@PreAuthorize("hasRole('app-upush-send-broadcast')")
public JSONResult appUPushSendBroadcast(@RequestBody AppUPushSendBroadcastParam param) {
appPushService.sendBroadcastNotification(param.getTitle(), param.getText(), param.getUri(), param.getDescription());
return JSONResult.ok();
}
@ApiOperation(value = "客户端用户关系表", notes = "客户端用户关系表")
@GetMapping("v1/app/push/client-user/list")
@PageLayout
@PreAuthorize("hasRole('app-push-client-user-list')")
@AdminMenu(menuName = "客户端用户关系表", order = 5)
public JSONResult<Page<PushClientInfo>> appPushClientUserList(@Valid PageParam page) {
return JSONResult.ok(jpaPageToPage(
pushClientInfoService.page(page, null),
page
));
}
@ApiOperation(value = "友盟推送配置", notes = "友盟推送配置")
@PostMapping("/v1/app/upush/config")
@EditLayout(paddingMappingMethod = "appUPushConfigGet")
@PreAuthorize("hasRole('app-upush-config')")
@AdminMenu(menuName = "友盟推送配置", order = 50)
public JSONResult appUPushConfig(@RequestBody UPushConfig param) {
uPushConfigService.set(param);
return JSONResult.ok();
}
@ApiOperation(value = "获取热更新配置", notes = "获取热更新配置")
@GetMapping("/v1/app/upush/config")
@PreAuthorize("hasRole('app-upush-config')")
public JSONResult<UPushConfig> appUPushConfigGet() {
return JSONResult.ok(uPushConfigService.get());
}
}
*/