Commit fc6e1d4e authored by machengbo's avatar machengbo

commit

parents faeff6ae 8684ae6f
package com.jz.dm.mall.moduls.controller.customer;
import com.jz.common.constant.RedisMessageConstant;
import com.jz.common.utils.Result;
import com.jz.common.utils.SMSUtils;
import com.jz.common.utils.ValidateCodeUtils;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
/**
* @ClassName: 短信发送接口
* @Author: Carl
* @Date: 2020/12/2
* @Version:
*/
@RestController
@RequestMapping("/validateCode")
@Api(tags = "短信发送api")
public class ValidateCodeController {
@Autowired
private JedisPool jedisPool;
/**
* 注册时发送的验证码
* @param telephone
* @return
*/
@PostMapping("/send4Login")
public Result send4Login(String telephone) {
// 查询redis里是否存在该手机号
Jedis jedis = jedisPool.getResource();
String key = RedisMessageConstant.SENDTYPE_LOGIN + "_" + telephone;
String codeInRedis = jedis.get(key);
if (codeInRedis != null && !codeInRedis.equals("")) {
// redis中的数据还未过期
return new Result(false, "验证码已发送,请注意查收!");
}else {
Integer code = ValidateCodeUtils.generateValidateCode(6);
try {
SMSUtils.sendShortMessage(SMSUtils.VALIDATE_CODE, telephone, code.toString());
} catch (Exception e) {
e.printStackTrace();
}
jedis.setex(key,5*60,code+"");
return new Result(true, "验证码发送成功!");
}
}
/**
* 修改密码发送验证码
* @param telephone
* @return
*/
@PostMapping("/send4Code")
public Result send4Code(String telephone) {
// 查询redis里是否存在该手机号
Jedis jedis = jedisPool.getResource();
String key = RedisMessageConstant.SENDTYPE_GETPWD + "_" + telephone;
String codeInRedis = jedis.get(key);
if (codeInRedis != null && !codeInRedis.equals("")) {
// redis中的数据还未过期
return new Result(false, "验证码已发送,请注意查收!");
}else {
Integer code = ValidateCodeUtils.generateValidateCode(6);
try {
SMSUtils.sendShortMessage(SMSUtils.VALIDATE_CODE, telephone, code.toString());
} catch (Exception e) {
e.printStackTrace();
}
jedis.setex(key,5*60,code+"");
return new Result(true, "验证码发送成功!");
}
}
}
......@@ -37,7 +37,7 @@ public class FinanceTradeFlowController extends BaseController {
@GetMapping(value = "/getAccountMoney")
@ApiOperation(value = "充值----获取账户余额", notes = "获取账户余额")
public Result<OrderDto> getAccountMoney(HttpServletRequest req) throws Exception {
//
return new Result<>();
}
......
package com.jz.dm.mall.moduls.mapper;
import com.jz.common.base.BaseMapper;
import com.jz.dm.mall.moduls.entity.FinanceCustomerAssets;
/**
......
package com.jz.dm.mall.moduls.service;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import java.util.Map;
import com.jz.common.entity.MallCustomer;
/**
* 商城用户(TMallCustomer)表服务接口
......
package com.jz.dm.mall.moduls.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.common.entity.MallCustomer;
import com.jz.dm.mall.moduls.mapper.MallCustomerDao;
import com.jz.dm.mall.moduls.service.MallCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 商城用户(TMallCustomer)表服务实现类
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment