Commit 72eb7018 authored by zhangc's avatar zhangc

Merge branch 'dm_dev' of gitlab.ioubuy.cn:yaobenzhang/dm_project into dm_dev

parents e7e3ddfa c937a079
......@@ -62,5 +62,17 @@
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.jz.common.base;
public class BaseController {
/*public User getCurrentUser(){
User user = (User) SecurityUtils.getSubject().getPrincipals().iterator().next();
return user;
}
public Integer getCurrentUserId(){
return getCurrentUser().getUserId();
}*/
}
package com.itheima.health.constant;
package com.jz.common.constant;
public interface RedisMessageConstant {
static final String SENDTYPE_ORDER = "001";//用于缓存体检预约时发送的验证码
static final String SENDTYPE_LOGIN = "002";//用于缓存手机号快速登录时发送的验证码
static final String SENDTYPE_GETPWD = "003";//用于缓存找回密码时发送的验证码
static final String SENDTYPE_GETPWD = "001";//用于缓存找回密码时发送的验证码
static final String SENDTYPE_LOGIN = "002"; // 用于缓存注册用户时发送的验证码
}
\ No newline at end of file
......@@ -105,6 +105,11 @@ public class Result<T> implements Serializable {
this.timestamp = timestamp;
}
public Result(boolean success, String message) {
this.success = success;
this.message = message;
}
public Result(boolean success, String message, Integer code) {
this.success = success;
this.message = message;
......
package com.jz.common.utils;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
/**
* @ClassName:
* @ClassName: 短信发送工具类
* @Author: Carl
* @Date: 2020/12/1
* @Version:
*/
public class SMSUtils {
public static final String VALIDATE_CODE = "SMS_198677589";//发送短信验证码 验证码签名, 改成你的
public static final String ORDER_NOTICE = "SMS_159771588";//成功通知, 通知类的模板(需要通用的签名)
private static final String SIGN_NAEM = "ysongq商城";// 短信的签名
private static final String PARAMETER_NAME="code"; // 短信模板内容中的参数名
private static final String ACCESS_KEY="LTAI4GAnKS1Gj2NwDepvyBuB"; //AccessKey ID
private static final String SECRET_KEY="BIHOQP6muPtCz9YzrSQpSj0dJjZIET"; //AccessKey Secret
public static void main(String[] args) throws ClientException {
SMSUtils.sendShortMessage("VALIDATE_CODE","18279617424","666666");
}
/**
* 发送短信
* @param templateCode 验证码的模板code
* @param phoneNumbers 接收的手机号码
* @param param 验证码
* @throws ClientException
*/
public static void sendShortMessage(String templateCode,String phoneNumbers,String param) throws ClientException {
//设置超时时间-可自行调整
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
//初始化ascClient需要的几个参数
final String product = "Dysmsapi";//短信API产品名称(短信产品名固定,无需修改)
final String domain = "dysmsapi.aliyuncs.com";//短信API产品域名(接口地址固定,无需修改)
//替换成你的AK
final String accessKeyId = ACCESS_KEY;//你的accessKeyId,参考本文档步骤2
final String accessKeySecret = SECRET_KEY;//你的accessKeySecret,参考本文档步骤2
//初始化ascClient,暂时不支持多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();
//使用post提交
request.setMethod(MethodType.POST);
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为国际区号+号码,如“85200000000”
request.setPhoneNumbers("1500000000");
//必填:短信签名-可在短信控制台中找到
request.setSignName("云通信");
//必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版
request.setTemplateCode("SMS_1000000");
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
//友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败
//参考:request.setTemplateParam("{\"变量1\":\"值1\",\"变量2\":\"值2\",\"变量3\":\"值3\"}")
request.setTemplateParam("{\"name\":\"Tom\", \"code\":\"123\"}");
//可选-上行短信扩展码(扩展码字段控制在7位或以下,无特殊需求用户请忽略此字段)
//request.setSmsUpExtendCode("90997");
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
request.setOutId("yourOutId");
//请求失败这里会抛ClientException异常
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
if(sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) {
//请求成功
}
}
}
package com.jz.common.utils;
import java.util.Random;
/**
* @ClassName:
* @ClassName: 随机生成验证码工具类
* @Author: Carl
* @Date: 2020/12/1
* @Version:
*/
public class ValidateCodeUtils {
/**
* 随机生成验证码
* @param length 长度为4位或者6位
* @return
*/
public static Integer generateValidateCode(int length){
Integer code =null;
if(length == 4){
code = new Random().nextInt(9999);//生成随机数,最大为9999
if(code < 1000){
code = code + 1000;//保证随机数为4位数字
}
}else if(length == 6){
code = new Random().nextInt(999999);//生成随机数,最大为999999
if(code < 100000){
code = code + 100000;//保证随机数为6位数字
}
}else{
throw new RuntimeException("只能生成4位或6位数字验证码");
}
return code;
}
/**
* 随机生成指定长度字符串验证码
* @param length 长度
* @return
*/
public static String generateValidateCode4String(int length){
Random rdm = new Random();
String hash1 = Integer.toHexString(rdm.nextInt());
String capstr = hash1.substring(0, length);
return capstr;
}
}
......@@ -125,6 +125,6 @@
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencies>
</project>
\ No newline at end of file
package com.jz.dm.mall.moduls.controller.customer;
import com.jz.common.base.BaseController;
import com.jz.common.constant.RedisMessageConstant;
import com.jz.common.entity.MallCustomer;
import com.jz.common.entity.SysUser;
import com.jz.common.utils.Result;
import com.jz.common.utils.StatusCode;
import com.jz.dm.mall.moduls.service.MallCustomerService;
import com.jz.manage.moduls.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.StringUtils;
......
......@@ -2,6 +2,7 @@ package com.jz.dm.mall.moduls.controller.order.bean;
import io.swagger.annotations.ApiModel;
import java.math.BigDecimal;
import java.util.Date;
/**
......@@ -33,7 +34,7 @@ public class OrderDto {
/**
* 订单金额
*/
private Double orderMoney;
private BigDecimal orderMoney;
/**
* 订单时间
*/
......@@ -45,7 +46,7 @@ public class OrderDto {
/**
* 支付金额
*/
private Double paymentMoney;
private BigDecimal paymentMoney;
/**
* 支付时间
*/
......@@ -57,7 +58,7 @@ public class OrderDto {
/**
* 优惠金额
*/
private Double districtMoney;
private BigDecimal districtMoney;
/**
* 购买方式:01年,02季,03月,04次(服务类型)
*/
......@@ -148,11 +149,11 @@ public class OrderDto {
this.orderStatus = orderStatus;
}
public Double getOrderMoney() {
public BigDecimal getOrderMoney() {
return orderMoney;
}
public void setOrderMoney(Double orderMoney) {
public void setOrderMoney(BigDecimal orderMoney) {
this.orderMoney = orderMoney;
}
......@@ -172,11 +173,11 @@ public class OrderDto {
this.sellerId = sellerId;
}
public Double getPaymentMoney() {
public BigDecimal getPaymentMoney() {
return paymentMoney;
}
public void setPaymentMoney(Double paymentMoney) {
public void setPaymentMoney(BigDecimal paymentMoney) {
this.paymentMoney = paymentMoney;
}
......@@ -196,11 +197,11 @@ public class OrderDto {
this.paymentMethod = paymentMethod;
}
public Double getDistrictMoney() {
public BigDecimal getDistrictMoney() {
return districtMoney;
}
public void setDistrictMoney(Double districtMoney) {
public void setDistrictMoney(BigDecimal districtMoney) {
this.districtMoney = districtMoney;
}
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
......@@ -35,7 +36,7 @@ public class Order implements Serializable {
/**
* 订单金额
*/
private Double orderMoney;
private BigDecimal orderMoney;
/**
* 订单时间
*/
......@@ -47,7 +48,7 @@ public class Order implements Serializable {
/**
* 支付金额
*/
private Double paymentMoney;
private BigDecimal paymentMoney;
/**
* 支付时间
*/
......@@ -59,7 +60,7 @@ public class Order implements Serializable {
/**
* 优惠金额
*/
private Double districtMoney;
private BigDecimal districtMoney;
/**
* 购买方式:01年,02季,03月,04次(服务类型)
*/
......@@ -142,11 +143,11 @@ public class Order implements Serializable {
this.orderStatus = orderStatus;
}
public Double getOrderMoney() {
public BigDecimal getOrderMoney() {
return orderMoney;
}
public void setOrderMoney(Double orderMoney) {
public void setOrderMoney(BigDecimal orderMoney) {
this.orderMoney = orderMoney;
}
......@@ -166,11 +167,11 @@ public class Order implements Serializable {
this.sellerId = sellerId;
}
public Double getPaymentMoney() {
public BigDecimal getPaymentMoney() {
return paymentMoney;
}
public void setPaymentMoney(Double paymentMoney) {
public void setPaymentMoney(BigDecimal paymentMoney) {
this.paymentMoney = paymentMoney;
}
......@@ -190,11 +191,11 @@ public class Order implements Serializable {
this.paymentMethod = paymentMethod;
}
public Double getDistrictMoney() {
public BigDecimal getDistrictMoney() {
return districtMoney;
}
public void setDistrictMoney(Double districtMoney) {
public void setDistrictMoney(BigDecimal districtMoney) {
this.districtMoney = districtMoney;
}
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
......@@ -31,7 +32,7 @@ public class OrderPayment implements Serializable {
/**
* 支付金额
*/
private Double paymentMoney;
private BigDecimal paymentMoney;
/**
* 支付时间
*/
......@@ -43,7 +44,7 @@ public class OrderPayment implements Serializable {
/**
* 优惠金额
*/
private Double districtMoney;
private BigDecimal districtMoney;
/**
* 支付状态
*/
......@@ -86,11 +87,11 @@ public class OrderPayment implements Serializable {
this.sellerId = sellerId;
}
public Double getPaymentMoney() {
public BigDecimal getPaymentMoney() {
return paymentMoney;
}
public void setPaymentMoney(Double paymentMoney) {
public void setPaymentMoney(BigDecimal paymentMoney) {
this.paymentMoney = paymentMoney;
}
......@@ -110,11 +111,11 @@ public class OrderPayment implements Serializable {
this.paymentMethod = paymentMethod;
}
public Double getDistrictMoney() {
public BigDecimal getDistrictMoney() {
return districtMoney;
}
public void setDistrictMoney(Double districtMoney) {
public void setDistrictMoney(BigDecimal districtMoney) {
this.districtMoney = districtMoney;
}
......
......@@ -141,6 +141,17 @@
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!--阿里云服务器短信平台-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
......
package com.jz.manage.moduls.controller.sys;
import com.jz.common.constant.RedisMessageConstant;
import com.jz.common.entity.SysUser;
import com.jz.common.utils.Result;
import com.jz.common.utils.StatusCode;
import com.jz.manage.moduls.controller.BaseController;
import com.jz.manage.moduls.service.SysUserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.security.auth.Subject;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
@RestController
@RequestMapping("/sys")
@Api(tags = "用户登录api")
public class LoginController extends BaseController {
@Autowired
private SysUserService sysUserService;
@Autowired
private RedisTemplate redisTemplate;
/**
* 登录功能
* @param account 账号
......@@ -34,18 +45,34 @@ public class LoginController extends BaseController {
return new Result<>(false, "用户名或密码错误!", StatusCode.ERROR);
}
// /**
// * 手机号码校验
// * @param paramMap
// * @param res
// * @return
// */
// @PostMapping(value = "/check")
// public Result loginCheck(@RequestBody Map<String, String> paramMap, HttpServletResponse res) {
// // 获取手机号码
// String telephone = paramMap.get("telephone");
//
// }
/**
* 手机号码校验
* @param paramMap
* @param res
* @return
*/
@PostMapping(value = "/check")
public Result loginCheck(@RequestBody Map<String, String> paramMap, HttpServletResponse res) {
// 获取手机号码
String telephone = paramMap.get("telephone");
String key = RedisMessageConstant.SENDTYPE_LOGIN + "_" + telephone;
// 获取redis中key对应的值
String codeInRedis = (String) redisTemplate.opsForValue().get(key);
if (StringUtils.isEmpty(codeInRedis)) {
return new Result(false, "请重新获取验证码!", StatusCode.ERROR);
}
// 判断验证码是否一致
if (!codeInRedis.equals(paramMap.get("validateCode"))) {
return new Result(false, "验证码不正确!", StatusCode.ERROR);
}
// 删除redis的验证码
redisTemplate.delete(key);
return new Result(true, "验证码正确!", StatusCode.OK);
}
/*@ApiOperation("登录接口")
@RequestMapping(value = "/login", method = RequestMethod.POST)
public Result<JSONObject> login(@RequestBody SysUser sysUser, HttpServletRequest request) throws Exception {
......
package com.jz.manage.moduls.controller.sys;
import com.jz.common.utils.Result;
import com.jz.manage.moduls.controller.BaseController;
import com.jz.manage.moduls.entity.SysUser;
import com.jz.manage.moduls.service.SysUserService;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -14,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequestMapping("sysUser")
@Api(tags = "用户功能api")
public class SysUserController extends BaseController {
/**
* 服务对象
......@@ -21,5 +27,10 @@ public class SysUserController extends BaseController {
@Autowired
private SysUserService sysUserService;
// @PostMapping("/register")
// public Result saveSysUser(@RequestBody SysUser sysUser) throws Exception{
// if (sysUser == null) {
// return new Result(false, "注册信息失败!");
// }
// }
}
\ No newline at end of file
package com.jz.dm.mall.moduls.controller.customer;
package com.jz.manage.moduls.controller.sys;
import com.aliyuncs.exceptions.ClientException;
import com.jz.common.constant.RedisMessageConstant;
......
......@@ -17,4 +17,6 @@ public interface SysUserDao extends BaseMapper<SysUser> {
List<Map> getUserRoleByAccount(@Param("account") String account);
// void saveSysUser(SysUser)
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ import java.util.Map;
public interface SysUserService {
/*
* 通过用户帐进行查询
* 通过用户帐进行查询
* */
SysUser selectByUsername(String account);
......
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