# v2.5.0 升级至 v2.6.0
# 组件更改说明
该升级指南以v2.5.0版本为基准,更早的版本请先参考之前版本的升级文档。
将diboot所有的组件版本号替换至2.6.0的最新版本,然后按照下述内容进行相关更改即可。
# diboot-core 内核
BaseController
中移除弃用方法buildQueryWrapper
,使用buildQueryWrapperByQueryParams
替换
# diboot-iam 权限体系
- 资源权限表字段变更
- 手动执行以下SQL更新数据结构(以下为MySQL脚本,其他库请自行转换)
ALTER TABLE iam_resource_permission MODIFY COLUMN permission_code varchar (200) null comment '权限编码' AFTER resource_code;
ALTER TABLE iam_resource_permission MODIFY COLUMN sort_id bigint null comment '排序号' AFTER permission_code;
1
2
2
- 基于 api_set 老字段的值更新 permission_code 新字段的值。将之前存储的uri转换为权限码标记。基于不同粒度的权限码分组,填充不同的权限码值。 如将权限分为“读”和“写”两组(v2.6.0默认分组),则更新对应的读权限接口uri(如列表页uri、详情页uri等)为"读"权限码:${YourEntityClass}:read; 对应的写权限接口uri(如新建表单uri、修改表单uri、删除等)为"写"权限码:${YourEntityClass}:write。
举例:将‘数据字典管理’下的列表首页和详情页记录对应的permission_code更新为: Dictionary:read,增删改相关页面记录对应的permission_code更新为Dictionary:write。
关于IAM权限码相关解释说明,请参考BindPermission注解使用
- 更新完毕之后再删除api_set列。
ALTER TABLE iam_resource_permission DROP COLUMN api_set;
1
- 接口变更
替换
AuthTokenController
中的以下接口@RestController @BindPermission(name = "登录认证", code = "AUTH") public class AuthTokenController extends BaseController { @Autowired private BaseCacheManager baseCacheManager; @GetMapping("/auth/captcha") public void captcha(@RequestParam("traceId")String traceId, HttpServletResponse response) throws Exception { response.setContentType("image/gif"); response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); // 算数验证码 ArithmeticCaptcha captcha = new ArithmeticCaptcha(); // 验证码存入缓存 baseCacheManager.putCacheObj(Cons.CACHE_CAPTCHA, traceId, captcha.text()); // 输出图片流 captcha.out(response.getOutputStream()); } @PostMapping("/auth/login") public JsonResult login(@RequestBody PwdCredential credential) throws Exception{ // 获取缓存中的验证码 String traceId = credential.getTraceId(); String verCode = credential.getCaptcha(); String captcha = baseCacheManager.getCacheString(Cons.CACHE_CAPTCHA, traceId); baseCacheManager.removeCacheObj(Cons.CACHE_CAPTCHA, traceId); // 判断验证码 if (verCode == null || !verCode.trim().toLowerCase().equals(captcha)) { return JsonResult.FAIL_VALIDATION("验证码错误"); } return JsonResult.OK(AuthServiceFactory.getAuthService(Cons.DICTCODE_AUTH_TYPE.PWD.name()).applyToken(credential)); } @PostMapping("/logout") public JsonResult logout() throws Exception { String accessToken = TokenUtils.getRequestToken(request); IamSecurityUtils.logoutByToken(accessToken); return JsonResult.OK(); } //... }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43IamUserController
的/list
接口替换@GetMapping("/list") public JsonResult getViewObjectListMapping(IamUserSearchDTO dto, Pagination pagination) throws Exception { Long orgId = dto.getOrgId(); dto.setOrgId(null); LambdaQueryWrapper<IamUser> queryWrapper = super.buildLambdaQueryWrapperByQueryParams(dto); List<IamUserVO> voList = iamUserService.getUserViewList(queryWrapper, pagination, orgId); // 返回结果 return JsonResult.OK(voList).bindPagination(pagination); }
1
2
3
4
5
6
7
8
9
10
11移除
IamResourcePermissionController
中以下三个接口@GetMapping("/apiDiff") public JsonResult apiDiff() throws Exception{ Map<String, Object> result = iamResourcePermissionService.extractCodeDiffDbPermissions(Cons.APPLICATION); return JsonResult.OK(result); } @PostMapping("/batchDeleteInvalidPermissionList") public JsonResult batchDeleteInvalidPermissionList(@RequestBody List<Long> resourcePermissionIdList) throws Exception { iamResourcePermissionService.deleteMenuAndPermissions(resourcePermissionIdList); return JsonResult.OK(); } @PostMapping("/modifyPermission") public JsonResult modifyPermission(@RequestBody ModifyIamResourcePermissionDTO modifyIamResourcePermissionDTO) throws Exception{ iamResourcePermissionService.updateEntity( Wrappers.<IamResourcePermission>lambdaUpdate() .set(IamResourcePermission::getApiSet, modifyIamResourcePermissionDTO.getApiSet()) .eq(IamResourcePermission::getId, modifyIamResourcePermissionDTO.getId()) ); return JsonResult.OK(); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# message 消息组件
- 如果依赖了消息组件,手动执行以下SQL更新数据结构(以下为MySQL脚本,其他库请自行转换):
ALTER TABLE message_template DROP COLUMN variables;
ALTER TABLE message_template MODIFY COLUMN `ext_data` varchar(500) DEFAULT NULL COMMENT '扩展数据' AFTER content;
1
2
2
调整变量填充变更详情查看消息组件文档
# 前端升级说明
- diboot-antd-admin前端调整
升级前请下载diboot-antd-admin 2.6.0 (opens new window)源码包,以下升级流程将依赖此包。
- diboot-element-admin前端调整
升级前请下载diboot-element-admin 2.6.0 (opens new window)源码包,以下升级流程将依赖此包。
- 对比新旧版本的相关页面及代码,替换或合并至本地。