使用mybatis-flex重构“通知公告”模块代码
This commit is contained in:
parent
a2ec2b31e0
commit
4edd8fa101
@ -34,8 +34,7 @@ import com.ruoyi.system.service.ISysConfigService;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/config")
|
@RequestMapping("/system/config")
|
||||||
public class SysConfigController extends BaseController
|
public class SysConfigController extends BaseController {
|
||||||
{
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
|
|
||||||
@ -44,8 +43,7 @@ public class SysConfigController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:config:list")
|
@SaCheckPermission("system:config:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysConfigBo config)
|
public TableDataInfo<SysConfigVo> list(SysConfigBo config) {
|
||||||
{
|
|
||||||
return configService.selectConfigPage(config);
|
return configService.selectConfigPage(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +53,7 @@ public class SysConfigController extends BaseController
|
|||||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:config:export")
|
@SaCheckPermission("system:config:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysConfigBo config)
|
public void export(HttpServletResponse response, SysConfigBo config) {
|
||||||
{
|
|
||||||
List<SysConfigVo> list = configService.selectConfigList(config);
|
List<SysConfigVo> list = configService.selectConfigList(config);
|
||||||
ExcelUtil.exportExcel(list, "参数数据", SysConfigVo.class, response);
|
ExcelUtil.exportExcel(list, "参数数据", SysConfigVo.class, response);
|
||||||
}
|
}
|
||||||
@ -66,8 +63,7 @@ public class SysConfigController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:config:query")
|
@SaCheckPermission("system:config:query")
|
||||||
@GetMapping(value = "/{configId}")
|
@GetMapping(value = "/{configId}")
|
||||||
public R<SysConfigVo> getInfo(@PathVariable Long configId)
|
public R<SysConfigVo> getInfo(@PathVariable Long configId) {
|
||||||
{
|
|
||||||
return R.ok(configService.selectConfigById(configId));
|
return R.ok(configService.selectConfigById(configId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +72,7 @@ public class SysConfigController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:config:query")
|
@SaCheckPermission("system:config:query")
|
||||||
@GetMapping(value = "/configKey/{configKey}")
|
@GetMapping(value = "/configKey/{configKey}")
|
||||||
public R<Void> getConfigKey(@PathVariable String configKey)
|
public R<Void> getConfigKey(@PathVariable String configKey) {
|
||||||
{
|
|
||||||
return R.ok(configService.selectConfigByKey(configKey));
|
return R.ok(configService.selectConfigByKey(configKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,13 +82,14 @@ public class SysConfigController extends BaseController
|
|||||||
@SaCheckPermission("system:config:add")
|
@SaCheckPermission("system:config:add")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysConfigBo config)
|
public R<Void> add(@Validated @RequestBody SysConfigBo config) {
|
||||||
{
|
if (!configService.checkConfigKeyUnique(config)) {
|
||||||
if (!configService.checkConfigKeyUnique(config))
|
|
||||||
{
|
|
||||||
return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
configService.insertConfig(config);
|
int insertedRows = configService.insertConfig(config);
|
||||||
|
if (insertedRows != 1) {
|
||||||
|
return R.fail("新增参数记录失败!");
|
||||||
|
}
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,13 +99,14 @@ public class SysConfigController extends BaseController
|
|||||||
@SaCheckPermission("system:config:edit")
|
@SaCheckPermission("system:config:edit")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysConfigBo config)
|
public R<Void> edit(@Validated @RequestBody SysConfigBo config) {
|
||||||
{
|
if (!configService.checkConfigKeyUnique(config)) {
|
||||||
if (!configService.checkConfigKeyUnique(config))
|
|
||||||
{
|
|
||||||
return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
configService.updateConfig(config);
|
boolean updated = configService.updateConfig(config);
|
||||||
|
if (!updated) {
|
||||||
|
R.fail("修改参数'" + config.getConfigName() + "'失败!");
|
||||||
|
}
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +116,7 @@ public class SysConfigController extends BaseController
|
|||||||
@SaCheckPermission("system:config:remove")
|
@SaCheckPermission("system:config:remove")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{configIds}")
|
@DeleteMapping("/{configIds}")
|
||||||
public R<Void> remove(@PathVariable Long[] configIds)
|
public R<Void> remove(@PathVariable Long[] configIds) {
|
||||||
{
|
|
||||||
configService.deleteConfigByIds(configIds);
|
configService.deleteConfigByIds(configIds);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
@ -131,8 +127,7 @@ public class SysConfigController extends BaseController
|
|||||||
@SaCheckPermission("system:config:remove")
|
@SaCheckPermission("system:config:remove")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/refreshCache")
|
@DeleteMapping("/refreshCache")
|
||||||
public R<Void> refreshCache()
|
public R<Void> refreshCache() {
|
||||||
{
|
|
||||||
configService.resetConfigCache();
|
configService.resetConfigCache();
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.ruoyi.system.controller.system;
|
package com.ruoyi.system.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import com.ruoyi.common.core.core.domain.R;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.security.utils.LoginHelper;
|
import com.ruoyi.system.domain.bo.SysNoticeBo;
|
||||||
|
import com.ruoyi.system.domain.vo.SysNoticeVo;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -19,8 +19,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.web.core.BaseController;
|
import com.ruoyi.common.web.core.BaseController;
|
||||||
import com.ruoyi.common.core.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
|
||||||
import com.ruoyi.system.service.ISysNoticeService;
|
import com.ruoyi.system.service.ISysNoticeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,11 +40,9 @@ public class SysNoticeController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:notice:list")
|
@SaCheckPermission("system:notice:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysNotice notice)
|
public TableDataInfo<SysNoticeVo> list(SysNoticeBo noticeBo)
|
||||||
{
|
{
|
||||||
startPage();
|
return noticeService.selectConfigPage(noticeBo);
|
||||||
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,9 +50,9 @@ public class SysNoticeController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:notice:query")
|
@SaCheckPermission("system:notice:query")
|
||||||
@GetMapping(value = "/{noticeId}")
|
@GetMapping(value = "/{noticeId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long noticeId)
|
public R<SysNoticeVo> getInfo(@PathVariable Long noticeId)
|
||||||
{
|
{
|
||||||
return success(noticeService.selectNoticeById(noticeId));
|
return R.ok(noticeService.selectNoticeById(noticeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,10 +61,13 @@ public class SysNoticeController extends BaseController
|
|||||||
@SaCheckPermission("system:notice:add")
|
@SaCheckPermission("system:notice:add")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysNotice notice)
|
public R<Void> add(@Validated @RequestBody SysNoticeBo noticeBo)
|
||||||
{
|
{
|
||||||
notice.setCreateBy(LoginHelper.getUserId());
|
int insertedRows = noticeService.insertNotice(noticeBo);
|
||||||
return toAjax(noticeService.insertNotice(notice));
|
if (insertedRows != 1) {
|
||||||
|
return R.fail("新增通知公告记录失败!");
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,10 +76,13 @@ public class SysNoticeController extends BaseController
|
|||||||
@SaCheckPermission("system:notice:edit")
|
@SaCheckPermission("system:notice:edit")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
|
public R<Void> edit(@Validated @RequestBody SysNoticeBo noticeBo)
|
||||||
{
|
{
|
||||||
notice.setUpdateBy(LoginHelper.getUserId());
|
Boolean updated = noticeService.updateNotice(noticeBo);
|
||||||
return toAjax(noticeService.updateNotice(notice));
|
if (!updated) {
|
||||||
|
R.fail("修改通知公告记录失败!");
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,8 +91,12 @@ public class SysNoticeController extends BaseController
|
|||||||
@SaCheckPermission("system:notice:remove")
|
@SaCheckPermission("system:notice:remove")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{noticeIds}")
|
@DeleteMapping("/{noticeIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] noticeIds)
|
public R<Void> remove(@PathVariable Long[] noticeIds)
|
||||||
{
|
{
|
||||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
boolean deleted = noticeService.deleteNoticeByIds(noticeIds);
|
||||||
|
if (!deleted) {
|
||||||
|
R.fail("删除通知公告记录失败!");
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,24 @@
|
|||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import com.mybatisflex.annotation.Id;
|
||||||
import jakarta.validation.constraints.Size;
|
import com.mybatisflex.annotation.KeyType;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import com.mybatisflex.annotation.Table;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||||
import com.ruoyi.common.core.xss.Xss;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知公告表 sys_notice
|
* 通知公告表 sys_notice
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Table(value = "sys_notice")
|
||||||
public class SysNotice extends BaseEntity
|
public class SysNotice extends BaseEntity
|
||||||
{
|
{
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 公告ID */
|
/** 公告ID */
|
||||||
|
@Id(keyType = KeyType.Auto)
|
||||||
private Long noticeId;
|
private Long noticeId;
|
||||||
|
|
||||||
/** 公告标题 */
|
/** 公告标题 */
|
||||||
@ -34,85 +33,6 @@ public class SysNotice extends BaseEntity
|
|||||||
/** 公告状态(0正常 1关闭) */
|
/** 公告状态(0正常 1关闭) */
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/** 备注 */
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
public Long getNoticeId()
|
|
||||||
{
|
|
||||||
return noticeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoticeId(Long noticeId)
|
|
||||||
{
|
|
||||||
this.noticeId = noticeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoticeTitle(String noticeTitle)
|
|
||||||
{
|
|
||||||
this.noticeTitle = noticeTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Xss(message = "公告标题不能包含脚本字符")
|
|
||||||
@NotBlank(message = "公告标题不能为空")
|
|
||||||
@Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
|
|
||||||
public String getNoticeTitle()
|
|
||||||
{
|
|
||||||
return noticeTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoticeType(String noticeType)
|
|
||||||
{
|
|
||||||
this.noticeType = noticeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNoticeType()
|
|
||||||
{
|
|
||||||
return noticeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoticeContent(String noticeContent)
|
|
||||||
{
|
|
||||||
this.noticeContent = noticeContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNoticeContent()
|
|
||||||
{
|
|
||||||
return noticeContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(String status)
|
|
||||||
{
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus()
|
|
||||||
{
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRemark() {
|
|
||||||
return remark;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemark(String remark) {
|
|
||||||
this.remark = remark;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("noticeId", getNoticeId())
|
|
||||||
.append("noticeTitle", getNoticeTitle())
|
|
||||||
.append("noticeType", getNoticeType())
|
|
||||||
.append("noticeContent", getNoticeContent())
|
|
||||||
.append("status", getStatus())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.append("remark", getRemark())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import java.util.Date;
|
|||||||
* @author Michelle.Chung
|
* @author Michelle.Chung
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@AutoMapper(target = SysNotice.class)
|
|
||||||
public class SysNoticeVo implements Serializable {
|
public class SysNoticeVo implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
|
@ -1,60 +1,16 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知公告表 数据层
|
* 通知公告表 数据层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
public interface SysNoticeMapper
|
@Mapper
|
||||||
|
public interface SysNoticeMapper extends BaseMapper<SysNotice>
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 查询公告信息
|
|
||||||
*
|
|
||||||
* @param noticeId 公告ID
|
|
||||||
* @return 公告信息
|
|
||||||
*/
|
|
||||||
public SysNotice selectNoticeById(Long noticeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询公告列表
|
|
||||||
*
|
|
||||||
* @param notice 公告信息
|
|
||||||
* @return 公告集合
|
|
||||||
*/
|
|
||||||
public List<SysNotice> selectNoticeList(SysNotice notice);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增公告
|
|
||||||
*
|
|
||||||
* @param notice 公告信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertNotice(SysNotice notice);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改公告
|
|
||||||
*
|
|
||||||
* @param notice 公告信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateNotice(SysNotice notice);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除公告
|
|
||||||
*
|
|
||||||
* @param noticeId 公告ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteNoticeById(Long noticeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除公告信息
|
|
||||||
*
|
|
||||||
* @param noticeIds 需要删除的公告ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteNoticeByIds(Long[] noticeIds);
|
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,18 @@ public interface ISysConfigService extends IService<SysConfig>
|
|||||||
/**
|
/**
|
||||||
* 查询参数配置列表
|
* 查询参数配置列表
|
||||||
*
|
*
|
||||||
* @param config 参数配置信息
|
* @param configBo 参数配置信息
|
||||||
* @return 参数配置集合
|
* @return 参数配置集合
|
||||||
*/
|
*/
|
||||||
List<SysConfigVo> selectConfigList(SysConfigBo config);
|
List<SysConfigVo> selectConfigList(SysConfigBo configBo);
|
||||||
|
|
||||||
TableDataInfo<SysConfigVo> selectConfigPage(SysConfigBo config);
|
/**
|
||||||
|
* 分页查询参数配置列表
|
||||||
|
*
|
||||||
|
* @param configBo 参数配置信息
|
||||||
|
* @return 参数配置集合
|
||||||
|
*/
|
||||||
|
TableDataInfo<SysConfigVo> selectConfigPage(SysConfigBo configBo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增参数配置
|
* 新增参数配置
|
||||||
@ -60,10 +66,10 @@ public interface ISysConfigService extends IService<SysConfig>
|
|||||||
/**
|
/**
|
||||||
* 修改参数配置
|
* 修改参数配置
|
||||||
*
|
*
|
||||||
* @param config 参数配置信息
|
* @param configBo 参数配置信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
boolean updateConfig(SysConfigBo config);
|
boolean updateConfig(SysConfigBo configBo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除参数信息
|
* 批量删除参数信息
|
||||||
@ -80,8 +86,8 @@ public interface ISysConfigService extends IService<SysConfig>
|
|||||||
/**
|
/**
|
||||||
* 校验参数键名是否唯一
|
* 校验参数键名是否唯一
|
||||||
*
|
*
|
||||||
* @param config 参数信息
|
* @param configBo 参数信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
boolean checkConfigKeyUnique(SysConfigBo config);
|
boolean checkConfigKeyUnique(SysConfigBo configBo);
|
||||||
}
|
}
|
||||||
|
@ -1,60 +1,65 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.service.IService;
|
||||||
|
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
|
import com.ruoyi.system.domain.bo.SysNoticeBo;
|
||||||
|
import com.ruoyi.system.domain.vo.SysNoticeVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告 服务层
|
* 公告 服务层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
public interface ISysNoticeService
|
public interface ISysNoticeService extends IService<SysNotice>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 查询公告信息
|
* 查询公告信息
|
||||||
*
|
*
|
||||||
* @param noticeId 公告ID
|
* @param noticeId 公告ID
|
||||||
* @return 公告信息
|
* @return 公告信息
|
||||||
*/
|
*/
|
||||||
public SysNotice selectNoticeById(Long noticeId);
|
SysNoticeVo selectNoticeById(Long noticeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询公告列表
|
* 查询公告列表
|
||||||
*
|
*
|
||||||
* @param notice 公告信息
|
* @param noticeBo 公告信息
|
||||||
* @return 公告集合
|
* @return 公告集合
|
||||||
*/
|
*/
|
||||||
public List<SysNotice> selectNoticeList(SysNotice notice);
|
List<SysNoticeVo> selectNoticeList(SysNoticeBo noticeBo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询公告列表
|
||||||
|
*
|
||||||
|
* @param noticeBo 公告信息
|
||||||
|
* @return 公告集合
|
||||||
|
*/
|
||||||
|
TableDataInfo<SysNoticeVo> selectConfigPage(SysNoticeBo noticeBo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增公告
|
* 新增公告
|
||||||
*
|
*
|
||||||
* @param notice 公告信息
|
* @param noticeBo 公告信息
|
||||||
* @return 结果
|
* @return 结果:受影响的行数
|
||||||
*/
|
*/
|
||||||
public int insertNotice(SysNotice notice);
|
int insertNotice(SysNoticeBo noticeBo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改公告
|
* 修改公告
|
||||||
*
|
*
|
||||||
* @param notice 公告信息
|
* @param noticeBo 公告信息
|
||||||
* @return 结果
|
* @return 结果:true 更新成功,false 更新失败
|
||||||
*/
|
*/
|
||||||
public int updateNotice(SysNotice notice);
|
Boolean updateNotice(SysNoticeBo noticeBo);
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除公告信息
|
|
||||||
*
|
|
||||||
* @param noticeId 公告ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteNoticeById(Long noticeId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除公告信息
|
* 批量删除公告信息
|
||||||
*
|
*
|
||||||
* @param noticeIds 需要删除的公告ID
|
* @param noticeIds 需要删除的公告ID
|
||||||
* @return 结果
|
* @return 结果:true 删除成功,false 删除失败
|
||||||
*/
|
*/
|
||||||
public int deleteNoticeByIds(Long[] noticeIds);
|
boolean deleteNoticeByIds(Long[] noticeIds);
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import com.ruoyi.common.core.utils.StringUtils;
|
|||||||
import com.ruoyi.system.domain.SysConfig;
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
import com.ruoyi.system.mapper.SysConfigMapper;
|
import com.ruoyi.system.mapper.SysConfigMapper;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import static com.ruoyi.system.domain.table.SysConfigTableDef.SYS_CONFIG;
|
import static com.ruoyi.system.domain.table.SysConfigTableDef.SYS_CONFIG;
|
||||||
|
|
||||||
@ -156,7 +157,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|||||||
* 新增参数配置
|
* 新增参数配置
|
||||||
*
|
*
|
||||||
* @param configBo 参数配置信息
|
* @param configBo 参数配置信息
|
||||||
* @return 结果
|
* @return 插入行数
|
||||||
*/
|
*/
|
||||||
@CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#configBo.configKey")
|
@CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#configBo.configKey")
|
||||||
@Override
|
@Override
|
||||||
@ -174,7 +175,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|||||||
* 修改参数配置
|
* 修改参数配置
|
||||||
*
|
*
|
||||||
* @param configBo 参数配置信息
|
* @param configBo 参数配置信息
|
||||||
* @return 结果
|
* @return true 更新成功,false 更新失败。
|
||||||
*/
|
*/
|
||||||
@CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#configBo.configKey")
|
@CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#configBo.configKey")
|
||||||
@Override
|
@Override
|
||||||
@ -194,6 +195,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|||||||
* @param configIds 需要删除的参数ID
|
* @param configIds 需要删除的参数ID
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public void deleteConfigByIds(Long[] configIds) {
|
public void deleteConfigByIds(Long[] configIds) {
|
||||||
for (Long configId : configIds) {
|
for (Long configId : configIds) {
|
||||||
SysConfigVo config = selectConfigById(configId);
|
SysConfigVo config = selectConfigById(configId);
|
||||||
|
@ -1,92 +1,144 @@
|
|||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.common.core.core.page.PageDomain;
|
||||||
|
import com.ruoyi.common.core.core.page.TableSupport;
|
||||||
|
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||||
|
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.system.domain.bo.SysNoticeBo;
|
||||||
|
import com.ruoyi.system.domain.vo.SysNoticeVo;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
import com.ruoyi.system.mapper.SysNoticeMapper;
|
import com.ruoyi.system.mapper.SysNoticeMapper;
|
||||||
import com.ruoyi.system.service.ISysNoticeService;
|
import com.ruoyi.system.service.ISysNoticeService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import static com.ruoyi.system.domain.table.SysNoticeTableDef.SYS_NOTICE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告 服务层实现
|
* 公告 服务层实现
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SysNoticeServiceImpl implements ISysNoticeService
|
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
|
||||||
{
|
@Resource
|
||||||
@Autowired
|
|
||||||
private SysNoticeMapper noticeMapper;
|
private SysNoticeMapper noticeMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryWrapper query() {
|
||||||
|
return super.query().from(SYS_NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询公告信息
|
* 查询公告信息
|
||||||
*
|
*
|
||||||
* @param noticeId 公告ID
|
* @param noticeId 公告ID
|
||||||
* @return 公告信息
|
* @return 公告信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysNotice selectNoticeById(Long noticeId)
|
public SysNoticeVo selectNoticeById(Long noticeId) {
|
||||||
{
|
return this.getOneAs(query().where(SYS_NOTICE.NOTICE_ID.eq(noticeId)), SysNoticeVo.class);
|
||||||
return noticeMapper.selectNoticeById(noticeId);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据noticeBo构建QueryWrapper查询条件
|
||||||
|
*
|
||||||
|
* @param noticeBo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private QueryWrapper buildQueryWrapper(SysNoticeBo noticeBo) {
|
||||||
|
QueryWrapper queryWrapper = query();
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(noticeBo.getNoticeTitle())) {
|
||||||
|
queryWrapper.and(SYS_NOTICE.NOTICE_TITLE.like(noticeBo.getNoticeTitle()));
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(noticeBo.getNoticeType())) {
|
||||||
|
queryWrapper.and(SYS_NOTICE.NOTICE_TYPE.eq(noticeBo.getNoticeType()));
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(noticeBo.getCreateBy())) {
|
||||||
|
queryWrapper.and(SYS_NOTICE.CREATE_BY.like(noticeBo.getCreateBy()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
|
||||||
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
|
queryWrapper.orderBy(orderBy);
|
||||||
|
}
|
||||||
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询公告列表
|
* 查询公告列表
|
||||||
*
|
*
|
||||||
* @param notice 公告信息
|
* @param noticeBo 公告信息
|
||||||
* @return 公告集合
|
* @return 公告集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysNotice> selectNoticeList(SysNotice notice)
|
public List<SysNoticeVo> selectNoticeList(SysNoticeBo noticeBo) {
|
||||||
{
|
QueryWrapper queryWrapper = buildQueryWrapper(noticeBo);
|
||||||
return noticeMapper.selectNoticeList(notice);
|
return this.listAs(queryWrapper, SysNoticeVo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增公告
|
* 分页查询公告列表
|
||||||
*
|
*
|
||||||
* @param notice 公告信息
|
* @param noticeBo 公告信息
|
||||||
* @return 结果
|
* @return 公告集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertNotice(SysNotice notice)
|
public TableDataInfo<SysNoticeVo> selectConfigPage(SysNoticeBo noticeBo) {
|
||||||
{
|
QueryWrapper queryWrapper = buildQueryWrapper(noticeBo);
|
||||||
return noticeMapper.insertNotice(notice);
|
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
|
|
||||||
|
Page<SysNoticeVo> page = this.getMapper().paginateAs(pageDomain.getPageNum(), pageDomain.getPageSize(), queryWrapper, SysNoticeVo.class);
|
||||||
|
return TableDataInfo.build(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增公告
|
||||||
|
*
|
||||||
|
* @param noticeBo 公告信息
|
||||||
|
* @return 受影响的行数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertNotice(SysNoticeBo noticeBo) {
|
||||||
|
SysNotice sysNotice = MapstructUtils.convert(noticeBo, SysNotice.class);
|
||||||
|
int ret = noticeMapper.insert(sysNotice, false);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改公告
|
* 修改公告
|
||||||
*
|
*
|
||||||
* @param notice 公告信息
|
* @param noticeBo 公告信息
|
||||||
* @return 结果
|
* @return true 更新成功,false 更新失败
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateNotice(SysNotice notice)
|
public Boolean updateNotice(SysNoticeBo noticeBo) {
|
||||||
{
|
SysNotice sysNotice = MapstructUtils.convert(noticeBo, SysNotice.class);
|
||||||
return noticeMapper.updateNotice(notice);
|
return this.updateById(sysNotice);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除公告对象
|
|
||||||
*
|
|
||||||
* @param noticeId 公告ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deleteNoticeById(Long noticeId)
|
|
||||||
{
|
|
||||||
return noticeMapper.deleteNoticeById(noticeId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除公告信息
|
* 批量删除公告信息
|
||||||
*
|
*
|
||||||
* @param noticeIds 需要删除的公告ID
|
* @param noticeIds 需要删除的公告ID
|
||||||
* @return 结果
|
* @return true 删除成功,false 删除失败
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteNoticeByIds(Long[] noticeIds)
|
@Transactional
|
||||||
{
|
public boolean deleteNoticeByIds(Long[] noticeIds) {
|
||||||
return noticeMapper.deleteNoticeByIds(noticeIds);
|
return this.removeByIds(Arrays.asList(noticeIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.ruoyi.system.mapper.SysNoticeMapper">
|
<mapper namespace="com.ruoyi.system.mapper.SysNoticeMapper">
|
||||||
|
|
||||||
<resultMap type="SysNotice" id="SysNoticeResult">
|
<resultMap type="SysNotice" id="SysNoticeResult">
|
||||||
<result property="noticeId" column="notice_id" />
|
<result property="noticeId" column="notice_id" />
|
||||||
<result property="noticeTitle" column="notice_title" />
|
<result property="noticeTitle" column="notice_title" />
|
||||||
@ -16,74 +16,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectNoticeVo">
|
<sql id="selectNoticeVo">
|
||||||
select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark
|
select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark
|
||||||
from sys_notice
|
from sys_notice
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeResult">
|
|
||||||
<include refid="selectNoticeVo"/>
|
|
||||||
where notice_id = #{noticeId}
|
</mapper>
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult">
|
|
||||||
<include refid="selectNoticeVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="noticeTitle != null and noticeTitle != ''">
|
|
||||||
AND notice_title like concat('%', #{noticeTitle}, '%')
|
|
||||||
</if>
|
|
||||||
<if test="noticeType != null and noticeType != ''">
|
|
||||||
AND notice_type = #{noticeType}
|
|
||||||
</if>
|
|
||||||
<if test="createBy != null and createBy != ''">
|
|
||||||
AND create_by like concat('%', #{createBy}, '%')
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertNotice" parameterType="SysNotice">
|
|
||||||
insert into sys_notice (
|
|
||||||
<if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
|
|
||||||
<if test="noticeType != null and noticeType != '' ">notice_type, </if>
|
|
||||||
<if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
|
|
||||||
<if test="status != null and status != '' ">status, </if>
|
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
||||||
create_time
|
|
||||||
)values(
|
|
||||||
<if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
|
|
||||||
<if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
|
|
||||||
<if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
|
|
||||||
<if test="status != null and status != ''">#{status}, </if>
|
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
||||||
sysdate()
|
|
||||||
)
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateNotice" parameterType="SysNotice">
|
|
||||||
update sys_notice
|
|
||||||
<set>
|
|
||||||
<if test="noticeTitle != null and noticeTitle != ''">notice_title = #{noticeTitle}, </if>
|
|
||||||
<if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if>
|
|
||||||
<if test="noticeContent != null">notice_content = #{noticeContent}, </if>
|
|
||||||
<if test="status != null and status != ''">status = #{status}, </if>
|
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
||||||
update_time = sysdate()
|
|
||||||
</set>
|
|
||||||
where notice_id = #{noticeId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteNoticeById" parameterType="Long">
|
|
||||||
delete from sys_notice where notice_id = #{noticeId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteNoticeByIds" parameterType="Long">
|
|
||||||
delete from sys_notice where notice_id in
|
|
||||||
<foreach item="noticeId" collection="array" open="(" separator="," close=")">
|
|
||||||
#{noticeId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user