|
|
@@ -1,6 +1,5 @@
|
|
|
package cn.reghao.devops.web.sys.controller;
|
|
|
|
|
|
-import cn.reghao.devops.web.util.db.PageSort;
|
|
|
import cn.reghao.devops.web.sys.db.repository.EmailAccountRepository;
|
|
|
import cn.reghao.devops.web.sys.db.repository.NotifyReceiverRepository;
|
|
|
import cn.reghao.devops.web.sys.model.vo.NotifyType;
|
|
|
@@ -9,11 +8,7 @@ import cn.reghao.devops.web.sys.model.po.NotifyReceiver;
|
|
|
import cn.reghao.jutil.jdk.result.WebResult;
|
|
|
import cn.reghao.jutil.jdk.string.StringRegexp;
|
|
|
import io.swagger.annotations.Api;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.http.MediaType;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.ui.Model;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -23,35 +18,20 @@ import java.util.List;
|
|
|
* @author reghao
|
|
|
* @date 2024-01-26 20:32:24
|
|
|
*/
|
|
|
-@Api(tags = "通知接收页面")
|
|
|
-@Controller
|
|
|
-@RequestMapping("/sys/notify/receiver")
|
|
|
-public class NotifyReceiverController {
|
|
|
+@Api(tags = "通知接收接口")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/sys/notify/receiver")
|
|
|
+public class ReceiverController {
|
|
|
private final NotifyReceiverRepository notifyReceiverRepository;
|
|
|
private final EmailAccountRepository emailAccountRepository;
|
|
|
|
|
|
- public NotifyReceiverController(NotifyReceiverRepository notifyReceiverRepository,
|
|
|
- EmailAccountRepository emailAccountRepository) {
|
|
|
+ public ReceiverController(NotifyReceiverRepository notifyReceiverRepository,
|
|
|
+ EmailAccountRepository emailAccountRepository) {
|
|
|
this.notifyReceiverRepository = notifyReceiverRepository;
|
|
|
this.emailAccountRepository = emailAccountRepository;
|
|
|
}
|
|
|
|
|
|
- @GetMapping("")
|
|
|
- public String receiverIndex(Model model) throws Exception {
|
|
|
- PageRequest pageRequest = PageSort.pageRequest();
|
|
|
- Page<NotifyReceiver> page = notifyReceiverRepository.findAll(pageRequest);
|
|
|
- model.addAttribute("page", page);
|
|
|
- model.addAttribute("list", page.getContent());
|
|
|
- return "/sys/notify/receiver";
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/add")
|
|
|
- public String receiverAdd(Model model) throws Exception {
|
|
|
- return "/sys/notify/receiveradd";
|
|
|
- }
|
|
|
-
|
|
|
@PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- @ResponseBody
|
|
|
public String saveReceiver(@Validated NotifyReceiver notifyReceiver) {
|
|
|
String type = notifyReceiver.getType();
|
|
|
NotifyReceiver notifyReceiver1 = notifyReceiverRepository.findByType(type);
|
|
|
@@ -77,15 +57,7 @@ public class NotifyReceiverController {
|
|
|
return WebResult.success();
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/edit/{name}")
|
|
|
- public String receiverEdit(@PathVariable("name") String name, Model model) throws Exception {
|
|
|
- NotifyReceiver notifyReceiver = notifyReceiverRepository.findByName(name);
|
|
|
- model.addAttribute("notifyReceiver", notifyReceiver);
|
|
|
- return "/sys/notify/receiveredit";
|
|
|
- }
|
|
|
-
|
|
|
@PostMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- @ResponseBody
|
|
|
public String editReceiver(@Validated NotifyReceiver notifyReceiver) {
|
|
|
String name = notifyReceiver.getName();
|
|
|
NotifyReceiver notifyReceiver1 = notifyReceiverRepository.findByName(name);
|
|
|
@@ -100,7 +72,6 @@ public class NotifyReceiverController {
|
|
|
}
|
|
|
|
|
|
@DeleteMapping(value = "/delete/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- @ResponseBody
|
|
|
public String deleteReceiver(@PathVariable("name") String name) {
|
|
|
NotifyReceiver notifyReceiver = notifyReceiverRepository.findByName(name);
|
|
|
if (notifyReceiver != null) {
|