|
|
@@ -4,13 +4,22 @@ import com.chuanghai.repair.entity.RepairsNotice;
|
|
|
import com.chuanghai.repair.service.RepairsNoticeService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
+/**
|
|
|
+ * @Author: 浮生
|
|
|
+ * @Date: 2022/2/25 星期五 19:36
|
|
|
+ * @Description: com.chuanghai.repair.controller
|
|
|
+ * @version: 1.0
|
|
|
+ */
|
|
|
@Api(tags = "公告管理")
|
|
|
@RestController
|
|
|
@RequestMapping("/notice")
|
|
|
@@ -19,33 +28,47 @@ public class NoticeController {
|
|
|
@Resource(name = "repairsNoticeService")
|
|
|
private RepairsNoticeService repairsNoticeService;
|
|
|
|
|
|
-// @ApiOperation("添加公告")
|
|
|
-// @PostMapping(value = "/addNotice")
|
|
|
-// public Boolean addNotice(String noticeContent, Date noticeTime, Integer adminId){
|
|
|
-//
|
|
|
-// }
|
|
|
+ @ApiOperation("添加公告")
|
|
|
+ @PostMapping(value = "/addNotice")
|
|
|
+ public Boolean addNotice(@ApiParam(name = "公告内容", required = true) String noticeContent,
|
|
|
+ @ApiParam(name = "发布时间") String noticeTime,
|
|
|
+ @ApiParam(name = "发布管理员Id") Integer adminId) {
|
|
|
+ //flag false 添加失败 true 添加成功
|
|
|
+ Boolean flag = Boolean.FALSE;
|
|
|
+ try {
|
|
|
+ if (adminId != null) {
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ noticeTime = df.format(new Date());
|
|
|
+ repairsNoticeService.addNotice(noticeContent, noticeTime, adminId);
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
|
|
|
@ApiOperation("发布公告")
|
|
|
@PostMapping(value = "/releaseNotice")
|
|
|
- public RepairsNotice releaseNotice(){
|
|
|
+ public RepairsNotice releaseNotice() {
|
|
|
RepairsNotice repairsNotice = null;
|
|
|
try {
|
|
|
repairsNotice = repairsNoticeService.releaseNotice();
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return repairsNotice;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("删除公告")
|
|
|
- @PostMapping(value = "/updateNotice")
|
|
|
- public Boolean updateNotice(String noticeId){
|
|
|
+ // @ApiOperation("删除公告")
|
|
|
+// @PostMapping(value = "/updateNotice")
|
|
|
+ public Boolean updateNotice(@ApiParam(name = "公告Id", required = true) String noticeId) {
|
|
|
Boolean flag = Boolean.FALSE;
|
|
|
try {
|
|
|
- if(repairsNoticeService.updateNotice(noticeId) == null){
|
|
|
+ if (repairsNoticeService.updateNotice(noticeId) == null) {
|
|
|
flag = Boolean.TRUE;
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return flag;
|
|
|
@@ -53,19 +76,31 @@ public class NoticeController {
|
|
|
|
|
|
// @ApiOperation("修改公告")
|
|
|
// @PostMapping(value = "/alterNotice")
|
|
|
-// public Boolean alterNotice(String noticeContent, Date noticeTime, Integer noticeId){
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
- @ApiOperation("查询全部公告")
|
|
|
- @PostMapping(value = "/queryAllNotice")
|
|
|
- public RepairsNotice queryAllNotice(String noticeStatus){
|
|
|
- RepairsNotice repairsNotice = null;
|
|
|
+ public Boolean alterNotice(@ApiParam(name = "公告内容", required = true) String noticeContent,
|
|
|
+ @ApiParam(name = "修改时间") String noticeTime,
|
|
|
+ @ApiParam(name = "公告Id", required = true) Integer noticeId) {
|
|
|
+ //flag false 修改失败 true 修改成功
|
|
|
+ Boolean flag = Boolean.FALSE;
|
|
|
try {
|
|
|
- if(noticeStatus!="" && noticeStatus!=null){
|
|
|
- repairsNotice = repairsNoticeService.queryAllNotice(noticeStatus);
|
|
|
+ if (noticeId != null) {
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ noticeTime = df.format(new Date());
|
|
|
+ repairsNoticeService.alterNotice(noticeContent, noticeTime, noticeId);
|
|
|
+ flag = Boolean.TRUE;
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ // @ApiOperation("查询全部公告")
|
|
|
+// @PostMapping(value = "/queryAllNotice")
|
|
|
+ public List<RepairsNotice> queryAllNotice() {
|
|
|
+ List<RepairsNotice> repairsNotice = null;
|
|
|
+ try {
|
|
|
+ repairsNotice = repairsNoticeService.queryAllNotice();
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return repairsNotice;
|