提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.controller.admin.mail; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.pojo.CommonResult; |
|
4 |
import com.iailab.framework.common.pojo.PageResult; |
|
5 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
6 |
import com.iailab.module.system.controller.admin.mail.vo.template.*; |
|
7 |
import com.iailab.module.system.dal.dataobject.mail.MailTemplateDO; |
|
8 |
import com.iailab.module.system.service.mail.MailSendService; |
|
9 |
import com.iailab.module.system.service.mail.MailTemplateService; |
|
10 |
import io.swagger.v3.oas.annotations.Operation; |
|
11 |
import io.swagger.v3.oas.annotations.Parameter; |
|
12 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
13 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
14 |
import org.springframework.web.bind.annotation.*; |
|
15 |
|
|
16 |
import javax.annotation.Resource; |
|
17 |
import javax.validation.Valid; |
|
18 |
import java.util.List; |
|
19 |
|
|
20 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
21 |
import static com.iailab.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
|
22 |
|
|
23 |
@Tag(name = "管理后台 - 邮件模版") |
|
24 |
@RestController |
|
25 |
@RequestMapping("/system/mail-template") |
|
26 |
public class MailTemplateController { |
|
27 |
|
|
28 |
@Resource |
|
29 |
private MailTemplateService mailTempleService; |
|
30 |
@Resource |
|
31 |
private MailSendService mailSendService; |
|
32 |
|
|
33 |
@PostMapping("/create") |
|
34 |
@Operation(summary = "创建邮件模版") |
|
35 |
@PreAuthorize("@ss.hasPermission('system:mail-template:create')") |
|
36 |
public CommonResult<Long> createMailTemplate(@Valid @RequestBody MailTemplateSaveReqVO createReqVO){ |
|
37 |
return success(mailTempleService.createMailTemplate(createReqVO)); |
|
38 |
} |
|
39 |
|
|
40 |
@PutMapping("/update") |
|
41 |
@Operation(summary = "修改邮件模版") |
|
42 |
@PreAuthorize("@ss.hasPermission('system:mail-template:update')") |
|
43 |
public CommonResult<Boolean> updateMailTemplate(@Valid @RequestBody MailTemplateSaveReqVO updateReqVO){ |
|
44 |
mailTempleService.updateMailTemplate(updateReqVO); |
|
45 |
return success(true); |
|
46 |
} |
|
47 |
|
|
48 |
@DeleteMapping("/delete") |
|
49 |
@Operation(summary = "删除邮件模版") |
|
50 |
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
51 |
@PreAuthorize("@ss.hasPermission('system:mail-template:delete')") |
|
52 |
public CommonResult<Boolean> deleteMailTemplate(@RequestParam("id") Long id) { |
|
53 |
mailTempleService.deleteMailTemplate(id); |
|
54 |
return success(true); |
|
55 |
} |
|
56 |
|
|
57 |
@GetMapping("/get") |
|
58 |
@Operation(summary = "获得邮件模版") |
|
59 |
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
60 |
@PreAuthorize("@ss.hasPermission('system:mail-template:query')") |
|
61 |
public CommonResult<MailTemplateRespVO> getMailTemplate(@RequestParam("id") Long id) { |
|
62 |
MailTemplateDO template = mailTempleService.getMailTemplate(id); |
|
63 |
return success(BeanUtils.toBean(template, MailTemplateRespVO.class)); |
|
64 |
} |
|
65 |
|
|
66 |
@GetMapping("/page") |
|
67 |
@Operation(summary = "获得邮件模版分页") |
|
68 |
@PreAuthorize("@ss.hasPermission('system:mail-template:query')") |
|
69 |
public CommonResult<PageResult<MailTemplateRespVO>> getMailTemplatePage(@Valid MailTemplatePageReqVO pageReqVO) { |
|
70 |
PageResult<MailTemplateDO> pageResult = mailTempleService.getMailTemplatePage(pageReqVO); |
|
71 |
return success(BeanUtils.toBean(pageResult, MailTemplateRespVO.class)); |
|
72 |
} |
|
73 |
|
|
74 |
@GetMapping({"/list-all-simple", "simple-list"}) |
|
75 |
@Operation(summary = "获得邮件模版精简列表") |
|
76 |
public CommonResult<List<MailTemplateSimpleRespVO>> getSimpleTemplateList() { |
|
77 |
List<MailTemplateDO> list = mailTempleService.getMailTemplateList(); |
|
78 |
return success(BeanUtils.toBean(list, MailTemplateSimpleRespVO.class)); |
|
79 |
} |
|
80 |
|
|
81 |
@PostMapping("/send-mail") |
|
82 |
@Operation(summary = "发送短信") |
|
83 |
@PreAuthorize("@ss.hasPermission('system:mail-template:send-mail')") |
|
84 |
public CommonResult<Long> sendMail(@Valid @RequestBody MailTemplateSendReqVO sendReqVO) { |
|
85 |
return success(mailSendService.sendSingleMailToAdmin(sendReqVO.getMail(), getLoginUserId(), |
|
86 |
sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams())); |
|
87 |
} |
|
88 |
|
|
89 |
} |