mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Temp commit
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
package com.cfive.pinnacle.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.cfive.pinnacle.entity.Notice;
|
||||
import com.cfive.pinnacle.service.INoticeService;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,8 +17,55 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @author FatttSnake
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/notice")
|
||||
@CrossOrigin
|
||||
public class NoticeController {
|
||||
@Autowired
|
||||
INoticeService noticeService;
|
||||
|
||||
//根据公告id查公告信息及发布人
|
||||
@GetMapping("/{nid}")
|
||||
public Result selectByNoticeId(@PathVariable Long nid) {
|
||||
Notice noticeById = noticeService.selectByNoticeId(nid);
|
||||
Integer code = noticeById != null ? Code.SELECT_NOTICE_OK : Code.SELECT_NOTICE_ERR;
|
||||
String msg = noticeById != null ? "" : "数据查询失败,请尝试!";
|
||||
return new Result(code, noticeById, msg);
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
//添加公告
|
||||
@GetMapping
|
||||
public Result selectAllNoticeId() {
|
||||
List<Notice> noticeList = noticeService.selectAllNoticeId();
|
||||
Integer code = noticeList != null ? Code.SELECT_ALL_OK : Code.SELECT_ALL_ERR;
|
||||
String msg = noticeList != null ? "" : "数据查询失败,请尝试!";
|
||||
return new Result(code, noticeList, msg);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Result updateNotice(@RequestBody Notice notice) {
|
||||
notice.setId(null); //清除id,使新插入的数据id自增
|
||||
notice.setModifyTime(LocalDateTime.now());
|
||||
notice.setOriginId(notice.getId());
|
||||
boolean updateById = noticeService.save(notice);
|
||||
Result result = new Result(updateById ? Code.UPDATE_OK : Code.UPDATE_ERR, updateById);
|
||||
return result;
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public Result addNotice(@RequestBody Notice notice){
|
||||
boolean insertNotice = noticeService.save(notice);
|
||||
Result result = new Result(insertNotice ? Code.SAVE_OK : Code.SAVE_ERR, insertNotice);
|
||||
return result;
|
||||
}
|
||||
|
||||
@DeleteMapping("/{nid}")
|
||||
public Result deleteByNoticeId(@PathVariable Long nid){
|
||||
boolean removeById= noticeService.removeById(nid);
|
||||
Result result = new Result(removeById ? Code.DELETE_OK : Code.DELETE_ERR, removeById);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Notice implements Serializable {
|
||||
private Long typeId;
|
||||
|
||||
/**
|
||||
* 发布者
|
||||
* 发布者id
|
||||
*/
|
||||
@TableField("sender_id")
|
||||
private Long senderId;
|
||||
@@ -104,6 +104,12 @@ public class Notice implements Serializable {
|
||||
@TableField("old")
|
||||
private Integer old;
|
||||
|
||||
/**
|
||||
* 发布者
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private User sender;
|
||||
|
||||
@TableField("deleted")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
@@ -111,4 +117,6 @@ public class Notice implements Serializable {
|
||||
@TableField("version")
|
||||
@Version
|
||||
private Integer version;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.cfive.pinnacle.entity.Notice;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公告 Mapper 接口
|
||||
@@ -14,5 +16,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
*/
|
||||
@Mapper
|
||||
public interface NoticeMapper extends BaseMapper<Notice> {
|
||||
Notice selectByNoticeId(Long nid);
|
||||
|
||||
List<Notice> selectAllNoticeId();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.cfive.pinnacle.service;
|
||||
import com.cfive.pinnacle.entity.Notice;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公告 服务类
|
||||
@@ -12,5 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface INoticeService extends IService<Notice> {
|
||||
Notice selectByNoticeId(Long nid);
|
||||
|
||||
List<Notice> selectAllNoticeId();
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@ import com.cfive.pinnacle.entity.Notice;
|
||||
import com.cfive.pinnacle.mapper.NoticeMapper;
|
||||
import com.cfive.pinnacle.service.INoticeService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公告 服务实现类
|
||||
@@ -16,5 +19,15 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService {
|
||||
@Autowired
|
||||
NoticeMapper noticeMapper;
|
||||
@Override
|
||||
public Notice selectByNoticeId(Long nid) {
|
||||
return noticeMapper.selectByNoticeId(nid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Notice> selectAllNoticeId() {
|
||||
return noticeMapper.selectAllNoticeId();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user