优化代码

This commit is contained in:
zhuyijun 2022-10-16 23:33:22 +08:00
parent 295cedcaed
commit 74ae51d555
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package cn.zyjblogs.server.client.controller;
import cn.zyjblogs.starter.common.entity.response.HttpCode;
import cn.zyjblogs.starter.common.entity.response.ResponseObject;
import cn.zyjblogs.starter.common.entity.response.ResponseResult;
import cn.zyjblogs.starter.web.apiversion.ApiVersion;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Set;
@Api(tags = {"客户端管理"})
@RestController
@ApiVersion(1)
@RequestMapping("/{v}/client")
@ResponseBody
@RequiredArgsConstructor
public class OauthClientController {
private final ClientDetailsService oauthClientDetailsService;
@GetMapping("/findScopeList")
@ApiVersion(1)
public ResponseObject<Set<String>> getList(String clientId) {
ClientDetails clientDetails = oauthClientDetailsService.loadClientByClientId(clientId);
if (clientDetails == null) {
return ResponseResult.error(HttpCode.BAD_REQUEST, "该客户端不存在");
}
return ResponseResult.success(clientDetails.getScope());
}
}

View File

@ -0,0 +1,15 @@
package cn.zyjblogs.server.client.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OauthClientNameVo {
private String name;
private String value;
}