From cf72330320ef843672e10181405b159e5747f694 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Wed, 1 Mar 2023 17:48:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ConfigGlobalController.java | 53 ------- .../GlobalConfigurationController.java | 53 ------- .../com/xkrs/dao/GlobalConfigurationDao.java | 15 -- .../entity/GlobalConfigurationEntity.java | 88 ----------- .../com/xkrs/service/GlobalConfigService.java | 19 --- .../service/GlobalConfigurationService.java | 27 ---- .../service/impl/FirePointServiceImpl.java | 4 - .../impl/GlobalConfigurationServiceImpl.java | 145 ------------------ 8 files changed, 404 deletions(-) delete mode 100644 src/main/java/com/xkrs/controller/ConfigGlobalController.java delete mode 100644 src/main/java/com/xkrs/controller/GlobalConfigurationController.java delete mode 100644 src/main/java/com/xkrs/dao/GlobalConfigurationDao.java delete mode 100644 src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java delete mode 100644 src/main/java/com/xkrs/service/GlobalConfigService.java delete mode 100644 src/main/java/com/xkrs/service/GlobalConfigurationService.java delete mode 100644 src/main/java/com/xkrs/service/impl/GlobalConfigurationServiceImpl.java diff --git a/src/main/java/com/xkrs/controller/ConfigGlobalController.java b/src/main/java/com/xkrs/controller/ConfigGlobalController.java deleted file mode 100644 index eb847fc..0000000 --- a/src/main/java/com/xkrs/controller/ConfigGlobalController.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.xkrs.controller; - -import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.model.qo.GlobalConfigDictQo; -import com.xkrs.service.GlobalConfigService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.lang.Nullable; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; -import java.util.Map; - -import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * 全局配置服务 - */ -@RestController -public class ConfigGlobalController { - - private final Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private GlobalConfigService globalConfigService; - - @GetMapping("/selectGlobalConfigDict") - public String selectGlobalConfigDict() { - return globalConfigService.selectGlobalConfigDict(); - } - - @GetMapping("/selectGlobalConfigValue") - public String selectGlobalConfigValue(@RequestParam(value = "code") Long code) { - Long value = globalConfigService.selectGlobalConfigValue(code); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, value, locale); - } - - @GetMapping("/selectGlobalConfig") - public String selectGlobalConfig(@RequestParam(required = false, value = "code") Long code) { - return globalConfigService.selectGlobalConfig(code); - } - - @PostMapping("/globalConfig") - public String globalConfig(@Nullable @RequestBody Map configMap) { - return globalConfigService.globalConfig(configMap); - } - - @PostMapping("/globalConfigDict") - public String globalConfigDict(@RequestBody GlobalConfigDictQo globalConfigDictQo) { - return globalConfigService.globalConfigDict(globalConfigDictQo); - } - -} diff --git a/src/main/java/com/xkrs/controller/GlobalConfigurationController.java b/src/main/java/com/xkrs/controller/GlobalConfigurationController.java deleted file mode 100644 index ebce1f6..0000000 --- a/src/main/java/com/xkrs/controller/GlobalConfigurationController.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.xkrs.controller; - -import com.xkrs.model.entity.GlobalConfigurationEntity; -import com.xkrs.service.GlobalConfigurationService; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -@RestController -@RequestMapping(value = "/global/configuration") -public class GlobalConfigurationController { - - @Resource - private GlobalConfigurationService globalConfigurationService; - - /** - * 新增全局配置 - */ - @PostMapping("/insert") - public String insertGlobalConfiguration(@RequestBody GlobalConfigurationEntity globalConfiguration) { - return globalConfigurationService.insertGlobalConfiguration(globalConfiguration); - } - - /** - * 删除全局配置 - */ - @PostMapping("/delete") - public String deleteGlobalConfiguration(@RequestBody GlobalConfigurationEntity globalConfiguration) { - return globalConfigurationService.deleteGlobalConfiguration(globalConfiguration); - } - - /** - * 修改全局配置 - */ - @PostMapping("/update") - public String updateGlobalConfiguration(@RequestBody GlobalConfigurationEntity globalConfiguration) { - return globalConfigurationService.updateGlobalConfiguration(globalConfiguration); - } - - /** - * 查询全局配置 - */ - @GetMapping("/query") - 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); - return globalConfigurationService.queryGlobalConfiguration(globalConfiguration); - } -} diff --git a/src/main/java/com/xkrs/dao/GlobalConfigurationDao.java b/src/main/java/com/xkrs/dao/GlobalConfigurationDao.java deleted file mode 100644 index 440661e..0000000 --- a/src/main/java/com/xkrs/dao/GlobalConfigurationDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.GlobalConfigurationEntity; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.stereotype.Component; - -import java.util.List; - -@Component -public interface GlobalConfigurationDao extends JpaRepository, JpaSpecificationExecutor { - - List findByKey(String key); - -} diff --git a/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java b/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java deleted file mode 100644 index e998c6e..0000000 --- a/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.xkrs.model.entity; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * 全局配置表 - */ -@Entity -@Table(name = "global_configuration") -public class GlobalConfigurationEntity implements Serializable { - - /** - * 主键id - */ - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "global_configuration_seq_gen") - @SequenceGenerator(name = "global_configuration_seq_gen", sequenceName = "global_configuration_id_seq", allocationSize = 1) - private Long id; - - /** - * 全局配置项所属的组 - */ - private String belongGroup; - - /** - * 全局配置项的键 - */ - private String key; - - /** - * 全局配置项的值 - */ - private String value; - - /** - * 备注信息 - */ - private String remark; - - public GlobalConfigurationEntity() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getBelongGroup() { - return belongGroup; - } - - public void setBelongGroup(String belongGroup) { - this.belongGroup = belongGroup; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getRemark() { - return remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - @Override - public String toString() { - return "GlobalConfigurationEntity{" + "id=" + id + ", belongGroup='" + belongGroup + '\'' + ", key='" + key + '\'' + ", value='" + value + '\'' + ", remark='" + remark + '\'' + '}'; - } -} diff --git a/src/main/java/com/xkrs/service/GlobalConfigService.java b/src/main/java/com/xkrs/service/GlobalConfigService.java deleted file mode 100644 index 0de13f1..0000000 --- a/src/main/java/com/xkrs/service/GlobalConfigService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.xkrs.service; - -import com.xkrs.model.qo.GlobalConfigDictQo; - -import java.util.Map; - -public interface GlobalConfigService { - - String selectGlobalConfigDict(); - - Long selectGlobalConfigValue(Long code); - - String selectGlobalConfig(Long code); - - String globalConfig(Map globalConfigMap); - - String globalConfigDict(GlobalConfigDictQo globalConfigDictQo); - -} diff --git a/src/main/java/com/xkrs/service/GlobalConfigurationService.java b/src/main/java/com/xkrs/service/GlobalConfigurationService.java deleted file mode 100644 index 2aaaddf..0000000 --- a/src/main/java/com/xkrs/service/GlobalConfigurationService.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.xkrs.service; - -import com.xkrs.model.entity.GlobalConfigurationEntity; - -public interface GlobalConfigurationService { - - /** - * 新增全局配置 - */ - String insertGlobalConfiguration(GlobalConfigurationEntity globalConfiguration); - - /** - * 删除全局配置 - */ - String deleteGlobalConfiguration(GlobalConfigurationEntity globalConfiguration); - - /** - * 修改全局配置 - */ - String updateGlobalConfiguration(GlobalConfigurationEntity globalConfiguration); - - /** - * 查询全局配置 - */ - String queryGlobalConfiguration(GlobalConfigurationEntity globalConfiguration); - -} diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 9b324e8..f88ee65 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -10,7 +10,6 @@ import com.xkrs.model.entity.FirePointEntity; import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.vo.GaoDeIgGeocodeVo; import com.xkrs.service.FirePointService; -import com.xkrs.service.GlobalConfigService; import com.xkrs.service.StreetService; import com.xkrs.straw.dao.SysUserDao; import com.xkrs.straw.model.entity.SysUserEntity; @@ -66,9 +65,6 @@ public class FirePointServiceImpl implements FirePointService { @Resource private FirePointQueryHelper firePointQueryHelper; - @Resource - private GlobalConfigService globalConfigService; - @Resource private StreetService streetService; diff --git a/src/main/java/com/xkrs/service/impl/GlobalConfigurationServiceImpl.java b/src/main/java/com/xkrs/service/impl/GlobalConfigurationServiceImpl.java deleted file mode 100644 index 497122c..0000000 --- a/src/main/java/com/xkrs/service/impl/GlobalConfigurationServiceImpl.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.xkrs.service.impl; - -import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.dao.GlobalConfigurationDao; -import com.xkrs.model.entity.GlobalConfigurationEntity; -import com.xkrs.service.GlobalConfigurationService; -import com.xkrs.utils.LocalNullUtils; -import org.apache.hc.core5.util.TextUtils; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.data.domain.Sort; -import org.springframework.data.jpa.domain.Specification; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import javax.persistence.criteria.Predicate; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -@Service -public class GlobalConfigurationServiceImpl implements GlobalConfigurationService { - - private final Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private GlobalConfigurationDao globalConfigurationDao; - - /** - * 新增全局配置 - */ - @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); - } - GlobalConfigurationEntity globalConfigurationEntity = new GlobalConfigurationEntity(); - globalConfigurationEntity.setBelongGroup(belongGroup); - globalConfigurationEntity.setKey(key); - globalConfigurationEntity.setValue(value); - globalConfigurationEntity.setRemark(remark); - globalConfigurationDao.save(globalConfigurationEntity); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "新增成功", locale); - } - - /** - * 删除全局配置 - */ - @Override - public String deleteGlobalConfiguration(GlobalConfigurationEntity globalConfiguration) { - Long id = globalConfiguration.getId(); - if (null == id) { - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "id不可为空", locale); - } - Optional targetEntityOptional = globalConfigurationDao.findById(id); - if (targetEntityOptional.isEmpty()) { - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "id不存在", locale); - } - globalConfigurationDao.deleteById(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "删除成功", locale); - } - - /** - * 修改全局配置 - */ - @Override - public String updateGlobalConfiguration(GlobalConfigurationEntity globalConfiguration) { - Long id = globalConfiguration.getId(); - if (null == id) { - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "id不可为空", locale); - } - Optional targetEntityOptional = globalConfigurationDao.findById(id); - 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); - } - GlobalConfigurationEntity targetEntity = targetEntityOptional.get(); - targetEntity.setBelongGroup(belongGroup); - targetEntity.setKey(key); - targetEntity.setValue(value); - if (!TextUtils.isEmpty(remark)) { - targetEntity.setRemark(remark); - } - globalConfigurationDao.save(targetEntity); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); - } - - /** - * 查询全局配置 - */ - @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(); - Specification specification = (root, criteriaQuery, criteriaBuilder) -> { - List predicateList = new ArrayList<>(); - 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 + "%")); - } - if (!TextUtils.isEmpty(value)) { - predicateList.add(criteriaBuilder.like(root.get("value").as(String.class), "%" + value + "%")); - } - if (!TextUtils.isEmpty(remark)) { - predicateList.add(criteriaBuilder.like(root.get("remark").as(String.class), "%" + remark + "%")); - } - Predicate[] predicateArray = new Predicate[predicateList.size()]; - return criteriaBuilder.and(predicateList.toArray(predicateArray)); - }; - List globalConfigurationEntityList = globalConfigurationDao.findAll(specification, Sort.by(Sort.Direction.ASC, "id")); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, globalConfigurationEntityList, locale); - } -}