diff --git a/src/main/java/com/xkrs/dao/GlobalConfigDao.java b/src/main/java/com/xkrs/dao/GlobalConfigDao.java deleted file mode 100644 index 2ed4665..0000000 --- a/src/main/java/com/xkrs/dao/GlobalConfigDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.GlobalConfigEntity; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.stereotype.Component; - -import java.util.Optional; - -@Component -public interface GlobalConfigDao extends JpaRepository, JpaSpecificationExecutor { - - Optional findByCode(Long code); - -} diff --git a/src/main/java/com/xkrs/dao/GlobalConfigDictDao.java b/src/main/java/com/xkrs/dao/GlobalConfigDictDao.java deleted file mode 100644 index 77572fa..0000000 --- a/src/main/java/com/xkrs/dao/GlobalConfigDictDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.GlobalConfigDictEntity; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.stereotype.Component; - -import java.util.Optional; - -@Component -public interface GlobalConfigDictDao extends JpaRepository, JpaSpecificationExecutor { - - Optional findByCode(Long code); - -} diff --git a/src/main/java/com/xkrs/model/entity/GlobalConfigDictEntity.java b/src/main/java/com/xkrs/model/entity/GlobalConfigDictEntity.java deleted file mode 100644 index 6366160..0000000 --- a/src/main/java/com/xkrs/model/entity/GlobalConfigDictEntity.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.xkrs.model.entity; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * 全局配置字典表 - */ -@Entity -@Table(name = "global_config_dict") -public class GlobalConfigDictEntity implements Serializable { - - /** - * 主键id - */ - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "global_config_dict_seq_gen") - @SequenceGenerator(name = "global_config_dict_seq_gen", sequenceName = "global_config_dict_id_seq", allocationSize = 1) - private Long id; - - /** - * 全局配置字典的编码 - */ - private Long code; - - /** - * 全局配置字典的名称 - */ - private String name; - - /** - * 全局配置字典的备注 - */ - private String remark; - - public GlobalConfigDictEntity() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getCode() { - return code; - } - - public void setCode(Long code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getRemark() { - return remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } -} diff --git a/src/main/java/com/xkrs/model/entity/GlobalConfigEntity.java b/src/main/java/com/xkrs/model/entity/GlobalConfigEntity.java deleted file mode 100644 index 02727d7..0000000 --- a/src/main/java/com/xkrs/model/entity/GlobalConfigEntity.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.xkrs.model.entity; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * 全局配置表 - */ -@Entity -@Table(name = "global_config") -public class GlobalConfigEntity implements Serializable { - - /** - * 主键id - */ - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "global_config_seq_gen") - @SequenceGenerator(name = "global_config_seq_gen", sequenceName = "global_config_id_seq", allocationSize = 1) - private Long id; - - /** - * 全局配置项的编号 - */ - private Long code; - - /** - * 全局配置项的值 - */ - private Long value; - - public GlobalConfigEntity() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getCode() { - return code; - } - - public void setCode(Long code) { - this.code = code; - } - - public Long getValue() { - return value; - } - - public void setValue(Long value) { - this.value = value; - } -} diff --git a/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java b/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java index 2edc2e6..e998c6e 100644 --- a/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java +++ b/src/main/java/com/xkrs/model/entity/GlobalConfigurationEntity.java @@ -83,12 +83,6 @@ public class GlobalConfigurationEntity implements Serializable { @Override public String toString() { - return "GlobalConfigurationEntity{" + - "id=" + id + - ", belongGroup='" + belongGroup + '\'' + - ", key='" + key + '\'' + - ", value='" + value + '\'' + - ", remark='" + remark + '\'' + - '}'; + return "GlobalConfigurationEntity{" + "id=" + id + ", belongGroup='" + belongGroup + '\'' + ", key='" + key + '\'' + ", value='" + value + '\'' + ", remark='" + remark + '\'' + '}'; } } diff --git a/src/main/java/com/xkrs/service/impl/GlobalConfigServiceImpl.java b/src/main/java/com/xkrs/service/impl/GlobalConfigServiceImpl.java deleted file mode 100644 index 6a811d0..0000000 --- a/src/main/java/com/xkrs/service/impl/GlobalConfigServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.xkrs.service.impl; - -import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.dao.GlobalConfigDao; -import com.xkrs.dao.GlobalConfigDictDao; -import com.xkrs.model.entity.GlobalConfigDictEntity; -import com.xkrs.model.entity.GlobalConfigEntity; -import com.xkrs.model.qo.GlobalConfigDictQo; -import com.xkrs.service.GlobalConfigService; -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.*; - -import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -@Service -public class GlobalConfigServiceImpl implements GlobalConfigService { - - private final Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private GlobalConfigDao globalConfigDao; - - @Resource - private GlobalConfigDictDao globalConfigDictDao; - - @Override - public String selectGlobalConfigDict() { - List globalConfigDictList = globalConfigDictDao.findAll(Sort.by(Sort.Direction.ASC, "id")); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, globalConfigDictList, locale); - } - - @Override - public Long selectGlobalConfigValue(Long code) { - try { - Optional existsGlobalConfigOptional = globalConfigDao.findByCode(code); - if (existsGlobalConfigOptional.isEmpty()) { - return 0L; - } - return existsGlobalConfigOptional.get().getValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return 0L; - } - - @Override - public String selectGlobalConfig(Long code) { - Specification specification = (root, criteriaQuery, criteriaBuilder) -> { - //查询条件集合 - List predicateList = new ArrayList<>(); - if (code != null) { - predicateList.add(criteriaBuilder.equal(root.get("code").as(Long.class), code)); - } - Predicate[] predicateArray = new Predicate[predicateList.size()]; - return criteriaBuilder.and(predicateList.toArray(predicateArray)); - }; - List globalConfigList = globalConfigDao.findAll(specification, Sort.by(Sort.Direction.ASC, "id")); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, globalConfigList, locale); - } - - @Override - public String globalConfig(Map globalConfigMap) { - if (globalConfigMap == null || globalConfigMap.isEmpty()) { - return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale); - } - for (Map.Entry entry : globalConfigMap.entrySet()) { - Long code = entry.getKey(); - Long value = entry.getValue(); - if (code == null || value == null) { - continue; - } - Optional existsGlobalConfigOptional = globalConfigDao.findByCode(code); - if (existsGlobalConfigOptional.isEmpty()) { - GlobalConfigEntity globalConfigEntity = new GlobalConfigEntity(); - globalConfigEntity.setCode(code); - globalConfigEntity.setValue(value); - globalConfigDao.save(globalConfigEntity); - } else { - GlobalConfigEntity existsGlobalConfig = existsGlobalConfigOptional.get(); - existsGlobalConfig.setCode(code); - existsGlobalConfig.setValue(value); - globalConfigDao.save(existsGlobalConfig); - } - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale); - } - - @Override - public String globalConfigDict(GlobalConfigDictQo globalConfigDictQo) { - Long code = globalConfigDictQo.getCode(); - String name = globalConfigDictQo.getName(); - String remark = globalConfigDictQo.getRemark(); - Optional existsGlobalConfigDictOptional = globalConfigDictDao.findByCode(code); - if (existsGlobalConfigDictOptional.isPresent()) { - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "配置失败", locale); - } - GlobalConfigDictEntity globalConfigDictEntity = new GlobalConfigDictEntity(); - globalConfigDictEntity.setCode(code); - globalConfigDictEntity.setName(name); - globalConfigDictEntity.setRemark(remark); - globalConfigDictDao.save(globalConfigDictEntity); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale); - } - -}