diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java index 6d793fab..9109d033 100644 --- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java +++ b/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))); } diff --git a/blade-ops/blade-develop/src/main/resources/templates/controller.java.vm b/blade-ops/blade-develop/src/main/resources/templates/controller.java.vm index b95f2048..b55a12c1 100644 --- a/blade-ops/blade-develop/src/main/resources/templates/controller.java.vm +++ b/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))); } diff --git a/blade-ops/blade-develop/src/test/resources/templates/controller.java.vm b/blade-ops/blade-develop/src/test/resources/templates/controller.java.vm index b95f2048..b55a12c1 100644 --- a/blade-ops/blade-develop/src/test/resources/templates/controller.java.vm +++ b/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))); } diff --git a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/config/DictFeignConfiguration.java b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/config/DictFeignConfiguration.java deleted file mode 100644 index 091d14dc..00000000 --- a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/config/DictFeignConfiguration.java +++ /dev/null @@ -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(); - } - -} diff --git a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClientFallback.java b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClientFallback.java index 6dd6dd9e..492a3a1a 100644 --- a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClientFallback.java +++ b/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 getValue(String code, Integer dictKey) { diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java index 0ba1d18a..0c506365 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java +++ b/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))); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java index 9fcff355..a44b4a79 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java +++ b/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))); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java index 7aba1bc7..a7545dca 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java +++ b/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))); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java index 52f249d3..db1f5afc 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java +++ b/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))); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java index 33257704..a8df5874 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java @@ -64,4 +64,11 @@ public interface IDictService extends IService { */ List getList(String code); + /** + * 新增或修改 + * @param dict + * @return + */ + boolean submit(Dict dict); + } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java index 318916b5..ebb2dec0 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java +++ b/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 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 implements ID return baseMapper.getList(code); } + @Override + @CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE}) + public boolean submit(Dict dict) { + LambdaQueryWrapper lqw = Wrappers.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); + } } diff --git a/pom.xml b/pom.xml index fb78cd91..5c577510 100644 --- a/pom.xml +++ b/pom.xml @@ -15,8 +15,8 @@ 1.8 2.9.2 1.5.21 - 1.8.9 - 3.0.7.1 + 1.9.0 + 3.1.0 4.0.1 1.6.0 0.2.1.RELEASE