mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
add the function of fuzzy query by senderIds had been completed
This commit is contained in:
@@ -8,10 +8,10 @@ import com.cfive.pinnacle.entity.common.ResponseCode;
|
|||||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||||
import com.cfive.pinnacle.service.INoticeReceiveService;
|
import com.cfive.pinnacle.service.INoticeReceiveService;
|
||||||
import com.cfive.pinnacle.service.INoticeService;
|
import com.cfive.pinnacle.service.INoticeService;
|
||||||
|
import com.cfive.pinnacle.utils.WebUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -39,7 +39,8 @@ public class NoticeController {
|
|||||||
//分页查询所有公告或分页模糊查询
|
//分页查询所有公告或分页模糊查询
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@PreAuthorize("hasAuthority('notice:manage:get')")
|
@PreAuthorize("hasAuthority('notice:manage:get')")
|
||||||
public ResponseResult<List<Notice>> selectPageNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime,String userName) {
|
public ResponseResult<List<Notice>> selectPageNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime,String userIdList) {
|
||||||
|
List<Long> userIds = WebUtil.convertStringToList(userIdList, Long.class);
|
||||||
Page<Notice> noticePage;
|
Page<Notice> noticePage;
|
||||||
if (null != currentPage && null != pageSize) {
|
if (null != currentPage && null != pageSize) {
|
||||||
noticePage = PageDTO.of(currentPage, pageSize);
|
noticePage = PageDTO.of(currentPage, pageSize);
|
||||||
@@ -47,7 +48,7 @@ public class NoticeController {
|
|||||||
// 不进行分页
|
// 不进行分页
|
||||||
noticePage = PageDTO.of(1, -1);
|
noticePage = PageDTO.of(1, -1);
|
||||||
}
|
}
|
||||||
IPage<Notice> noticeIPage = noticeService.selectPageNotice(noticePage, title.trim(), type.trim(), startTime.trim(), endTime.trim(),userName.trim());
|
IPage<Notice> noticeIPage = noticeService.selectPageNotice(noticePage, title.trim(), type.trim(), startTime.trim(), endTime.trim(),userIds);
|
||||||
int code = noticeIPage.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
|
int code = noticeIPage.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
|
||||||
String msg = noticeIPage.getRecords() != null ? String.valueOf(noticeIPage.getTotal()) : "数据查询失败,请重试!";
|
String msg = noticeIPage.getRecords() != null ? String.valueOf(noticeIPage.getTotal()) : "数据查询失败,请重试!";
|
||||||
return ResponseResult.build(code, msg, noticeIPage.getRecords());
|
return ResponseResult.build(code, msg, noticeIPage.getRecords());
|
||||||
|
|||||||
@@ -20,6 +20,6 @@ import java.util.List;
|
|||||||
public interface NoticeMapper extends BaseMapper<Notice> {
|
public interface NoticeMapper extends BaseMapper<Notice> {
|
||||||
Notice selectByNoticeId(Long nid);
|
Notice selectByNoticeId(Long nid);
|
||||||
|
|
||||||
IPage<Notice> selectPageNotice(IPage<?> page, String title, String type, LocalDateTime startTime, LocalDateTime endTime,String userName);
|
IPage<Notice> selectPageNotice(IPage<?> page, String title, String type, LocalDateTime startTime, LocalDateTime endTime,List<Long> userIdList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,5 +27,5 @@ public interface INoticeService extends IService<Notice> {
|
|||||||
|
|
||||||
Boolean addNotice(Notice notice);
|
Boolean addNotice(Notice notice);
|
||||||
|
|
||||||
IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime,String userName);
|
IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime,List<Long> userIdList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime,String userName) {
|
public IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime,List<Long> userIdList) {
|
||||||
LocalDateTime start=null,end=null;
|
LocalDateTime start=null,end=null;
|
||||||
if (startTime!=""&&endTime!=""){
|
if (startTime!=""&&endTime!=""){
|
||||||
start= LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
start= LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
}
|
}
|
||||||
return noticeMapper.selectPageNotice(page, title, type, start, end,userName);
|
return noticeMapper.selectPageNotice(page, title, type, start, end,userIdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -50,12 +50,12 @@
|
|||||||
<if test="null!=startTime">
|
<if test="null!=startTime">
|
||||||
and n.send_time >= #{startTime}
|
and n.send_time >= #{startTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="null !=endTime">
|
<if test="null != endTime">
|
||||||
and n.end_time < #{endTime}
|
and n.end_time < #{endTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="null!=userName and userName!=''">
|
<foreach collection="userIdList" item="item" index="index" open="and u.id in (" separator="," close=")">
|
||||||
and u.username = #{userName}
|
#{item}
|
||||||
</if>
|
</foreach>
|
||||||
and n.deleted = 0
|
and n.deleted = 0
|
||||||
and n.old = 0
|
and n.old = 0
|
||||||
</where>
|
</where>
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ export default {
|
|||||||
type: '',
|
type: '',
|
||||||
startTime: '',
|
startTime: '',
|
||||||
endTime: '',
|
endTime: '',
|
||||||
userName: ''
|
userIdList: []
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.$emit('selectByCond')
|
this.$emit('selectByCond')
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
color: '#fff',
|
color: '#fff',
|
||||||
'font-size': '20px'
|
'font-size': '20px'
|
||||||
}"
|
}"
|
||||||
|
@filter-change="handleFilterChange"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<el-table-column type="index" label="序号" width="75" align="center">
|
<el-table-column type="index" label="序号" width="75" align="center">
|
||||||
@@ -79,9 +80,8 @@
|
|||||||
prop="sender.username"
|
prop="sender.username"
|
||||||
label="发布者"
|
label="发布者"
|
||||||
width="100"
|
width="100"
|
||||||
column-key="sender.username"
|
column-key="senderId"
|
||||||
:filters="filterSenderName"
|
:filters="senderList"
|
||||||
:filter-method="filterTag"
|
|
||||||
filter-placement="bottom-end"
|
filter-placement="bottom-end"
|
||||||
align="center"
|
align="center"
|
||||||
>
|
>
|
||||||
@@ -150,7 +150,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import _ from 'lodash'
|
|
||||||
import { mapState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { useNoticeStore } from '@/store/notice'
|
import { useNoticeStore } from '@/store/notice'
|
||||||
import { COLOR_TOP, SIZE_ICON_MD, SIZE_ICON_SM } from '@/constants/Common.constants'
|
import { COLOR_TOP, SIZE_ICON_MD, SIZE_ICON_SM } from '@/constants/Common.constants'
|
||||||
@@ -170,15 +169,11 @@ export default {
|
|||||||
'currentPage',
|
'currentPage',
|
||||||
'pageSize',
|
'pageSize',
|
||||||
'multiDeleteSelection',
|
'multiDeleteSelection',
|
||||||
'search'
|
'search',
|
||||||
|
'senderList'
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
emits: ['clearFilter', 'handleDeleteById'],
|
emits: ['handleDeleteById', 'getNoticeSender', 'filterSender'],
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
filterSenderName: []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: [],
|
props: [],
|
||||||
methods: {
|
methods: {
|
||||||
SIZE_ICON_SM() {
|
SIZE_ICON_SM() {
|
||||||
@@ -203,20 +198,6 @@ export default {
|
|||||||
return title
|
return title
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filterTag(value) {
|
|
||||||
noticeStore.$patch((state) => {
|
|
||||||
state.search.userName = value
|
|
||||||
})
|
|
||||||
noticeStore.selectAllNotice(
|
|
||||||
this.currentPage,
|
|
||||||
this.pageSize,
|
|
||||||
this.search.title,
|
|
||||||
this.search.type,
|
|
||||||
this.search.startTime,
|
|
||||||
this.search.endTime,
|
|
||||||
this.search.userName
|
|
||||||
)
|
|
||||||
},
|
|
||||||
formatDate(row, column) {
|
formatDate(row, column) {
|
||||||
// 获取单元格数据
|
// 获取单元格数据
|
||||||
const data = row[column.property]
|
const data = row[column.property]
|
||||||
@@ -261,7 +242,7 @@ export default {
|
|||||||
this.search.type,
|
this.search.type,
|
||||||
this.search.startTime,
|
this.search.startTime,
|
||||||
this.search.endTime,
|
this.search.endTime,
|
||||||
this.search.userName
|
this.search.userIdList
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
handleCurrentChange(currentPage) {
|
handleCurrentChange(currentPage) {
|
||||||
@@ -276,31 +257,21 @@ export default {
|
|||||||
this.search.type,
|
this.search.type,
|
||||||
this.search.startTime,
|
this.search.startTime,
|
||||||
this.search.endTime,
|
this.search.endTime,
|
||||||
this.search.userName
|
this.search.userIdList
|
||||||
)
|
)
|
||||||
|
},
|
||||||
|
handleFilterChange(filters) {
|
||||||
|
noticeStore.$patch((state) => {
|
||||||
|
state.search.userIdList = filters.senderId
|
||||||
|
})
|
||||||
|
this.$emit('filterSender')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
noticeStore.selectAllNotice(this.currentPage, this.pageSize, '', '', '', '', '')
|
noticeStore.selectAllNotice(this.currentPage, this.pageSize, '', '', '', '', [])
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
this.$refs.tableRef.clearFilter(['sender.username'])
|
this.$emit('getNoticeSender')
|
||||||
this.filterSenderName = []
|
|
||||||
const nameArray = []
|
|
||||||
if (!_.isEmpty(this.selectData)) {
|
|
||||||
for (let i = 0; i < this.selectData.length; i++) {
|
|
||||||
nameArray.push(this.selectData[i].sender.username)
|
|
||||||
}
|
|
||||||
const newArr = nameArray.filter((item, i, arr) => {
|
|
||||||
return arr.indexOf(item) === i
|
|
||||||
})
|
|
||||||
for (let j = 0; j < newArr.length; j++) {
|
|
||||||
const senderName = { text: '', value: '' }
|
|
||||||
senderName.text = newArr[j]
|
|
||||||
senderName.value = newArr[j]
|
|
||||||
this.filterSenderName.push(senderName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
<notice-manage-table
|
<notice-manage-table
|
||||||
@handleDeleteById="handleDeleteById"
|
@handleDeleteById="handleDeleteById"
|
||||||
|
@getNoticeSender="getNoticeSender"
|
||||||
|
@filterSender="getLoading"
|
||||||
ref="manageTable"
|
ref="manageTable"
|
||||||
></notice-manage-table>
|
></notice-manage-table>
|
||||||
</el-main>
|
</el-main>
|
||||||
@@ -92,7 +94,7 @@ export default {
|
|||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
''
|
[]
|
||||||
)
|
)
|
||||||
} else if (response.data.code === 20034) {
|
} else if (response.data.code === 20034) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
@@ -119,8 +121,9 @@ export default {
|
|||||||
this.search.type,
|
this.search.type,
|
||||||
this.search.startTime,
|
this.search.startTime,
|
||||||
this.search.endTime,
|
this.search.endTime,
|
||||||
this.search.userName
|
this.search.userIdList
|
||||||
)
|
)
|
||||||
|
// noticeStore.search.userIdList = []
|
||||||
},
|
},
|
||||||
deleteBatchByIds() {
|
deleteBatchByIds() {
|
||||||
const multiDeleteIds = []
|
const multiDeleteIds = []
|
||||||
@@ -147,7 +150,7 @@ export default {
|
|||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
''
|
[]
|
||||||
)
|
)
|
||||||
} else if (response.data.code === 20034) {
|
} else if (response.data.code === 20034) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
@@ -164,6 +167,20 @@ export default {
|
|||||||
type: 'warning'
|
type: 'warning'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
getNoticeSender() {
|
||||||
|
const senders = []
|
||||||
|
request.get('/user/notice').then((response) => {
|
||||||
|
for (let i = 0; i < response.data.data.length; i++) {
|
||||||
|
const senderName = { text: '', value: '' }
|
||||||
|
senderName.text = response.data.data[i].username
|
||||||
|
senderName.value = response.data.data[i].id
|
||||||
|
senders.push(senderName)
|
||||||
|
}
|
||||||
|
noticeStore.$patch((state) => {
|
||||||
|
state.senderList = senders
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -175,7 +192,8 @@ export default {
|
|||||||
'currentPage',
|
'currentPage',
|
||||||
'pageSize',
|
'pageSize',
|
||||||
'multiDeleteSelection',
|
'multiDeleteSelection',
|
||||||
'search'
|
'search',
|
||||||
|
'senderList'
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export const useNoticeStore = defineStore('notice', {
|
|||||||
type: '',
|
type: '',
|
||||||
startTime: '',
|
startTime: '',
|
||||||
endTime: '',
|
endTime: '',
|
||||||
userName: ''
|
userIdList: []
|
||||||
},
|
},
|
||||||
selectData: [
|
selectData: [
|
||||||
{
|
{
|
||||||
@@ -91,6 +91,7 @@ export const useNoticeStore = defineStore('notice', {
|
|||||||
currentViewPage: 'All',
|
currentViewPage: 'All',
|
||||||
hackReset: true,
|
hackReset: true,
|
||||||
departmentList: [],
|
departmentList: [],
|
||||||
|
senderList: [],
|
||||||
multiDeleteSelection: [],
|
multiDeleteSelection: [],
|
||||||
noticeShowData: {
|
noticeShowData: {
|
||||||
content: '',
|
content: '',
|
||||||
@@ -121,14 +122,14 @@ export const useNoticeStore = defineStore('notice', {
|
|||||||
},
|
},
|
||||||
getters: {},
|
getters: {},
|
||||||
actions: {
|
actions: {
|
||||||
async selectAllNotice(
|
selectAllNotice(
|
||||||
currentPage: number,
|
currentPage: number,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
title: string,
|
title: string,
|
||||||
type: string,
|
type: string,
|
||||||
startTime: string,
|
startTime: string,
|
||||||
endTime: string,
|
endTime: string,
|
||||||
userName: string
|
userIdList: []
|
||||||
) {
|
) {
|
||||||
void request
|
void request
|
||||||
.get('/notice/page', {
|
.get('/notice/page', {
|
||||||
@@ -138,7 +139,7 @@ export const useNoticeStore = defineStore('notice', {
|
|||||||
type,
|
type,
|
||||||
startTime,
|
startTime,
|
||||||
endTime,
|
endTime,
|
||||||
userName
|
userIdList: userIdList.toString() + ''
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.data.code === 20021) {
|
if (response.data.code === 20021) {
|
||||||
@@ -177,8 +178,8 @@ export const useNoticeStore = defineStore('notice', {
|
|||||||
this.departmentList = response.data.data
|
this.departmentList = response.data.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async handleAddNotice(addFormData: IAddNoticeData) {
|
handleAddNotice(addFormData: IAddNoticeData) {
|
||||||
await request.post('/notice', addFormData).then((response) => {
|
void request.post('/notice', addFormData).then((response) => {
|
||||||
if (response.data.code === 20022) {
|
if (response.data.code === 20022) {
|
||||||
this.dialogAddVisible = false
|
this.dialogAddVisible = false
|
||||||
ElMessage({
|
ElMessage({
|
||||||
@@ -192,10 +193,10 @@ export const useNoticeStore = defineStore('notice', {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await this.selectAllNotice(1, 5, '', '', '', '', '')
|
this.selectAllNotice(1, 5, '', '', '', '', [])
|
||||||
},
|
},
|
||||||
async handleUpdateNotice(updateNotice: IAddNoticeData) {
|
handleUpdateNotice(updateNotice: IAddNoticeData) {
|
||||||
await request.put('/notice', updateNotice).then((response) => {
|
void request.put('/notice', updateNotice).then((response) => {
|
||||||
if (response.data.code === 20023) {
|
if (response.data.code === 20023) {
|
||||||
this.dialogEditVisible = false
|
this.dialogEditVisible = false
|
||||||
this.editFlag = false
|
this.editFlag = false
|
||||||
@@ -210,7 +211,7 @@ export const useNoticeStore = defineStore('notice', {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await this.selectAllNotice(1, 5, '', '', '', '', '')
|
this.selectAllNotice(1, 5, '', '', '', '', [])
|
||||||
this.hackReset = false
|
this.hackReset = false
|
||||||
},
|
},
|
||||||
async modifyNoticeIsRead(notice: INotice) {
|
async modifyNoticeIsRead(notice: INotice) {
|
||||||
|
|||||||
Reference in New Issue
Block a user