refactor: 分离终端配置.

This commit is contained in:
lijiahangmax
2024-01-11 00:43:18 +08:00
parent b5cdd0b362
commit 7f9a97180e
21 changed files with 225 additions and 423 deletions

View File

@@ -13,6 +13,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
@@ -50,8 +51,10 @@ public class PreferenceController {
@GetMapping("/get")
@Operation(summary = "查询用户偏好")
@Parameter(name = "type", description = "type", required = true)
public Map<String, Object> getPreference(@RequestParam("type") String type) {
return preferenceService.getPreferenceByType(type);
@Parameter(name = "items", description = "items")
public Map<String, Object> getPreference(@RequestParam("type") String type,
@RequestParam(name = "items", required = false) List<String> items) {
return preferenceService.getPreferenceByType(type, items);
}
}

View File

@@ -4,6 +4,7 @@ import com.orion.ops.module.infra.entity.request.preference.PreferenceUpdatePart
import com.orion.ops.module.infra.entity.request.preference.PreferenceUpdateRequest;
import com.orion.ops.module.infra.enums.PreferenceTypeEnum;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;
@@ -34,10 +35,11 @@ public interface PreferenceService {
/**
* 查询用户偏好
*
* @param type type
* @param type type
* @param items items
* @return rows
*/
Map<String, Object> getPreferenceByType(String type);
Map<String, Object> getPreferenceByType(String type, List<String> items);
/**
* 获取用户偏好

View File

@@ -3,6 +3,7 @@ package com.orion.ops.module.infra.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.lang.function.Functions;
import com.orion.lang.utils.Refs;
import com.orion.lang.utils.collect.Lists;
import com.orion.lang.utils.collect.Maps;
import com.orion.ops.framework.common.utils.Valid;
import com.orion.ops.framework.redis.core.utils.RedisMaps;
@@ -125,10 +126,17 @@ public class PreferenceServiceImpl implements PreferenceService {
}
@Override
public Map<String, Object> getPreferenceByType(String type) {
public Map<String, Object> getPreferenceByType(String type, List<String> items) {
Long userId = SecurityUtils.getLoginUserId();
PreferenceTypeEnum typeEnum = Valid.valid(PreferenceTypeEnum::of, type);
return this.getPreferenceByCache(userId, typeEnum);
// 查询缓存
Map<String, Object> preference = this.getPreferenceByCache(userId, typeEnum);
if (Lists.isEmpty(items)) {
return preference;
}
Map<String, Object> partial = Maps.newMap();
items.forEach(s -> partial.put(s, preference.get(s)));
return partial;
}
@Override