删除无用代码
This commit is contained in:
parent
ab6e8eae95
commit
cf72330320
@ -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<Long, Long> configMap) {
|
||||
return globalConfigService.globalConfig(configMap);
|
||||
}
|
||||
|
||||
@PostMapping("/globalConfigDict")
|
||||
public String globalConfigDict(@RequestBody GlobalConfigDictQo globalConfigDictQo) {
|
||||
return globalConfigService.globalConfigDict(globalConfigDictQo);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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<GlobalConfigurationEntity, Long>, JpaSpecificationExecutor<GlobalConfigurationEntity> {
|
||||
|
||||
List<GlobalConfigurationEntity> findByKey(String key);
|
||||
|
||||
}
|
@ -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 + '\'' + '}';
|
||||
}
|
||||
}
|
@ -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<Long, Long> globalConfigMap);
|
||||
|
||||
String globalConfigDict(GlobalConfigDictQo globalConfigDictQo);
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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<GlobalConfigurationEntity> 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<GlobalConfigurationEntity> 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<GlobalConfigurationEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
|
||||
List<Predicate> 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<GlobalConfigurationEntity> globalConfigurationEntityList = globalConfigurationDao.findAll(specification, Sort.by(Sort.Direction.ASC, "id"));
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, globalConfigurationEntityList, locale);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user