From 45d82fa0880fa92e3099e31885fafcc73d9b43a4 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Thu, 1 Sep 2022 11:39:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=A8=E5=B1=80=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=A1=A8=E7=9A=84=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GlobalConfigurationController.java | 3 ++- .../entity/GlobalConfigurationEntity.java | 14 ++++++++++++ .../impl/GlobalConfigurationServiceImpl.java | 22 ++++++++++++------- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/xkrs/controller/GlobalConfigurationController.java b/src/main/java/com/xkrs/controller/GlobalConfigurationController.java index 4e4b927..ebce1f6 100644 --- a/src/main/java/com/xkrs/controller/GlobalConfigurationController.java +++ b/src/main/java/com/xkrs/controller/GlobalConfigurationController.java @@ -41,9 +41,10 @@ public class GlobalConfigurationController { * 查询全局配置 */ @GetMapping("/query") - public String queryGlobalConfiguration(@RequestParam(required = false, value = "id") Long id, @RequestParam(required = false, value = "key") String key, @RequestParam(required = false, value = "value") String value, @RequestParam(required = false, value = "remark") String remark) { + public String queryGlobalConfiguration(@RequestParam(required = false, value = "id") Long id, @RequestParam(required = false, value = "group") String group, @RequestParam(required = false, value = "key") String key, @RequestParam(required = false, value = "value") String value, @RequestParam(required = false, value = "remark") String remark) { GlobalConfigurationEntity globalConfiguration = new GlobalConfigurationEntity(); globalConfiguration.setId(id); + globalConfiguration.setBelongGroup(group); globalConfiguration.setKey(key); globalConfiguration.setValue(value); globalConfiguration.setRemark(remark); diff --git a/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java b/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java index 59485d1..2edc2e6 100644 --- a/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java +++ b/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java @@ -18,6 +18,11 @@ public class GlobalConfigurationEntity implements Serializable { @SequenceGenerator(name = "global_configuration_seq_gen", sequenceName = "global_configuration_id_seq", allocationSize = 1) private Long id; + /** + * 全局配置项所属的组 + */ + private String belongGroup; + /** * 全局配置项的键 */ @@ -44,6 +49,14 @@ public class GlobalConfigurationEntity implements Serializable { this.id = id; } + public String getBelongGroup() { + return belongGroup; + } + + public void setBelongGroup(String belongGroup) { + this.belongGroup = belongGroup; + } + public String getKey() { return key; } @@ -72,6 +85,7 @@ public class GlobalConfigurationEntity implements Serializable { public String toString() { return "GlobalConfigurationEntity{" + "id=" + id + + ", belongGroup='" + belongGroup + '\'' + ", key='" + key + '\'' + ", value='" + value + '\'' + ", remark='" + remark + '\'' + diff --git a/src/main/java/com/xkrs/service/impl/GlobalConfigurationServiceImpl.java b/src/main/java/com/xkrs/service/impl/GlobalConfigurationServiceImpl.java index 2694448..497122c 100644 --- a/src/main/java/com/xkrs/service/impl/GlobalConfigurationServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/GlobalConfigurationServiceImpl.java @@ -33,20 +33,21 @@ public class GlobalConfigurationServiceImpl implements GlobalConfigurationServic */ @Override public String insertGlobalConfiguration(GlobalConfigurationEntity globalConfiguration) { + final String belongGroup = LocalNullUtils.formatNullValue(globalConfiguration.getBelongGroup()); final String key = LocalNullUtils.formatNullValue(globalConfiguration.getKey()); final String value = LocalNullUtils.formatNullValue(globalConfiguration.getValue()); final String remark = LocalNullUtils.formatNullValue(globalConfiguration.getRemark()); + if (TextUtils.isEmpty(belongGroup)) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "belongGroup不可为空", locale); + } if (TextUtils.isEmpty(key)) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "key不可为空", locale); } if (TextUtils.isEmpty(value)) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "value不可为空", locale); } - List duplicatedEntityList = globalConfigurationDao.findByKey(key); - if (duplicatedEntityList != null && duplicatedEntityList.size() > 0) { - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "key已存在", locale); - } GlobalConfigurationEntity globalConfigurationEntity = new GlobalConfigurationEntity(); + globalConfigurationEntity.setBelongGroup(belongGroup); globalConfigurationEntity.setKey(key); globalConfigurationEntity.setValue(value); globalConfigurationEntity.setRemark(remark); @@ -84,20 +85,21 @@ public class GlobalConfigurationServiceImpl implements GlobalConfigurationServic if (targetEntityOptional.isEmpty()) { return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "id不存在", locale); } + final String belongGroup = LocalNullUtils.formatNullValue(globalConfiguration.getBelongGroup()); final String key = LocalNullUtils.formatNullValue(globalConfiguration.getKey()); final String value = LocalNullUtils.formatNullValue(globalConfiguration.getValue()); final String remark = LocalNullUtils.formatNullValue(globalConfiguration.getRemark()); + if (TextUtils.isEmpty(belongGroup)) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "belongGroup不可为空", locale); + } if (TextUtils.isEmpty(key)) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "key不可为空", locale); } if (TextUtils.isEmpty(value)) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "value不可为空", locale); } - List duplicatedEntityList = globalConfigurationDao.findByKey(key); - if (duplicatedEntityList != null && duplicatedEntityList.size() > 0) { - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "key已存在", locale); - } GlobalConfigurationEntity targetEntity = targetEntityOptional.get(); + targetEntity.setBelongGroup(belongGroup); targetEntity.setKey(key); targetEntity.setValue(value); if (!TextUtils.isEmpty(remark)) { @@ -113,6 +115,7 @@ public class GlobalConfigurationServiceImpl implements GlobalConfigurationServic @Override public String queryGlobalConfiguration(GlobalConfigurationEntity globalConfiguration) { final Long id = globalConfiguration.getId(); + final String belongGroup = globalConfiguration.getBelongGroup(); final String key = globalConfiguration.getKey(); final String value = globalConfiguration.getValue(); final String remark = globalConfiguration.getRemark(); @@ -121,6 +124,9 @@ public class GlobalConfigurationServiceImpl implements GlobalConfigurationServic if (null != id) { predicateList.add(criteriaBuilder.equal(root.get("id").as(Long.class), id)); } + if (!TextUtils.isEmpty(belongGroup)) { + predicateList.add(criteriaBuilder.like(root.get("belongGroup").as(String.class), "%" + belongGroup + "%")); + } if (!TextUtils.isEmpty(key)) { predicateList.add(criteriaBuilder.like(root.get("key").as(String.class), "%" + key + "%")); }