Skip to content

Commit

Permalink
✨支持前端刷新hash值
Browse files Browse the repository at this point in the history
  • Loading branch information
evil0th authored and Hccake committed May 4, 2024
1 parent f5900d8 commit 77e2bd2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
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

0 comments on commit 77e2bd2

Please sign in to comment.