Browse Source

add: 知识库鉴权接口开发

zhongwei
haungxing 2 months ago
parent
commit
87e694397a
  1. 13
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java
  2. 3
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/SessionContentVO.java
  3. 11
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/manager/SessionRedisManager.java

13
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java

@ -15,11 +15,12 @@ import com.hnac.gglm.bigmodel.interactive.service.IHznlmInteractiveService;
import com.hnac.gglm.bigmodel.interactive.service.IResolveService; import com.hnac.gglm.bigmodel.interactive.service.IResolveService;
import com.hnac.gglm.bigmodel.interactive.vo.AuthDataVO; import com.hnac.gglm.bigmodel.interactive.vo.AuthDataVO;
import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO;
import com.hnac.gglm.bigmodel.interactive.vo.SessionContentVO;
import com.hnac.gglm.bigmodel.manager.SessionRedisManager;
import groovy.util.logging.Slf4j; import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.ParamCache; import org.springblade.system.cache.ParamCache;
import org.springblade.system.dto.DeptStationDTO; import org.springblade.system.dto.DeptStationDTO;
@ -43,6 +44,7 @@ public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService {
private final AuthenticationService authenticationService; private final AuthenticationService authenticationService;
private final IAuthClient authClient; private final IAuthClient authClient;
private final SessionRedisManager sessionRedisManager;
@Override @Override
public List<AuthDataVO> getAuthData(AuthDataDTO req) { public List<AuthDataVO> getAuthData(AuthDataDTO req) {
@ -85,10 +87,15 @@ public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService {
@Override @Override
public Map<String, Object> knowledgeAuth(AuthDataDTO req) { public Map<String, Object> knowledgeAuth(AuthDataDTO req) {
String areaAuth = ParamCache.getValue(ParamKeyConstants.LIBRARY_AREA);
String levelAuth = ParamCache.getValue(ParamKeyConstants.LIBRARY_AUTH_LEVEL);
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
SessionContentVO sessionContent = sessionRedisManager.getSessionContent(req.getSessionId());
if(Func.isNotEmpty(sessionContent) && Func.isNotEmpty(sessionContent.getAreaAuth())) {
result.put("areaAuth", Func.toStrList(",",sessionContent.getAreaAuth()));
} else {
String areaAuth = ParamCache.getValue(ParamKeyConstants.LIBRARY_AREA);
result.put("areaAuth", Optional.ofNullable(areaAuth).map(auth -> Func.toStrList(",",auth)).orElse(Lists.newArrayList())); result.put("areaAuth", Optional.ofNullable(areaAuth).map(auth -> Func.toStrList(",",auth)).orElse(Lists.newArrayList()));
}
String levelAuth = ParamCache.getValue(ParamKeyConstants.LIBRARY_AUTH_LEVEL);
result.put("levelAuth",Optional.ofNullable(levelAuth).map(Integer::valueOf).orElse(0)); result.put("levelAuth",Optional.ofNullable(levelAuth).map(Integer::valueOf).orElse(0));
return result; return result;
} }

3
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/SessionContentVO.java

@ -16,4 +16,7 @@ public class SessionContentVO implements Serializable {
/**机器码**/ /**机器码**/
private String machineCode; private String machineCode;
/**行业类型**/
private String areaAuth;
} }

11
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/manager/SessionRedisManager.java

@ -1,5 +1,7 @@
package com.hnac.gglm.bigmodel.manager; package com.hnac.gglm.bigmodel.manager;
import com.hnac.gglm.bigmodel.interactive.vo.SessionContentVO;
import com.hnac.gglm.bigmodel.websocket.constants.RedisKeyConstants;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -29,4 +31,13 @@ public class SessionRedisManager {
public List<String> getSessionIds() { public List<String> getSessionIds() {
return redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1); return redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1);
} }
/**
* 获取大模型会话传入的内容
* @param chatId 会话ID
* @return 会话内容
*/
public SessionContentVO getSessionContent(String chatId) {
return (SessionContentVO) redisTemplate.opsForHash().get(RedisKeyConstants.SESSION_CONTENT_KEY, chatId);
}
} }

Loading…
Cancel
Save