test(user): 调用omada API测试
This commit is contained in:
@@ -70,6 +70,11 @@
|
||||
<artifactId>wfc-api-user</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- WFC Api Omada -->
|
||||
<dependency>
|
||||
<groupId>org.wfc</groupId>
|
||||
<artifactId>wfc-api-omada</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package org.wfc.user.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.wfc.common.core.domain.LoginUser;
|
||||
import org.wfc.common.core.utils.StringUtils;
|
||||
import org.wfc.common.core.web.controller.BaseController;
|
||||
import org.wfc.common.core.web.domain.AjaxResult;
|
||||
import org.wfc.common.core.web.form.WANFiRedirectParams;
|
||||
import org.wfc.common.security.utils.SecurityUtils;
|
||||
import org.wfc.omada.api.client.OmadaClientApi;
|
||||
import org.wfc.omada.api.client.model.OperationResponseClientDetail;
|
||||
import org.wfc.omada.api.hotspot.OmadaAuthorizedClientApi;
|
||||
import org.wfc.omada.api.hotspot.model.OperationResponseWithoutResult;
|
||||
import org.wfc.user.api.domain.UUser;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 客户端操作处理
|
||||
*
|
||||
* @author wfc
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/client")
|
||||
public class ClientController extends BaseController {
|
||||
@Autowired
|
||||
private OmadaClientApi omadaClientApi;
|
||||
|
||||
@Autowired
|
||||
private OmadaAuthorizedClientApi omadaAuthorizedClientApi;
|
||||
|
||||
/**
|
||||
* 获取客户信息
|
||||
*/
|
||||
// @RequiresLogin()
|
||||
@GetMapping("/auth")
|
||||
public AjaxResult auth() {
|
||||
LoginUser<UUser> loginUser = SecurityUtils.getLoginUser();
|
||||
WANFiRedirectParams wanFiRedirectParams = loginUser.getWanFiRedirectParams();
|
||||
if (wanFiRedirectParams == null) {
|
||||
return error("not wanfi redirect params");
|
||||
}
|
||||
String site = wanFiRedirectParams.getSite();
|
||||
String clientMac = wanFiRedirectParams.getClientMac();
|
||||
if (StringUtils.isBlank(site) || StringUtils.isBlank(clientMac)) {
|
||||
return error("not mac address");
|
||||
}
|
||||
ResponseEntity<OperationResponseWithoutResult> posts = omadaAuthorizedClientApi.authClient(site, clientMac);
|
||||
return success(Objects.requireNonNull(posts.getBody()).getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户信息
|
||||
*/
|
||||
// @RequiresLogin()
|
||||
@GetMapping("/unauth")
|
||||
public AjaxResult unauth() {
|
||||
LoginUser<UUser> loginUser = SecurityUtils.getLoginUser();
|
||||
WANFiRedirectParams wanFiRedirectParams = loginUser.getWanFiRedirectParams();
|
||||
if (wanFiRedirectParams == null) {
|
||||
return error("not wanfi redirect params");
|
||||
}
|
||||
String site = wanFiRedirectParams.getSite();
|
||||
String clientMac = wanFiRedirectParams.getClientMac();
|
||||
if (StringUtils.isBlank(site) || StringUtils.isBlank(clientMac)) {
|
||||
return error("not mac address");
|
||||
}
|
||||
ResponseEntity<OperationResponseWithoutResult> posts = omadaAuthorizedClientApi.cancelAuthClient(site, clientMac);
|
||||
return success(Objects.requireNonNull(posts.getBody()).getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户信息
|
||||
*/
|
||||
// @RequiresLogin()
|
||||
@GetMapping("/info")
|
||||
public AjaxResult info() {
|
||||
LoginUser<UUser> loginUser = SecurityUtils.getLoginUser();
|
||||
WANFiRedirectParams wanFiRedirectParams = loginUser.getWanFiRedirectParams();
|
||||
if (wanFiRedirectParams == null) {
|
||||
return error("not wanfi redirect params");
|
||||
}
|
||||
String site = wanFiRedirectParams.getSite();
|
||||
String clientMac = wanFiRedirectParams.getClientMac();
|
||||
if (StringUtils.isBlank(site) || StringUtils.isBlank(clientMac)) {
|
||||
return error("not mac address");
|
||||
}
|
||||
ResponseEntity<OperationResponseClientDetail> posts = omadaClientApi.getClientDetail(site, clientMac);
|
||||
return success(Objects.requireNonNull(posts.getBody()).getResult());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,4 +53,11 @@ mybatis:
|
||||
swagger:
|
||||
title: 系统模块接口文档
|
||||
license: Powered By wfc
|
||||
licenseUrl: https://wfc.vip
|
||||
licenseUrl: https://wfc.vip
|
||||
|
||||
# Omada 配置
|
||||
omada:
|
||||
omada-url: 'https://192.168.2.248:8043'
|
||||
omadac-id: 'f3aa6e479b94222581523710cc2c2a9d'
|
||||
client-id: '5036e77c81a74008821c694a715fe2b8'
|
||||
client-secret: '29faa06fb7f244b094377b48eb3083a7'
|
||||
|
||||
Reference in New Issue
Block a user