package com.iailab.module.system.controller.admin.mail; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO; import com.iailab.module.system.controller.admin.mail.vo.account.MailAccountRespVO; import com.iailab.module.system.controller.admin.mail.vo.account.MailAccountSaveReqVO; import com.iailab.module.system.controller.admin.mail.vo.account.MailAccountSimpleRespVO; import com.iailab.module.system.dal.dataobject.mail.MailAccountDO; import com.iailab.module.system.service.mail.MailAccountService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; import java.util.List; import static com.iailab.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 邮箱账号") @RestController @RequestMapping("/system/mail-account") public class MailAccountController { @Resource private MailAccountService mailAccountService; @PostMapping("/create") @Operation(summary = "创建邮箱账号") @PreAuthorize("@ss.hasPermission('system:mail-account:create')") public CommonResult createMailAccount(@Valid @RequestBody MailAccountSaveReqVO createReqVO) { return success(mailAccountService.createMailAccount(createReqVO)); } @PutMapping("/update") @Operation(summary = "修改邮箱账号") @PreAuthorize("@ss.hasPermission('system:mail-account:update')") public CommonResult updateMailAccount(@Valid @RequestBody MailAccountSaveReqVO updateReqVO) { mailAccountService.updateMailAccount(updateReqVO); return success(true); } @DeleteMapping("/delete") @Operation(summary = "删除邮箱账号") @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('system:mail-account:delete')") public CommonResult deleteMailAccount(@RequestParam Long id) { mailAccountService.deleteMailAccount(id); return success(true); } @GetMapping("/get") @Operation(summary = "获得邮箱账号") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('system:mail-account:query')") public CommonResult getMailAccount(@RequestParam("id") Long id) { MailAccountDO account = mailAccountService.getMailAccount(id); return success(BeanUtils.toBean(account, MailAccountRespVO.class)); } @GetMapping("/page") @Operation(summary = "获得邮箱账号分页") @PreAuthorize("@ss.hasPermission('system:mail-account:query')") public CommonResult> getMailAccountPage(@Valid MailAccountPageReqVO pageReqVO) { PageResult pageResult = mailAccountService.getMailAccountPage(pageReqVO); return success(BeanUtils.toBean(pageResult, MailAccountRespVO.class)); } @GetMapping({"/list-all-simple", "simple-list"}) @Operation(summary = "获得邮箱账号精简列表") public CommonResult> getSimpleMailAccountList() { List list = mailAccountService.getMailAccountList(); return success(BeanUtils.toBean(list, MailAccountSimpleRespVO.class)); } }