删除无用代码

This commit is contained in:
liuchengqian 2023-03-01 17:35:42 +08:00
parent be546eb535
commit ab6e8eae95
6 changed files with 1 additions and 275 deletions

View File

@ -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<GlobalConfigEntity, Long>, JpaSpecificationExecutor<GlobalConfigEntity> {
Optional<GlobalConfigEntity> findByCode(Long code);
}

View File

@ -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<GlobalConfigDictEntity, Long>, JpaSpecificationExecutor<GlobalConfigDictEntity> {
Optional<GlobalConfigDictEntity> findByCode(Long code);
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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 + '\'' + '}';
}
}

View File

@ -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<GlobalConfigDictEntity> globalConfigDictList = globalConfigDictDao.findAll(Sort.by(Sort.Direction.ASC, "id"));
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, globalConfigDictList, locale);
}
@Override
public Long selectGlobalConfigValue(Long code) {
try {
Optional<GlobalConfigEntity> 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<GlobalConfigEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
//查询条件集合
List<Predicate> 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<GlobalConfigEntity> globalConfigList = globalConfigDao.findAll(specification, Sort.by(Sort.Direction.ASC, "id"));
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, globalConfigList, locale);
}
@Override
public String globalConfig(Map<Long, Long> globalConfigMap) {
if (globalConfigMap == null || globalConfigMap.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale);
}
for (Map.Entry<Long, Long> entry : globalConfigMap.entrySet()) {
Long code = entry.getKey();
Long value = entry.getValue();
if (code == null || value == null) {
continue;
}
Optional<GlobalConfigEntity> 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<GlobalConfigDictEntity> 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);
}
}