1. 基本完成通知模块的迁移
parent
42a984c8d0
commit
6a36fe65b2
@ -1,86 +0,0 @@
|
|||||||
package com.ruoyi.system.service.impl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
|
||||||
import com.ruoyi.system.mapper.SysNoticeMapper;
|
|
||||||
import com.ruoyi.system.service.ISysNoticeService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公告 服务层实现
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SysNoticeServiceImpl implements ISysNoticeService {
|
|
||||||
@Autowired
|
|
||||||
private SysNoticeMapper noticeMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询公告信息
|
|
||||||
*
|
|
||||||
* @param noticeId 公告ID
|
|
||||||
* @return 公告信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SysNotice selectNoticeById(Long noticeId) {
|
|
||||||
return noticeMapper.selectNoticeById(noticeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询公告列表
|
|
||||||
*
|
|
||||||
* @param notice 公告信息
|
|
||||||
* @return 公告集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysNotice> selectNoticeList(SysNotice notice) {
|
|
||||||
return noticeMapper.selectNoticeList(notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增公告
|
|
||||||
*
|
|
||||||
* @param notice 公告信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int insertNotice(SysNotice notice) {
|
|
||||||
return noticeMapper.insertNotice(notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改公告
|
|
||||||
*
|
|
||||||
* @param notice 公告信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int updateNotice(SysNotice notice) {
|
|
||||||
return noticeMapper.updateNotice(notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除公告对象
|
|
||||||
*
|
|
||||||
* @param noticeId 公告ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deleteNoticeById(Long noticeId) {
|
|
||||||
return noticeMapper.deleteNoticeById(noticeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除公告信息
|
|
||||||
*
|
|
||||||
* @param noticeIds 需要删除的公告ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deleteNoticeByIds(Long[] noticeIds) {
|
|
||||||
return noticeMapper.deleteNoticeByIds(noticeIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,64 +1,72 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.controller.notice;
|
package cn.iocoder.dashboard.modules.system.controller.notice;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeCreateReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticePageReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeRespVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeUpdateReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.convert.notice.SysNoticeConvert;
|
||||||
|
import cn.iocoder.dashboard.modules.system.service.notice.SysNoticeService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@Api(tags = "通知公告 API")
|
@Api(tags = "通知公告 API")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/notice")
|
@RequestMapping("/system/notice")
|
||||||
public class SysNoticeController {
|
public class SysNoticeController {
|
||||||
|
|
||||||
// /**
|
@Resource
|
||||||
// * 获取通知公告列表
|
private SysNoticeService noticeService;
|
||||||
// */
|
|
||||||
|
@ApiOperation("获取通知公告列表")
|
||||||
|
@GetMapping("/page")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:notice:list')")
|
// @PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||||
// @GetMapping("/list")
|
public CommonResult<PageResult<SysNoticeRespVO>> pageNotices(@Validated SysNoticePageReqVO reqVO) {
|
||||||
// public TableDataInfo list(SysNotice notice) {
|
return success(SysNoticeConvert.INSTANCE.convertPage(noticeService.pageNotices(reqVO)));
|
||||||
// startPage();
|
}
|
||||||
// List<SysNotice> list = noticeService.selectNoticeList(notice);
|
|
||||||
// return getDataTable(list);
|
@ApiOperation("获得通知公告")
|
||||||
// }
|
@ApiImplicitParam(name = "id", value = "编号", readOnly = true, example = "1024", dataTypeClass = Long.class)
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 根据通知公告编号获取详细信息
|
|
||||||
// */
|
|
||||||
// @PreAuthorize("@ss.hasPermi('system:notice:query')")
|
// @PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||||
// @GetMapping(value = "/{noticeId}")
|
@GetMapping(value = "/get")
|
||||||
// public AjaxResult getInfo(@PathVariable Long noticeId) {
|
public CommonResult<SysNoticeRespVO> getNotice(@RequestParam("id") Long id) {
|
||||||
// return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
return success(SysNoticeConvert.INSTANCE.convert(noticeService.getNotice(id)));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
@ApiOperation("新增通知公告")
|
||||||
// * 新增通知公告
|
|
||||||
// */
|
|
||||||
// @PreAuthorize("@ss.hasPermi('system:notice:add')")
|
// @PreAuthorize("@ss.hasPermi('system:notice:add')")
|
||||||
// @Log(title = "通知公告", businessType = BusinessType.INSERT)
|
// @Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||||
// @PostMapping
|
@PostMapping("/create")
|
||||||
// public AjaxResult add(@Validated @RequestBody SysNotice notice) {
|
public CommonResult<Long> createNotice(@Validated @RequestBody SysNoticeCreateReqVO reqVO) {
|
||||||
// notice.setCreateBy(SecurityUtils.getUsername());
|
Long noticeId = noticeService.createNotice(reqVO);
|
||||||
// return toAjax(noticeService.insertNotice(notice));
|
return success(noticeId);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
@ApiOperation("修改通知公告")
|
||||||
// * 修改通知公告
|
|
||||||
// */
|
|
||||||
// @PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
// @PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
||||||
// @Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
// @Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||||
// @PutMapping
|
@PostMapping("/update")
|
||||||
// public AjaxResult edit(@Validated @RequestBody SysNotice notice) {
|
public CommonResult<Boolean> updateNotice(@Validated @RequestBody SysNoticeUpdateReqVO reqVO) {
|
||||||
// notice.setUpdateBy(SecurityUtils.getUsername());
|
noticeService.updateNotice(reqVO);
|
||||||
// return toAjax(noticeService.updateNotice(notice));
|
return success(true);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
@ApiOperation("删除通知公告")
|
||||||
// * 删除通知公告
|
@ApiImplicitParam(name = "id", value = "编号", readOnly = true, example = "1024", dataTypeClass = Long.class)
|
||||||
// */
|
|
||||||
// @PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
// @PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
||||||
// @Log(title = "通知公告", businessType = BusinessType.DELETE)
|
// @Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||||
// @DeleteMapping("/{noticeIds}")
|
@PostMapping("/delete")
|
||||||
// public AjaxResult remove(@PathVariable Long[] noticeIds) {
|
public CommonResult<Boolean> deleteNotice(@RequestParam("id") Long id) {
|
||||||
// return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
noticeService.deleteNotice(id);
|
||||||
// }
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.system.controller.notice.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostBaseVO;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@ApiModel("通知公告创建 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysNoticeCreateReqVO extends SysPostBaseVO {
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.system.controller.notice.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.pojo.PageParam;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@ApiModel("通知公告分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysNoticePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "通知公告名称", example = "芋道", notes = "模糊匹配")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "展示状态", example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.system.controller.notice.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostBaseVO;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ApiModel("通知公告信息 Response VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysNoticeRespVO extends SysPostBaseVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "通知公告序号", required = true, example = "1024")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.system.controller.notice.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostBaseVO;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ApiModel("岗位公告更新 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysNoticeUpdateReqVO extends SysPostBaseVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "岗位公告编号", required = true, example = "1024")
|
||||||
|
@NotNull(message = "岗位公告编号不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,9 +1,20 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.dal.mysql.dao.notice;
|
package cn.iocoder.dashboard.modules.system.dal.mysql.dao.notice;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
|
||||||
|
import cn.iocoder.dashboard.framework.mybatis.core.util.MyBatisUtils;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticePageReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO;
|
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SysNoticeMapper extends BaseMapper<SysNoticeDO> {
|
public interface SysNoticeMapper extends BaseMapper<SysNoticeDO> {
|
||||||
|
|
||||||
|
default IPage<SysNoticeDO> selectList(SysNoticePageReqVO reqVO) {
|
||||||
|
return selectPage(MyBatisUtils.buildPage(reqVO),
|
||||||
|
new QueryWrapperX<SysNoticeDO>().likeIfPresent("title", reqVO.getTitle())
|
||||||
|
.eqIfPresent("status", reqVO.getStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,51 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.system.service.notice;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeCreateReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticePageReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeUpdateReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知公告 Service 接口
|
||||||
|
*/
|
||||||
|
public interface SysNoticeService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得岗位公告公告分页列表
|
||||||
|
*
|
||||||
|
* @param reqVO 分页条件
|
||||||
|
* @return 部门分页列表
|
||||||
|
*/
|
||||||
|
PageResult<SysNoticeDO> pageNotices(SysNoticePageReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得岗位公告公告信息
|
||||||
|
*
|
||||||
|
* @param id 岗位公告公告编号
|
||||||
|
* @return 岗位公告公告信息
|
||||||
|
*/
|
||||||
|
SysNoticeDO getNotice(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建岗位公告公告
|
||||||
|
*
|
||||||
|
* @param reqVO 岗位公告公告信息
|
||||||
|
* @return 岗位公告公告编号
|
||||||
|
*/
|
||||||
|
Long createNotice(SysNoticeCreateReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新岗位公告公告
|
||||||
|
*
|
||||||
|
* @param reqVO 岗位公告公告信息
|
||||||
|
*/
|
||||||
|
void updateNotice(SysNoticeUpdateReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除岗位公告公告信息
|
||||||
|
*
|
||||||
|
* @param id 岗位公告公告编号
|
||||||
|
*/
|
||||||
|
void deleteNotice(Long id);
|
||||||
|
}
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.system.service.notice.impl;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
||||||
|
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeCreateReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticePageReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeUpdateReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.convert.dept.SysPostConvert;
|
||||||
|
import cn.iocoder.dashboard.modules.system.convert.notice.SysNoticeConvert;
|
||||||
|
import cn.iocoder.dashboard.modules.system.dal.mysql.dao.notice.SysNoticeMapper;
|
||||||
|
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.service.notice.SysNoticeService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.NOTICE_NOT_FOUND;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知公告 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysNoticeServiceImpl implements SysNoticeService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysNoticeMapper noticeMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<SysNoticeDO> pageNotices(SysNoticePageReqVO reqVO) {
|
||||||
|
return SysNoticeConvert.INSTANCE.convertPage02(noticeMapper.selectList(reqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysNoticeDO getNotice(Long id) {
|
||||||
|
return noticeMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createNotice(SysNoticeCreateReqVO reqVO) {
|
||||||
|
SysNoticeDO notice = SysNoticeConvert.INSTANCE.convert(reqVO);
|
||||||
|
return notice.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateNotice(SysNoticeUpdateReqVO reqVO) {
|
||||||
|
// 校验是否存在
|
||||||
|
this.checkNoticeExists(reqVO.getId());
|
||||||
|
// 更新通知公告
|
||||||
|
SysNoticeDO updateObj = SysNoticeConvert.INSTANCE.convert(reqVO);
|
||||||
|
noticeMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteNotice(Long id) {
|
||||||
|
// 校验是否存在
|
||||||
|
this.checkNoticeExists(id);
|
||||||
|
// 删除通知公告
|
||||||
|
noticeMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkNoticeExists(Long id) {
|
||||||
|
if (id == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SysNoticeDO notice = noticeMapper.selectById(id);
|
||||||
|
if (notice == null) {
|
||||||
|
throw ServiceExceptionUtil.exception(NOTICE_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue