Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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 @@ -321,8 +321,17 @@ public enum ExceptionEnum implements IBaseError {
/**
* Cm 339 exception enum.
*/
CM339("CM339", "token检验失败,请重新登录");
CM339("CM339", "token检验失败,请重新登录"),

/**
* Cm 340 exception enum.
*/
CM340("CM340", "请求资源不存在"),

/**
* Cm 341 exception enum.
*/
CM341("CM341", "组织在当前用户组织列表中匹配不到");
/**
Comment thread
coderabbitai[bot] marked this conversation as resolved.
* 错误码
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class AiChatController {
@SystemControllerLog(description = "AI chat")
@PostMapping("/ai/chat")
public ResponseEntity<?> aiChat(@RequestBody ChatRequest request,
@RequestHeader(value = "Authorization", required = false) String authorization) throws Exception {
@RequestHeader(value = "Authorization", required = true) String authorization) throws Exception {
Comment thread
msslulu marked this conversation as resolved.

if (authorization != null && authorization.startsWith("Bearer ")) {
String token = authorization.replace("Bearer ", "");
Expand Down Expand Up @@ -117,7 +117,7 @@ public ResponseEntity<?> aiChat(@RequestBody ChatRequest request,
@SystemControllerLog(description = "AI completions")
@PostMapping("/chat/completions")
public ResponseEntity<?> completions(@RequestBody ChatRequest request,
@RequestHeader(value = "Authorization", required = false) String authorization) throws Exception {
@RequestHeader(value = "Authorization", required = true) String authorization) throws Exception {
if (authorization != null && authorization.startsWith("Bearer ")) {
String token = authorization.replace("Bearer ", "");
request.setApiKey(token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ public Result<User> me() {
user.setUsername(loginUserContext.getLoginUserId());
}
user.setTenant(tenants);

user.setPassword(null);
user.setPrivateKey(null);
user.setPublicKey(null);
user.setSalt(null);
return Result.success(user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public void addInterceptors(InterceptorRegistry registry) {
// 登录相关
"/platform-center/api/user/login",
// 忘记密码
"/platform-center/api/user/forgot-password"
"/platform-center/api/user/forgot-password",
// AI
"/app-center/api/ai/chat",
"/app-center/api/chat/completions"
Comment thread
msslulu marked this conversation as resolved.
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.tinyengine.it.model.entity.Tenant;
import com.tinyengine.it.model.entity.User;
import com.tinyengine.it.service.app.UserService;
import com.tinyengine.it.service.platform.TenantService;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -238,10 +239,12 @@ public Result<ValidationResult> validateToken(@RequestParam String token) {
@SystemControllerLog(description = "设置当前组织")
@GetMapping("/user/tenant")
public Result<SSOTicket> setTenant(@RequestParam Integer tenantId) {
List<Tenant> tenants = loginUserContext.getTenants();
List<Tenant> tenants = authUsersUnitsRolesMapper.queryAllTenantByUserId(Integer.valueOf(loginUserContext.getLoginUserId()));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

Comment thread
msslulu marked this conversation as resolved.
Outdated
if (tenantId == null) {
return Result.failed(ExceptionEnum.CM320);
}

if (tenants == null || tenants.isEmpty()) {
return Result.failed(ExceptionEnum.CM337);
}
Expand All @@ -259,7 +262,7 @@ public Result<SSOTicket> setTenant(@RequestParam Integer tenantId) {
}

if (!found) {
return Result.failed(ExceptionEnum.CM337);
return Result.failed(ExceptionEnum.CM341);
}

// 通过 RequestContextHolder 获取请求
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,18 +495,16 @@ public Page addIsHome(Page pageInfo) {
* @return the app home page id
*/
public int getAppHomePageId(int appId) {
log.info("Getting home page ID for appId: {}, TenantId: {}", appId, loginUserContext.getTenantId());
App appInfo = appMapper.queryAppById(appId, loginUserContext.getTenantId());
// appHomePageId 存在为null的情况,即app没有设置首页
Integer homePage = appInfo.getHomePage();

// 将 homePage 转换为整数,如果为空则默认为 0
int id;
if (homePage == null) {
id = 0;
return id;
if (appInfo == null) {
throw new ServiceException(ExceptionEnum.CM340.getResultCode(), "App not found for ID: " + appId+",TenantId:"+loginUserContext.getTenantId());
}
id = homePage;
return id;
// 将 homePage 转换为整数,如果为空则默认为 0
Integer homePage = appInfo.getHomePage();
log.info("Retrieved home page ID: {} for appId: {}", homePage, appId);
return homePage != null ? homePage : 0;
}

/**
Expand Down
Loading