公告管理代码
This commit is contained in:
parent
7bb0c3997d
commit
c8207fef82
|
@ -0,0 +1,74 @@
|
|||
package io.renren.modules.notice.controller;
|
||||
|
||||
|
||||
import io.renren.common.annotation.LogOperation;
|
||||
import io.renren.common.constant.Constant;
|
||||
import io.renren.common.page.PageData;
|
||||
import io.renren.common.utils.Result;
|
||||
import io.renren.modules.notice.dto.SysNoticeManagementDTO;
|
||||
import io.renren.modules.notice.entity.SysNoticeManagementEntity;
|
||||
import io.renren.modules.notice.service.SysNoticeManagementService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sys/notice/noticeManagement")
|
||||
@Api(tags = "公告管理")
|
||||
public class SysNoticeManagementController {
|
||||
private static Logger logger = LoggerFactory.getLogger(SysNoticeController.class);
|
||||
@Autowired
|
||||
private SysNoticeManagementService sysNoticeManagementService;
|
||||
|
||||
// 添加公告
|
||||
@PostMapping("/addNotice")
|
||||
@ApiOperation("添加")
|
||||
@LogOperation("添加")
|
||||
public void addNotice(@RequestBody String content){
|
||||
sysNoticeManagementService.addNotice(content);
|
||||
}
|
||||
|
||||
// 删除公告
|
||||
@DeleteMapping("/deleteNotice")
|
||||
@ApiOperation("删除")
|
||||
@LogOperation("删除")
|
||||
public void deleteNotice(@RequestBody int num){
|
||||
sysNoticeManagementService.deleteNotice(num);
|
||||
}
|
||||
|
||||
// 修改公告
|
||||
@PutMapping("/updateNotice")
|
||||
@ApiOperation("修改")
|
||||
@LogOperation("修改")
|
||||
public void updateNotice(@RequestBody String content){
|
||||
sysNoticeManagementService.updateNotice(content);
|
||||
}
|
||||
|
||||
// 查询公告
|
||||
@GetMapping("/getContent")
|
||||
@ApiOperation("查询")
|
||||
@LogOperation("查询")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = "date", value = "天数", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = "content", value = "内容", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int")})
|
||||
public Result<PageData<SysNoticeManagementDTO>> getContent(@RequestParam Map<String, Object> params){
|
||||
PageData<SysNoticeManagementDTO> page = sysNoticeManagementService.getContent(params);
|
||||
return new Result<PageData<SysNoticeManagementDTO>>().ok(page);
|
||||
}
|
||||
|
||||
// 公告周期
|
||||
@PostMapping("/period")
|
||||
@ApiOperation("公告周期")
|
||||
@LogOperation("公告周期")
|
||||
public void period(Date publishTime){
|
||||
sysNoticeManagementService.period(publishTime);}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package io.renren.modules.notice.dao;
|
||||
|
||||
import io.renren.common.dao.BaseDao;
|
||||
import io.renren.modules.notice.entity.SysNoticeManagementEntity;
|
||||
import io.renren.modules.sys.entity.SysDeptEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysNoticeManagementDao extends BaseDao<SysNoticeManagementEntity> {
|
||||
// 添加公告
|
||||
int addNotice(String content);
|
||||
// 删除公告
|
||||
int deleteNotice(int num);
|
||||
|
||||
// 修改公告
|
||||
int updateNotice(String content);
|
||||
|
||||
// 查询公告
|
||||
List<SysNoticeManagementEntity> getContent(String content, int pageNum, int pageSize);
|
||||
|
||||
//公告周期
|
||||
int period(Date publishTime);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package io.renren.modules.notice.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "公告管理")
|
||||
public class SysNoticeManagementDTO implements Serializable {
|
||||
@ApiModelProperty(name = "id", value = "ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(name = "content", value = "公告内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(name = "publish_time", value = "发布时间")
|
||||
private Date publishTime;
|
||||
|
||||
@ApiModelProperty(name = "del_flag", value = "删除状态")
|
||||
private int delFlag;
|
||||
|
||||
@ApiModelProperty(name = "create_date", value = "创建时间")
|
||||
private Date createDate;
|
||||
|
||||
@ApiModelProperty(name = "creator", value = "作者")
|
||||
private Long creator;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.renren.modules.notice.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.renren.common.entity.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class SysNoticeManagementEntity extends BaseEntity implements Serializable {
|
||||
|
||||
|
||||
@ApiModelProperty(name = "content", value = "公告内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(name = "publish_time", value = "发布时间")
|
||||
private Date publishTime;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package io.renren.modules.notice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import io.renren.common.page.PageData;
|
||||
import io.renren.common.service.CrudService;
|
||||
import io.renren.modules.monitor.entity.Result;
|
||||
import io.renren.modules.notice.dto.SysNoticeManagementDTO;
|
||||
import io.renren.modules.notice.entity.SysNoticeManagementEntity;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SysNoticeManagementService extends CrudService<SysNoticeManagementEntity, SysNoticeManagementDTO>{
|
||||
// 添加公告
|
||||
void addNotice(String content);
|
||||
|
||||
// 删除公告
|
||||
void deleteNotice(int num);
|
||||
|
||||
// 修改公告
|
||||
void updateNotice(String content);
|
||||
|
||||
// 查询公告
|
||||
PageData<SysNoticeManagementDTO> getContent(Map<String, Object> params);
|
||||
|
||||
// 公告周期
|
||||
void period(Date publishTime);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package io.renren.modules.notice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.renren.common.page.PageData;
|
||||
import io.renren.common.service.impl.CrudServiceImpl;
|
||||
import io.renren.modules.notice.dao.SysNoticeManagementDao;
|
||||
import io.renren.modules.notice.dto.SysNoticeManagementDTO;
|
||||
import io.renren.modules.notice.entity.SysNoticeManagementEntity;
|
||||
import io.renren.modules.notice.service.SysNoticeManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class SysNoticeManagementImpl extends CrudServiceImpl<SysNoticeManagementDao, SysNoticeManagementEntity, SysNoticeManagementDTO> implements SysNoticeManagementService {
|
||||
@Autowired
|
||||
private SysNoticeManagementDao sysNoticeManagementDao;
|
||||
@Override
|
||||
public QueryWrapper<SysNoticeManagementEntity> getWrapper(Map<String, Object> params) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 添加公告
|
||||
@Override
|
||||
public void addNotice(String content){
|
||||
sysNoticeManagementDao.addNotice(content);
|
||||
}
|
||||
|
||||
// 删除公告
|
||||
@Override
|
||||
public void deleteNotice(int num) {
|
||||
sysNoticeManagementDao.deleteNotice(num);
|
||||
}
|
||||
|
||||
// 修改公告
|
||||
@Override
|
||||
public void updateNotice(String content) {
|
||||
sysNoticeManagementDao.updateNotice(content);
|
||||
}
|
||||
|
||||
// 查询公告
|
||||
@Override
|
||||
public PageData<SysNoticeManagementDTO> getContent(Map<String, Object> params) {
|
||||
//分页
|
||||
IPage<SysNoticeManagementEntity> page = getPage(params, null, false);
|
||||
|
||||
String content = params.get("content").toString();
|
||||
int pageNum = (int)params.get("limit");
|
||||
int pageSize = (int)params.get("page");
|
||||
//查询
|
||||
List<SysNoticeManagementEntity> list = sysNoticeManagementDao.getContent(content, (pageNum -1) * pageSize, pageSize);
|
||||
|
||||
return getPageData(list, page.getTotal(), SysNoticeManagementDTO.class);
|
||||
}
|
||||
|
||||
// 公告周期
|
||||
@Override
|
||||
public void period(Date publishTime){
|
||||
sysNoticeManagementDao.period(publishTime);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?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="io.renren.modules.notice.dao.SysNoticeManagementDao">
|
||||
<!--insert 添加公告-->
|
||||
<insert id = "addNotice" parameterType = "io.renren.modules.notice.entity.SysNoticeManagementEntity">
|
||||
insert into sys_notice_management (num, content, publish_time)
|
||||
values(#{num, jdbcType = INT},
|
||||
#{content, jdbcType = LONGTEXT},
|
||||
LOCALTIMESTAMP(0)
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!--delete 删除公告-->
|
||||
<delete id = "deleteNotice" >
|
||||
delete from sys_notice_management where num = #{num}
|
||||
</delete>
|
||||
|
||||
<!--update 修改公告-->
|
||||
<update id = "updateNotice" parameterType = "io.renren.modules.notice.entity.SysNoticeManagementEntity">
|
||||
update sys_notice_management
|
||||
set content = #{content},
|
||||
publish_time = LOCALTIMESTAMP(0)
|
||||
where num = #{num}
|
||||
</update>
|
||||
|
||||
<!--select 查询公告-->
|
||||
<select id = "getContent" resultType = "io.renren.modules.notice.entity.SysNoticeManagementEntity">
|
||||
select *
|
||||
from sys_notice_management
|
||||
where content LIKE '%通知%' OR '%重要%' OR '%公告%' AND LIMIT ${pageNum, pageSize}
|
||||
</select>
|
||||
|
||||
<!--select 公告周期-->
|
||||
<select id = "period" resultType = "java.lang.Integer">
|
||||
select publish_time
|
||||
from sys_notice_management
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue