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

Temp commit on 2023-05-01 5:00

This commit is contained in:
cccccyb
2023-05-01 05:01:54 +08:00
parent cdf47bc0bb
commit e8bc1f5945
11 changed files with 133 additions and 90 deletions

View File

@@ -1,6 +1,8 @@
package com.cfive.pinnacle.controller; package com.cfive.pinnacle.controller;
import com.cfive.pinnacle.entity.Notice; import com.cfive.pinnacle.entity.Notice;
import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.service.INoticeService; import com.cfive.pinnacle.service.INoticeService;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -27,45 +29,45 @@ public class NoticeController {
//根据公告id查公告信息及发布人 //根据公告id查公告信息及发布人
@GetMapping("/{nid}") @GetMapping("/{nid}")
public Result selectByNoticeId(@PathVariable Long nid) { public ResponseResult selectByNoticeId(@PathVariable Long nid) {
Notice noticeById = noticeService.selectByNoticeId(nid); Notice noticeById = noticeService.selectByNoticeId(nid);
Integer code = noticeById != null ? Code.SELECT_NOTICE_OK : Code.SELECT_NOTICE_ERR; Integer code = noticeById != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticeById != null ? "" : "数据查询失败,请尝试!"; String msg = noticeById != null ? "" : "数据查询失败,请尝试!";
return new Result(code, noticeById, msg); return ResponseResult.build(code, msg, noticeById);
} }
; ;
//添加公告 //添加公告
@GetMapping @GetMapping
public Result selectAllNoticeId() { public ResponseResult selectAllNotice() {
List<Notice> noticeList = noticeService.selectAllNoticeId(); List<Notice> noticeList = noticeService.selectAllNotice();
Integer code = noticeList != null ? Code.SELECT_ALL_OK : Code.SELECT_ALL_ERR; Integer code = noticeList != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticeList != null ? "" : "数据查询失败,请尝试!"; String msg = noticeList != null ? "" : "数据查询失败,请尝试!";
return new Result(code, noticeList, msg); return ResponseResult.build(code, msg, noticeList);
} }
@PostMapping @PostMapping
public Result updateNotice(@RequestBody Notice notice) { public ResponseResult updateNotice(@RequestBody Notice notice) {
notice.setId(null); //清除id使新插入的数据id自增 notice.setId(null); //清除id使新插入的数据id自增
notice.setModifyTime(LocalDateTime.now());
notice.setOriginId(notice.getId()); notice.setOriginId(notice.getId());
boolean updateById = noticeService.save(notice); boolean updateById = noticeService.save(notice);
Result result = new Result(updateById ? Code.UPDATE_OK : Code.UPDATE_ERR, updateById); String msg = updateById ? "" : "数据修改失败,请尝试!";
return result; return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById);
} }
@PutMapping @PutMapping
public Result addNotice(@RequestBody Notice notice){ public ResponseResult addNotice(@RequestBody Notice notice) {
boolean insertNotice = noticeService.save(notice); boolean insertNotice = noticeService.save(notice);
Result result = new Result(insertNotice ? Code.SAVE_OK : Code.SAVE_ERR, insertNotice); String msg = insertNotice ? "" : "数据添加失败,请尝试!";
return result; return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, insertNotice);
} }
@DeleteMapping("/{nid}") @DeleteMapping("/{nid}")
public Result deleteByNoticeId(@PathVariable Long nid){ public ResponseResult deleteByNoticeId(@PathVariable Long nid) {
boolean removeById= noticeService.removeById(nid); boolean removeById = noticeService.deleteById(nid);
Result result = new Result(removeById ? Code.DELETE_OK : Code.DELETE_ERR, removeById); String msg = removeById ? "" : "数据删除失败,请尝试!";
return result; return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, removeById);
} }
} }

View File

@@ -1,18 +0,0 @@
package com.cfive.pinnacle.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 公告接收 前端控制器
* </p>
*
* @author FatttSnake
* @since 2023-04-30
*/
@RestController
@RequestMapping("/noticeReceive")
public class NoticeReceiveController {
}

View File

@@ -45,17 +45,29 @@ public class Notice implements Serializable {
private String content; private String content;
/** /**
* 公告类型 * 公告类型Id
*/ */
@TableField("type_id") @TableField("type_id")
private Long typeId; private Long typeId;
/**
* 公告类型
*/
@TableField(exist = false)
private NoticeType noticeType;
/** /**
* 发布者id * 发布者id
*/ */
@TableField("sender_id") @TableField("sender_id")
private Long senderId; private Long senderId;
/**
* 发布者
*/
@TableField(exist = false)
private User sender;
/** /**
* 创建时间 * 创建时间
*/ */
@@ -104,12 +116,6 @@ public class Notice implements Serializable {
@TableField("old") @TableField("old")
private Integer old; private Integer old;
/**
* 发布者
*/
@TableField(exist = false)
private User sender;
@TableField("deleted") @TableField("deleted")
@TableLogic @TableLogic
private Integer deleted; private Integer deleted;

View File

@@ -32,17 +32,29 @@ public class NoticeReceive implements Serializable {
private Long id; private Long id;
/** /**
* 用户 * 用户Id
*/ */
@TableField("user_id") @TableField("user_id")
private Long userId; private Long userId;
/** /**
* 公告 * 用户
*/
@TableField(exist = false)
private User user;
/**
* 公告Id
*/ */
@TableField("notice_id") @TableField("notice_id")
private Long noticeId; private Long noticeId;
/**
* 公告
*/
@TableField(exist = false)
private Notice notice;
/** /**
* 已读 * 已读
*/ */

View File

@@ -18,5 +18,5 @@ import java.util.List;
public interface NoticeMapper extends BaseMapper<Notice> { public interface NoticeMapper extends BaseMapper<Notice> {
Notice selectByNoticeId(Long nid); Notice selectByNoticeId(Long nid);
List<Notice> selectAllNoticeId(); List<Notice> selectAllNotice();
} }

View File

@@ -16,5 +16,7 @@ import java.util.List;
public interface INoticeService extends IService<Notice> { public interface INoticeService extends IService<Notice> {
Notice selectByNoticeId(Long nid); Notice selectByNoticeId(Long nid);
List<Notice> selectAllNoticeId(); List<Notice> selectAllNotice();
Boolean deleteById(Long nid);
} }

View File

@@ -1,7 +1,10 @@
package com.cfive.pinnacle.service.impl; package com.cfive.pinnacle.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cfive.pinnacle.entity.Notice; import com.cfive.pinnacle.entity.Notice;
import com.cfive.pinnacle.entity.NoticeReceive;
import com.cfive.pinnacle.mapper.NoticeMapper; import com.cfive.pinnacle.mapper.NoticeMapper;
import com.cfive.pinnacle.mapper.NoticeReceiveMapper;
import com.cfive.pinnacle.service.INoticeService; import com.cfive.pinnacle.service.INoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -21,13 +24,28 @@ import java.util.List;
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService { public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService {
@Autowired @Autowired
NoticeMapper noticeMapper; NoticeMapper noticeMapper;
@Autowired
NoticeReceiveMapper noticeReceiveMapper;
@Override @Override
public Notice selectByNoticeId(Long nid) { public Notice selectByNoticeId(Long nid) {
return noticeMapper.selectByNoticeId(nid); return noticeMapper.selectByNoticeId(nid);
} }
@Override @Override
public List<Notice> selectAllNoticeId() { public List<Notice> selectAllNotice() {
return noticeMapper.selectAllNoticeId(); return noticeMapper.selectAllNotice();
} }
@Override
public Boolean deleteById(Long nid) {
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
lqw.eq(NoticeReceive::getNoticeId, nid);
List<NoticeReceive> noticeReceives = noticeReceiveMapper.selectList(lqw);
for (NoticeReceive nrc:
noticeReceives) {
noticeReceiveMapper.deleteById(nrc.getId());
}
return noticeMapper.deleteById(nid)==0;
}
} }

View File

@@ -1,30 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cfive.pinnacle.mapper.NoticeMapper"> <mapper namespace="com.cfive.pinnacle.mapper.NoticeMapper">
<!-- 根据公告id查公告信息及发布人 --> <!-- 根据公告id查公告信息及发布人、公告类别名 -->
<select id="selectByNoticeId" resultMap="NoticeByIdResultMap" parameterType="long"> <select id="selectByNoticeId" resultMap="NoticeByIdResultMap" parameterType="long">
select * select *
from t_user u, from t_user u,
t_notice t t_notice n,
where u.id = t.sender_id t_notice_type type
and t.id = #{nid} where u.id = n.sender_id
and t.deleted = 0 and type.id=n.type_id
and n.id = #{nid}
and n.deleted = 0
and n.old=0
</select> </select>
<resultMap id="NoticeByIdResultMap" type="notice" autoMapping="true"> <resultMap id="NoticeByIdResultMap" type="notice" autoMapping="true">
<association property="sender" javaType="user" autoMapping="true"/> <association property="sender" javaType="user" autoMapping="true"/>
<association property="noticeType" javaType="noticeType" autoMapping="true"/>
</resultMap> </resultMap>
<!-- 查询所有公告 --> <!-- 查询所有公告 -->
<select id="selectAllNoticeId" resultMap="NoticeAllResultMap"> <select id="selectAllNotice" resultMap="NoticeAllResultMap">
select * select *
from t_user u, from t_user u,
t_notice t t_notice n,
where u.id = t.sender_id t_notice_type type
and t.deleted = 0 where u.id = n.sender_id
and type.id=n.type_id
and n.deleted = 0
and n.old=0
</select> </select>
<resultMap id="NoticeAllResultMap" type="notice" autoMapping="true"> <resultMap id="NoticeAllResultMap" type="notice" autoMapping="true">
<association property="sender" javaType="user" autoMapping="true"/> <association property="sender" javaType="user" autoMapping="true"/>
<association property="noticeType" javaType="noticeType" autoMapping="true"/>
</resultMap> </resultMap>
</mapper> </mapper>

View File

@@ -1,11 +1,11 @@
package com.cfive.pinnacle.notice; package com.cfive.pinnacle.notice;
import com.cfive.pinnacle.controller.NoticeController; import com.cfive.pinnacle.controller.NoticeController;
import com.cfive.pinnacle.controller.Result;
import com.cfive.pinnacle.entity.Department;
import com.cfive.pinnacle.entity.Notice; import com.cfive.pinnacle.entity.Notice;
import com.cfive.pinnacle.entity.NoticeReceive;
import com.cfive.pinnacle.entity.NoticeType; import com.cfive.pinnacle.entity.NoticeType;
import com.cfive.pinnacle.entity.User; import com.cfive.pinnacle.entity.User;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.service.IDepartmentService; import com.cfive.pinnacle.service.IDepartmentService;
import com.cfive.pinnacle.service.INoticeReceiveService; import com.cfive.pinnacle.service.INoticeReceiveService;
import com.cfive.pinnacle.service.INoticeTypeService; import com.cfive.pinnacle.service.INoticeTypeService;
@@ -33,20 +33,20 @@ public class NoticeTest {
@Test @Test
void selectByIdTest() { void selectByIdTest() {
Result notice = noticeController.selectByNoticeId(21L); ResponseResult selectByNoticeId = noticeController.selectByNoticeId(21L);
System.out.println(notice.getData()); System.out.println(selectByNoticeId.getData());
} }
@Test @Test
void selectAllTest() { void selectAllTest() {
Result noticeList = noticeController.selectAllNoticeId(); ResponseResult noticeList = noticeController.selectAllNotice();
System.out.println(noticeList.getData()); System.out.println(noticeList.getData());
} }
@Test @Test
void updateTest() { void updateTest() {
Result notice =noticeController.selectByNoticeId(23L); ResponseResult notice = noticeController.selectByNoticeId(23L);
Result updateNotice = noticeController.updateNotice((Notice)notice.getData()); ResponseResult updateNotice = noticeController.updateNotice((Notice) notice.getData());
System.out.println(updateNotice.getData()); System.out.println(updateNotice.getData());
} }
@@ -56,14 +56,13 @@ public class NoticeTest {
notice.setTitle("title1"); notice.setTitle("title1");
notice.setTypeId(1652684907554496514L); notice.setTypeId(1652684907554496514L);
notice.setSenderId(1652714496280469506L); notice.setSenderId(1652714496280469506L);
LocalDateTime startDate = LocalDateTime.parse("2023-03-21 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); LocalDateTime sendTime = LocalDateTime.parse("2023-05-11 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime endDate = LocalDateTime.parse("2023-09-01 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); LocalDateTime endTime = LocalDateTime.parse("2023-09-01 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// notice.setEffectiveDate(startDate); notice.setPriority(2);
// notice.setEndDate(endDate); notice.setSendTime(sendTime);
// notice.setSenderID(2); notice.setEndTime(endTime);
notice.setContent("Content1"); notice.setContent("Content1");
Result updateNotice = noticeController.addNotice(notice); noticeController.addNotice(notice);
System.out.println(updateNotice.getData());
} }
@Test @Test
void insertNoticeTypeTest(){ void insertNoticeTypeTest(){
@@ -74,11 +73,11 @@ public class NoticeTest {
@Test @Test
void insertNoticeRecTest(){ void insertNoticeRecTest(){
User user = new User(); NoticeReceive receive = new NoticeReceive();
user.setUsername("cyb"); receive.setNoticeId(1652734384348790786L);
user.setPasswd("123"); receive.setUserId(1652714496280469506L);
user.setDepartmentId(1652713919467151362L); iNoticeReceiveService.save(receive);
iUserService.save(user);
// iNoticeTypeService.save(noticeType);
} }
} }

View File

@@ -16,11 +16,11 @@
:formatter="formatter" :formatter="formatter"
show-overflow-tooltip show-overflow-tooltip
/> />
<el-table-column prop="category" label="公告类别" width="180" /> <el-table-column prop="noticeType.name" label="公告类别" width="180" />
<el-table-column prop="status" label="状态" width="180" /> <el-table-column prop="priority" label="优先级" width="180" />
<el-table-column <el-table-column
prop="sendTime" prop="sendTime"
label="创建时间" label="生效时间"
sortable sortable
width="180" width="180"
column-key="date" column-key="date"
@@ -34,7 +34,7 @@
:formatter="formatDate" :formatter="formatDate"
/> />
<el-table-column <el-table-column
prop="endDate" prop="endTime"
label="失效时间" label="失效时间"
sortable sortable
width="180" width="180"
@@ -42,7 +42,7 @@
:formatter="formatDate" :formatter="formatDate"
/> />
<el-table-column <el-table-column
prop="sender.userName" prop="sender.username"
label="发布人" label="发布人"
width="100" width="100"
:filters="[ :filters="[
@@ -56,7 +56,7 @@
<el-tag <el-tag
:type="scope.row.sender.userName === 'Home' ? '' : 'success'" :type="scope.row.sender.userName === 'Home' ? '' : 'success'"
disable-transitions disable-transitions
>{{ scope.row.sender.userName }} >{{ scope.row.sender.username }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
@@ -93,7 +93,7 @@ export default {
return row.title return row.title
}, },
filterTag(value, row) { filterTag(value, row) {
return row.sender.userName === value return row.sender.username === value
}, },
filterHandler(value, row, column) { filterHandler(value, row, column) {
const property = column['property'] const property = column['property']
@@ -111,14 +111,16 @@ export default {
console.log(index, row.id) console.log(index, row.id)
}, },
handleDelete(index, row) { handleDelete(index, row) {
axios.delete('http://localhost:8080/notice/' + row.id).then((response) => { // console.log(row.id)
axios.delete('http://localhost:8621/notice/' + row.id).then((response) => {
console.log(response.data) console.log(response.data)
this.selectAllNotice() this.selectAllNotice()
}) })
}, },
selectAllNotice() { selectAllNotice() {
axios.get('http://localhost:8080/notice').then((response) => { axios.get('http://localhost:8621/notice').then((response) => {
this.tableData = response.data.data this.tableData = response.data.data;
console.log(response.data.data[0].id)
}) })
} }
}, },

View File

@@ -0,0 +1,14 @@
<template>
<notice-table/>
</template>
<script>
import NoticeTable from "@/components/NoticeTable.vue";
export default {
name: "NoticeHome"
};
</script>
<style scoped>
</style>