Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨支持前端刷新hash值 #22

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,24 @@ public void updateDictItemStatusById(Long itemId, Integer status) {
this.eventPublisher.publishEvent(new DictChangeEvent(dictCode));
}

/**
* 通过id刷新hash值
* @param id 字典id
*/
public void refreshDictHashById(Long id) {
// 查询现有数据
SysDict dict = this.sysDictService.getById(id);
Assert.notNull(dict, () -> new BusinessException(BaseResultCode.LOGIC_CHECK_ERROR.getCode(), "错误的字典 id:" + id));

// 更新字典 hash
String dictCode = dict.getCode();
Assert.isTrue(this.sysDictService.updateHashCode(dictCode),
() -> new BusinessException(BaseResultCode.UPDATE_DATABASE_ERROR.getCode(), "字典 Hash 更新异常"));

// 发布字典更新事件
this.eventPublisher.publishEvent(new DictChangeEvent(dictCode));
}

/**
* 字典项分页
* @param pageParam 分页属性
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ public ApiResult<Void> removeById(@PathVariable("id") Long id) {
return ApiResult.ok();
}

/**
* 通过id刷新hash值
* @param id id
* @return ApiResult
*/
@UpdateOperationLogging(msg = "通过id刷新hash值")
@PatchMapping("/refresh/{id}")
@Authorize("hasPermission('system:dict:edit')")
@Operation(summary = "通过id刷新hash值", description = "通过id刷新hash值")
public ApiResult<Void> refreshDictHashById(@PathVariable("id") Long id) {
this.sysDictManager.refreshDictHashById(id);
return ApiResult.ok();
}

/**
* 分页查询
* @param pageParam 分页参数
Expand Down
Loading