|
@@ -1,17 +1,17 @@
|
|
package com.huimv.production.service.impl;
|
|
package com.huimv.production.service.impl;
|
|
|
|
|
|
|
|
+import com.huimv.production.domain.ConfigEntity;
|
|
import com.huimv.production.domain.IndexParameterEntity;
|
|
import com.huimv.production.domain.IndexParameterEntity;
|
|
|
|
+import com.huimv.production.repo.ConfigEntityRepository;
|
|
import com.huimv.production.repo.IndexParameterEntityRepository;
|
|
import com.huimv.production.repo.IndexParameterEntityRepository;
|
|
import com.huimv.production.result.Result;
|
|
import com.huimv.production.result.Result;
|
|
import com.huimv.production.result.ResultStatus;
|
|
import com.huimv.production.result.ResultStatus;
|
|
import com.huimv.production.service.IndexParameterService;
|
|
import com.huimv.production.service.IndexParameterService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.domain.Example;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Project : huimv.shiwan
|
|
* @Project : huimv.shiwan
|
|
@@ -24,6 +24,8 @@ import java.util.Map;
|
|
public class IndexParameterServiceImpl implements IndexParameterService {
|
|
public class IndexParameterServiceImpl implements IndexParameterService {
|
|
@Autowired
|
|
@Autowired
|
|
private IndexParameterEntityRepository parameterEntityRepository;
|
|
private IndexParameterEntityRepository parameterEntityRepository;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ConfigEntityRepository configRepo;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result add(IndexParameterEntity parameterEntity) {
|
|
public Result add(IndexParameterEntity parameterEntity) {
|
|
@@ -70,7 +72,6 @@ public class IndexParameterServiceImpl implements IndexParameterService {
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
return new Result(10001,"修改失败");
|
|
return new Result(10001,"修改失败");
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -82,8 +83,54 @@ public class IndexParameterServiceImpl implements IndexParameterService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @Method : setDatasourceType
|
|
|
|
+ * @Description :
|
|
|
|
+ * @Params : [datasourceType]
|
|
|
|
+ * @Return : com.huimv.production.result.Result
|
|
|
|
+ *
|
|
|
|
+ * @Author : ZhuoNing
|
|
|
|
+ * @Date : 2021/5/22
|
|
|
|
+ * @Time : 16:04
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Result setDatasourceType(String datasourceType){
|
|
|
|
+ // 先查询记录是否存在,存在就修改,不存在就添加
|
|
|
|
+ ConfigEntity configEntity = new ConfigEntity();
|
|
|
|
+ configEntity.setKey("datasourceType");;
|
|
|
|
+ Example<ConfigEntity> example = Example.of(configEntity);
|
|
|
|
+ Optional<ConfigEntity> configOptional = configRepo.findOne(example);
|
|
|
|
+ if(configOptional.isPresent()){
|
|
|
|
+ ConfigEntity configData = configOptional.get();
|
|
|
|
+ configData.setValue(datasourceType);
|
|
|
|
+ configRepo.saveAndFlush(configData);
|
|
|
|
+ }else{
|
|
|
|
+ ConfigEntity addConfigData = new ConfigEntity();
|
|
|
|
+ addConfigData.setKey("datasourceType");
|
|
|
|
+ addConfigData.setValue(datasourceType);
|
|
|
|
+ configRepo.saveAndFlush(addConfigData);
|
|
|
|
+ }
|
|
|
|
+ return new Result(10000,"设置成功");
|
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Result getDatasourceType() {
|
|
|
|
+ String datasourceTypeVal = "true";
|
|
|
|
+ ConfigEntity configEntity = new ConfigEntity();
|
|
|
|
+ configEntity.setKey("datasourceType");;
|
|
|
|
+ Example<ConfigEntity> example = Example.of(configEntity);
|
|
|
|
+ Optional<ConfigEntity> configOptional = configRepo.findOne(example);
|
|
|
|
+ if(configOptional.isPresent()){
|
|
|
|
+ ConfigEntity configData = configOptional.get();
|
|
|
|
+ datasourceTypeVal = configData.getValue();
|
|
|
|
+ }else{
|
|
|
|
+ ConfigEntity addConfigData = new ConfigEntity();
|
|
|
|
+ addConfigData.setKey("datasourceType");
|
|
|
|
+ addConfigData.setValue(datasourceTypeVal);
|
|
|
|
+ configRepo.saveAndFlush(addConfigData);
|
|
|
|
+ }
|
|
|
|
+ return new Result(10000,"设置成功",datasourceTypeVal);
|
|
|
|
+ }
|
|
|
|
|
|
/* @Override
|
|
/* @Override
|
|
public Result findAll() {
|
|
public Result findAll() {
|