add 公告管理
This commit is contained in:
+72
@@ -0,0 +1,72 @@
|
||||
package com.jero.modules.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.system.entity.SysNotice;
|
||||
import com.jero.modules.system.service.ISysNoticeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/7/14 15:42
|
||||
* @remarks: 公告管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sysNotice")
|
||||
@Api(tags = "公告管理")
|
||||
public class SysNoticeController {
|
||||
|
||||
@Autowired
|
||||
private ISysNoticeService sysNoticeService;
|
||||
|
||||
@ApiOperation(value = "公告管理-添加", notes = "公告管理-添加")
|
||||
@PostMapping(value = "/add")
|
||||
@RequiresPermissions("sysNotice:add")
|
||||
public Result<String> add(@Validated @RequestBody SysNotice sysNotice) {
|
||||
sysNoticeService.add(sysNotice);
|
||||
return Result.OK(Result.OPERATING_SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "公告管理-根据id删除", notes = "公告管理-根据id删除")
|
||||
@GetMapping(value = "/deleteById")
|
||||
@RequiresPermissions("sysNotice:deleteById")
|
||||
public Result<String> deleteById(@RequestParam(name = "id") String id) {
|
||||
sysNoticeService.deleteById(id);
|
||||
return Result.OK(Result.OPERATING_SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "公告管理-根据ids批量删除", notes = "公告管理-根据ids批量删除")
|
||||
@GetMapping(value = "/deleteBatch")
|
||||
@RequiresPermissions("sysNotice:deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids") String ids) {
|
||||
sysNoticeService.deleteBatch(ids);
|
||||
return Result.OK(Result.OPERATING_SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "公告管理-编辑", notes = "公告管理-编辑")
|
||||
@PostMapping(value = "/edit")
|
||||
@RequiresPermissions("sysNotice:edit")
|
||||
public Result<String> edit(@Validated @RequestBody SysNotice sysNotice) {
|
||||
sysNoticeService.edit(sysNotice);
|
||||
return Result.OK(Result.OPERATING_SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "公告管理-分页查询", notes = "公告管理-分页查询")
|
||||
@GetMapping(value = "/pageList")
|
||||
@RequiresPermissions("sysNotice:pageList")
|
||||
public Result<IPage<SysNotice>> pageList(SysNotice sysNotice,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
IPage<SysNotice> pageList = sysNoticeService.pageList(sysNotice, pageNo, pageSize, req);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.jero.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/7/14 14:31
|
||||
* @remarks: 公告管理表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SysNotice implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
/**创建人*/
|
||||
private String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/**更新人*/
|
||||
private String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("公告名称")
|
||||
private String noticeName;
|
||||
@ApiModelProperty("公告内容")
|
||||
private String noticeContent;
|
||||
@ApiModelProperty("附件")
|
||||
private String noticeFile;
|
||||
@ApiModelProperty("状态(1-启用,0-禁用)")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer noticeStatus;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.jero.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.jero.modules.system.entity.SysNotice;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/7/14 14:49
|
||||
* @remarks: 公告管理
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysNoticeMapper extends BaseMapper<SysNotice> {
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.jero.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.modules.system.entity.SysNotice;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/7/14 15:25
|
||||
* @remarks: 公告管理
|
||||
*/
|
||||
public interface ISysNoticeService extends IService<SysNotice> {
|
||||
void add(SysNotice sysNotice);
|
||||
|
||||
void deleteById(String id);
|
||||
|
||||
void deleteBatch(String ids);
|
||||
|
||||
void edit(SysNotice sysNotice);
|
||||
|
||||
IPage<SysNotice> pageList(SysNotice sysNotice, Integer pageNo, Integer pageSize, HttpServletRequest req);
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.jero.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.modules.system.entity.SysNotice;
|
||||
import com.jero.modules.system.mapper.SysNoticeMapper;
|
||||
import com.jero.modules.system.service.ISysNoticeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/7/14 15:41
|
||||
* @remarks: 公告管理
|
||||
*/
|
||||
@Service
|
||||
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
|
||||
@Override
|
||||
public void add(SysNotice sysNotice) {
|
||||
save(sysNotice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBatch(String ids) {
|
||||
removeByIds(Arrays.asList(ids.split(",")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(SysNotice sysNotice) {
|
||||
updateById(sysNotice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysNotice> pageList(SysNotice sysNotice, Integer pageNo, Integer pageSize, HttpServletRequest req) {
|
||||
Page<SysNotice> page = new Page<>(pageNo, pageSize);
|
||||
QueryWrapper<SysNotice> queryWrapper = QueryGenerator.initQueryWrapper(sysNotice, req.getParameterMap());
|
||||
return page(page, queryWrapper);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user