diff --git a/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeController.java b/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeController.java index 6bd74d7..801231f 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeController.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeController.java @@ -35,7 +35,7 @@ public class NoticeController { //根据公告id查公告信息及发布人 @GetMapping("/{nid}") - public ResponseResult selectByNoticeId(@PathVariable Long nid) { + public ResponseResult selectByNoticeId(@PathVariable Long nid) { Notice noticeById = noticeService.selectByNoticeId(nid); Integer code = noticeById != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; String msg = noticeById != null ? "" : "数据查询失败,请重试!"; @@ -44,7 +44,7 @@ public class NoticeController { //查询所有公告或模糊查询 @GetMapping - public ResponseResult selectAllNotice(String title, String type, String startTime, String endTime) { + public ResponseResult> selectAllNotice(String title, String type, String startTime, String endTime) { List noticeList; if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) { noticeList = noticeService.selectAllNotice(); @@ -59,7 +59,7 @@ public class NoticeController { //根据登录用户id查询所接收的公告 @GetMapping("/self") - public ResponseResult selectByUserId(Integer readStatus) { + public ResponseResult> selectByUserId(Integer readStatus) { List noticesByUserId = noticeReceiveService.selectByUserId(readStatus); Integer code = noticesByUserId != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; String msg = noticesByUserId != null ? "" : "数据查询失败,请重试!"; @@ -68,52 +68,52 @@ public class NoticeController { //修改登录用户所接收公告的阅读状态 @PutMapping("/modify_notice_read") - public ResponseResult modifyNoticeIsRead(@RequestBody Notice notice) { + public ResponseResult modifyNoticeIsRead(@RequestBody Notice notice) { boolean updateById = false; if (null != notice) { updateById = noticeReceiveService.modifyNoticeIsRead(notice); } String msg = updateById ? "" : "服务器出错,请重试!"; - return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById); + return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null); } //更新公告 @PutMapping - public ResponseResult updateNotice(@RequestBody Notice notice) { + public ResponseResult updateNotice(@RequestBody Notice notice) { boolean updateById = noticeService.updateNotice(notice); String msg = updateById ? "" : "数据修改失败,请重试!"; - return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById); + return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null); } //修改公告置顶状态 @PutMapping("/update_notice_top") - public ResponseResult updateNoticeTop(@RequestBody Notice notice) { + public ResponseResult updateNoticeTop(@RequestBody Notice notice) { String operationMessage = notice.getTop() == 1 ? "取消置顶" : "置顶"; boolean updateResult = noticeService.updateNoticeTop(notice); String msg = updateResult ? "已成功" + operationMessage : operationMessage + "失败,请重试!"; - return ResponseResult.build(updateResult ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateResult); + return ResponseResult.build(updateResult ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null); } //添加公告 @PostMapping - public ResponseResult addNotice(@RequestBody Notice notice) { + public ResponseResult addNotice(@RequestBody Notice notice) { Boolean insertNotice = noticeService.addNotice(notice); String msg = insertNotice ? "" : "数据添加失败,请重试!"; - return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, insertNotice); + return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg,null); } //删除公告 @DeleteMapping("/{nid}") - public ResponseResult deleteByNoticeId(@PathVariable Long nid) { + public ResponseResult deleteByNoticeId(@PathVariable Long nid) { boolean removeById = noticeService.deleteById(nid); String msg = removeById ? "" : "数据删除失败,请重试!"; - return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, removeById); + return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null); } //分页查询所有公告或分页模糊查询 @GetMapping("/page") - public ResponseResult selectPageAllNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) { + public ResponseResult> selectPageAllNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) { IPage noticePageList; Page page = new Page(); if (null != currentPage && null != pageSize) { diff --git a/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeTypeController.java b/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeTypeController.java index d7c6eb3..18de656 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeTypeController.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeTypeController.java @@ -32,7 +32,7 @@ public class NoticeTypeController { //查询已启用的公告类型 @GetMapping("/enable") - public ResponseResult selectEnableTypeList(){ + public ResponseResult> selectEnableTypeList(){ List selectTypeName = noticeTypeService.selectEnableTypeList(); Integer code = selectTypeName != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; String msg = selectTypeName != null ? "" : "数据查询失败,请重试!"; @@ -41,7 +41,7 @@ public class NoticeTypeController { //查询所有公告类型 @GetMapping - public ResponseResult selectTypeList(){ + public ResponseResult> selectTypeList(){ List selectTypeList = noticeTypeService.selectTypeList(); Integer code = selectTypeList != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; String msg = selectTypeList != null ? "" : "数据查询失败,请重试!"; @@ -50,14 +50,14 @@ public class NoticeTypeController { //修改公告类型启用或禁用 @GetMapping("/update") - public ResponseResult updateTypeEnableById(String typeId,Integer enable){ + public ResponseResult updateTypeEnableById(String typeId,Integer enable){ Long tid=null; if (StringUtils.hasText(typeId)){ tid = Long.parseLong(typeId); } Boolean updateEnableById = noticeTypeService.updateTypeEnableById(tid, enable); String msg = updateEnableById ? "" : "修改失败,请重试!"; - return ResponseResult.build(updateEnableById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateEnableById); + return ResponseResult.build(updateEnableById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null); } //添加公告类型 @@ -67,4 +67,20 @@ public class NoticeTypeController { String msg = insertNotice ? "" : "数据添加失败,请重试!"; return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, insertNotice); } + + //修改公告类型 + @PutMapping + public ResponseResult updateNoticeType(@RequestBody NoticeType noticeType){ + boolean updateById =noticeTypeService.updateNoticeType(noticeType); + String msg = updateById ? "" : "数据修改失败,请重试!"; + return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null); + } + + //删除公告类型 + @DeleteMapping("/{typeId}") + public ResponseResult deleteNoticeTypeById(@PathVariable Long typeId) { + boolean removeById = noticeTypeService.deleteNoticeTypeById(typeId); + String msg = removeById ? "" : "数据删除失败,请重试!"; + return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null); + } } diff --git a/Pinnacle/src/main/java/com/cfive/pinnacle/service/INoticeTypeService.java b/Pinnacle/src/main/java/com/cfive/pinnacle/service/INoticeTypeService.java index 69f265a..80289d4 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/service/INoticeTypeService.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/service/INoticeTypeService.java @@ -21,4 +21,9 @@ public interface INoticeTypeService extends IService { Boolean addNoticeType(NoticeType noticeType); + Boolean updateNoticeType(NoticeType noticeType); + + Boolean deleteNoticeTypeById(Long typeId); + + } diff --git a/Pinnacle/src/main/java/com/cfive/pinnacle/service/impl/NoticeTypeServiceImpl.java b/Pinnacle/src/main/java/com/cfive/pinnacle/service/impl/NoticeTypeServiceImpl.java index 255f3e0..fa645f1 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/service/impl/NoticeTypeServiceImpl.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/service/impl/NoticeTypeServiceImpl.java @@ -54,4 +54,14 @@ public class NoticeTypeServiceImpl extends ServiceImpl0; } + + @Override + public Boolean updateNoticeType(NoticeType noticeType) { + return noticeTypeMapper.updateById(noticeType)>0; + } + + @Override + public Boolean deleteNoticeTypeById(Long typeId) { + return noticeTypeMapper.deleteById(typeId)>0; + } } diff --git a/ui/src/components/notice/NoticeCommitForm.vue b/ui/src/components/notice/NoticeCommitForm.vue index f397aee..a0dea39 100644 --- a/ui/src/components/notice/NoticeCommitForm.vue +++ b/ui/src/components/notice/NoticeCommitForm.vue @@ -1,113 +1,123 @@ -