优化全局配置表的增删改查操作
This commit is contained in:
parent
f58dfb5274
commit
45d82fa088
@ -41,9 +41,10 @@ public class GlobalConfigurationController {
|
|||||||
* 查询全局配置
|
* 查询全局配置
|
||||||
*/
|
*/
|
||||||
@GetMapping("/query")
|
@GetMapping("/query")
|
||||||
public String queryGlobalConfiguration(@RequestParam(required = false, value = "id") Long id, @RequestParam(required = false, value = "key") String key, @RequestParam(required = false, value = "value") String value, @RequestParam(required = false, value = "remark") String remark) {
|
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();
|
GlobalConfigurationEntity globalConfiguration = new GlobalConfigurationEntity();
|
||||||
globalConfiguration.setId(id);
|
globalConfiguration.setId(id);
|
||||||
|
globalConfiguration.setBelongGroup(group);
|
||||||
globalConfiguration.setKey(key);
|
globalConfiguration.setKey(key);
|
||||||
globalConfiguration.setValue(value);
|
globalConfiguration.setValue(value);
|
||||||
globalConfiguration.setRemark(remark);
|
globalConfiguration.setRemark(remark);
|
||||||
|
@ -18,6 +18,11 @@ public class GlobalConfigurationEntity implements Serializable {
|
|||||||
@SequenceGenerator(name = "global_configuration_seq_gen", sequenceName = "global_configuration_id_seq", allocationSize = 1)
|
@SequenceGenerator(name = "global_configuration_seq_gen", sequenceName = "global_configuration_id_seq", allocationSize = 1)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局配置项所属的组
|
||||||
|
*/
|
||||||
|
private String belongGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局配置项的键
|
* 全局配置项的键
|
||||||
*/
|
*/
|
||||||
@ -44,6 +49,14 @@ public class GlobalConfigurationEntity implements Serializable {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBelongGroup() {
|
||||||
|
return belongGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBelongGroup(String belongGroup) {
|
||||||
|
this.belongGroup = belongGroup;
|
||||||
|
}
|
||||||
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
@ -72,6 +85,7 @@ public class GlobalConfigurationEntity implements Serializable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "GlobalConfigurationEntity{" +
|
return "GlobalConfigurationEntity{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
|
", belongGroup='" + belongGroup + '\'' +
|
||||||
", key='" + key + '\'' +
|
", key='" + key + '\'' +
|
||||||
", value='" + value + '\'' +
|
", value='" + value + '\'' +
|
||||||
", remark='" + remark + '\'' +
|
", remark='" + remark + '\'' +
|
||||||
|
@ -33,20 +33,21 @@ public class GlobalConfigurationServiceImpl implements GlobalConfigurationServic
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String insertGlobalConfiguration(GlobalConfigurationEntity globalConfiguration) {
|
public String insertGlobalConfiguration(GlobalConfigurationEntity globalConfiguration) {
|
||||||
|
final String belongGroup = LocalNullUtils.formatNullValue(globalConfiguration.getBelongGroup());
|
||||||
final String key = LocalNullUtils.formatNullValue(globalConfiguration.getKey());
|
final String key = LocalNullUtils.formatNullValue(globalConfiguration.getKey());
|
||||||
final String value = LocalNullUtils.formatNullValue(globalConfiguration.getValue());
|
final String value = LocalNullUtils.formatNullValue(globalConfiguration.getValue());
|
||||||
final String remark = LocalNullUtils.formatNullValue(globalConfiguration.getRemark());
|
final String remark = LocalNullUtils.formatNullValue(globalConfiguration.getRemark());
|
||||||
|
if (TextUtils.isEmpty(belongGroup)) {
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "belongGroup不可为空", locale);
|
||||||
|
}
|
||||||
if (TextUtils.isEmpty(key)) {
|
if (TextUtils.isEmpty(key)) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "key不可为空", locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "key不可为空", locale);
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(value)) {
|
if (TextUtils.isEmpty(value)) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "value不可为空", locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "value不可为空", locale);
|
||||||
}
|
}
|
||||||
List<GlobalConfigurationEntity> duplicatedEntityList = globalConfigurationDao.findByKey(key);
|
|
||||||
if (duplicatedEntityList != null && duplicatedEntityList.size() > 0) {
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "key已存在", locale);
|
|
||||||
}
|
|
||||||
GlobalConfigurationEntity globalConfigurationEntity = new GlobalConfigurationEntity();
|
GlobalConfigurationEntity globalConfigurationEntity = new GlobalConfigurationEntity();
|
||||||
|
globalConfigurationEntity.setBelongGroup(belongGroup);
|
||||||
globalConfigurationEntity.setKey(key);
|
globalConfigurationEntity.setKey(key);
|
||||||
globalConfigurationEntity.setValue(value);
|
globalConfigurationEntity.setValue(value);
|
||||||
globalConfigurationEntity.setRemark(remark);
|
globalConfigurationEntity.setRemark(remark);
|
||||||
@ -84,20 +85,21 @@ public class GlobalConfigurationServiceImpl implements GlobalConfigurationServic
|
|||||||
if (targetEntityOptional.isEmpty()) {
|
if (targetEntityOptional.isEmpty()) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "id不存在", locale);
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "id不存在", locale);
|
||||||
}
|
}
|
||||||
|
final String belongGroup = LocalNullUtils.formatNullValue(globalConfiguration.getBelongGroup());
|
||||||
final String key = LocalNullUtils.formatNullValue(globalConfiguration.getKey());
|
final String key = LocalNullUtils.formatNullValue(globalConfiguration.getKey());
|
||||||
final String value = LocalNullUtils.formatNullValue(globalConfiguration.getValue());
|
final String value = LocalNullUtils.formatNullValue(globalConfiguration.getValue());
|
||||||
final String remark = LocalNullUtils.formatNullValue(globalConfiguration.getRemark());
|
final String remark = LocalNullUtils.formatNullValue(globalConfiguration.getRemark());
|
||||||
|
if (TextUtils.isEmpty(belongGroup)) {
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "belongGroup不可为空", locale);
|
||||||
|
}
|
||||||
if (TextUtils.isEmpty(key)) {
|
if (TextUtils.isEmpty(key)) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "key不可为空", locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "key不可为空", locale);
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(value)) {
|
if (TextUtils.isEmpty(value)) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "value不可为空", locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "value不可为空", locale);
|
||||||
}
|
}
|
||||||
List<GlobalConfigurationEntity> duplicatedEntityList = globalConfigurationDao.findByKey(key);
|
|
||||||
if (duplicatedEntityList != null && duplicatedEntityList.size() > 0) {
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "key已存在", locale);
|
|
||||||
}
|
|
||||||
GlobalConfigurationEntity targetEntity = targetEntityOptional.get();
|
GlobalConfigurationEntity targetEntity = targetEntityOptional.get();
|
||||||
|
targetEntity.setBelongGroup(belongGroup);
|
||||||
targetEntity.setKey(key);
|
targetEntity.setKey(key);
|
||||||
targetEntity.setValue(value);
|
targetEntity.setValue(value);
|
||||||
if (!TextUtils.isEmpty(remark)) {
|
if (!TextUtils.isEmpty(remark)) {
|
||||||
@ -113,6 +115,7 @@ public class GlobalConfigurationServiceImpl implements GlobalConfigurationServic
|
|||||||
@Override
|
@Override
|
||||||
public String queryGlobalConfiguration(GlobalConfigurationEntity globalConfiguration) {
|
public String queryGlobalConfiguration(GlobalConfigurationEntity globalConfiguration) {
|
||||||
final Long id = globalConfiguration.getId();
|
final Long id = globalConfiguration.getId();
|
||||||
|
final String belongGroup = globalConfiguration.getBelongGroup();
|
||||||
final String key = globalConfiguration.getKey();
|
final String key = globalConfiguration.getKey();
|
||||||
final String value = globalConfiguration.getValue();
|
final String value = globalConfiguration.getValue();
|
||||||
final String remark = globalConfiguration.getRemark();
|
final String remark = globalConfiguration.getRemark();
|
||||||
@ -121,6 +124,9 @@ public class GlobalConfigurationServiceImpl implements GlobalConfigurationServic
|
|||||||
if (null != id) {
|
if (null != id) {
|
||||||
predicateList.add(criteriaBuilder.equal(root.get("id").as(Long.class), 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)) {
|
if (!TextUtils.isEmpty(key)) {
|
||||||
predicateList.add(criteriaBuilder.like(root.get("key").as(String.class), "%" + key + "%"));
|
predicateList.add(criteriaBuilder.like(root.get("key").as(String.class), "%" + key + "%"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user