|
|
@@ -0,0 +1,69 @@
|
|
|
+package cn.reghao.devops.manager.notification.controller;
|
|
|
+
|
|
|
+import cn.reghao.devops.manager.notification.db.repository.NotifyReceiverRepository;
|
|
|
+import cn.reghao.devops.manager.notification.model.po.NotifyReceiver;
|
|
|
+import cn.reghao.devops.manager.util.db.PageSort;
|
|
|
+import cn.reghao.jutil.jdk.result.WebResult;
|
|
|
+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.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author reghao
|
|
|
+ * @date 2024-01-26 20:32:24
|
|
|
+ */
|
|
|
+@Api(tags = "通知接收页面")
|
|
|
+@Controller
|
|
|
+@RequestMapping("/sys/notify/receiver")
|
|
|
+public class NotifyReceiverController {
|
|
|
+ private final NotifyReceiverRepository notifyReceiverRepository;
|
|
|
+
|
|
|
+ public NotifyReceiverController(NotifyReceiverRepository notifyReceiverRepository) {
|
|
|
+ this.notifyReceiverRepository = notifyReceiverRepository;
|
|
|
+ }
|
|
|
+
|
|
|
+ @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";
|
|
|
+ }
|
|
|
+
|
|
|
+ @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 = "/save", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String saveReceiver(@Validated NotifyReceiver notifyReceiver) {
|
|
|
+ String type = notifyReceiver.getType();
|
|
|
+ NotifyReceiver notifyReceiver1 = notifyReceiverRepository.findByType(type);
|
|
|
+ return WebResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping(value = "/delete/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String deleteReceiver(@PathVariable("name") String name) throws Exception {
|
|
|
+ NotifyReceiver notifyReceiver = notifyReceiverRepository.findByName(name);
|
|
|
+ if (notifyReceiver != null) {
|
|
|
+ notifyReceiverRepository.delete(notifyReceiver);
|
|
|
+ }
|
|
|
+
|
|
|
+ return WebResult.success();
|
|
|
+ }
|
|
|
+}
|