浏览代码

feat:“添加公告功能”

soobin 1 年之前
父节点
当前提交
78b4dda84a
共有 1 个文件被更改,包括 19 次插入4 次删除
  1. 19 4
      src/main/java/com/szwl/controller/TNoticeController.java

+ 19 - 4
src/main/java/com/szwl/controller/TNoticeController.java

@@ -16,11 +16,9 @@ import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -38,6 +36,23 @@ public class TNoticeController {
     TAdminService tAdminService;
     TAdminService tAdminService;
     @Autowired
     @Autowired
     TNoticeService noticeService;
     TNoticeService noticeService;
+
+    @ApiOperation(value = "添加公告")
+    @GetMapping("/addNotice")
+    public ResponseModel<?> addNotice(@RequestBody TNotice notice) {
+        if(StringUtils.isEmpty(notice.getNote())){
+            return R.fail(ResponseCodesEnum.A0001,"内容为空");
+        }
+        TNotice tNotice = new TNotice();
+        tNotice.setCreateDate(new Date());
+        tNotice.setModifyDate(new Date());
+        tNotice.setTitle(notice.getTitle());
+        tNotice.setNote(notice.getNote());
+        tNotice.setStatus("0");
+        noticeService.save(tNotice);
+        return R.ok(tNotice,"添加成功");
+    }
+
     @ApiOperation(value = "获取公告")
     @ApiOperation(value = "获取公告")
     @GetMapping("/getNotice")
     @GetMapping("/getNotice")
     public ResponseModel<?> getNotice(String adminId) {
     public ResponseModel<?> getNotice(String adminId) {