From a17df59f4509ca9d56208bb7ffb7399a94d991f7 Mon Sep 17 00:00:00 2001 From: dataprince Date: Sun, 1 Oct 2023 11:26:54 +0800 Subject: [PATCH] =?UTF-8?q?5=E4=B8=AA=E6=A8=A1=E5=9D=97=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E4=BB=A3=E7=A0=81:=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E8=87=AA=E5=A2=9E=E4=B8=BB=E9=94=AE=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E9=9B=AA=E8=8A=B1=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/system/SysConfigController.java | 4 ++-- .../controller/system/SysDeptController.java | 4 ++-- .../controller/system/SysDictDataController.java | 4 ++-- .../controller/system/SysNoticeController.java | 4 ++-- .../controller/system/SysPostController.java | 4 ++-- .../java/com/ruoyi/system/domain/SysConfig.java | 8 +------- .../java/com/ruoyi/system/domain/SysDept.java | 2 +- .../com/ruoyi/system/domain/SysDictData.java | 3 +-- .../com/ruoyi/system/domain/SysDictType.java | 3 +-- .../java/com/ruoyi/system/domain/SysNotice.java | 3 +-- .../java/com/ruoyi/system/domain/SysPost.java | 12 +----------- .../ruoyi/system/service/ISysConfigService.java | 4 ++-- .../ruoyi/system/service/ISysDeptService.java | 4 ++-- .../system/service/ISysDictDataService.java | 4 ++-- .../ruoyi/system/service/ISysNoticeService.java | 4 ++-- .../ruoyi/system/service/ISysPostService.java | 4 ++-- .../service/impl/SysConfigServiceImpl.java | 16 +++------------- .../system/service/impl/SysDeptServiceImpl.java | 6 +++--- .../service/impl/SysDictDataServiceImpl.java | 6 +++--- .../service/impl/SysDictTypeServiceImpl.java | 7 ++----- .../service/impl/SysNoticeServiceImpl.java | 7 +++---- .../system/service/impl/SysPostServiceImpl.java | 6 +++--- 22 files changed, 43 insertions(+), 76 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 1b3c878..f961bb6 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 @@ -86,8 +86,8 @@ public class SysConfigController extends BaseController { if (!configService.checkConfigKeyUnique(config)) { return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); } - int insertedRows = configService.insertConfig(config); - if (insertedRows != 1) { + boolean inserted = configService.insertConfig(config); + if (!inserted) { return R.fail("新增参数记录失败!"); } return R.ok(); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysDeptController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysDeptController.java index 4ba3506..ef63cb1 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysDeptController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysDeptController.java @@ -85,8 +85,8 @@ public class SysDeptController extends BaseController { if (!deptService.checkDeptNameUnique(dept)) { return R.fail("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } - int inserted = deptService.insertDept(dept); - if (inserted != 1) { + boolean inserted = deptService.insertDept(dept); + if (!inserted) { return R.fail("新增部门记录失败!"); } return R.ok(); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysDictDataController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysDictDataController.java index bdaa876..182c5fe 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysDictDataController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysDictDataController.java @@ -91,8 +91,8 @@ public class SysDictDataController extends BaseController { @Log(title = "字典数据", businessType = BusinessType.INSERT) @PostMapping public R add(@Validated @RequestBody SysDictDataBo dictDataBo) { - int insertedRows = dictDataService.insertDictData(dictDataBo); - if (insertedRows == 0) { + boolean inserted = dictDataService.insertDictData(dictDataBo); + if (!inserted) { return R.fail("新增字典数据记录失败!"); } 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 5f61f62..c7997d4 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 @@ -63,8 +63,8 @@ public class SysNoticeController extends BaseController @PostMapping public R add(@Validated @RequestBody SysNoticeBo noticeBo) { - int insertedRows = noticeService.insertNotice(noticeBo); - if (insertedRows != 1) { + boolean inserted = noticeService.insertNotice(noticeBo); + if (!inserted) { return R.fail("新增通知公告记录失败!"); } return R.ok(); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysPostController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysPostController.java index a3ee24b..186886d 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysPostController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysPostController.java @@ -85,8 +85,8 @@ public class SysPostController extends BaseController { return R.fail("新增岗位'" + postBo.getPostName() + "'失败,岗位编码已存在"); } - int insertedRows = postService.insertPost(postBo); - if (insertedRows != 1) { + boolean inserted = postService.insertPost(postBo); + if (!inserted) { return R.fail("新增岗位记录失败!"); } return R.ok(); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java index afac517..275acc4 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java @@ -1,9 +1,7 @@ package com.ruoyi.system.domain; import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; -import com.mybatisflex.core.keygen.KeyGenerators; import lombok.Data; import lombok.EqualsAndHashCode; import com.ruoyi.common.orm.core.domain.BaseEntity; @@ -21,11 +19,7 @@ public class SysConfig extends BaseEntity { /** 参数主键 */ -// @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId) //TODO:ID主键修改为雪花算法 -// @Id(keyType = KeyType.Generator, value = KeyGenerators.flexId) - //@Id - //@Excel(name = "参数主键", cellType = ColumnType.NUMERIC) - @Id(keyType = KeyType.Auto) + @Id private Long configId; /** 参数名称 */ diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDept.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDept.java index b06ea4b..5bdb8ab 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDept.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDept.java @@ -29,7 +29,7 @@ public class SysDept extends BaseEntity { /** 部门ID */ - @Id(keyType = KeyType.Auto) + @Id private Long deptId; /** 父部门ID */ diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictData.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictData.java index d9265ca..971e6e6 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictData.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictData.java @@ -1,7 +1,6 @@ package com.ruoyi.system.domain; import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; import lombok.Data; import lombok.EqualsAndHashCode; @@ -19,7 +18,7 @@ import com.ruoyi.common.orm.core.domain.BaseEntity; public class SysDictData extends BaseEntity { /** 字典编码 */ - @Id(keyType = KeyType.Auto) + @Id private Long dictCode; /** 字典排序 */ diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictType.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictType.java index 0a3f141..03ef060 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictType.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictType.java @@ -1,7 +1,6 @@ package com.ruoyi.system.domain; import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; import lombok.Data; import lombok.EqualsAndHashCode; @@ -18,7 +17,7 @@ import com.ruoyi.common.orm.core.domain.BaseEntity; public class SysDictType extends BaseEntity { /** 字典主键 */ - @Id(keyType = KeyType.Auto) + @Id private Long dictId; /** 字典名称 */ 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 1a177cf..3bf8057 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,7 +1,6 @@ package com.ruoyi.system.domain; import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; import lombok.Data; import lombok.EqualsAndHashCode; @@ -18,7 +17,7 @@ import com.ruoyi.common.orm.core.domain.BaseEntity; public class SysNotice extends BaseEntity { /** 公告ID */ - @Id(keyType = KeyType.Auto) + @Id private Long noticeId; /** 公告标题 */ diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java index e2225dd..9d3749f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java @@ -2,21 +2,11 @@ package com.ruoyi.system.domain; import com.mybatisflex.annotation.Column; import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; import lombok.Data; import lombok.EqualsAndHashCode; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.core.annotation.Excel; -import com.ruoyi.common.core.annotation.Excel.ColumnType; import com.ruoyi.common.orm.core.domain.BaseEntity; -import java.io.Serial; - /** * 岗位表 sys_post * @@ -28,7 +18,7 @@ import java.io.Serial; public class SysPost extends BaseEntity { /** 岗位序号 */ - @Id(keyType = KeyType.Auto) + @Id private Long postId; /** 岗位编码 */ 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 851e292..4f03b64 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 @@ -59,9 +59,9 @@ public interface ISysConfigService extends IBaseService * 新增参数配置 * * @param config 参数配置信息 - * @return 结果 + * @return true 操作成功,false 操作失败 */ - int insertConfig(SysConfigBo config); + boolean insertConfig(SysConfigBo config); /** * 修改参数配置 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index 127ef48..de33de4 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -90,9 +90,9 @@ public interface ISysDeptService extends IBaseService * 新增保存部门信息 * * @param deptBo 部门信息 - * @return 受影响的行数 + * @return true 操作成功,false 操作失败 */ - int insertDept(SysDeptBo deptBo); + boolean insertDept(SysDeptBo deptBo); /** * 修改保存部门信息 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java index f34a769..ef98805 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java @@ -77,9 +77,9 @@ public interface ISysDictDataService extends IBaseService * 新增保存字典数据信息 * * @param dataBo 字典数据信息 - * @return 结果:受影响的行数 + * @return true 操作成功,false 操作失败 */ - int insertDictData(SysDictDataBo dataBo); + boolean insertDictData(SysDictDataBo dataBo); /** * 修改保存字典数据信息 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 8219d37..1569e87 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 @@ -43,9 +43,9 @@ public interface ISysNoticeService extends IBaseService * 新增公告 * * @param noticeBo 公告信息 - * @return 结果:受影响的行数 + * @return true 操作成功,false 操作失败 */ - int insertNotice(SysNoticeBo noticeBo); + boolean insertNotice(SysNoticeBo noticeBo); /** * 修改公告 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java index 81b22e1..3629768 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java @@ -98,9 +98,9 @@ public interface ISysPostService extends IBaseService * 新增保存岗位信息 * * @param post 岗位信息 - * @return 结果 + * @return true 操作成功,false 操作失败 */ - int insertPost(SysPostBo post); + boolean insertPost(SysPostBo post); /** * 修改保存岗位信息 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 7f90659..dcb82c2 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 @@ -5,8 +5,6 @@ import java.util.List; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; import com.ruoyi.common.core.constant.CacheNames; -import com.ruoyi.common.core.core.page.PageDomain; -import com.ruoyi.common.core.core.page.TableSupport; import com.ruoyi.common.core.service.ConfigService; import com.ruoyi.common.core.utils.MapstructUtils; import com.ruoyi.common.core.utils.SpringUtils; @@ -40,8 +38,6 @@ import static com.ruoyi.system.domain.table.SysConfigTableDef.SYS_CONFIG; @RequiredArgsConstructor @Service public class SysConfigServiceImpl extends BaseServiceImpl implements ISysConfigService, ConfigService { - @Resource - private SysConfigMapper configMapper; @Override public QueryWrapper query() { @@ -148,19 +144,13 @@ public class SysConfigServiceImpl extends BaseServiceImpl * 新增保存部门信息 * * @param deptBo 部门信息 - * @return 受影响的行数 + * @return true 操作成功,false 操作失败 */ @Override - public int insertDept(SysDeptBo deptBo) { + public boolean insertDept(SysDeptBo deptBo) { SysDeptVo info = selectDeptById(deptBo.getParentId()); // 如果父节点不为正常状态,则不允许新增子节点 if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { @@ -256,7 +256,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl SysDept dept = MapstructUtils.convert(deptBo, SysDept.class); dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); dept.setDelFlag("0");//0代表存在 - return deptMapper.insert(dept, false); + return this.save(dept); } /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java index defeabf..a3a3bb2 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java @@ -172,14 +172,14 @@ public class SysDictDataServiceImpl extends BaseServiceImpl implements ISysDictTypeService, DictService { - @Resource - private SysDictTypeMapper dictTypeMapper; - @Resource private ISysDictDataService sysDictDataService; @@ -204,8 +201,8 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl insertDictType(SysDictTypeBo sysDictTypeBo) { SysDictType dict = MapstructUtils.convert(sysDictTypeBo, SysDictType.class); - int row = dictTypeMapper.insert(dict,false); - if (row > 0) + boolean saved = this.save(dict); + if (saved) { // 新增 type 下无 data 数据 返回空防止缓存穿透 return new ArrayList<>(); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java index 0d74c65..03681df 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java @@ -108,13 +108,12 @@ public class SysNoticeServiceImpl extends BaseServiceImpl * 新增保存岗位信息 * * @param postBo 岗位信息 - * @return 结果 + * @return true 操作成功,false 操作失败 */ @Override - public int insertPost(SysPostBo postBo) + public boolean insertPost(SysPostBo postBo) { SysPost sysPost = MapstructUtils.convert(postBo, SysPost.class); - return postMapper.insert(sysPost,false); + return this.save(sysPost); } /**