提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.controller.admin.notify; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.enums.UserTypeEnum; |
|
4 |
import com.iailab.framework.common.pojo.CommonResult; |
|
5 |
import com.iailab.framework.common.pojo.PageResult; |
|
6 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
7 |
import com.iailab.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO; |
|
8 |
import com.iailab.module.system.controller.admin.notify.vo.template.NotifyTemplateRespVO; |
|
9 |
import com.iailab.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO; |
|
10 |
import com.iailab.module.system.controller.admin.notify.vo.template.NotifyTemplateSendReqVO; |
|
11 |
import com.iailab.module.system.dal.dataobject.notify.NotifyTemplateDO; |
|
12 |
import com.iailab.module.system.service.notify.NotifySendService; |
|
13 |
import com.iailab.module.system.service.notify.NotifyTemplateService; |
|
14 |
import io.swagger.v3.oas.annotations.Operation; |
|
15 |
import io.swagger.v3.oas.annotations.Parameter; |
|
16 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
17 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
18 |
import org.springframework.validation.annotation.Validated; |
|
19 |
import org.springframework.web.bind.annotation.*; |
|
20 |
|
|
21 |
import javax.annotation.Resource; |
|
22 |
import javax.validation.Valid; |
|
23 |
|
|
24 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
25 |
|
|
26 |
@Tag(name = "管理后台 - 站内信模版") |
|
27 |
@RestController |
|
28 |
@RequestMapping("/system/notify-template") |
|
29 |
@Validated |
|
30 |
public class NotifyTemplateController { |
|
31 |
|
|
32 |
@Resource |
|
33 |
private NotifyTemplateService notifyTemplateService; |
|
34 |
|
|
35 |
@Resource |
|
36 |
private NotifySendService notifySendService; |
|
37 |
|
|
38 |
@PostMapping("/create") |
|
39 |
@Operation(summary = "创建站内信模版") |
|
40 |
@PreAuthorize("@ss.hasPermission('system:notify-template:create')") |
|
41 |
public CommonResult<Long> createNotifyTemplate(@Valid @RequestBody NotifyTemplateSaveReqVO createReqVO) { |
|
42 |
return success(notifyTemplateService.createNotifyTemplate(createReqVO)); |
|
43 |
} |
|
44 |
|
|
45 |
@PutMapping("/update") |
|
46 |
@Operation(summary = "更新站内信模版") |
|
47 |
@PreAuthorize("@ss.hasPermission('system:notify-template:update')") |
|
48 |
public CommonResult<Boolean> updateNotifyTemplate(@Valid @RequestBody NotifyTemplateSaveReqVO updateReqVO) { |
|
49 |
notifyTemplateService.updateNotifyTemplate(updateReqVO); |
|
50 |
return success(true); |
|
51 |
} |
|
52 |
|
|
53 |
@DeleteMapping("/delete") |
|
54 |
@Operation(summary = "删除站内信模版") |
|
55 |
@Parameter(name = "id", description = "编号", required = true) |
|
56 |
@PreAuthorize("@ss.hasPermission('system:notify-template:delete')") |
|
57 |
public CommonResult<Boolean> deleteNotifyTemplate(@RequestParam("id") Long id) { |
|
58 |
notifyTemplateService.deleteNotifyTemplate(id); |
|
59 |
return success(true); |
|
60 |
} |
|
61 |
|
|
62 |
@GetMapping("/get") |
|
63 |
@Operation(summary = "获得站内信模版") |
|
64 |
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
65 |
@PreAuthorize("@ss.hasPermission('system:notify-template:query')") |
|
66 |
public CommonResult<NotifyTemplateRespVO> getNotifyTemplate(@RequestParam("id") Long id) { |
|
67 |
NotifyTemplateDO template = notifyTemplateService.getNotifyTemplate(id); |
|
68 |
return success(BeanUtils.toBean(template, NotifyTemplateRespVO.class)); |
|
69 |
} |
|
70 |
|
|
71 |
@GetMapping("/page") |
|
72 |
@Operation(summary = "获得站内信模版分页") |
|
73 |
@PreAuthorize("@ss.hasPermission('system:notify-template:query')") |
|
74 |
public CommonResult<PageResult<NotifyTemplateRespVO>> getNotifyTemplatePage(@Valid NotifyTemplatePageReqVO pageVO) { |
|
75 |
PageResult<NotifyTemplateDO> pageResult = notifyTemplateService.getNotifyTemplatePage(pageVO); |
|
76 |
return success(BeanUtils.toBean(pageResult, NotifyTemplateRespVO.class)); |
|
77 |
} |
|
78 |
|
|
79 |
@PostMapping("/send-notify") |
|
80 |
@Operation(summary = "发送站内信") |
|
81 |
@PreAuthorize("@ss.hasPermission('system:notify-template:send-notify')") |
|
82 |
public CommonResult<Long> sendNotify(@Valid @RequestBody NotifyTemplateSendReqVO sendReqVO) { |
|
83 |
if (UserTypeEnum.MEMBER.getValue().equals(sendReqVO.getUserType())) { |
|
84 |
return success(notifySendService.sendSingleNotifyToMember(sendReqVO.getUserId(), |
|
85 |
sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams())); |
|
86 |
} else { |
|
87 |
return success(notifySendService.sendSingleNotifyToAdmin(sendReqVO.getUserId(), |
|
88 |
sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams())); |
|
89 |
} |
|
90 |
} |
|
91 |
} |