提交 b82c39e6 编写于 作者: J johnniang

Move test mail to MailController

上级 0b4823d0
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("发送成功");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册