mirror of https://github.com/halo-dev/halo
Move test mail to MailController
parent
0b4823d015
commit
b82c39e620
|
@ -0,0 +1,34 @@
|
|||
package run.halo.app.controller.admin.api;
|
||||
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import run.halo.app.model.params.MailParam;
|
||||
import run.halo.app.model.support.BaseResponse;
|
||||
import run.halo.app.service.MailService;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* Mail controller.
|
||||
*
|
||||
* @author johnniang
|
||||
* @date 19-5-7
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/admin/mails")
|
||||
public class MailController {
|
||||
|
||||
private final MailService mailService;
|
||||
|
||||
public MailController(MailService mailService) {
|
||||
this.mailService = mailService;
|
||||
}
|
||||
|
||||
@PostMapping("test")
|
||||
public BaseResponse testMail(@Valid @RequestBody MailParam mailParam) {
|
||||
mailService.sendMail(mailParam.getTo(), mailParam.getSubject(), mailParam.getContent());
|
||||
return BaseResponse.ok("发送成功");
|
||||
}
|
||||
}
|
|
@ -26,12 +26,8 @@ public class OptionController {
|
|||
|
||||
private final OptionService optionService;
|
||||
|
||||
private final MailService mailService;
|
||||
|
||||
public OptionController(OptionService optionService,
|
||||
MailService mailService) {
|
||||
public OptionController(OptionService optionService) {
|
||||
this.optionService = optionService;
|
||||
this.mailService = mailService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
|
@ -46,7 +42,7 @@ public class OptionController {
|
|||
|
||||
@GetMapping("map_view")
|
||||
@ApiOperation("Lists all options with map view")
|
||||
public Map<String, Object> listAllWithMapView(@RequestParam(value = "key", required = false) List<String> keys) {
|
||||
public Map<String, Object> listAllWithMapView(@RequestParam(value = "key[]", required = false) List<String> keys) {
|
||||
if (CollectionUtils.isEmpty(keys)) {
|
||||
return optionService.listOptions();
|
||||
}
|
||||
|
@ -55,7 +51,7 @@ public class OptionController {
|
|||
}
|
||||
|
||||
@GetMapping("map_keys")
|
||||
@ApiOperation("List all of options by keys")
|
||||
@ApiOperation("List all of options by keys, replaced by `listAllWithMapView`")
|
||||
@Deprecated
|
||||
public Map<String, Object> listByKeysWithMapView(@RequestParam(value = "keys") String keys) {
|
||||
return optionService.listByKeys(keys);
|
||||
|
@ -67,9 +63,4 @@ public class OptionController {
|
|||
optionService.save(optionMap);
|
||||
}
|
||||
|
||||
@PostMapping("test_mail")
|
||||
public BaseResponse testMail(@Valid @RequestBody MailParam mailParam){
|
||||
mailService.sendMail(mailParam.getTo(),mailParam.getSubject(),mailParam.getContent());
|
||||
return BaseResponse.ok("发送成功");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue