From 5a498a763fc29c6676d35881abe6eb7c966ddac9 Mon Sep 17 00:00:00 2001 From: cccccyb <995134776@qq.com> Date: Wed, 24 May 2023 03:47:59 +0800 Subject: [PATCH] add the function of updateNoticeType --- .../controller/NoticeTypeController.java | 13 ++- .../service/impl/NoticeTypeServiceImpl.java | 4 +- .../com/cfive/pinnacle/notice/NoticeTest.java | 5 -- ui/src/components/notice/NoticeCommitForm.vue | 2 - .../components/notice/NoticeManageTable.vue | 2 - .../notice/NoticeTypeCommitForm.vue | 26 ++++-- ui/src/components/notice/NoticeTypeTable.vue | 84 +++++++++++++------ ui/src/pages/notice/NoticeTypeManage.vue | 47 +++++++---- ui/src/store/notice.ts | 33 +++++--- 9 files changed, 141 insertions(+), 75 deletions(-) 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 d63703f..d7c6eb3 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeTypeController.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeTypeController.java @@ -4,6 +4,7 @@ import com.cfive.pinnacle.entity.NoticeType; import com.cfive.pinnacle.entity.common.ResponseCode; import com.cfive.pinnacle.entity.common.ResponseResult; import com.cfive.pinnacle.service.INoticeTypeService; +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,8 +24,8 @@ import java.util.List; @RestController @RequestMapping("/notice_type") @CrossOrigin +@Slf4j public class NoticeTypeController { - private final Logger LOGGER = LoggerFactory.getLogger(getClass()); @Autowired INoticeTypeService noticeTypeService; @@ -49,21 +50,19 @@ public class NoticeTypeController { //修改公告类型启用或禁用 @GetMapping("/update") - public ResponseResult updateTypeEnableById(String typeId,Boolean enable){ + public ResponseResult updateTypeEnableById(String typeId,Integer enable){ Long tid=null; - Integer isEnable = null; - if (StringUtils.hasText(typeId)&&null!=enable){ + if (StringUtils.hasText(typeId)){ tid = Long.parseLong(typeId); - isEnable = (enable == true ? 1 : 0); } - Boolean updateEnableById = noticeTypeService.updateTypeEnableById(tid, isEnable); + Boolean updateEnableById = noticeTypeService.updateTypeEnableById(tid, enable); String msg = updateEnableById ? "" : "修改失败,请重试!"; return ResponseResult.build(updateEnableById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateEnableById); } //添加公告类型 @PostMapping - public ResponseResult addNoticeType(NoticeType noticeType){ + public ResponseResult addNoticeType(@RequestBody NoticeType noticeType){ Boolean insertNotice = noticeTypeService.addNoticeType(noticeType); String msg = insertNotice ? "" : "数据添加失败,请重试!"; return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, insertNotice); 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 e4a6f51..255f3e0 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 @@ -27,7 +27,9 @@ public class NoticeTypeServiceImpl extends ServiceImpl selectTypeList() { - return noticeTypeMapper.selectList(null); + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.orderByDesc(NoticeType::getId); + return noticeTypeMapper.selectList(lqw); } @Override diff --git a/Pinnacle/src/test/java/com/cfive/pinnacle/notice/NoticeTest.java b/Pinnacle/src/test/java/com/cfive/pinnacle/notice/NoticeTest.java index 16910b5..bdc87db 100644 --- a/Pinnacle/src/test/java/com/cfive/pinnacle/notice/NoticeTest.java +++ b/Pinnacle/src/test/java/com/cfive/pinnacle/notice/NoticeTest.java @@ -40,11 +40,6 @@ public class NoticeTest { ResponseResult selectByNoticeId = noticeController.selectByNoticeId(21L); } - @Test - void selectAllTest() { -// ResponseResult noticeList = noticeController.selectAllNotice(null, null,null,null); - } - @Test void updateTest() { ResponseResult notice = noticeController.selectByNoticeId(23L); diff --git a/ui/src/components/notice/NoticeCommitForm.vue b/ui/src/components/notice/NoticeCommitForm.vue index 5492363..f397aee 100644 --- a/ui/src/components/notice/NoticeCommitForm.vue +++ b/ui/src/components/notice/NoticeCommitForm.vue @@ -181,8 +181,6 @@ export default { // 编辑操作 if (noticeStore.editFlag===true) { this.addData = noticeStore.noticeShowData - // 判断是否置顶 - this.addData.top=(noticeStore.noticeShowData.top===1); } }, mounted() { diff --git a/ui/src/components/notice/NoticeManageTable.vue b/ui/src/components/notice/NoticeManageTable.vue index d7bf98c..91f34a8 100644 --- a/ui/src/components/notice/NoticeManageTable.vue +++ b/ui/src/components/notice/NoticeManageTable.vue @@ -210,7 +210,6 @@ export default { return new Date(data).toLocaleString() }, handleEdit(row) { - console.log(row) noticeStore.$patch((state) => { state.hackReset = true state.noticeShowData = row @@ -228,7 +227,6 @@ export default { }) }, handleShow(row) { - console.log(row) noticeStore.$patch((state) => { state.dialogShowVisible = true state.noticeShowData = row diff --git a/ui/src/components/notice/NoticeTypeCommitForm.vue b/ui/src/components/notice/NoticeTypeCommitForm.vue index eb226e1..5a3854f 100644 --- a/ui/src/components/notice/NoticeTypeCommitForm.vue +++ b/ui/src/components/notice/NoticeTypeCommitForm.vue @@ -16,14 +16,24 @@ diff --git a/ui/src/components/notice/NoticeTypeTable.vue b/ui/src/components/notice/NoticeTypeTable.vue index 20b2e5d..903ff27 100644 --- a/ui/src/components/notice/NoticeTypeTable.vue +++ b/ui/src/components/notice/NoticeTypeTable.vue @@ -12,8 +12,7 @@ :header-cell-style="{ background: 'darksalmon', 'text-align': 'center', - color: '#fff', - 'font-size': '20px' + color: '#fff' }" > @@ -25,6 +24,8 @@ style="--el-switch-on-color: #13ce66; --el-switch-off-color: #afb2b8" active-text="启用" inactive-text="禁用" + :active-value="1" + :inactive-value="0" @change="switchChang(scope.row.id, scope.row.enable)" /> @@ -34,10 +35,7 @@