diff --git a/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/constant/WifiConstants.java b/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/constant/WifiConstants.java new file mode 100644 index 0000000..d2dbc0b --- /dev/null +++ b/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/constant/WifiConstants.java @@ -0,0 +1,14 @@ +package org.wfc.common.core.constant; + +/** + * @description: wifi 常量 + * @author: cyc + * @since: 2025-02-07 + */ +public class WifiConstants { + + /** + * 密码最大错误次数 + */ + public final static int ERROR_CODE_SUCCESS = 0; +} diff --git a/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/exception/OmadaException.java b/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/exception/OmadaException.java new file mode 100644 index 0000000..1aca628 --- /dev/null +++ b/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/exception/OmadaException.java @@ -0,0 +1,20 @@ +package org.wfc.common.core.exception; + +import org.wfc.common.core.exception.wifi.WifiException; + +/** + * @description: omada 异常 + * @author: cyc + * @since: 2025-02-07 + */ +public class OmadaException extends WifiException { + private static final long serialVersionUID = 1L; + + public OmadaException() { + super("wifi.omada.api.error"); + } + + public OmadaException(String msg) { + super(msg); + } +} diff --git a/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/exception/wifi/WifiException.java b/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/exception/wifi/WifiException.java new file mode 100644 index 0000000..276b73e --- /dev/null +++ b/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/exception/wifi/WifiException.java @@ -0,0 +1,16 @@ +package org.wfc.common.core.exception.wifi; + +import org.wfc.common.core.exception.base.BaseException; + +/** + * @description: wifi 异常 + * @author: cyc + * @since: 2025-02-07 + */ +public class WifiException extends BaseException { + private static final long serialVersionUID = 1L; + + public WifiException(String code, Object... args) { + super("user", code, args, null); + } +} diff --git a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties index 7b38880..7987290 100644 --- a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties +++ b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties @@ -64,6 +64,7 @@ tenant.number.not.blank=Tenant number cannot be blank tenant.not.exists=Sorry, your tenant does not exist. Please contact the administrator tenant.blocked=Sorry, your tenant is disabled. Please contact the administrator tenant.expired=Sorry, your tenant has expired. Please contact the administrator. +wifi.omada.api.error=Omada API connection failed ## wfc-modules-user user.kyc.birthdate.not.blank=Date of birth cannot be blank user.kyc.birthdate.not.valid=Date of birth format error diff --git a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties index 667cf35..78aa675 100644 --- a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties +++ b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties @@ -64,6 +64,7 @@ tenant.number.not.blank=租户编号不能为空 tenant.not.exists=对不起, 您的租户不存在,请联系管理员 tenant.blocked=对不起,您的租户已禁用,请联系管理员 tenant.expired=对不起,您的租户已过期,请联系管理员 +wifi.omada.api.error=Omada API 连接失败 ## wfc-modules-user user.kyc.birthdate.not.blank=出生日期不能为空 user.kyc.birthdate.not.valid=出生日期格式错误 diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysDashboardController.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysDashboardController.java index 9d2d60c..c6598d7 100644 --- a/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysDashboardController.java +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysDashboardController.java @@ -24,9 +24,8 @@ public class SysDashboardController extends BaseController { @GetMapping("/page") - public TableDataInfo page(@RequestParam(value = "searchKey", required = false) String searchKey) { - startPage(); - return sysDashboardService.getSiteList(searchKey); + public TableDataInfo page(@RequestParam(value = "searchKey", required = false) String searchKey, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) { + return sysDashboardService.getSiteList(searchKey, pageNum, pageSize); } @GetMapping("/overview") diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/ISysDashboardService.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/ISysDashboardService.java index 2eebcc6..718febd 100644 --- a/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/ISysDashboardService.java +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/ISysDashboardService.java @@ -10,7 +10,7 @@ import org.wfc.system.domain.vo.SysDashboardVo; */ public interface ISysDashboardService { - TableDataInfo getSiteList(String searchKey); + TableDataInfo getSiteList(String searchKey, Integer pageNum, Integer pageSize); SysDashboardVo overview(); } diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/SysDashboardServiceImpl.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/SysDashboardServiceImpl.java index f6b54df..4191dc9 100644 --- a/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/SysDashboardServiceImpl.java +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/SysDashboardServiceImpl.java @@ -2,7 +2,6 @@ package org.wfc.system.service.impl; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.github.pagehelper.PageHelper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -10,7 +9,9 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.wfc.common.core.constant.CacheConstants; import org.wfc.common.core.constant.HttpStatus; +import org.wfc.common.core.constant.WifiConstants; import org.wfc.common.core.domain.LoginUser; +import org.wfc.common.core.exception.OmadaException; import org.wfc.common.core.web.page.TableDataInfo; import org.wfc.common.redis.service.RedisService; import org.wfc.omada.api.monitor.OmadaDashboardApi; @@ -28,7 +29,6 @@ import org.wfc.system.service.ISysDashboardService; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; /** @@ -52,12 +52,13 @@ public class SysDashboardServiceImpl implements ISysDashboardService { private UUserMapper userMapper; @Override - public TableDataInfo getSiteList(String searchKey) { - ResponseEntity siteList = omadaSiteApi.getSiteList(PageHelper.getLocalPage().getPageNum(), PageHelper.getLocalPage().getPageSize(), searchKey); - if (siteList.getBody() == null) { - return getDataTable(Collections.emptyList(), 0L); + public TableDataInfo getSiteList(String searchKey, Integer pageNum, Integer pageSize) { + ResponseEntity siteList = omadaSiteApi.getSiteList(pageNum, pageSize, searchKey); + if (siteList.getBody() == null || siteList.getBody().getErrorCode() != WifiConstants.ERROR_CODE_SUCCESS) { + log.error("Omada error msg: {}",siteList.getBody().getMsg()); + throw new OmadaException(); } - log.info("Omada reulst msg: {}",siteList.getBody().getMsg()); + List sites = siteList.getBody().getResult().getData(); List siteVos = new ArrayList<>(); for (SiteSummaryInfo site : sites) { @@ -77,9 +78,11 @@ public class SysDashboardServiceImpl implements ISysDashboardService { public SysDashboardVo overview() { ResponseEntity siteList = omadaSiteApi.getSiteList(1, 1000); SysDashboardVo sysDashboardVo = new SysDashboardVo(); - if (siteList.getBody() == null) { - return sysDashboardVo; + if (siteList.getBody() == null || siteList.getBody().getErrorCode() != WifiConstants.ERROR_CODE_SUCCESS) { + log.error("Omada error msg: {}",siteList.getBody().getMsg()); + throw new OmadaException(); } + List sites = siteList.getBody().getResult().getData(); List dashboardOverviews = new ArrayList<>();