保存快捷键.
This commit is contained in:
@@ -26,3 +26,8 @@ Authorization: {{token}}
|
||||
GET {{baseUrl}}/infra/preference/get?type=SYSTEM
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
### 查询默认偏好
|
||||
GET {{baseUrl}}/infra/preference/get-default?type=TERMINAL&items=shortcutSetting
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
@@ -57,5 +57,14 @@ public class PreferenceController {
|
||||
return preferenceService.getPreferenceByType(type, items);
|
||||
}
|
||||
|
||||
@GetMapping("/get-default")
|
||||
@Operation(summary = "查询默认偏好")
|
||||
@Parameter(name = "type", description = "type", required = true)
|
||||
@Parameter(name = "items", description = "items")
|
||||
public Map<String, Object> getDefaultPreference(@RequestParam("type") String type,
|
||||
@RequestParam(name = "items", required = false) List<String> items) {
|
||||
return preferenceService.getDefaultPreferenceByType(type, items);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,15 @@ public interface PreferenceService {
|
||||
*/
|
||||
Map<String, Object> getPreferenceByType(String type, List<String> items);
|
||||
|
||||
/**
|
||||
* 查询默认偏好
|
||||
*
|
||||
* @param type type
|
||||
* @param items items
|
||||
* @return rows
|
||||
*/
|
||||
Map<String, Object> getDefaultPreferenceByType(String type, List<String> items);
|
||||
|
||||
/**
|
||||
* 获取用户偏好
|
||||
*
|
||||
|
||||
@@ -139,6 +139,22 @@ public class PreferenceServiceImpl implements PreferenceService {
|
||||
return partial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDefaultPreferenceByType(String type, List<String> items) {
|
||||
PreferenceTypeEnum preferenceType = Valid.valid(PreferenceTypeEnum::of, type);
|
||||
// 获取默认值
|
||||
Map<String, String> defaultModel = preferenceType.getStrategy()
|
||||
.getDefault()
|
||||
.toMap();
|
||||
Map<String, Object> result = Maps.newMap();
|
||||
if (Lists.isEmpty(items)) {
|
||||
defaultModel.forEach((k, v) -> result.put(k, Refs.unref(defaultModel.get(k))));
|
||||
} else {
|
||||
items.forEach(s -> result.put(s, Refs.unref(defaultModel.get(s))));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public Future<Map<String, Object>> getPreferenceAsync(Long userId, PreferenceTypeEnum type) {
|
||||
|
||||
Reference in New Issue
Block a user