diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/AbstractWifiApi.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/AbstractWifiApi.java new file mode 100644 index 0000000..5c482c3 --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/AbstractWifiApi.java @@ -0,0 +1,9 @@ +package org.wfc.user.api; + +/** + * @description: API抽象层 + * @author: cyc + * @since: 2024-12-30 + */ +public abstract class AbstractWifiApi implements IWifiApi { +} diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/IWifiApi.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/IWifiApi.java new file mode 100644 index 0000000..7a308f9 --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/IWifiApi.java @@ -0,0 +1,17 @@ +package org.wfc.user.api; + +import org.wfc.user.api.omada.domain.dto.ClientRateLimitSettingDto; + +/** + * @description: API接口 + * @author: cyc + * @since: 2024-12-30 + */ +public interface IWifiApi { + + boolean authClient(String siteId, String clientMac); + + boolean cancelAuthClient(String siteId, String clientMac); + + boolean updateClientRateLimitSetting(String siteId, String clientMac, ClientRateLimitSettingDto clientRateLimitSettingDto); +} diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/config/WifiApiAutoConfig.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/config/WifiApiAutoConfig.java new file mode 100644 index 0000000..daaad36 --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/config/WifiApiAutoConfig.java @@ -0,0 +1,23 @@ +package org.wfc.user.api.config; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.wfc.user.api.IWifiApi; +import org.wfc.user.api.omada.OmadaWifiApi; + +/** + * @description: API 自动装配 + * @author: cyc + * @since: 2024-12-30 + */ +@Configuration +public class WifiApiAutoConfig { + + @ConditionalOnProperty(prefix = "wifi.api", name = "name", havingValue = "omada", matchIfMissing = true) + @Bean + public IWifiApi omadaApi() { + return new OmadaWifiApi(); + } + +} diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/AbstractOmadaWifiApi.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/AbstractOmadaWifiApi.java new file mode 100644 index 0000000..215036a --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/AbstractOmadaWifiApi.java @@ -0,0 +1,13 @@ +package org.wfc.user.api.omada; + +import org.wfc.user.api.AbstractWifiApi; + +/** + * @description: Omada API 抽象层 + * @author: cyc + * @since: 2024-12-30 + */ +public abstract class AbstractOmadaWifiApi extends AbstractWifiApi { + + +} diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/OmadaWifiApi.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/OmadaWifiApi.java new file mode 100644 index 0000000..753ef46 --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/OmadaWifiApi.java @@ -0,0 +1,43 @@ +package org.wfc.user.api.omada; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.wfc.omada.api.client.OmadaClientApi; +import org.wfc.omada.api.client.model.ClientRateLimitSetting; +import org.wfc.omada.api.client.model.OperationResponseWithoutResult; +import org.wfc.omada.api.hotspot.OmadaAuthorizedClientApi; +import org.wfc.user.api.omada.domain.convert.OmadaConvert; +import org.wfc.user.api.omada.domain.dto.ClientRateLimitSettingDto; + +/** + * @description: Omada API + * @author: cyc + * @since: 2024-12-30 + */ +public class OmadaWifiApi extends AbstractOmadaWifiApi { + + @Autowired + private OmadaAuthorizedClientApi omadaAuthorizedClientApi; + + @Autowired + private OmadaClientApi omadaClientApi; + + @Override + public boolean authClient(String siteId, String clientMac) { + omadaAuthorizedClientApi.authClient(siteId, clientMac); + return true; + } + + @Override + public boolean cancelAuthClient(String siteId, String clientMac) { + omadaAuthorizedClientApi.cancelAuthClient(siteId, clientMac); + return true; + } + + @Override + public boolean updateClientRateLimitSetting(String siteId, String clientMac, ClientRateLimitSettingDto clientRateLimitSettingDto) { + ClientRateLimitSetting clientRateLimitSetting = OmadaConvert.INSTANCE.toClientRateLimitSettingDto(clientRateLimitSettingDto); + ResponseEntity response = omadaClientApi.updateClientRateLimitSetting(siteId, clientMac, clientRateLimitSetting); + return true; + } +} diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/domain/convert/OmadaConvert.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/domain/convert/OmadaConvert.java new file mode 100644 index 0000000..975a3bf --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/domain/convert/OmadaConvert.java @@ -0,0 +1,19 @@ +package org.wfc.user.api.omada.domain.convert; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import org.wfc.omada.api.client.model.ClientRateLimitSetting; +import org.wfc.user.api.omada.domain.dto.ClientRateLimitSettingDto; + +/** + * @description: OmadaMapping + * @author: cyc + * @since: 2024-12-30 + */ +@Mapper +public interface OmadaConvert { + + OmadaConvert INSTANCE = Mappers.getMapper(OmadaConvert.class); + + ClientRateLimitSetting toClientRateLimitSettingDto(ClientRateLimitSettingDto dto); +} diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/domain/dto/ClientRateLimitSettingDto.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/domain/dto/ClientRateLimitSettingDto.java new file mode 100644 index 0000000..8a058e8 --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/domain/dto/ClientRateLimitSettingDto.java @@ -0,0 +1,130 @@ +package org.wfc.user.api.omada.domain.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.Objects; + +/** + * ClientRateLimitSetting + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-12-04T10:16:05.926+08:00[Asia/Shanghai]") + +public class ClientRateLimitSettingDto { + @JsonProperty("mode") + private Integer mode; + + @JsonProperty("rateLimitProfileId") + private String rateLimitProfileId; + + @JsonProperty("customRateLimit") + private CustomRateLimitEntityDto customRateLimit; + + public ClientRateLimitSettingDto mode(Integer mode) { + this.mode = mode; + return this; + } + + /** + * Rate limit mode should be a value as follows:
0: Custom mode. Apply the given rate limit value to the client;
1: Rate limit profile mode. Find the corresponding rate limit file with rate limit ID and apply it to the client. + * @return mode + */ + @ApiModelProperty(required = true, value = "Rate limit mode should be a value as follows:
0: Custom mode. Apply the given rate limit value to the client;
1: Rate limit profile mode. Find the corresponding rate limit file with rate limit ID and apply it to the client.") + @NotNull + + + public Integer getMode() { + return mode; + } + + public void setMode(Integer mode) { + this.mode = mode; + } + + public ClientRateLimitSettingDto rateLimitProfileId(String rateLimitProfileId) { + this.rateLimitProfileId = rateLimitProfileId; + return this; + } + + /** + * Rate limit profile ID. Required when ratelimit mode is 1 + * @return rateLimitProfileId + */ + @ApiModelProperty(value = "Rate limit profile ID. Required when ratelimit mode is 1") + + + public String getRateLimitProfileId() { + return rateLimitProfileId; + } + + public void setRateLimitProfileId(String rateLimitProfileId) { + this.rateLimitProfileId = rateLimitProfileId; + } + + public ClientRateLimitSettingDto customRateLimit(CustomRateLimitEntityDto customRateLimit) { + this.customRateLimit = customRateLimit; + return this; + } + + /** + * Get customRateLimit + * @return customRateLimit + */ + @ApiModelProperty(value = "") + + @Valid + + public CustomRateLimitEntityDto getCustomRateLimit() { + return customRateLimit; + } + + public void setCustomRateLimit(CustomRateLimitEntityDto customRateLimit) { + this.customRateLimit = customRateLimit; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClientRateLimitSettingDto clientRateLimitSetting = (ClientRateLimitSettingDto) o; + return Objects.equals(this.mode, clientRateLimitSetting.mode) && + Objects.equals(this.rateLimitProfileId, clientRateLimitSetting.rateLimitProfileId) && + Objects.equals(this.customRateLimit, clientRateLimitSetting.customRateLimit); + } + + @Override + public int hashCode() { + return Objects.hash(mode, rateLimitProfileId, customRateLimit); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClientRateLimitSetting {\n"); + + sb.append(" mode: ").append(toIndentedString(mode)).append("\n"); + sb.append(" rateLimitProfileId: ").append(toIndentedString(rateLimitProfileId)).append("\n"); + sb.append(" customRateLimit: ").append(toIndentedString(customRateLimit)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/domain/dto/CustomRateLimitEntityDto.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/domain/dto/CustomRateLimitEntityDto.java new file mode 100644 index 0000000..91f52f2 --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/api/omada/domain/dto/CustomRateLimitEntityDto.java @@ -0,0 +1,203 @@ +package org.wfc.user.api.omada.domain.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + +/** + * Custom configuration rate limit. + */ +@ApiModel(description = "Custom configuration rate limit.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-12-04T10:16:05.926+08:00[Asia/Shanghai]") + +public class CustomRateLimitEntityDto { + @JsonProperty("upEnable") + private Boolean upEnable; + + @JsonProperty("upUnit") + private Integer upUnit; + + @JsonProperty("upLimit") + private Integer upLimit; + + @JsonProperty("downEnable") + private Boolean downEnable; + + @JsonProperty("downUnit") + private Integer downUnit; + + @JsonProperty("downLimit") + private Integer downLimit; + + public CustomRateLimitEntityDto upEnable(Boolean upEnable) { + this.upEnable = upEnable; + return this; + } + + /** + * Up limit enable + * @return upEnable + */ + @ApiModelProperty(value = "Up limit enable") + + + public Boolean getUpEnable() { + return upEnable; + } + + public void setUpEnable(Boolean upEnable) { + this.upEnable = upEnable; + } + + public CustomRateLimitEntityDto upUnit(Integer upUnit) { + this.upUnit = upUnit; + return this; + } + + /** + * Up limit unit should be a value as follows: 1: Kbps; 2: Mbps + * @return upUnit + */ + @ApiModelProperty(value = "Up limit unit should be a value as follows: 1: Kbps; 2: Mbps") + + + public Integer getUpUnit() { + return upUnit; + } + + public void setUpUnit(Integer upUnit) { + this.upUnit = upUnit; + } + + public CustomRateLimitEntityDto upLimit(Integer upLimit) { + this.upLimit = upLimit; + return this; + } + + /** + * Up limit should be within the range of 1–1024. + * @return upLimit + */ + @ApiModelProperty(value = "Up limit should be within the range of 1–1024.") + + + public Integer getUpLimit() { + return upLimit; + } + + public void setUpLimit(Integer upLimit) { + this.upLimit = upLimit; + } + + public CustomRateLimitEntityDto downEnable(Boolean downEnable) { + this.downEnable = downEnable; + return this; + } + + /** + * Down limit enable + * @return downEnable + */ + @ApiModelProperty(value = "Down limit enable") + + + public Boolean getDownEnable() { + return downEnable; + } + + public void setDownEnable(Boolean downEnable) { + this.downEnable = downEnable; + } + + public CustomRateLimitEntityDto downUnit(Integer downUnit) { + this.downUnit = downUnit; + return this; + } + + /** + * Down limit unit should be a value as follows: 1: Kbps; 2: Mbps + * @return downUnit + */ + @ApiModelProperty(value = "Down limit unit should be a value as follows: 1: Kbps; 2: Mbps") + + + public Integer getDownUnit() { + return downUnit; + } + + public void setDownUnit(Integer downUnit) { + this.downUnit = downUnit; + } + + public CustomRateLimitEntityDto downLimit(Integer downLimit) { + this.downLimit = downLimit; + return this; + } + + /** + * Down limit should be within the range of 1–1024. + * @return downLimit + */ + @ApiModelProperty(value = "Down limit should be within the range of 1–1024.") + + + public Integer getDownLimit() { + return downLimit; + } + + public void setDownLimit(Integer downLimit) { + this.downLimit = downLimit; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomRateLimitEntityDto customRateLimitEntity = (CustomRateLimitEntityDto) o; + return Objects.equals(this.upEnable, customRateLimitEntity.upEnable) && + Objects.equals(this.upUnit, customRateLimitEntity.upUnit) && + Objects.equals(this.upLimit, customRateLimitEntity.upLimit) && + Objects.equals(this.downEnable, customRateLimitEntity.downEnable) && + Objects.equals(this.downUnit, customRateLimitEntity.downUnit) && + Objects.equals(this.downLimit, customRateLimitEntity.downLimit); + } + + @Override + public int hashCode() { + return Objects.hash(upEnable, upUnit, upLimit, downEnable, downUnit, downLimit); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CustomRateLimitEntity {\n"); + + sb.append(" upEnable: ").append(toIndentedString(upEnable)).append("\n"); + sb.append(" upUnit: ").append(toIndentedString(upUnit)).append("\n"); + sb.append(" upLimit: ").append(toIndentedString(upLimit)).append("\n"); + sb.append(" downEnable: ").append(toIndentedString(downEnable)).append("\n"); + sb.append(" downUnit: ").append(toIndentedString(downUnit)).append("\n"); + sb.append(" downLimit: ").append(toIndentedString(downLimit)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java index 35de9fe..abaafe3 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java @@ -14,10 +14,10 @@ import org.springframework.transaction.annotation.Transactional; import org.wfc.common.core.domain.LoginUser; import org.wfc.common.security.utils.SecurityUtils; import org.wfc.omada.api.client.OmadaClientApi; -import org.wfc.omada.api.client.model.ClientRateLimitSetting; -import org.wfc.omada.api.client.model.CustomRateLimitEntity; -import org.wfc.omada.api.hotspot.OmadaAuthorizedClientApi; +import org.wfc.user.api.IWifiApi; import org.wfc.user.api.domain.bo.UClientBo; +import org.wfc.user.api.omada.domain.dto.ClientRateLimitSettingDto; +import org.wfc.user.api.omada.domain.dto.CustomRateLimitEntityDto; import org.wfc.user.domain.UAccount; import org.wfc.user.domain.UClient; import org.wfc.user.domain.vo.UAccountDashboardVo; @@ -48,7 +48,7 @@ public class UAccountServiceImpl extends ServiceImpl i private UCdrMapper ucdrMapper; @Autowired - private OmadaAuthorizedClientApi omadaAuthorizedClientApi; + private IWifiApi wifiApi; @Autowired private UClientMapper clientMapper; @@ -87,16 +87,16 @@ public class UAccountServiceImpl extends ServiceImpl i .in(UClient::getUserId, userIds)); for (UClient client : clients) { try { - omadaAuthorizedClientApi.cancelAuthClient(client.getSiteId(), client.getClientMac()); + wifiApi.cancelAuthClient(client.getSiteId(), client.getClientMac()); // 取消带宽限速 - ClientRateLimitSetting clientRateLimitSetting = new ClientRateLimitSetting(); + ClientRateLimitSettingDto clientRateLimitSetting = new ClientRateLimitSettingDto(); clientRateLimitSetting.setMode(0); - CustomRateLimitEntity customRateLimitEntity = new CustomRateLimitEntity(); - customRateLimitEntity.setDownEnable(false); - customRateLimitEntity.setUpEnable(false); - clientRateLimitSetting.setCustomRateLimit(customRateLimitEntity); - omadaClientApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting); + CustomRateLimitEntityDto customRateLimitEntityDto = new CustomRateLimitEntityDto(); + customRateLimitEntityDto.setDownEnable(false); + customRateLimitEntityDto.setUpEnable(false); + clientRateLimitSetting.setCustomRateLimit(customRateLimitEntityDto); + wifiApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting); } catch (Exception e) { log.info("unAuth error: {}", e.getMessage()); } @@ -114,21 +114,21 @@ public class UAccountServiceImpl extends ServiceImpl i if (account.getStartTime().before(current) && account.getEndTime().after(current) && (!account.getTrafficEnable() || account.getTrafficUsed() <= account.getTraffic()) && (!account.getDurationEnable() || account.getDurationUsed() <= account.getDuration())) { - omadaAuthorizedClientApi.authClient(client.getSiteId(), client.getClientMac()); + wifiApi.authClient(client.getSiteId(), client.getClientMac()); // 带宽限速 if (account.getRateLimitEnable()) { - ClientRateLimitSetting clientRateLimitSetting = new ClientRateLimitSetting(); + ClientRateLimitSettingDto clientRateLimitSetting = new ClientRateLimitSettingDto(); clientRateLimitSetting.setMode(0); - CustomRateLimitEntity customRateLimitEntity = new CustomRateLimitEntity(); - customRateLimitEntity.setDownEnable(account.getDownLimitEnable()); - customRateLimitEntity.setDownLimit(account.getDownLimit() == null ? 0 : account.getDownLimit().intValue()); - customRateLimitEntity.setDownUnit(1); - customRateLimitEntity.setUpEnable(account.getUpLimitEnable()); - customRateLimitEntity.setUpLimit(account.getUpLimit() == null ? 0 : account.getUpLimit().intValue()); - customRateLimitEntity.setUpUnit(1); - clientRateLimitSetting.setCustomRateLimit(customRateLimitEntity); - omadaClientApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting); + CustomRateLimitEntityDto customRateLimitEntityDto = new CustomRateLimitEntityDto(); + customRateLimitEntityDto.setDownEnable(account.getDownLimitEnable()); + customRateLimitEntityDto.setDownLimit(account.getDownLimit() == null ? 0 : account.getDownLimit().intValue()); + customRateLimitEntityDto.setDownUnit(1); + customRateLimitEntityDto.setUpEnable(account.getUpLimitEnable()); + customRateLimitEntityDto.setUpLimit(account.getUpLimit() == null ? 0 : account.getUpLimit().intValue()); + customRateLimitEntityDto.setUpUnit(1); + clientRateLimitSetting.setCustomRateLimit(customRateLimitEntityDto); + wifiApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting); } } diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java index 06ca9e5..2b82aff 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java @@ -11,10 +11,9 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.wfc.common.security.utils.SecurityUtils; -import org.wfc.omada.api.client.OmadaClientApi; -import org.wfc.omada.api.client.model.ClientRateLimitSetting; -import org.wfc.omada.api.client.model.CustomRateLimitEntity; -import org.wfc.omada.api.hotspot.OmadaAuthorizedClientApi; +import org.wfc.user.api.IWifiApi; +import org.wfc.user.api.omada.domain.dto.ClientRateLimitSettingDto; +import org.wfc.user.api.omada.domain.dto.CustomRateLimitEntityDto; import org.wfc.user.domain.UAccount; import org.wfc.user.domain.UClient; import org.wfc.user.domain.UOrder; @@ -59,10 +58,7 @@ public class UOrderServiceImpl extends ServiceImpl impleme private IUClientService clientService; @Autowired - private OmadaAuthorizedClientApi omadaAuthorizedClientApi; - - @Autowired - private OmadaClientApi omadaClientApi; + private IWifiApi wifiApi; public void paySuccess(Long orderId) { // 支付成功回调(预留) @@ -100,21 +96,21 @@ public class UOrderServiceImpl extends ServiceImpl impleme List clients = clientService.list(Wrappers.lambdaQuery().eq(UClient::getUserId, order.getUserId())); for (UClient client : clients) { if (StrUtil.isNotBlank(client.getSiteId())) { - omadaAuthorizedClientApi.authClient(client.getSiteId(), client.getClientMac()); + wifiApi.authClient(client.getSiteId(), client.getClientMac()); // 带宽限速 if (account.getRateLimitEnable()) { - ClientRateLimitSetting clientRateLimitSetting = new ClientRateLimitSetting(); + ClientRateLimitSettingDto clientRateLimitSetting = new ClientRateLimitSettingDto(); clientRateLimitSetting.setMode(0); - CustomRateLimitEntity customRateLimitEntity = new CustomRateLimitEntity(); - customRateLimitEntity.setDownEnable(account.getDownLimitEnable()); - customRateLimitEntity.setDownLimit(account.getDownLimit() == null ? 0 : account.getDownLimit().intValue()); - customRateLimitEntity.setDownUnit(1); - customRateLimitEntity.setUpEnable(account.getUpLimitEnable()); - customRateLimitEntity.setUpLimit(account.getUpLimit() == null ? 0 : account.getUpLimit().intValue()); - customRateLimitEntity.setUpUnit(1); - clientRateLimitSetting.setCustomRateLimit(customRateLimitEntity); - omadaClientApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting); + CustomRateLimitEntityDto customRateLimitEntityDto = new CustomRateLimitEntityDto(); + customRateLimitEntityDto.setDownEnable(account.getDownLimitEnable()); + customRateLimitEntityDto.setDownLimit(account.getDownLimit() == null ? 0 : account.getDownLimit().intValue()); + customRateLimitEntityDto.setDownUnit(1); + customRateLimitEntityDto.setUpEnable(account.getUpLimitEnable()); + customRateLimitEntityDto.setUpLimit(account.getUpLimit() == null ? 0 : account.getUpLimit().intValue()); + customRateLimitEntityDto.setUpUnit(1); + clientRateLimitSetting.setCustomRateLimit(customRateLimitEntityDto); + wifiApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting); } } }