Browse Source

🐛 修复 字典BUG

test
smallchill 6 years ago
parent
commit
c13485c1ae
  1. 2
      blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java
  2. 2
      blade-ops/blade-develop/src/main/resources/templates/controller.java.vm
  3. 2
      blade-ops/blade-develop/src/test/resources/templates/controller.java.vm
  4. 36
      blade-service-api/blade-dict-api/src/main/java/org/springblade/system/config/DictFeignConfiguration.java
  5. 2
      blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClientFallback.java
  6. 2
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java
  7. 9
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java
  8. 2
      blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java
  9. 2
      blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java
  10. 7
      blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java
  11. 17
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java
  12. 4
      pom.xml

2
blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java

@ -87,7 +87,7 @@ public class CodeController extends BladeController {
* 删除
*/
@PostMapping("/remove")
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
@ApiOperation(value = "删除", notes = "传入ids", position = 7)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(codeService.removeByIds(Func.toIntList(ids)));
}

2
blade-ops/blade-develop/src/main/resources/templates/controller.java.vm

@ -141,7 +141,7 @@ public class $!{table.controllerName} {
* 删除 $!{table.comment}
*/
@PostMapping("/remove")
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
@ApiOperation(value = "删除", notes = "传入ids", position = 7)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status($!{table.entityPath}Service.removeByIds(Func.toIntList(ids)));
}

2
blade-ops/blade-develop/src/test/resources/templates/controller.java.vm

@ -141,7 +141,7 @@ public class $!{table.controllerName} {
* 删除 $!{table.comment}
*/
@PostMapping("/remove")
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
@ApiOperation(value = "删除", notes = "传入ids", position = 7)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status($!{table.entityPath}Service.removeByIds(Func.toIntList(ids)));
}

36
blade-service-api/blade-dict-api/src/main/java/org/springblade/system/config/DictFeignConfiguration.java

@ -1,36 +0,0 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.system.config;
import org.springblade.system.feign.IDictClientFallback;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 字典feign失败配置
*
* @author Chill
*/
@Configuration
public class DictFeignConfiguration {
@Bean
public IDictClientFallback dictClientFallback() {
return new IDictClientFallback();
}
}

2
blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClientFallback.java

@ -18,6 +18,7 @@ package org.springblade.system.feign;
import org.springblade.core.tool.api.R;
import org.springblade.system.entity.Dict;
import org.springframework.stereotype.Component;
import java.util.List;
@ -26,6 +27,7 @@ import java.util.List;
*
* @author Chill
*/
@Component
public class IDictClientFallback implements IDictClient {
@Override
public R<String> getValue(String code, Integer dictKey) {

2
blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java

@ -100,7 +100,7 @@ public class DeptController extends BladeController {
* 删除
*/
@PostMapping("/remove")
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
@ApiOperation(value = "删除", notes = "传入ids", position = 7)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(deptService.removeByIds(Func.toIntList(ids)));
}

9
blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java

@ -27,6 +27,7 @@ import org.springblade.system.entity.Dict;
import org.springblade.system.service.IDictService;
import org.springblade.system.vo.DictVO;
import org.springblade.system.wrapper.DictWrapper;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -34,6 +35,9 @@ import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import static org.springblade.common.cache.CacheNames.DICT_LIST;
import static org.springblade.common.cache.CacheNames.DICT_VALUE;
/**
* 控制器
*
@ -93,7 +97,7 @@ public class DictController extends BladeController {
@PostMapping("/submit")
@ApiOperation(value = "新增或修改", notes = "传入dict", position = 6)
public R submit(@Valid @RequestBody Dict dict) {
return R.status(dictService.saveOrUpdate(dict));
return R.status(dictService.submit(dict));
}
@ -101,7 +105,8 @@ public class DictController extends BladeController {
* 删除
*/
@PostMapping("/remove")
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
@CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE})
@ApiOperation(value = "删除", notes = "传入ids", position = 7)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(dictService.removeByIds(Func.toIntList(ids)));
}

2
blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java

@ -141,7 +141,7 @@ public class MenuController extends BladeController {
* 删除
*/
@PostMapping("/remove")
@ApiOperation(value = "物理删除", notes = "传入ids", position = 9)
@ApiOperation(value = "删除", notes = "传入ids", position = 9)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(menuService.removeByIds(Func.toIntList(ids)));
}

2
blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java

@ -99,7 +99,7 @@ public class RoleController extends BladeController {
* 删除
*/
@PostMapping("/remove")
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
@ApiOperation(value = "删除", notes = "传入ids", position = 7)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(roleService.removeByIds(Func.toIntList(ids)));
}

7
blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java

@ -64,4 +64,11 @@ public interface IDictService extends IService<Dict> {
*/
List<Dict> getList(String code);
/**
* 新增或修改
* @param dict
* @return
*/
boolean submit(Dict dict);
}

17
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java

@ -16,7 +16,10 @@
*/
package org.springblade.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.utils.Func;
@ -25,6 +28,7 @@ import org.springblade.system.entity.Dict;
import org.springblade.system.mapper.DictMapper;
import org.springblade.system.service.IDictService;
import org.springblade.system.vo.DictVO;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@ -55,8 +59,7 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
@Override
@Cacheable(cacheNames = DICT_VALUE, key = "#code+'_'+#dictKey")
public String getValue(String code, Integer dictKey) {
String value = Func.toStr(baseMapper.getValue(code, dictKey), StringPool.EMPTY);
return value;
return Func.toStr(baseMapper.getValue(code, dictKey), StringPool.EMPTY);
}
@Override
@ -65,4 +68,14 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
return baseMapper.getList(code);
}
@Override
@CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE})
public boolean submit(Dict dict) {
LambdaQueryWrapper<Dict> lqw = Wrappers.<Dict>query().lambda().eq(Dict::getCode, dict.getCode()).eq(Dict::getDictKey, dict.getDictKey());
Integer cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(Dict::getId, dict.getId()));
if (cnt > 0) {
throw new ApiException("当前字典键值已存在!");
}
return saveOrUpdate(dict);
}
}

4
pom.xml

@ -15,8 +15,8 @@
<java.version>1.8</java.version>
<swagger.version>2.9.2</swagger.version>
<swagger.models.version>1.5.21</swagger.models.version>
<swagger.bootstrapui.version>1.8.9</swagger.bootstrapui.version>
<mybatis.plus.version>3.0.7.1</mybatis.plus.version>
<swagger.bootstrapui.version>1.9.0</swagger.bootstrapui.version>
<mybatis.plus.version>3.1.0</mybatis.plus.version>
<curator.framework.version>4.0.1</curator.framework.version>
<protostuff.version>1.6.0</protostuff.version>
<alibaba.cloud.version>0.2.1.RELEASE</alibaba.cloud.version>

Loading…
Cancel
Save