1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-04 22:41:24 +08:00

add the function of deleteBatchNoticeType

This commit is contained in:
cccccyb
2023-05-30 01:56:18 +08:00
parent c5a131ea9f
commit 81ab047f20
10 changed files with 85 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ import com.cfive.pinnacle.service.INoticeReceiveService;
import com.cfive.pinnacle.service.INoticeService; import com.cfive.pinnacle.service.INoticeService;
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.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -36,6 +37,7 @@ public class NoticeController {
//根据公告id查公告信息及发布人 //根据公告id查公告信息及发布人
@GetMapping("/{nid}") @GetMapping("/{nid}")
@PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<Notice> selectByNoticeId(@PathVariable Long nid) { public ResponseResult<Notice> selectByNoticeId(@PathVariable Long nid) {
Notice noticeById = noticeService.selectByNoticeId(nid); Notice noticeById = noticeService.selectByNoticeId(nid);
Integer code = noticeById != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; Integer code = noticeById != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
@@ -45,6 +47,7 @@ public class NoticeController {
//查询所有公告或模糊查询 //查询所有公告或模糊查询
@GetMapping @GetMapping
@PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<List<Notice>> selectAllNotice(String title, String type, String startTime, String endTime) { public ResponseResult<List<Notice>> selectAllNotice(String title, String type, String startTime, String endTime) {
List<Notice> noticeList; List<Notice> noticeList;
if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) { if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) {
@@ -60,6 +63,7 @@ public class NoticeController {
//根据登录用户id查询所接收的公告 //根据登录用户id查询所接收的公告
@GetMapping("/self") @GetMapping("/self")
@PreAuthorize("hasAuthority('notice:self:get')")
public ResponseResult<List<Notice>> selectByUserId(Integer readStatus) { public ResponseResult<List<Notice>> selectByUserId(Integer readStatus) {
List<Notice> noticesByUserId = noticeReceiveService.selectByUserId(readStatus); List<Notice> noticesByUserId = noticeReceiveService.selectByUserId(readStatus);
Integer code = noticesByUserId != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; Integer code = noticesByUserId != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
@@ -69,6 +73,7 @@ public class NoticeController {
//修改登录用户所接收公告的阅读状态 //修改登录用户所接收公告的阅读状态
@PutMapping("/modify_notice_read") @PutMapping("/modify_notice_read")
@PreAuthorize("hasAuthority('notice:self:get')")
public ResponseResult<?> modifyNoticeIsRead(@RequestBody Notice notice) { public ResponseResult<?> modifyNoticeIsRead(@RequestBody Notice notice) {
Boolean updateById = false; Boolean updateById = false;
if (null != notice) { if (null != notice) {
@@ -81,6 +86,7 @@ public class NoticeController {
//更新公告 //更新公告
@PutMapping @PutMapping
@PreAuthorize("hasAuthority('notice:manage:modify')")
public ResponseResult<?> updateNotice(@RequestBody Notice notice) { public ResponseResult<?> updateNotice(@RequestBody Notice notice) {
Boolean updateById = noticeService.updateNotice(notice); Boolean updateById = noticeService.updateNotice(notice);
String msg = updateById ? "" : "数据修改失败,请重试!"; String msg = updateById ? "" : "数据修改失败,请重试!";
@@ -89,6 +95,7 @@ public class NoticeController {
//修改公告置顶状态 //修改公告置顶状态
@PutMapping("/update_notice_top") @PutMapping("/update_notice_top")
@PreAuthorize("hasAuthority('notice:self:get')")
public ResponseResult<?> updateNoticeTop(@RequestBody Notice notice) { public ResponseResult<?> updateNoticeTop(@RequestBody Notice notice) {
String operationMessage = notice.getTop() == 1 ? "取消置顶" : "置顶"; String operationMessage = notice.getTop() == 1 ? "取消置顶" : "置顶";
Boolean updateResult = noticeService.updateNoticeTop(notice); Boolean updateResult = noticeService.updateNoticeTop(notice);
@@ -98,6 +105,7 @@ public class NoticeController {
//添加公告 //添加公告
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('notice:manage:add')")
public ResponseResult<?> addNotice(@RequestBody Notice notice) { public ResponseResult<?> addNotice(@RequestBody Notice notice) {
Boolean insertNotice = noticeService.addNotice(notice); Boolean insertNotice = noticeService.addNotice(notice);
String msg = insertNotice ? "" : "数据添加失败,请重试!"; String msg = insertNotice ? "" : "数据添加失败,请重试!";
@@ -106,6 +114,7 @@ public class NoticeController {
//删除公告 //删除公告
@DeleteMapping("/{nid}") @DeleteMapping("/{nid}")
@PreAuthorize("hasAuthority('notice:manage:delete')")
public ResponseResult<?> deleteByNoticeId(@PathVariable Long nid) { public ResponseResult<?> deleteByNoticeId(@PathVariable Long nid) {
Boolean removeById = noticeService.deleteById(nid); Boolean removeById = noticeService.deleteById(nid);
String msg = removeById ? "" : "数据删除失败,请重试!"; String msg = removeById ? "" : "数据删除失败,请重试!";
@@ -114,6 +123,7 @@ public class NoticeController {
//批量删除公告 //批量删除公告
@PostMapping("/batch") @PostMapping("/batch")
@PreAuthorize("hasAuthority('notice:manage:delete')")
public ResponseResult<?> deleteBatchByIds(@RequestBody List<String> noticeIds){ public ResponseResult<?> deleteBatchByIds(@RequestBody List<String> noticeIds){
// List<String>转List<Long> // List<String>转List<Long>
List<Long> nIds = noticeIds.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); List<Long> nIds = noticeIds.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
@@ -124,6 +134,7 @@ public class NoticeController {
//分页查询所有公告或分页模糊查询 //分页查询所有公告或分页模糊查询
@GetMapping("/page") @GetMapping("/page")
@PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<List<Notice>> selectPageAllNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) { public ResponseResult<List<Notice>> selectPageAllNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) {
IPage<Notice> noticePageList; IPage<Notice> noticePageList;
Page<Notice> page = new Page(); Page<Notice> page = new Page();

View File

@@ -13,6 +13,7 @@ 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;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@@ -53,6 +54,7 @@ public class NoticeTypeController {
//分页查询所有公告类型 //分页查询所有公告类型
@GetMapping("/page") @GetMapping("/page")
@PreAuthorize("hasAuthority('notice:type:get')")
public ResponseResult<List<NoticeType>> selectPageTypeList(Integer currentPage, Integer pageSize){ public ResponseResult<List<NoticeType>> selectPageTypeList(Integer currentPage, Integer pageSize){
Page<NoticeType> noticeTypePage=new Page<>(); Page<NoticeType> noticeTypePage=new Page<>();
if (null != currentPage && null != pageSize) { if (null != currentPage && null != pageSize) {
@@ -108,4 +110,15 @@ public class NoticeTypeController {
String msg = removeById ? "" : "数据删除失败,请重试!"; String msg = removeById ? "" : "数据删除失败,请重试!";
return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null); return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null);
} }
//批量删除公告
@PostMapping("/batch")
@PreAuthorize("hasAuthority('notice:manage:delete')")
public ResponseResult<?> deleteBatchByTypeIds(@RequestBody List<String> noticeTypeIds){
// List<String>转List<Long>
List<Long> nTypeIds = noticeTypeIds.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
Boolean deleteBatchByIds = noticeTypeService.deleteBatchByTypeIds(nTypeIds);
String msg = deleteBatchByIds ? "" : "数据删除失败,请重试!";
return ResponseResult.build(deleteBatchByIds ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null);
}
} }

View File

@@ -28,5 +28,7 @@ public interface INoticeTypeService extends IService<NoticeType> {
Boolean deleteNoticeTypeById(Long typeId); Boolean deleteNoticeTypeById(Long typeId);
Boolean deleteBatchByTypeIds(List<Long> typeIds);
} }

View File

@@ -70,4 +70,9 @@ public class NoticeTypeServiceImpl extends ServiceImpl<NoticeTypeMapper, NoticeT
public Boolean deleteNoticeTypeById(Long typeId) { public Boolean deleteNoticeTypeById(Long typeId) {
return noticeTypeMapper.deleteById(typeId)>0; return noticeTypeMapper.deleteById(typeId)>0;
} }
@Override
public Boolean deleteBatchByTypeIds(List<Long> typeIds) {
return noticeTypeMapper.deleteBatchIds(typeIds)>0;
}
} }

View File

@@ -112,6 +112,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
@Override @Override
public User getUserWithPower(String username) { public User getUserWithPower(String username) {
User user = userMapper.getOneWithPowerByUsername(username); User user = userMapper.getOneWithPowerByUsername(username);
if (user == null) {
return null;
}
if (user.getId() == 1L) { if (user.getId() == 1L) {
List<Menu> menus = menuMapper.selectList(Wrappers.emptyWrapper()); List<Menu> menus = menuMapper.selectList(Wrappers.emptyWrapper());
List<Element> elements = elementMapper.selectList(Wrappers.emptyWrapper()); List<Element> elements = elementMapper.selectList(Wrappers.emptyWrapper());

View File

@@ -99,13 +99,13 @@ export default {
'dataLoading', 'dataLoading',
'hackReset', 'hackReset',
'showTypeData', 'showTypeData',
'addTypeData' 'addTypeData',
'multiDeleteSelection'
]) ])
}, },
data() { data() {
return { return {
filterSenderName: [], filterSenderName: [],
multipleSelection: [],
search: '' search: ''
} }
}, },
@@ -113,7 +113,9 @@ export default {
methods: { methods: {
handleSelectionChange(val) { handleSelectionChange(val) {
// val的值为所勾选行的数组对象 // val的值为所勾选行的数组对象
this.multipleSelection = val noticeTypeStore.$patch((state) => {
state.multiDeleteSelection = val
})
}, },
indexFormat(index) { indexFormat(index) {
return (this.currentPage - 1) * this.pageSize + index + 1 return (this.currentPage - 1) * this.pageSize + index + 1

View File

@@ -160,6 +160,11 @@ export default {
}) })
}) })
.catch(() => {}) .catch(() => {})
} else {
ElMessage({
message: '请至少选择一项进行删除',
type: 'warning'
})
} }
} }
}, },

View File

@@ -6,7 +6,7 @@
<icon-pinnacle-add /> </el-icon <icon-pinnacle-add /> </el-icon
>添加类型</el-button >添加类型</el-button
> >
<el-button type="primary" :size="'large'" <el-button type="primary" :size="'large'" @click="deleteBatchByTypeIds"
><el-icon :size="SIZE_ICON_MD()" style="color: white; margin-right: 3px"> ><el-icon :size="SIZE_ICON_MD()" style="color: white; margin-right: 3px">
<icon-pinnacle-delete /> </el-icon <icon-pinnacle-delete /> </el-icon
>批量删除</el-button >批量删除</el-button
@@ -63,7 +63,8 @@ export default {
'hackReset', 'hackReset',
'addTypeData', 'addTypeData',
'currentPage', 'currentPage',
'pageSize' 'pageSize',
'multiDeleteSelection'
]) ])
}, },
data() { data() {
@@ -127,6 +128,41 @@ export default {
}) })
}) })
.catch(() => {}) .catch(() => {})
},
deleteBatchByTypeIds() {
const multiDeleteTypeIds = []
if (this.multiDeleteSelection.length > 0) {
for (let i = 0; i < this.multiDeleteSelection.length; i++) {
multiDeleteTypeIds.push(this.multiDeleteSelection[i].id)
}
ElMessageBox.confirm('确定是否要批量删除?该操作将无法回退', '警告', {
confirmButtonText: '确定',
cancelButtonText: '我再想想',
type: 'warning'
})
.then(() => {
request.post('/notice_type/batch', multiDeleteTypeIds).then((response) => {
if (response.data.code === 20024) {
ElMessage({
message: '删除成功.',
type: 'success'
})
noticeTypeStore.selectNoticeType(this.currentPage, this.pageSize)
} else if (response.data.code === 20034) {
ElMessage({
message: response.data.msg,
type: 'error'
})
}
})
})
.catch(() => {})
} else {
ElMessage({
message: '请至少选择一项进行删除',
type: 'warning'
})
}
} }
}, },
mounted() {} mounted() {}

View File

@@ -6,7 +6,8 @@ const noticeRouter = {
icon: shallowRef(IconPinnacleNotice), icon: shallowRef(IconPinnacleNotice),
requiresMenu: true, requiresMenu: true,
requiresScrollbar: false, requiresScrollbar: false,
requiresPadding: true requiresPadding: true,
requiresAuth: true
}, },
children: [ children: [
{ {

View File

@@ -236,6 +236,7 @@ export const useNoticeTypeStore = defineStore('notice_type', {
hackReset: true, hackReset: true,
editFlag: false, editFlag: false,
enableNoticeTypeList: [], enableNoticeTypeList: [],
multiDeleteSelection: [],
noticeTypeList: [ noticeTypeList: [
{ {
id: '', id: '',