1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 06:51:23 +08:00

add noticeTypeManage module

This commit is contained in:
cccccyb
2023-05-16 03:13:19 +08:00
parent a2508b887e
commit c860e9c3e8
23 changed files with 460 additions and 91 deletions

View File

@@ -38,7 +38,7 @@ public class NoticeController {
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 ? "" : "数据查询失败,请试!";
String msg = noticeById != null ? "" : "数据查询失败,请试!";
return ResponseResult.build(code, msg, noticeById);
}
@@ -53,16 +53,16 @@ public class NoticeController {
}
int code = noticeList != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticeList != null ? "" : "数据查询失败,请试!";
String msg = noticeList != null ? "" : "数据查询失败,请试!";
return ResponseResult.build(code, msg, noticeList);
}
//根据登录用户id查询所接收的公告
@GetMapping("/ByUserId")
public ResponseResult selectAllByUserId() {
List<Notice> noticesByUserId = noticeReceiveService.selectAllByUserId();
public ResponseResult selectByUserId(Integer readStatus) {
List<Notice> noticesByUserId = noticeReceiveService.selectByUserId(readStatus);
Integer code = noticesByUserId != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticesByUserId != null ? "" : "数据查询失败,请试!";
String msg = noticesByUserId != null ? "" : "数据查询失败,请试!";
return ResponseResult.build(code, msg, noticesByUserId);
}
@@ -70,7 +70,7 @@ public class NoticeController {
@PutMapping
public ResponseResult updateNotice(@RequestBody Notice notice) {
boolean updateById = noticeService.updateNotice(notice);
String msg = updateById ? "" : "数据修改失败,请试!";
String msg = updateById ? "" : "数据修改失败,请试!";
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById);
}
@@ -78,7 +78,7 @@ public class NoticeController {
@PostMapping
public ResponseResult addNotice(@RequestBody Notice notice) {
Boolean insertNotice = noticeService.addNotice(notice);
String msg = insertNotice ? "" : "数据添加失败,请试!";
String msg = insertNotice ? "" : "数据添加失败,请试!";
return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, insertNotice);
}
@@ -86,7 +86,7 @@ public class NoticeController {
@DeleteMapping("/{nid}")
public ResponseResult deleteByNoticeId(@PathVariable Long nid) {
boolean removeById = noticeService.deleteById(nid);
String msg = removeById ? "" : "数据删除失败,请试!";
String msg = removeById ? "" : "数据删除失败,请试!";
return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, removeById);
}
@@ -109,7 +109,7 @@ public class NoticeController {
noticePageList = noticeService.selectPageByCond(page,title, type, startTime, endTime);
}
int code = noticePageList.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticePageList.getRecords() != null ? String.valueOf(noticePageList.getTotal()) : "数据查询失败,请试!";
String msg = noticePageList.getRecords() != null ? String.valueOf(noticePageList.getTotal()) : "数据查询失败,请试!";
return ResponseResult.build(code, msg, noticePageList.getRecords());
}

View File

@@ -1,15 +1,12 @@
package com.cfive.pinnacle.controller;
import com.cfive.pinnacle.entity.Notice;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -28,12 +25,33 @@ public class NoticeTypeController {
@Autowired
INoticeTypeService noticeTypeService;
@GetMapping
public ResponseResult selectTypeList(){
List<NoticeType> selectTypeName = noticeTypeService.selectTypeList();
@GetMapping("/enable")
public ResponseResult selectEnableTypeList(){
List<NoticeType> selectTypeName = noticeTypeService.selectEnableTypeList();
Integer code = selectTypeName != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = selectTypeName != null ? "" : "数据查询失败,请试!";
String msg = selectTypeName != null ? "" : "数据查询失败,请试!";
return ResponseResult.build(code, msg, selectTypeName);
}
@GetMapping
public ResponseResult selectTypeList(){
List<NoticeType> selectTypeList = noticeTypeService.selectTypeList();
Integer code = selectTypeList != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = selectTypeList != null ? "" : "数据查询失败,请重试!";
return ResponseResult.build(code, msg, selectTypeList);
}
@PutMapping
public ResponseResult updateTypeEnableById(String typeId,Boolean enable){
System.out.println(typeId+'\t'+enable);
Long tid=null;
Integer isEnable=null;
if (StringUtils.hasText(typeId)&&null!=enable){
tid = Long.parseLong(typeId);
isEnable = (enable == true ? 1 : 0);
}
Boolean updateEnableById = noticeTypeService.updateTypeEnableById(tid, isEnable);
String msg = updateEnableById ? "" : "修改失败,请重试!";
return ResponseResult.build(updateEnableById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateEnableById);
}
}

View File

@@ -17,6 +17,6 @@ import java.util.List;
*/
@Mapper
public interface NoticeReceiveMapper extends BaseMapper<NoticeReceive> {
List<Notice> selectAllByUserId(Long userId);
List<Notice> selectByUserId(Long userId,Integer readStatus);
}

View File

@@ -15,5 +15,5 @@ import java.util.List;
* @since 2023-04-30
*/
public interface INoticeReceiveService extends IService<NoticeReceive> {
List<Notice> selectAllByUserId();
List<Notice> selectByUserId(Integer readStatus);
}

View File

@@ -15,5 +15,8 @@ import java.util.List;
*/
public interface INoticeTypeService extends IService<NoticeType> {
List<NoticeType> selectTypeList();
List<NoticeType> selectEnableTypeList();
Boolean updateTypeEnableById(Long typeId, Integer enable);
}

View File

@@ -24,8 +24,8 @@ public class NoticeReceiveServiceImpl extends ServiceImpl<NoticeReceiveMapper, N
@Autowired
private NoticeReceiveMapper noticeReceiveMapper;
@Override
public List<Notice> selectAllByUserId() {
public List<Notice> selectByUserId(Integer readStatus) {
Long userId = WebUtil.getLoginUser().getUser().getId();
return noticeReceiveMapper.selectAllByUserId(userId);
return noticeReceiveMapper.selectByUserId(userId,readStatus);
}
}

View File

@@ -2,6 +2,7 @@ package com.cfive.pinnacle.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cfive.pinnacle.entity.NoticeType;
import com.cfive.pinnacle.mapper.NoticeTypeMapper;
import com.cfive.pinnacle.service.INoticeTypeService;
@@ -26,9 +27,24 @@ public class NoticeTypeServiceImpl extends ServiceImpl<NoticeTypeMapper, NoticeT
NoticeTypeMapper noticeTypeMapper;
@Override
public List<NoticeType> selectTypeList() {
return noticeTypeMapper.selectList(null);
}
@Override
public List<NoticeType> selectEnableTypeList() {
LambdaQueryWrapper<NoticeType> lqw = new LambdaQueryWrapper<>();
lqw.eq(NoticeType::getEnable, 1);
List<NoticeType> noticeTypes = noticeTypeMapper.selectList(lqw);
return noticeTypes;
}
@Override
public Boolean updateTypeEnableById(Long typeId, Integer enable) {
if ((null==typeId)||(null==enable)){
return false;
}
LambdaUpdateWrapper<NoticeType> luw = new LambdaUpdateWrapper<>();
luw.eq(null!=typeId,NoticeType::getId, typeId).set(null!=enable,NoticeType::getEnable,enable);
return noticeTypeMapper.update(null, luw)>0;
}
}

View File

@@ -1,31 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cfive.pinnacle.mapper.NoticeReceiveMapper">
<select id="selectAllByUserId" parameterType="Long" resultMap="selectAllMap">
select u.id uid,
username,
n.id nid,
title,
content,
type_id,
sender_id,
create_time,
send_time,
end_time,
priority,
top,
modify_time,
origin_id,
type.id typeId,
name,
type.enable,
notice_receive.id receiveId,
notice_receive.already_read receiveRead
<!--查询所有或根据用户阅读状态进行查询-->
<select id="selectByUserId" resultMap="selectAllMap">
select u.id uid,
u.username,
n.id nid,
n.title,
n.content,
n.type_id,
n.sender_id,
n.create_time,
n.send_time,
n.end_time,
n.priority,
n.top,
n.modify_time,
n.origin_id,
type.id typeId,
type.name,
type.enable,
notice_receive.id receiveId,
notice_receive.already_read receiveRead
from t_notice_receive notice_receive
left join t_notice n on n.id = notice_receive.notice_id
left join t_notice_type type on type.id = n.type_id
left join t_user u on n.sender_id = u.id
where notice_receive.user_id=#{userId}
left join t_notice n on n.id = notice_receive.notice_id
left join t_notice_type type on type.id = n.type_id
left join t_user u on n.sender_id = u.id
<where>
<if test="null!=readStatus and readStatus>=0">
and notice_receive.already_read=#{readStatus}
</if>
and notice_receive.user_id=#{userId}
</where>
</select>
<resultMap id="selectAllMap" type="notice" autoMapping="true">
<id property="id" column="nid"/>