app 用户登录 用户注册 退出
redis 5库 token的key为ONLINE_APP_USER:用户id app端 登录校验 code -4 账号过期 app端 版本是否更新校验 redis 5库 版本是否更新的key为LDBL_APP_VERSION:android/ios:版本号 全局跨域放行处理 经纬度计算距离工作类
This commit is contained in:
@@ -1,36 +1,35 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbMerchantAccountMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.AuthUserDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.OnlineUserDto;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||
import com.chaozhanggui.system.cashierservice.service.LoginService;
|
||||
import com.chaozhanggui.system.cashierservice.service.OnlineUserService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.IpUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.MD5Utils;
|
||||
import com.chaozhanggui.system.cashierservice.util.StringUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||
import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@@ -58,6 +57,8 @@ public class LoginContoller {
|
||||
|
||||
@Resource
|
||||
TbMerchantAccountMapper merchantAccountMapper;
|
||||
@Autowired
|
||||
RedisUtil redisUtil;
|
||||
|
||||
|
||||
@RequestMapping("/wx/business/login")
|
||||
@@ -223,35 +224,37 @@ public class LoginContoller {
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param nickName 用户昵称
|
||||
* @param password 密码
|
||||
* @param code 验证码
|
||||
* phone 手机号
|
||||
* nickName 用户昵称
|
||||
* password 密码
|
||||
* code 验证码
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("register")
|
||||
public Result register(@RequestBody TbUserInfo userInfo) {
|
||||
boolean tf = loginService.validate(userInfo.getCode(), userInfo.getTelephone());
|
||||
if (tf) {
|
||||
return loginService.register(userInfo.getTelephone(), userInfo.getPassword(), userInfo.getNickName());
|
||||
} else {
|
||||
return Result.fail("验证码校验失败");
|
||||
}
|
||||
}
|
||||
// @PostMapping("register")
|
||||
// public Result register(@RequestBody TbUserInfo userInfo) {
|
||||
// boolean tf = loginService.validate(userInfo.getCode(), userInfo.getTelephone());
|
||||
// if (tf) {
|
||||
// return loginService.register(userInfo.getTelephone(), userInfo.getPassword(), userInfo.getNickName());
|
||||
// } else {
|
||||
// return Result.fail("验证码校验失败");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* App登录用户端的请求接口
|
||||
*
|
||||
* @param username 手机号
|
||||
* @param password 密码登录时使用
|
||||
* @param code 验证码登录时使用
|
||||
* App登录用户端的请求接口 登录即注册
|
||||
* 查看 {@link com.chaozhanggui.system.cashierservice.entity.dto.AuthUserDto}
|
||||
* username 手机号
|
||||
* password 密码登录时使用
|
||||
* code 验证码登录时使用
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/app/login")
|
||||
public Result applogin(@RequestBody AuthUserDto authUserDto) {
|
||||
if (ObjectUtil.isNull(authUserDto.getCode())) {
|
||||
if(StringUtils.isBlank(authUserDto.getPassword())){
|
||||
return Result.fail("请输入密码,或使用验证码登录");
|
||||
}
|
||||
//验证密码
|
||||
String mdPasswordString = MD5Utils.MD5Encode(authUserDto.getPassword(), "utf-8");
|
||||
return loginService.appLogin(authUserDto.getUsername(), mdPasswordString);
|
||||
@@ -266,4 +269,15 @@ public class LoginContoller {
|
||||
}
|
||||
|
||||
|
||||
//退出登录的接口
|
||||
@PostMapping("/loginOut")
|
||||
public Result loginOut(HttpServletRequest request) {
|
||||
String token = request.getHeader("token");
|
||||
//获取当前登录人的账号
|
||||
String userId = TokenUtil.parseParamFromToken(token, "userId").toString();
|
||||
redisUtil.deleteByKey(RedisCst.ONLINE_APP_USER.concat(userId));
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user