diff --git a/renren-admin/src/main/java/io/renren/modules/notice/controller/SysNoticeManagementController.java b/renren-admin/src/main/java/io/renren/modules/notice/controller/SysNoticeManagementController.java new file mode 100644 index 00000000..f31c7643 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/notice/controller/SysNoticeManagementController.java @@ -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> getContent(@RequestParam Map params){ + PageData page = sysNoticeManagementService.getContent(params); + return new Result>().ok(page); + } + + // 公告周期 + @PostMapping("/period") + @ApiOperation("公告周期") + @LogOperation("公告周期") + public void period(Date publishTime){ + sysNoticeManagementService.period(publishTime);} +} diff --git a/renren-admin/src/main/java/io/renren/modules/notice/dao/SysNoticeManagementDao.java b/renren-admin/src/main/java/io/renren/modules/notice/dao/SysNoticeManagementDao.java new file mode 100644 index 00000000..9868d02d --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/notice/dao/SysNoticeManagementDao.java @@ -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 { + // 添加公告 + int addNotice(String content); + // 删除公告 + int deleteNotice(int num); + + // 修改公告 + int updateNotice(String content); + + // 查询公告 + List getContent(String content, int pageNum, int pageSize); + + //公告周期 + int period(Date publishTime); +} diff --git a/renren-admin/src/main/java/io/renren/modules/notice/dto/SysNoticeManagementDTO.java b/renren-admin/src/main/java/io/renren/modules/notice/dto/SysNoticeManagementDTO.java new file mode 100644 index 00000000..40c164d4 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/notice/dto/SysNoticeManagementDTO.java @@ -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; +} diff --git a/renren-admin/src/main/java/io/renren/modules/notice/entity/SysNoticeManagementEntity.java b/renren-admin/src/main/java/io/renren/modules/notice/entity/SysNoticeManagementEntity.java new file mode 100644 index 00000000..0862d256 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/notice/entity/SysNoticeManagementEntity.java @@ -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; +} diff --git a/renren-admin/src/main/java/io/renren/modules/notice/service/SysNoticeManagementService.java b/renren-admin/src/main/java/io/renren/modules/notice/service/SysNoticeManagementService.java new file mode 100644 index 00000000..3e0cf655 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/notice/service/SysNoticeManagementService.java @@ -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{ + // 添加公告 + void addNotice(String content); + + // 删除公告 + void deleteNotice(int num); + + // 修改公告 + void updateNotice(String content); + + // 查询公告 + PageData getContent(Map params); + + // 公告周期 + void period(Date publishTime); +} diff --git a/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeManagementImpl.java b/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeManagementImpl.java new file mode 100644 index 00000000..073abfb8 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeManagementImpl.java @@ -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 implements SysNoticeManagementService { + @Autowired + private SysNoticeManagementDao sysNoticeManagementDao; + @Override + public QueryWrapper getWrapper(Map 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 getContent(Map params) { + //分页 + IPage page = getPage(params, null, false); + + String content = params.get("content").toString(); + int pageNum = (int)params.get("limit"); + int pageSize = (int)params.get("page"); + //查询 + List list = sysNoticeManagementDao.getContent(content, (pageNum -1) * pageSize, pageSize); + + return getPageData(list, page.getTotal(), SysNoticeManagementDTO.class); + } + + // 公告周期 + @Override + public void period(Date publishTime){ + sysNoticeManagementDao.period(publishTime); + } +} diff --git a/renren-admin/src/main/resources/sysNoticeManagement.xml b/renren-admin/src/main/resources/sysNoticeManagement.xml new file mode 100644 index 00000000..19b5af38 --- /dev/null +++ b/renren-admin/src/main/resources/sysNoticeManagement.xml @@ -0,0 +1,39 @@ + + + + + + insert into sys_notice_management (num, content, publish_time) + values(#{num, jdbcType = INT}, + #{content, jdbcType = LONGTEXT}, + LOCALTIMESTAMP(0) + ) + + + + + delete from sys_notice_management where num = #{num} + + + + + update sys_notice_management + set content = #{content}, + publish_time = LOCALTIMESTAMP(0) + where num = #{num} + + + + + + + + + \ No newline at end of file