From 7031dd593bb718154d19bc366d3b3a2cd2918ea4 Mon Sep 17 00:00:00 2001 From: cccccyb <995134776@qq.com> Date: Sun, 4 Jun 2023 18:32:25 +0800 Subject: [PATCH] add the function of fuzzy query in the page of NoticeView had been completed --- .../pinnacle/controller/NoticeController.java | 4 +- .../pinnacle/mapper/NoticeReceiveMapper.java | 3 +- .../service/INoticeReceiveService.java | 3 +- .../impl/NoticeReceiveServiceImpl.java | 20 ++- .../resources/mapper/NoticeReceiveMapper.xml | 12 ++ .../{NoticeHead.vue => NoticeManageHead.vue} | 1 - ui/src/components/notice/NoticeViewCard.vue | 4 +- ui/src/components/notice/NoticeViewHead.vue | 143 ++++++++++++++++++ ui/src/pages/notice/AlReadView.vue | 10 +- ui/src/pages/notice/AllReceiveNoticeView.vue | 10 +- ui/src/pages/notice/NoticeManage.vue | 17 ++- ui/src/pages/notice/NoticeTypeManage.vue | 14 +- ui/src/pages/notice/NoticeView.vue | 23 ++- ui/src/pages/notice/ToReadView.vue | 10 +- ui/src/store/notice.ts | 59 +++++--- 15 files changed, 284 insertions(+), 49 deletions(-) rename ui/src/components/notice/{NoticeHead.vue => NoticeManageHead.vue} (99%) create mode 100644 ui/src/components/notice/NoticeViewHead.vue 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 0a47da6..c5d4f40 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeController.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/controller/NoticeController.java @@ -67,8 +67,8 @@ public class NoticeController { //根据登录用户id查询所接收的公告 @GetMapping("/self") @PreAuthorize("hasAuthority('notice:self:get')") - public ResponseResult> selectByUserId(Integer readStatus) { - List noticesByUserId = noticeReceiveService.selectByUserId(readStatus); + public ResponseResult> selectByUserId(Integer readStatus,String title, String type, String startTime, String endTime) { + List noticesByUserId = noticeReceiveService.selectByUserId(readStatus, title.trim(), type.trim(), startTime.trim(), endTime.trim()); Integer code = noticesByUserId != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; String msg = noticesByUserId != null ? "" : "数据查询失败,请重试!"; return ResponseResult.build(code, msg, noticesByUserId); diff --git a/Pinnacle/src/main/java/com/cfive/pinnacle/mapper/NoticeReceiveMapper.java b/Pinnacle/src/main/java/com/cfive/pinnacle/mapper/NoticeReceiveMapper.java index 62fd8e1..7951f14 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/mapper/NoticeReceiveMapper.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/mapper/NoticeReceiveMapper.java @@ -5,6 +5,7 @@ import com.cfive.pinnacle.entity.NoticeReceive; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; +import java.time.LocalDateTime; import java.util.List; /** @@ -17,7 +18,7 @@ import java.util.List; */ @Mapper public interface NoticeReceiveMapper extends BaseMapper { - List selectByUserId(Long userId,Integer readStatus); + List selectByUserId(Long userId, Integer readStatus, String title, String type, LocalDateTime startTime, LocalDateTime endTime); List selectLimitByUserId(Long userId); } diff --git a/Pinnacle/src/main/java/com/cfive/pinnacle/service/INoticeReceiveService.java b/Pinnacle/src/main/java/com/cfive/pinnacle/service/INoticeReceiveService.java index 0c56590..d27875c 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/service/INoticeReceiveService.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/service/INoticeReceiveService.java @@ -4,6 +4,7 @@ import com.cfive.pinnacle.entity.Notice; import com.cfive.pinnacle.entity.NoticeReceive; import com.baomidou.mybatisplus.extension.service.IService; +import java.time.LocalDateTime; import java.util.List; /** @@ -15,7 +16,7 @@ import java.util.List; * @since 2023-04-30 */ public interface INoticeReceiveService extends IService { - List selectByUserId(Integer readStatus); + List selectByUserId(Integer readStatus, String title, String type, String startTime, String endTime); List selectLimitByUserId(); diff --git a/Pinnacle/src/main/java/com/cfive/pinnacle/service/impl/NoticeReceiveServiceImpl.java b/Pinnacle/src/main/java/com/cfive/pinnacle/service/impl/NoticeReceiveServiceImpl.java index ed062ae..92ce9a8 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/service/impl/NoticeReceiveServiceImpl.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/service/impl/NoticeReceiveServiceImpl.java @@ -10,6 +10,8 @@ import com.cfive.pinnacle.utils.WebUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; /** @@ -24,10 +26,16 @@ import java.util.List; public class NoticeReceiveServiceImpl extends ServiceImpl implements INoticeReceiveService { @Autowired private NoticeReceiveMapper noticeReceiveMapper; + @Override - public List selectByUserId(Integer readStatus) { + public List selectByUserId(Integer readStatus, String title, String type, String startTime, String endTime) { Long userId = WebUtil.getLoginUser().getUser().getId(); - return noticeReceiveMapper.selectByUserId(userId,readStatus); + LocalDateTime start = null, end = null; + if (startTime != "" && endTime != "") { + start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + } + return noticeReceiveMapper.selectByUserId(userId, readStatus, title, type, start, end); } @Override @@ -39,12 +47,12 @@ public class NoticeReceiveServiceImpl extends ServiceImpl luw = new LambdaUpdateWrapper<>(); Long userId = WebUtil.getLoginUser().getUser().getId(); - luw.eq(NoticeReceive::getNoticeId, notice.getId()).eq(NoticeReceive::getUserId, userId).set(null!=readStatus,NoticeReceive::getAlreadyRead, readStatus); - return noticeReceiveMapper.update(null,luw)>0; + luw.eq(NoticeReceive::getNoticeId, notice.getId()).eq(NoticeReceive::getUserId, userId).set(null != readStatus, NoticeReceive::getAlreadyRead, readStatus); + return noticeReceiveMapper.update(null, luw) > 0; } } diff --git a/Pinnacle/src/main/resources/mapper/NoticeReceiveMapper.xml b/Pinnacle/src/main/resources/mapper/NoticeReceiveMapper.xml index 7ee83c3..205d59a 100644 --- a/Pinnacle/src/main/resources/mapper/NoticeReceiveMapper.xml +++ b/Pinnacle/src/main/resources/mapper/NoticeReceiveMapper.xml @@ -30,6 +30,18 @@ and notice_receive.already_read=#{readStatus} + + and instr(n.title,#{title})>0 + + + and instr(type.name,#{type})>0 + + + and n.send_time >= #{startTime} + + + and n.end_time < #{endTime} + and notice_receive.user_id=#{userId} and notice_receive.deleted=0 diff --git a/ui/src/components/notice/NoticeHead.vue b/ui/src/components/notice/NoticeManageHead.vue similarity index 99% rename from ui/src/components/notice/NoticeHead.vue rename to ui/src/components/notice/NoticeManageHead.vue index c0cd66e..8567be8 100644 --- a/ui/src/components/notice/NoticeHead.vue +++ b/ui/src/components/notice/NoticeManageHead.vue @@ -4,7 +4,6 @@ :model="search" class="demo-form-inline" label-width="auto" - ref="searchForm" style="min-width: 1185px" > diff --git a/ui/src/components/notice/NoticeViewCard.vue b/ui/src/components/notice/NoticeViewCard.vue index 839a2f1..7e11dbd 100644 --- a/ui/src/components/notice/NoticeViewCard.vue +++ b/ui/src/components/notice/NoticeViewCard.vue @@ -175,7 +175,7 @@ export default { } else if (this.currentViewPage === 'AlRead') { flag = 1 } - await noticeStore.selectAllNoticeSelf(flag) + await noticeStore.selectAllNoticeSelf(flag, '', '', '', '') }, handleDialogClose() { noticeStore.$patch((state) => { @@ -208,7 +208,7 @@ export default { } else if (this.currentViewPage === 'AlRead') { flag = 1 } - await noticeStore.selectAllNoticeSelf(flag) + await noticeStore.selectAllNoticeSelf(flag, '', '', '', '') } }, mounted() {}, diff --git a/ui/src/components/notice/NoticeViewHead.vue b/ui/src/components/notice/NoticeViewHead.vue new file mode 100644 index 0000000..f5c6456 --- /dev/null +++ b/ui/src/components/notice/NoticeViewHead.vue @@ -0,0 +1,143 @@ + + + + + diff --git a/ui/src/pages/notice/AlReadView.vue b/ui/src/pages/notice/AlReadView.vue index d7de12b..5da6fc3 100644 --- a/ui/src/pages/notice/AlReadView.vue +++ b/ui/src/pages/notice/AlReadView.vue @@ -14,7 +14,15 @@ export default { state.showLoading = true state.currentViewPage = 'AlRead' }) - noticeStore.selectAllNoticeSelf(1) + noticeStore.selectAllNoticeSelf(1, '', '', '', '') + noticeStore.$patch((state) => { + state.searchBySelf = { + title: '', + type: '', + startTime: '', + endTime: '' + } + }) } } diff --git a/ui/src/pages/notice/AllReceiveNoticeView.vue b/ui/src/pages/notice/AllReceiveNoticeView.vue index 66ad5bd..7780db7 100644 --- a/ui/src/pages/notice/AllReceiveNoticeView.vue +++ b/ui/src/pages/notice/AllReceiveNoticeView.vue @@ -15,7 +15,15 @@ export default { state.showLoading = true state.currentViewPage = 'All' }) - noticeStore.selectAllNoticeSelf(-1) + noticeStore.selectAllNoticeSelf(-1, '', '', '', '') + noticeStore.$patch((state) => { + state.searchBySelf = { + title: '', + type: '', + startTime: '', + endTime: '' + } + }) }, computed: { ...mapState(useNoticeStore, ['showLoading']) diff --git a/ui/src/pages/notice/NoticeManage.vue b/ui/src/pages/notice/NoticeManage.vue index 701c51f..052ec8a 100644 --- a/ui/src/pages/notice/NoticeManage.vue +++ b/ui/src/pages/notice/NoticeManage.vue @@ -1,7 +1,7 @@ diff --git a/ui/src/store/notice.ts b/ui/src/store/notice.ts index 28df817..38bdcf0 100644 --- a/ui/src/store/notice.ts +++ b/ui/src/store/notice.ts @@ -1,6 +1,13 @@ import { defineStore } from 'pinia' import request from '@/services' import { ElMessage } from 'element-plus' +import { + DATABASE_SAVE_ERROR, + DATABASE_SAVE_OK, + DATABASE_SELECT_OK, + DATABASE_UPDATE_ERROR, + DATABASE_UPDATE_OK +} from '@/constants/Common.constants' export interface IAddNoticeData { title: string @@ -55,6 +62,12 @@ export const useNoticeStore = defineStore('notice', { endTime: '', userIdList: [] }, + searchBySelf: { + title: '', + type: '', + startTime: '', + endTime: '' + }, selectData: [ { content: '', @@ -142,7 +155,7 @@ export const useNoticeStore = defineStore('notice', { userIdList: userIdList.toString() + '' }) .then((response) => { - if (response.data.code === 20021) { + if (response.data.code === DATABASE_SELECT_OK) { this.selectData = response.data.data this.total = parseInt(response.data.msg) this.loading = false @@ -155,13 +168,23 @@ export const useNoticeStore = defineStore('notice', { } }) }, - async selectAllNoticeSelf(readStatus: number) { + async selectAllNoticeSelf( + readStatus: number, + title: string, + type: string, + startTime: string, + endTime: string + ) { await request .get('/notice/self', { - readStatus + readStatus, + title, + type, + startTime, + endTime }) .then((response) => { - if (response.data.code === 20021) { + if (response.data.code === DATABASE_SELECT_OK) { this.selectData = response.data.data this.showLoading = false } else { @@ -180,13 +203,13 @@ export const useNoticeStore = defineStore('notice', { }, handleAddNotice(addFormData: IAddNoticeData) { void request.post('/notice', addFormData).then((response) => { - if (response.data.code === 20022) { + if (response.data.code === DATABASE_SAVE_OK) { this.dialogAddVisible = false ElMessage({ message: '发布成功.', type: 'success' }) - } else if (response.data.code === 20032) { + } else if (response.data.code === DATABASE_SAVE_ERROR) { ElMessage({ message: response.data.msg, type: 'error' @@ -197,14 +220,14 @@ export const useNoticeStore = defineStore('notice', { }, handleUpdateNotice(updateNotice: IAddNoticeData) { void request.put('/notice', updateNotice).then((response) => { - if (response.data.code === 20023) { + if (response.data.code === DATABASE_UPDATE_OK) { this.dialogEditVisible = false this.editFlag = false ElMessage({ message: '修改成功.', type: 'success' }) - } else if (response.data.code === 20033) { + } else if (response.data.code === DATABASE_UPDATE_ERROR) { ElMessage({ message: response.data.msg, type: 'error' @@ -216,7 +239,7 @@ export const useNoticeStore = defineStore('notice', { }, async modifyNoticeIsRead(notice: INotice) { await request.put('/notice/modify_notice_read', notice).then((response) => { - if (response.data.code === 20033) { + if (response.data.code === DATABASE_UPDATE_ERROR) { ElMessage({ message: response.data.msg, type: 'error' @@ -226,12 +249,12 @@ export const useNoticeStore = defineStore('notice', { }, async modifyTop(notice: INotice) { await request.put('/notice/update_notice_top', notice).then((response) => { - if (response.data.code === 20023) { + if (response.data.code === DATABASE_UPDATE_OK) { ElMessage({ message: response.data.msg, type: 'success' }) - } else if (response.data.code === 20033) { + } else if (response.data.code === DATABASE_UPDATE_ERROR) { ElMessage({ message: response.data.msg, type: 'error' @@ -282,7 +305,7 @@ export const useNoticeTypeStore = defineStore('notice_type', { }, async selectNoticeType(currentPage: number, pageSize: number) { await request.get('/notice_type/page', { currentPage, pageSize }).then((response) => { - if (response.data.code === 20021) { + if (response.data.code === DATABASE_SELECT_OK) { this.noticeTypeList = response.data.data this.total = parseInt(response.data.msg) if (this.noticeTypeList.length !== 0) { @@ -304,12 +327,12 @@ export const useNoticeTypeStore = defineStore('notice_type', { enable }) .then((response) => { - if (response.data.code === 20023) { + if (response.data.code === DATABASE_UPDATE_OK) { ElMessage({ message: '修改成功.', type: 'success' }) - } else if (response.data.code === 20033) { + } else if (response.data.code === DATABASE_UPDATE_ERROR) { ElMessage({ message: response.data.msg, type: 'error' @@ -319,13 +342,13 @@ export const useNoticeTypeStore = defineStore('notice_type', { }, async handleAddNoticeType(addFormData: IAddNoticeTypeData) { await request.post('/notice_type', addFormData).then((response) => { - if (response.data.code === 20022) { + if (response.data.code === DATABASE_SAVE_OK) { this.dialogAddTypeVisible = false ElMessage({ message: '添加成功.', type: 'success' }) - } else if (response.data.code === 20032) { + } else if (response.data.code === DATABASE_SAVE_ERROR) { ElMessage({ message: response.data.msg, type: 'error' @@ -336,7 +359,7 @@ export const useNoticeTypeStore = defineStore('notice_type', { }, async handleUpdateNoticeType(updateNotice: IAddNoticeTypeData) { await request.put('/notice_type', updateNotice).then((response) => { - if (response.data.code === 20023) { + if (response.data.code === DATABASE_UPDATE_OK) { this.dialogEditTypeVisible = false this.editFlag = false this.hackReset = false @@ -349,7 +372,7 @@ export const useNoticeTypeStore = defineStore('notice_type', { message: '修改成功.', type: 'success' }) - } else if (response.data.code === 20033) { + } else if (response.data.code === DATABASE_UPDATE_ERROR) { ElMessage({ message: response.data.msg, type: 'error'