You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package com.web.controller;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.*;
import com.hai.config.UnionUserConfig;
import com.hai.config.WxMaConfiguration;
import com.hai.entity.HighUser;
import com.hai.enum_type.LoginPlatform;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.order.type.PlatformType;
import com.hai.service.HighUserService;
import com.web.type.LoginType;
import com.hai.enum_type.RedisFileFolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javafx.application.Platform;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/26 23:08
*/
@Controller
@RequestMapping(value = "/login")
@Api(value = "登录业务")
public class LoginController {
private static Logger log = LoggerFactory.getLogger(LoginController.class);
@Resource
private RedisUtil redisUtil;
@Resource
private HighUserService userService;
@Resource
private UserCenter userCenter;
@Resource
private WxMaConfiguration wxMaConfiguration;
@Resource
private UnionUserConfig unionUserConfig;
@RequestMapping(value = "/phone", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "手机号登录")
public ResponseData phone(@RequestBody JSONObject body,
HttpServletRequest request, HttpServletResponse response) {
try {
if (body == null
|| StringUtils.isBlank(body.getString("platform"))
|| StringUtils.isBlank(body.getString("type"))
|| StringUtils.isBlank(body.getString("phone"))
) {
log.error("LoginController --> phone() error!", "请求参数校验失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
String phone = body.getString("phone");
System.out.println(body);
// 客户端
LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform"));
if (platform == null) {
log.error("LoginController --> phone() error!", "未知客户端");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端");
}
// 校验手机号格式
if (MemberValidateUtil.validatePhone(phone) == false) {
log.error("LoginController --> phone() error!", "请输入正确的手机号");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号");
}
// 登录类型
LoginType loginType = LoginType.getDataByType(body.getString("type"));
if (loginType == null) {
log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type"));
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型");
}
if (body.getString("type").equals(LoginType.SMS.getCode())) {
if (StringUtils.isBlank(body.getString("smsCode"))) {
log.error("LoginController --> phone() error!", "请输入短信验证码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码");
|