2
0

fix: 修复仪表盘分页

This commit is contained in:
caiyuchao
2025-02-08 11:19:25 +08:00
parent 804b25a875
commit faa8e0ad5e
8 changed files with 67 additions and 13 deletions

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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=出生日期格式错误

View File

@@ -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")

View File

@@ -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();
}

View File

@@ -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<OperationResponseGridVoSiteSummaryInfo> 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<OperationResponseGridVoSiteSummaryInfo> 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<SiteSummaryInfo> sites = siteList.getBody().getResult().getData();
List<SysDashboardSiteVo> siteVos = new ArrayList<>();
for (SiteSummaryInfo site : sites) {
@@ -77,9 +78,11 @@ public class SysDashboardServiceImpl implements ISysDashboardService {
public SysDashboardVo overview() {
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> 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<SiteSummaryInfo> sites = siteList.getBody().getResult().getData();
List<GetDashboardOverview> dashboardOverviews = new ArrayList<>();