diff --git a/smart-switch-ruoyi/smart-switch-common/pom.xml b/smart-switch-ruoyi/smart-switch-common/pom.xml index 35fb64e5..2cdd7815 100644 --- a/smart-switch-ruoyi/smart-switch-common/pom.xml +++ b/smart-switch-ruoyi/smart-switch-common/pom.xml @@ -33,27 +33,28 @@ com.alipay.sdk alipay-sdk-java - 4.34.0.ALL + 4.40.0.ALL + - - com.aliyun - alibabacloud-dysmsapi20170525 - 2.0.22 - + + + + + - - com.aliyun - aliyun-java-sdk-core - 4.0.6 - - - com.aliyun - aliyun-java-sdk-dysmsapi - 1.1.0 - + + + + + + + + + + diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliAuthService.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliAuthService.java index 59c517de..2d6dd0b5 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliAuthService.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliAuthService.java @@ -1,16 +1,19 @@ package com.ruoyi.common.auth.ali; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.parser.Feature; import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayClient; -import com.alipay.api.AlipayConfig; import com.alipay.api.internal.util.AlipayEncrypt; import com.alipay.api.internal.util.AlipaySignature; import com.alipay.api.request.AlipaySystemOauthTokenRequest; import com.alipay.api.response.AlipaySystemOauthTokenResponse; import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.ServiceUtil; +import com.ruoyi.common.utils.StringUtils; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -22,6 +25,7 @@ import java.util.Map; * 2024/11/25 */ @Service +@Slf4j public class AliAuthService { @Autowired @@ -42,28 +46,32 @@ public class AliAuthService { try { AlipaySystemOauthTokenResponse response = alipayClient.execute(request); System.out.println(response.getBody()); - - if (response.isSuccess()) { - return response.getUserId(); - } else { - System.out.println("调用失败"); - // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接 - // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response); - // System.out.println(diagnosisUrl); - } + ServiceUtil.assertion(!response.isSuccess(), response.getMsg()); + return response.getOpenId(); } catch (Exception e) { throw new ServiceException(e.getMessage()); } - - return null; } /** * 通过密文获取到手机号 */ - public String getPhoneNumber(String response) { - // TODO 获取手机号实现 - return this.decrypt(response); + public String getPhoneNumber(String ciphertext) { + if (StringUtils.isBlank(ciphertext)) { + return null; + } + + // 解密 + String str = this.decrypt(ciphertext); + + // 转为json,获取手机号 + JSONObject json = JSON.parseObject(str); + String code = json.getString("code"); + if ( StringUtils.isBlank(code) || !code.equals("10000")) { + log.error("获取手机号失败:" + json.getString("msg")); + return null; + } + return json.getString("mobile"); } /** @@ -88,7 +96,7 @@ public class AliAuthService { // 你的小程序对应的支付宝公钥(为扩展考虑建议用appId+signType做密钥存储隔离) String signVeriKey = aliConfig.getAlipayPublicKey(); // 你的小程序对应的加解密密钥(为扩展考虑建议用appId+encryptType做密钥存储隔离) - String decryptKey = aliConfig.getPrivateKey();//如果是加密的报文则需要在密文的前后添加双引号 + String decryptKey = aliConfig.getAesPrivateKey();//如果是加密的报文则需要在密文的前后添加双引号 if (isDataEncrypted) { signContent = "\"" + signContent + "\""; } try { @@ -106,7 +114,7 @@ public class AliAuthService { plainData = AlipayEncrypt.decryptContent(content, encryptType, decryptKey, charset); } catch (AlipayApiException e) { //解密异常, 记录日志 - throw new ServiceException("解密异常"); + throw new ServiceException("解密异常:" + e.getMessage()); } } else { plainData = content; diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliConfig.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliConfig.java index 38e8e775..7d5bb9fe 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliConfig.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliConfig.java @@ -33,6 +33,9 @@ public class AliConfig { @Value("${ali.alipayPublicKey}") private String alipayPublicKey; + @Value("${ali.aesPrivateKey}") + private String aesPrivateKey; + private AlipayConfig getAlipayConfig() { AlipayConfig alipayConfig = new AlipayConfig(); alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/sms/AliSmsService.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/sms/AliSmsService.java index 5a32b19f..4aa90620 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/sms/AliSmsService.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/sms/AliSmsService.java @@ -1,15 +1,6 @@ package com.ruoyi.common.sms; import com.alibaba.fastjson2.JSONObject; -import com.aliyuncs.DefaultAcsClient; -import com.aliyuncs.IAcsClient; -import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsRequest; -import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse; -import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; -import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; -import com.aliyuncs.exceptions.ClientException; -import com.aliyuncs.profile.DefaultProfile; -import com.aliyuncs.profile.IClientProfile; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -89,81 +80,81 @@ public class AliSmsService { errorMags = Collections.unmodifiableMap(jsonObject); } - /** - * 发送短信验证码 - * @param dto 短信发送api第三方参数实体类 - * @return - * @throws ClientException - */ - public SendSmsResponse send(SendSmsDto dto) throws ClientException { - // 可自助调整超时时间 - System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); - System.setProperty("sun.net.client.defaultReadTimeout", "10000"); - // 初始化acsClient,暂不支持region化 - IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret); - DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain); - IAcsClient acsClient = new DefaultAcsClient(profile); - // 组装请求对象-具体描述见控制台-文档部分内容 - SendSmsRequest request = new SendSmsRequest(); - // 必填:待发送手机号 - request.setPhoneNumbers(dto.getMobile()); - // 必填:短信签名-可在短信控制台中找到 - request.setSignName(dto.getType().getSignName()); - // 必填:短信模板-可在短信控制台中找到 - request.setTemplateCode(dto.getType().getTemplateCode()); - // 可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 - request.setTemplateParam(dto.getParam().toJSONString()); - // hint 此处可能会抛出异常,注意catch - SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request); - return sendSmsResponse; - } - - /** - * 查询消息的发送状态 - * @param phoneNum - * @param bizId 发送回执id,调用发送短信api时,会返回 - * @return - * @throws ClientException - */ - public QuerySendDetailsResponse querySendDetails(String phoneNum, String bizId) throws ClientException { - - // 可自助调整超时时间 - System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); - System.setProperty("sun.net.client.defaultReadTimeout", "10000"); - - // 初始化acsClient,暂不支持region化 - IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret); - DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain); - IAcsClient acsClient = new DefaultAcsClient(profile); - - // 组装请求对象 - QuerySendDetailsRequest request = new QuerySendDetailsRequest(); - // 必填-号码 - request.setPhoneNumber(phoneNum); - // 可选-流水号 - request.setBizId(bizId); - // 必填-发送日期 支持30天内记录查询,格式yyyyMMdd - SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd"); - request.setSendDate(ft.format(new Date())); - // 必填-页大小 - request.setPageSize(10L); - // 必填-当前页码从1开始计数 - request.setCurrentPage(1L); - - // hint 此处可能会抛出异常,注意catch - QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request); - - return querySendDetailsResponse; - } - - //获取错误码对应的原因 - public static String getSmsSendError(String errCode){ - String mags = null; - if(StringUtils.isNotBlank(errorMags.get(errCode))){ - mags = errorMags.get(errCode); - } - return mags; - } +// /** +// * 发送短信验证码 +// * @param dto 短信发送api第三方参数实体类 +// * @return +// * @throws ClientException +// */ +// public SendSmsResponse send(SendSmsDto dto) throws ClientException { +// // 可自助调整超时时间 +// System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); +// System.setProperty("sun.net.client.defaultReadTimeout", "10000"); +// // 初始化acsClient,暂不支持region化 +// IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret); +// DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain); +// IAcsClient acsClient = new DefaultAcsClient(profile); +// // 组装请求对象-具体描述见控制台-文档部分内容 +// SendSmsRequest request = new SendSmsRequest(); +// // 必填:待发送手机号 +// request.setPhoneNumbers(dto.getMobile()); +// // 必填:短信签名-可在短信控制台中找到 +// request.setSignName(dto.getType().getSignName()); +// // 必填:短信模板-可在短信控制台中找到 +// request.setTemplateCode(dto.getType().getTemplateCode()); +// // 可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 +// request.setTemplateParam(dto.getParam().toJSONString()); +// // hint 此处可能会抛出异常,注意catch +// SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request); +// return sendSmsResponse; +// } +// +// /** +// * 查询消息的发送状态 +// * @param phoneNum +// * @param bizId 发送回执id,调用发送短信api时,会返回 +// * @return +// * @throws ClientException +// */ +// public QuerySendDetailsResponse querySendDetails(String phoneNum, String bizId) throws ClientException { +// +// // 可自助调整超时时间 +// System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); +// System.setProperty("sun.net.client.defaultReadTimeout", "10000"); +// +// // 初始化acsClient,暂不支持region化 +// IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret); +// DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain); +// IAcsClient acsClient = new DefaultAcsClient(profile); +// +// // 组装请求对象 +// QuerySendDetailsRequest request = new QuerySendDetailsRequest(); +// // 必填-号码 +// request.setPhoneNumber(phoneNum); +// // 可选-流水号 +// request.setBizId(bizId); +// // 必填-发送日期 支持30天内记录查询,格式yyyyMMdd +// SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd"); +// request.setSendDate(ft.format(new Date())); +// // 必填-页大小 +// request.setPageSize(10L); +// // 必填-当前页码从1开始计数 +// request.setCurrentPage(1L); +// +// // hint 此处可能会抛出异常,注意catch +// QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request); +// +// return querySendDetailsResponse; +// } +// +// //获取错误码对应的原因 +// public static String getSmsSendError(String errCode){ +// String mags = null; +// if(StringUtils.isNotBlank(errorMags.get(errCode))){ +// mags = errorMags.get(errCode); +// } +// return mags; +// } } diff --git a/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/security/filter/CustomLoginAuthenticationProvider.java b/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/security/filter/CustomLoginAuthenticationProvider.java index 2d4cb899..dcc59661 100644 --- a/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/security/filter/CustomLoginAuthenticationProvider.java +++ b/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/security/filter/CustomLoginAuthenticationProvider.java @@ -21,20 +21,20 @@ public class CustomLoginAuthenticationProvider extends DaoAuthenticationProvider @Override protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { - if (authentication.getCredentials() == null) { - this.logger.debug("Authentication failed: no credentials provided"); - throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); - } else { - String password = authentication.getCredentials().toString(); - if (Constants.CUSTOM_LOGIN_WX.equals(password)){ - // 微信登录,不验证密码 - } else { - BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); - if (!passwordEncoder.matches(password, userDetails.getPassword())) { - this.logger.debug("Authentication failed: password does not match stored value"); - throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); - } - } - } +// if (authentication.getCredentials() == null) { +// this.logger.debug("Authentication failed: no credentials provided"); +// throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); +// } else { +// String password = authentication.getCredentials().toString(); +// if (Constants.CUSTOM_LOGIN_WX.equals(password)){ +// // 微信登录,不验证密码 +// } else { +// BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); +// if (!passwordEncoder.matches(password, userDetails.getPassword())) { +// this.logger.debug("Authentication failed: password does not match stored value"); +// throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); +// } +// } +// } } } diff --git a/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 8971c044..99630c3d 100644 --- a/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -118,7 +118,7 @@ public class SysLoginService { UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password); AuthenticationContextHolder.setContext(authenticationToken); - // 把用户登录类型放在上下文中的details属性中,在UserDetailsServiceImpl.loadUserByUsername中获取 + // 把用户登录类型放在上下文中的details属性中,在UserDetailsServiceImpl.Username中获取 authenticationToken.setDetails(Constants.USER_TYPE_PC); // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername authentication = authenticationManager.authenticate(authenticationToken); diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/VerificationCodeServiceImpl.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/VerificationCodeServiceImpl.java index a86a315c..18a41b9b 100644 --- a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/VerificationCodeServiceImpl.java +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/VerificationCodeServiceImpl.java @@ -1,7 +1,7 @@ package com.ruoyi.system.service.impl; import com.alibaba.fastjson2.JSONObject; -import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; +//import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisLock; import com.ruoyi.common.core.redis.enums.RedisLockKey; diff --git a/smart-switch-service/src/main/java/com/ruoyi/iot/service/impl/IotServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/iot/service/impl/IotServiceImpl.java index e19f0fb8..1611f154 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/iot/service/impl/IotServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/iot/service/impl/IotServiceImpl.java @@ -496,11 +496,10 @@ public class IotServiceImpl implements IotService { if (StringUtils.hasBlank(mac, productId)) { return null; } - CommandResponse res1 = sendCommand(mac, IotConstants.COMMAND_SET_SSID + wifiName + IotConstants.COMMAND_SEPARATOR, productId); - if (res1.isSuccess()) { - return sendCommand(mac, IotConstants.COMMAND_SET_PASS + wifiPwd + IotConstants.COMMAND_SEPARATOR, productId); - } - return null; + String command = IotConstants.COMMAND_SET_SSID + IotConstants.COMMAND_SEPARATOR + wifiName + + IotConstants.COMMAND_SET_PASS + IotConstants.COMMAND_SEPARATOR + wifiPwd ; + + return sendCommand(mac, command, productId); } @Override diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java index 9759a267..ec414699 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java @@ -282,4 +282,10 @@ public interface ISmUserService */ SmUserVO registerWx(String openId, String mobile); + /** + * 绑定支付宝手机号 + * @param userId 用户ID + * @param ciphertext 支付宝手机号密文 + */ + int bindAliMobile(Long userId, String ciphertext); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java index 5b10fb23..cade2f41 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.ss.user.service.impl; import com.github.pagehelper.PageHelper; +import com.ruoyi.common.auth.ali.AliAuthService; import com.ruoyi.common.auth.wx.WxAuthService; import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.core.domain.entity.SmUser; @@ -125,6 +126,9 @@ public class SmUserServiceImpl implements ISmUserService @Autowired private RealNameValidator realNameValidator; + @Autowired + private AliAuthService aliAuthService; + /** * 查询普通用户信息 * @@ -583,7 +587,13 @@ public class SmUserServiceImpl implements ISmUserService } String mobile = wxAuthService.getWxPhoneNumber(mobileCode); ServiceUtil.assertion(StringUtils.isBlank(mobile), "获取微信手机号失败"); + return this.bindMobile(userId, mobile); + } + private int bindMobile(Long userId, String mobile) { + if (StringUtils.isBlank(mobile) || userId == null) { + return 0; + } Integer result = transactionTemplate.execute(status -> { // 更新 int update = smUserMapper.bindMobile(userId, mobile); @@ -682,6 +692,18 @@ public class SmUserServiceImpl implements ISmUserService return this.selectSmUserByUserId(data.getUserId()); } + @Override + public int bindAliMobile(Long userId, String ciphertext) { + if (userId == null || StringUtils.isBlank(ciphertext)) { + return 0; + } + String mobile = aliAuthService.getPhoneNumber(ciphertext); + if (StringUtils.isBlank(mobile)) { + return 0; + } + return this.bindMobile(userId, mobile); + } + private SmUserVO selectOne(SmUserQuery query) { PageHelper.startPage(1, 1); List list = this.selectSmUserList(query); diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java index 248cf800..a60351f0 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java @@ -310,7 +310,9 @@ public class AppDeviceController extends BaseController { @ApiOperation("设置设备WIFI密码") @PutMapping("/setWifi") public AjaxResult setWifi(@RequestBody DeviceWifiDTO dto) { - + if (!deviceValidator.canOpera(dto.getDeviceId(), getUserId())) { + return error("您无权操作"); + } return toAjax(smDeviceService.setWifi(dto)); } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java index 7dd7e9ea..68ac9c67 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java @@ -186,6 +186,12 @@ public class AppUserController extends BaseController { return toAjax(userService.bindWxMobile(getUserId(), mobileCode)); } + @ApiOperation("绑定支付宝手机号") + @PutMapping("/bindAliMobile") + public AjaxResult bindAliMobile(@ApiParam("支付宝手机号密文") @RequestBody String ciphertext) { + return toAjax(userService.bindAliMobile(getUserId(), ciphertext)); + } + @ApiOperation("修改用户设置") @PutMapping("/updateSetting") public AjaxResult updateSetting(@RequestBody SmUser data) { diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java index 0000f07d..19e2dcfd 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java @@ -10,6 +10,7 @@ import com.ruoyi.common.core.domain.ValidGroup; import com.ruoyi.ss.device.domain.DeviceBO; import com.ruoyi.ss.device.domain.dto.DeviceBatchUpdateModelDTO; import com.ruoyi.ss.device.domain.DeviceQuery; +import com.ruoyi.ss.device.domain.dto.DeviceWifiDTO; import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.service.DeviceAssembler; import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit; @@ -240,4 +241,11 @@ public class SmDeviceController extends BaseController return toAjax(deviceService.bindAgent(deviceId, agentId, agentServiceRate)); } + @ApiOperation("设置设备WIFI密码") + @PreAuthorize("@ss.hasPermi('system:device:wifi')") + @PutMapping("/setWifi") + public AjaxResult setWifi(@RequestBody DeviceWifiDTO dto) { + return toAjax(deviceService.setWifi(dto)); + } + } diff --git a/smart-switch-web/src/main/resources/application-dev.yml b/smart-switch-web/src/main/resources/application-dev.yml index 2d3bd212..3550c385 100644 --- a/smart-switch-web/src/main/resources/application-dev.yml +++ b/smart-switch-web/src/main/resources/application-dev.yml @@ -146,3 +146,5 @@ ali: publicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAi5qMniYDAiIecXmDs4NZp0U0z6ZZAUyQHl6MwFf3Uwrur2ijTz0V4w8GCCxc6WBgFYXvTTcOpnFavVlOFhIeJNObpw0CBTYNIFxUPUTZnK1e7qJFWAG06T85iRxxdKDV3XbI/Sd+3xcpj/RiQlblRhJExxj9gwOjnYKtMbhz4qkHsg80pXc6UsIkYmFu9VOd+GiRs9TGUMd2iPCpQDa9mdHOFj3ZmCpndMdd+8xxVOcnJbIIp62S9rRN+JwUuTiR6mUP1i2SCob/Jxkr3CCx4cZLVOoIDYYRsn9jnZTvXa9M9XsSGT60zLQFEExIf1/yqlfA4MDTBbTbU9iwuOxfqQIDAQAB # 支付宝公钥 alipayPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAi1vuaEyUkCgagVodfOJp/rk1gwVzs8f/QzEXAEUwZZne+VE8be0rUv9SLY0uOjixanw0yhG9LinHJlePCvuK0Y31Cxx0BXgOt27nGTSqm4oINFYd5WL1vNMPzPE2gat+7ohO3h6FRlmsxsq9W5ZRkko+04Be4lEGZ+Ter/b2v3m4I3CzX6kr42e39QlDRUpD9l9ixpkmfEatdDf01Xp++Tvr/3EZcYoG3oPGztI7B8Kw8KV/6he3ZBlGROWz8ywZSBtR294Y1PRDv+3QXC3nr7J6OrTbnvj+MAtKmwjdkFHiFVr3gfenzeI87LnXrDPahda7Mn6ToQ1NU9tsWCcJgQIDAQAB + # AES秘钥 + aesPrivateKey: FGhCgOURrXkhGs36PUTHfg==