Commit 9429ec31 authored by ysongq's avatar ysongq

no message

parent dc4d230b
......@@ -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.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
......@@ -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