Showing
1 changed file
with
56 additions
and
58 deletions
@@ -34,68 +34,66 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant. | @@ -34,68 +34,66 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant. | ||
34 | @RequiredArgsConstructor | 34 | @RequiredArgsConstructor |
35 | public class YtNoticeController extends BaseController { | 35 | public class YtNoticeController extends BaseController { |
36 | 36 | ||
37 | - private final SysNoticeService sysNoticeService; | 37 | + private final SysNoticeService sysNoticeService; |
38 | 38 | ||
39 | - @GetMapping( | ||
40 | - path = "page", | ||
41 | - params = {PAGE_SIZE, PAGE}) | ||
42 | - @ApiOperation("分页") | ||
43 | - public YtPageData<SysNoticeDTO> page( | ||
44 | - @RequestParam(value = "type", required = false) SysNoticeTypeEnum type, | ||
45 | - @RequestParam(PAGE_SIZE) int pageSize, | ||
46 | - @RequestParam(PAGE) int page, | ||
47 | - @RequestParam(value = ORDER_FILED, required = false) String orderBy, | ||
48 | - @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) | ||
49 | - throws ThingsboardException { | ||
50 | - Map<String, Object> queryMap = new HashMap<>(); | ||
51 | - queryMap.put(PAGE_SIZE, pageSize); | ||
52 | - queryMap.put(PAGE, page); | ||
53 | - queryMap.put(ORDER_FILED, orderBy); | ||
54 | - queryMap.put("tenantId", getCurrentUser().getCurrentTenantId()); | ||
55 | - if (orderType != null) { | ||
56 | - queryMap.put(ORDER_TYPE, orderType.name()); | 39 | + @GetMapping( |
40 | + path = "page", | ||
41 | + params = {PAGE_SIZE, PAGE}) | ||
42 | + @ApiOperation("分页") | ||
43 | + public YtPageData<SysNoticeDTO> page( | ||
44 | + @RequestParam(value = "type", required = false) SysNoticeTypeEnum type, | ||
45 | + @RequestParam(PAGE_SIZE) int pageSize, | ||
46 | + @RequestParam(PAGE) int page, | ||
47 | + @RequestParam(value = ORDER_FILED, required = false) String orderBy, | ||
48 | + @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) | ||
49 | + throws ThingsboardException { | ||
50 | + Map<String, Object> queryMap = new HashMap<>(); | ||
51 | + queryMap.put(PAGE_SIZE, pageSize); | ||
52 | + queryMap.put(PAGE, page); | ||
53 | + queryMap.put(ORDER_FILED, orderBy); | ||
54 | + queryMap.put("tenantId", getCurrentUser().getCurrentTenantId()); | ||
55 | + if (orderType != null) { | ||
56 | + queryMap.put(ORDER_TYPE, orderType.name()); | ||
57 | + } | ||
58 | + // 通知类型 | ||
59 | + if (type != null) { | ||
60 | + queryMap.put("type", type.name()); | ||
61 | + } | ||
62 | + queryMap.put("creator", getCurrentUser().getCurrentUserId()); | ||
63 | + return sysNoticeService.page(queryMap); | ||
57 | } | 64 | } |
58 | - // 通知类型 | ||
59 | - if (type != null) { | ||
60 | - queryMap.put("type", type.name()); | ||
61 | - } | ||
62 | - if (getCurrentUser().isCustomerUser()){ | ||
63 | - //当前用户 | ||
64 | - queryMap.put("creator",getCurrentUser().getCurrentUserId()); | ||
65 | - } return sysNoticeService.page(queryMap); | ||
66 | - } | ||
67 | 65 | ||
68 | - @GetMapping("{id}") | ||
69 | - @ApiOperation("详情") | ||
70 | - public ResponseEntity<SysNoticeDTO> get(@PathVariable("id") String id) | ||
71 | - throws ThingsboardException { | ||
72 | - return ResponseEntity.ok(sysNoticeService.get(id, getCurrentUser().getCurrentTenantId())); | ||
73 | - } | 66 | + @GetMapping("{id}") |
67 | + @ApiOperation("详情") | ||
68 | + public ResponseEntity<SysNoticeDTO> get(@PathVariable("id") String id) | ||
69 | + throws ThingsboardException { | ||
70 | + return ResponseEntity.ok(sysNoticeService.get(id, getCurrentUser().getCurrentTenantId())); | ||
71 | + } | ||
74 | 72 | ||
75 | - @DeleteMapping("delete") | ||
76 | - @ApiOperation("批量删除") | ||
77 | - public void delete(@Validated({DeleteGroup.class})@RequestBody DeleteDTO deleteDTO) throws ThingsboardException { | ||
78 | - sysNoticeService.delete(deleteDTO.getIds(), getCurrentUser().getCurrentTenantId()); | ||
79 | - } | 73 | + @DeleteMapping("delete") |
74 | + @ApiOperation("批量删除") | ||
75 | + public void delete(@Validated({DeleteGroup.class}) @RequestBody DeleteDTO deleteDTO) throws ThingsboardException { | ||
76 | + sysNoticeService.delete(deleteDTO.getIds(), getCurrentUser().getCurrentTenantId()); | ||
77 | + } | ||
80 | 78 | ||
81 | - @PostMapping("save") | ||
82 | - @ApiOperation("保存草稿") | ||
83 | - public ResponseEntity<SysNoticeDTO> save(@Validated(AddGroup.class)@RequestBody SysNoticeDTO sysNoticeDTO) throws ThingsboardException { | ||
84 | - sysNoticeDTO.setStatus(FastIotConstants.DraftStatus.DRAFT); | ||
85 | - SysNoticeDTO newSysNoticeDTO = | ||
86 | - sysNoticeService.save(sysNoticeDTO, getCurrentUser().getCurrentTenantId()); | ||
87 | - return newSysNoticeDTO == null ? ResponseEntity.badRequest().build() : ResponseEntity.ok().build(); | ||
88 | - } | 79 | + @PostMapping("save") |
80 | + @ApiOperation("保存草稿") | ||
81 | + public ResponseEntity<SysNoticeDTO> save(@Validated(AddGroup.class) @RequestBody SysNoticeDTO sysNoticeDTO) throws ThingsboardException { | ||
82 | + sysNoticeDTO.setStatus(FastIotConstants.DraftStatus.DRAFT); | ||
83 | + SysNoticeDTO newSysNoticeDTO = | ||
84 | + sysNoticeService.save(sysNoticeDTO, getCurrentUser().getCurrentTenantId()); | ||
85 | + return newSysNoticeDTO == null ? ResponseEntity.badRequest().build() : ResponseEntity.ok().build(); | ||
86 | + } | ||
89 | 87 | ||
90 | - @PostMapping("send") | ||
91 | - @ApiOperation("发布通知") | ||
92 | - public ResponseEntity<SysNoticeDTO> send(@RequestBody SysNoticeDTO sysNoticeDTO) throws ThingsboardException { | ||
93 | - sysNoticeDTO.setStatus(FastIotConstants.DraftStatus.PUBLISHED); | ||
94 | - SysNoticeDTO sysNoticeDto = | ||
95 | - sysNoticeService.send( | ||
96 | - sysNoticeDTO, | ||
97 | - getCurrentUser().getCurrentTenantId(), | ||
98 | - getCurrentUser().getCurrentUserId()); | ||
99 | - return sysNoticeDto == null ? ResponseEntity.badRequest().build() : ResponseEntity.ok().build(); | ||
100 | - } | 88 | + @PostMapping("send") |
89 | + @ApiOperation("发布通知") | ||
90 | + public ResponseEntity<SysNoticeDTO> send(@RequestBody SysNoticeDTO sysNoticeDTO) throws ThingsboardException { | ||
91 | + sysNoticeDTO.setStatus(FastIotConstants.DraftStatus.PUBLISHED); | ||
92 | + SysNoticeDTO sysNoticeDto = | ||
93 | + sysNoticeService.send( | ||
94 | + sysNoticeDTO, | ||
95 | + getCurrentUser().getCurrentTenantId(), | ||
96 | + getCurrentUser().getCurrentUserId()); | ||
97 | + return sysNoticeDto == null ? ResponseEntity.badRequest().build() : ResponseEntity.ok().build(); | ||
98 | + } | ||
101 | } | 99 | } |