From 4edd8fa1017ea5b32099723e215fe8d4df7b4435 Mon Sep 17 00:00:00 2001 From: dataprince Date: Fri, 15 Sep 2023 11:47:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8mybatis-flex=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E2=80=9C=E9=80=9A=E7=9F=A5=E5=85=AC=E5=91=8A=E2=80=9D?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysConfigController.java | 43 +++--- .../system/SysNoticeController.java | 44 +++--- .../com/ruoyi/system/domain/SysNotice.java | 100 ++---------- .../ruoyi/system/domain/vo/SysNoticeVo.java | 1 - .../ruoyi/system/mapper/SysNoticeMapper.java | 56 +------ .../system/service/ISysConfigService.java | 20 ++- .../system/service/ISysNoticeService.java | 59 ++++---- .../service/impl/SysConfigServiceImpl.java | 6 +- .../service/impl/SysNoticeServiceImpl.java | 142 ++++++++++++------ .../mapper/system/SysNoticeMapper.xml | 76 +--------- 10 files changed, 213 insertions(+), 334 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysConfigController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysConfigController.java index a917b74..1b3c878 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysConfigController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysConfigController.java @@ -34,8 +34,7 @@ import com.ruoyi.system.service.ISysConfigService; @RequiredArgsConstructor @RestController @RequestMapping("/system/config") -public class SysConfigController extends BaseController -{ +public class SysConfigController extends BaseController { @Resource private ISysConfigService configService; @@ -44,8 +43,7 @@ public class SysConfigController extends BaseController */ @SaCheckPermission("system:config:list") @GetMapping("/list") - public TableDataInfo list(SysConfigBo config) - { + public TableDataInfo list(SysConfigBo config) { return configService.selectConfigPage(config); } @@ -55,8 +53,7 @@ public class SysConfigController extends BaseController @Log(title = "参数管理", businessType = BusinessType.EXPORT) @SaCheckPermission("system:config:export") @PostMapping("/export") - public void export(HttpServletResponse response, SysConfigBo config) - { + public void export(HttpServletResponse response, SysConfigBo config) { List list = configService.selectConfigList(config); ExcelUtil.exportExcel(list, "参数数据", SysConfigVo.class, response); } @@ -66,8 +63,7 @@ public class SysConfigController extends BaseController */ @SaCheckPermission("system:config:query") @GetMapping(value = "/{configId}") - public R getInfo(@PathVariable Long configId) - { + public R getInfo(@PathVariable Long configId) { return R.ok(configService.selectConfigById(configId)); } @@ -76,8 +72,7 @@ public class SysConfigController extends BaseController */ @SaCheckPermission("system:config:query") @GetMapping(value = "/configKey/{configKey}") - public R getConfigKey(@PathVariable String configKey) - { + public R getConfigKey(@PathVariable String configKey) { return R.ok(configService.selectConfigByKey(configKey)); } @@ -87,13 +82,14 @@ public class SysConfigController extends BaseController @SaCheckPermission("system:config:add") @Log(title = "参数管理", businessType = BusinessType.INSERT) @PostMapping - public R add(@Validated @RequestBody SysConfigBo config) - { - if (!configService.checkConfigKeyUnique(config)) - { + public R add(@Validated @RequestBody SysConfigBo config) { + if (!configService.checkConfigKeyUnique(config)) { return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); } - configService.insertConfig(config); + int insertedRows = configService.insertConfig(config); + if (insertedRows != 1) { + return R.fail("新增参数记录失败!"); + } return R.ok(); } @@ -103,13 +99,14 @@ public class SysConfigController extends BaseController @SaCheckPermission("system:config:edit") @Log(title = "参数管理", businessType = BusinessType.UPDATE) @PutMapping - public R edit(@Validated @RequestBody SysConfigBo config) - { - if (!configService.checkConfigKeyUnique(config)) - { + public R edit(@Validated @RequestBody SysConfigBo config) { + if (!configService.checkConfigKeyUnique(config)) { return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); } - configService.updateConfig(config); + boolean updated = configService.updateConfig(config); + if (!updated) { + R.fail("修改参数'" + config.getConfigName() + "'失败!"); + } return R.ok(); } @@ -119,8 +116,7 @@ public class SysConfigController extends BaseController @SaCheckPermission("system:config:remove") @Log(title = "参数管理", businessType = BusinessType.DELETE) @DeleteMapping("/{configIds}") - public R remove(@PathVariable Long[] configIds) - { + public R remove(@PathVariable Long[] configIds) { configService.deleteConfigByIds(configIds); return R.ok(); } @@ -131,8 +127,7 @@ public class SysConfigController extends BaseController @SaCheckPermission("system:config:remove") @Log(title = "参数管理", businessType = BusinessType.CLEAN) @DeleteMapping("/refreshCache") - public R refreshCache() - { + public R refreshCache() { configService.resetConfigCache(); return R.ok(); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysNoticeController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysNoticeController.java index 1d9d842..bc2ff90 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysNoticeController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysNoticeController.java @@ -1,12 +1,12 @@ package com.ruoyi.system.controller.system; -import java.util.List; - 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.enums.BusinessType; 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 lombok.RequiredArgsConstructor; 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.RestController; 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; /** @@ -42,11 +40,9 @@ public class SysNoticeController extends BaseController */ @SaCheckPermission("system:notice:list") @GetMapping("/list") - public TableDataInfo list(SysNotice notice) + public TableDataInfo list(SysNoticeBo noticeBo) { - startPage(); - List list = noticeService.selectNoticeList(notice); - return getDataTable(list); + return noticeService.selectConfigPage(noticeBo); } /** @@ -54,9 +50,9 @@ public class SysNoticeController extends BaseController */ @SaCheckPermission("system:notice:query") @GetMapping(value = "/{noticeId}") - public AjaxResult getInfo(@PathVariable Long noticeId) + public R 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") @Log(title = "通知公告", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@Validated @RequestBody SysNotice notice) + public R add(@Validated @RequestBody SysNoticeBo noticeBo) { - notice.setCreateBy(LoginHelper.getUserId()); - return toAjax(noticeService.insertNotice(notice)); + int insertedRows = noticeService.insertNotice(noticeBo); + if (insertedRows != 1) { + return R.fail("新增通知公告记录失败!"); + } + return R.ok(); } /** @@ -77,10 +76,13 @@ public class SysNoticeController extends BaseController @SaCheckPermission("system:notice:edit") @Log(title = "通知公告", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@Validated @RequestBody SysNotice notice) + public R edit(@Validated @RequestBody SysNoticeBo noticeBo) { - notice.setUpdateBy(LoginHelper.getUserId()); - return toAjax(noticeService.updateNotice(notice)); + Boolean updated = noticeService.updateNotice(noticeBo); + if (!updated) { + R.fail("修改通知公告记录失败!"); + } + return R.ok(); } /** @@ -89,8 +91,12 @@ public class SysNoticeController extends BaseController @SaCheckPermission("system:notice:remove") @Log(title = "通知公告", businessType = BusinessType.DELETE) @DeleteMapping("/{noticeIds}") - public AjaxResult remove(@PathVariable Long[] noticeIds) + public R remove(@PathVariable Long[] noticeIds) { - return toAjax(noticeService.deleteNoticeByIds(noticeIds)); + boolean deleted = noticeService.deleteNoticeByIds(noticeIds); + if (!deleted) { + R.fail("删除通知公告记录失败!"); + } + return R.ok(); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java index 7b79ef2..1a177cf 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java @@ -1,25 +1,24 @@ package com.ruoyi.system.domain; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Size; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; +import com.mybatisflex.annotation.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; import com.ruoyi.common.orm.core.domain.BaseEntity; -import com.ruoyi.common.core.xss.Xss; - -import java.io.Serial; /** * 通知公告表 sys_notice * * @author ruoyi */ +@Data +@EqualsAndHashCode(callSuper = true) +@Table(value = "sys_notice") public class SysNotice extends BaseEntity { - @Serial - private static final long serialVersionUID = 1L; - /** 公告ID */ + @Id(keyType = KeyType.Auto) private Long noticeId; /** 公告标题 */ @@ -34,85 +33,6 @@ public class SysNotice extends BaseEntity /** 公告状态(0正常 1关闭) */ private String status; - /** - * 备注 - */ + /** 备注 */ 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(); - } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/SysNoticeVo.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/SysNoticeVo.java index 57a20d0..5f33ef2 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/SysNoticeVo.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/SysNoticeVo.java @@ -18,7 +18,6 @@ import java.util.Date; * @author Michelle.Chung */ @Data -@AutoMapper(target = SysNotice.class) public class SysNoticeVo implements Serializable { @Serial diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java index c34f0a2..ad54279 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java @@ -1,60 +1,16 @@ package com.ruoyi.system.mapper; -import java.util.List; +import com.mybatisflex.core.BaseMapper; import com.ruoyi.system.domain.SysNotice; +import org.apache.ibatis.annotations.Mapper; /** * 通知公告表 数据层 - * - * @author ruoyi + * + * @author 数据小王子 */ -public interface SysNoticeMapper +@Mapper +public interface SysNoticeMapper extends BaseMapper { - /** - * 查询公告信息 - * - * @param noticeId 公告ID - * @return 公告信息 - */ - public SysNotice selectNoticeById(Long noticeId); - /** - * 查询公告列表 - * - * @param notice 公告信息 - * @return 公告集合 - */ - public List 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); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java index 9979e6a..a096e3f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java @@ -42,12 +42,18 @@ public interface ISysConfigService extends IService /** * 查询参数配置列表 * - * @param config 参数配置信息 + * @param configBo 参数配置信息 * @return 参数配置集合 */ - List selectConfigList(SysConfigBo config); + List selectConfigList(SysConfigBo configBo); - TableDataInfo selectConfigPage(SysConfigBo config); + /** + * 分页查询参数配置列表 + * + * @param configBo 参数配置信息 + * @return 参数配置集合 + */ + TableDataInfo selectConfigPage(SysConfigBo configBo); /** * 新增参数配置 @@ -60,10 +66,10 @@ public interface ISysConfigService extends IService /** * 修改参数配置 * - * @param config 参数配置信息 + * @param configBo 参数配置信息 * @return 结果 */ - boolean updateConfig(SysConfigBo config); + boolean updateConfig(SysConfigBo configBo); /** * 批量删除参数信息 @@ -80,8 +86,8 @@ public interface ISysConfigService extends IService /** * 校验参数键名是否唯一 * - * @param config 参数信息 + * @param configBo 参数信息 * @return 结果 */ - boolean checkConfigKeyUnique(SysConfigBo config); + boolean checkConfigKeyUnique(SysConfigBo configBo); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java index 47ce1b7..a1b6660 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java @@ -1,60 +1,65 @@ package com.ruoyi.system.service; 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.bo.SysNoticeBo; +import com.ruoyi.system.domain.vo.SysNoticeVo; /** * 公告 服务层 - * - * @author ruoyi + * + * @author 数据小王子 */ -public interface ISysNoticeService +public interface ISysNoticeService extends IService { /** * 查询公告信息 - * + * * @param noticeId 公告ID * @return 公告信息 */ - public SysNotice selectNoticeById(Long noticeId); + SysNoticeVo selectNoticeById(Long noticeId); /** * 查询公告列表 - * - * @param notice 公告信息 + * + * @param noticeBo 公告信息 * @return 公告集合 */ - public List selectNoticeList(SysNotice notice); + List selectNoticeList(SysNoticeBo noticeBo); + + /** + * 分页查询公告列表 + * + * @param noticeBo 公告信息 + * @return 公告集合 + */ + TableDataInfo selectConfigPage(SysNoticeBo noticeBo); /** * 新增公告 - * - * @param notice 公告信息 - * @return 结果 + * + * @param noticeBo 公告信息 + * @return 结果:受影响的行数 */ - public int insertNotice(SysNotice notice); + int insertNotice(SysNoticeBo noticeBo); /** * 修改公告 - * - * @param notice 公告信息 - * @return 结果 + * + * @param noticeBo 公告信息 + * @return 结果:true 更新成功,false 更新失败 */ - public int updateNotice(SysNotice notice); + Boolean updateNotice(SysNoticeBo noticeBo); - /** - * 删除公告信息 - * - * @param noticeId 公告ID - * @return 结果 - */ - public int deleteNoticeById(Long noticeId); - /** * 批量删除公告信息 - * + * * @param noticeIds 需要删除的公告ID - * @return 结果 + * @return 结果:true 删除成功,false 删除失败 */ - public int deleteNoticeByIds(Long[] noticeIds); + boolean deleteNoticeByIds(Long[] noticeIds); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index 0e50bc4..e446e19 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -28,6 +28,7 @@ import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.system.domain.SysConfig; import com.ruoyi.system.mapper.SysConfigMapper; import com.ruoyi.system.service.ISysConfigService; +import org.springframework.transaction.annotation.Transactional; import static com.ruoyi.system.domain.table.SysConfigTableDef.SYS_CONFIG; @@ -156,7 +157,7 @@ public class SysConfigServiceImpl extends ServiceImpl implements ISysNoticeService { + @Resource private SysNoticeMapper noticeMapper; + @Override + public QueryWrapper query() { + return super.query().from(SYS_NOTICE); + } + /** * 查询公告信息 - * + * * @param noticeId 公告ID * @return 公告信息 */ @Override - public SysNotice selectNoticeById(Long noticeId) - { - return noticeMapper.selectNoticeById(noticeId); + public SysNoticeVo selectNoticeById(Long noticeId) { + return this.getOneAs(query().where(SYS_NOTICE.NOTICE_ID.eq(noticeId)), SysNoticeVo.class); + } + + /** + * 根据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 公告集合 */ @Override - public List selectNoticeList(SysNotice notice) - { - return noticeMapper.selectNoticeList(notice); + public List selectNoticeList(SysNoticeBo noticeBo) { + QueryWrapper queryWrapper = buildQueryWrapper(noticeBo); + return this.listAs(queryWrapper, SysNoticeVo.class); } /** - * 新增公告 - * - * @param notice 公告信息 - * @return 结果 + * 分页查询公告列表 + * + * @param noticeBo 公告信息 + * @return 公告集合 */ @Override - public int insertNotice(SysNotice notice) - { - return noticeMapper.insertNotice(notice); + public TableDataInfo selectConfigPage(SysNoticeBo noticeBo) { + QueryWrapper queryWrapper = buildQueryWrapper(noticeBo); + + PageDomain pageDomain = TableSupport.buildPageRequest(); + + Page 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 公告信息 - * @return 结果 + * + * @param noticeBo 公告信息 + * @return true 更新成功,false 更新失败 */ @Override - public int updateNotice(SysNotice notice) - { - return noticeMapper.updateNotice(notice); - } - - /** - * 删除公告对象 - * - * @param noticeId 公告ID - * @return 结果 - */ - @Override - public int deleteNoticeById(Long noticeId) - { - return noticeMapper.deleteNoticeById(noticeId); + public Boolean updateNotice(SysNoticeBo noticeBo) { + SysNotice sysNotice = MapstructUtils.convert(noticeBo, SysNotice.class); + return this.updateById(sysNotice); } /** * 批量删除公告信息 - * + * * @param noticeIds 需要删除的公告ID - * @return 结果 + * @return true 删除成功,false 删除失败 */ @Override - public int deleteNoticeByIds(Long[] noticeIds) - { - return noticeMapper.deleteNoticeByIds(noticeIds); + @Transactional + public boolean deleteNoticeByIds(Long[] noticeIds) { + return this.removeByIds(Arrays.asList(noticeIds)); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml index 65d3079..47d22c7 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -16,74 +16,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - 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 - - - - - - - insert into sys_notice ( - notice_title, - notice_type, - notice_content, - status, - remark, - create_by, - create_time - )values( - #{noticeTitle}, - #{noticeType}, - #{noticeContent}, - #{status}, - #{remark}, - #{createBy}, - sysdate() - ) - - - - update sys_notice - - notice_title = #{noticeTitle}, - notice_type = #{noticeType}, - notice_content = #{noticeContent}, - status = #{status}, - update_by = #{updateBy}, - update_time = sysdate() - - where notice_id = #{noticeId} - - - - delete from sys_notice where notice_id = #{noticeId} - - - - delete from sys_notice where notice_id in - - #{noticeId} - - - - \ No newline at end of file + + + +