小程序用户信息修改接口
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.czg.account.dto.user.userinfo;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class UserInfoPwdEditDTO {
|
||||
/**
|
||||
* 支付密码
|
||||
*/
|
||||
@NotEmpty(message = "支付密码不为空")
|
||||
private String payPwd;
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
@NotEmpty(message = "验证码不为空")
|
||||
private String code;
|
||||
}
|
||||
@@ -36,5 +36,5 @@ public interface ShopUserService extends IService<ShopUser> {
|
||||
|
||||
CzgResult<String> getCode(long userInfoId, long shopId);
|
||||
|
||||
CzgResult<Boolean> join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO);
|
||||
boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.user.userinfo.UserInfoDTO;
|
||||
import com.czg.account.dto.user.userinfo.UserInfoEditDTO;
|
||||
import com.czg.account.dto.user.userinfo.UserInfoPwdEditDTO;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
@@ -13,4 +15,10 @@ import com.mybatisflex.core.service.IService;
|
||||
public interface UserInfoService extends IService<UserInfo> {
|
||||
|
||||
UserInfoDTO getInfo(long userInfoId);
|
||||
|
||||
Boolean updateInfo(long userId, UserInfoEditDTO userInfoEditDTO);
|
||||
|
||||
Boolean updatePwd(long userId, UserInfoPwdEditDTO userInfoPwdEditDTO);
|
||||
|
||||
Boolean getCode(Long userId, String type);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.czg.utils;
|
||||
|
||||
import com.aliyun.dysmsapi20170525.Client;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 验证码工具类
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SmsUtil {
|
||||
|
||||
/**
|
||||
* 阿里云key
|
||||
*/
|
||||
@Value("${alipay.sms.key}")
|
||||
private String key;
|
||||
/**
|
||||
* 阿里云secret
|
||||
*/
|
||||
@Value("${alipay.sms.secret}")
|
||||
private String secret;
|
||||
/**
|
||||
* 短信模板id
|
||||
*/
|
||||
@Value("${alipay.sms.templateCode}")
|
||||
private String templateCode;
|
||||
|
||||
public Client createClient() throws Exception {
|
||||
Config config = new Config();
|
||||
config.accessKeyId = key;
|
||||
config.accessKeySecret = secret;
|
||||
return new Client(config);
|
||||
}
|
||||
|
||||
public void sendCode(String phone, String checkCode) {
|
||||
try {
|
||||
Client client = createClient();
|
||||
// 1.发送短信
|
||||
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest()
|
||||
.setSignName("银收客")
|
||||
.setTemplateCode(templateCode)
|
||||
.setTemplateParam("{\"code\":" + "'" + checkCode + "'" + "}")
|
||||
.setPhoneNumbers(phone);
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
log.info("短信发送请求参数: 手机号: {}, 短信模板: {}, 短信内容: {}", phone, templateCode, checkCode);
|
||||
SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||
if (sendSmsResponse.getStatusCode() != 200) {
|
||||
throw new ApiNotPrintException("短信发送失败");
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.info("发送短信失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Config config = new Config();
|
||||
config.accessKeyId = "LTAI5tPdEfYSZcqHbjCrtPRD";
|
||||
config.accessKeySecret = "DZjyHBq3nTujF0NMLxnZgsecU8ZCvy";
|
||||
Client client = new Client(config);
|
||||
// 1.发送短信
|
||||
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest()
|
||||
.setSignName("银收客")
|
||||
.setTemplateCode("SMS_244665149")
|
||||
.setTemplateParam("{\"code\":" + "'" + "23123" + "'" + "}")
|
||||
.setPhoneNumbers("19502966242");
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||
System.out.println(sendSmsResponse);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user