From 6632ca1e355a42c2bcfc48889ce26a43e5ee4324 Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:27:36 +0800 Subject: [PATCH] ADD file via upload --- SystemAnnouncementController.java | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 SystemAnnouncementController.java diff --git a/SystemAnnouncementController.java b/SystemAnnouncementController.java new file mode 100644 index 0000000..8521656 --- /dev/null +++ b/SystemAnnouncementController.java @@ -0,0 +1,34 @@ +package com.qsd.orange.controller; + +import com.qsd.orange.global.R; +import com.qsd.orange.po.SysAnnouncement; +import com.qsd.orange.service.AnnouncementService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.userdetails.User; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; + +@RestController +@RequestMapping("system/announcement") +public class SystemAnnouncementController { + + @Autowired + private AnnouncementService announcementService; + + @PostMapping("add") + public R add(@Valid SysAnnouncement announcement, Authentication authentication){ + User user = (User)authentication.getPrincipal(); + String username = user.getUsername(); + return R.choose(announcementService.add(announcement, username) > 0); + } + + @PostMapping("update") + public R update(SysAnnouncement announcement){ + return R.choose(announcementService.update(announcement) > 0); + } + +}