xin
2025-06-03 51df6e262c2d625e700a8194cbe0ec1e40b80843
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
package com.oying.rest;
 
import com.oying.service.EmailService;
import com.oying.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import com.oying.annotation.Log;
import com.oying.domain.dto.EmailDto;
import com.oying.domain.EmailConfig;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
/**
 * 发送邮件
 *
 * @author Z
 * @date 2018/09/28 6:55:53
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("api/email")
@Api(tags = "工具:邮件管理")
public class EmailController {
 
    private final EmailService emailService;
 
    @GetMapping
    public ResponseEntity<Object> queryEmailConfig() {
        return new ResponseEntity<>(R.success(emailService.find()), HttpStatus.OK);
    }
 
    @Log("配置邮件")
    @PutMapping
    @ApiOperation("配置邮件")
    public ResponseEntity<Object> updateEmailConfig(@Validated @RequestBody EmailConfig emailConfig) throws Exception {
        emailService.config(emailConfig, emailService.find());
        return new ResponseEntity<>(R.success(), HttpStatus.OK);
    }
 
    @Log("发送邮件")
    @PostMapping
    @ApiOperation("发送邮件")
    public ResponseEntity<Object> sendEmail(@Validated @RequestBody EmailDto emailDto) {
        emailService.send(emailDto, emailService.find());
        return new ResponseEntity<>(R.success(), HttpStatus.OK);
    }
}