|
15 | 15 | import com.tinyengine.it.common.base.Result; |
16 | 16 | import com.tinyengine.it.common.context.LoginUserContext; |
17 | 17 | import com.tinyengine.it.common.exception.ExceptionEnum; |
| 18 | +import com.tinyengine.it.common.exception.ServiceException; |
18 | 19 | import com.tinyengine.it.common.log.SystemControllerLog; |
19 | 20 | import com.tinyengine.it.login.model.*; |
20 | 21 | import com.tinyengine.it.login.utils.JwtUtil; |
|
35 | 36 | import io.swagger.v3.oas.annotations.responses.ApiResponse; |
36 | 37 | import jakarta.servlet.http.HttpServletRequest; |
37 | 38 | import jakarta.validation.Valid; |
| 39 | +import lombok.extern.slf4j.Slf4j; |
38 | 40 | import org.springframework.beans.factory.annotation.Autowired; |
39 | 41 | import org.springframework.validation.annotation.Validated; |
40 | 42 | import org.springframework.web.bind.annotation.CrossOrigin; |
@@ -230,10 +232,18 @@ public Result<ValidationResult> validateToken(@RequestParam String token) { |
230 | 232 | schema = @Schema(implementation = App.class))), |
231 | 233 | @ApiResponse(responseCode = "400", description = "请求失败") |
232 | 234 | }) |
| 235 | + |
233 | 236 | @SystemControllerLog(description = "设置当前组织") |
234 | 237 | @GetMapping("/user/tenant") |
235 | 238 | public Result<SSOTicket> setTenant(@RequestParam Integer tenantId) { |
236 | | - List<Tenant> tenants = authUsersUnitsRolesMapper.queryAllTenantByUserId(Integer.valueOf(loginUserContext.getLoginUserId())); |
| 239 | + int userIdInt; |
| 240 | + String userId = loginUserContext.getLoginUserId(); |
| 241 | + try { |
| 242 | + userIdInt = Integer.parseInt(userId); |
| 243 | + } catch (NumberFormatException e) { |
| 244 | + return Result.failed(ExceptionEnum.CM342); |
| 245 | + } |
| 246 | + List<Tenant> tenants = authUsersUnitsRolesMapper.queryAllTenantByUserId(userIdInt); |
237 | 247 |
|
238 | 248 | if (tenantId == null) { |
239 | 249 | return Result.failed(ExceptionEnum.CM320); |
|
0 commit comments