汽修登录 注册 验证码
This commit is contained in:
parent
d1cd46f67f
commit
221eb5c7ae
@ -15,6 +15,8 @@ import cn.iocoder.yudao.module.rescue.domain.LoginBody;
|
|||||||
import cn.iocoder.yudao.module.rescue.domain.WxLoginBody;
|
import cn.iocoder.yudao.module.rescue.domain.WxLoginBody;
|
||||||
import cn.iocoder.yudao.module.rescue.service.IDriverInfoService;
|
import cn.iocoder.yudao.module.rescue.service.IDriverInfoService;
|
||||||
import cn.iocoder.yudao.module.rescue.utils.RescueSysLoginService;
|
import cn.iocoder.yudao.module.rescue.utils.RescueSysLoginService;
|
||||||
|
import cn.iocoder.yudao.module.rescue.utils.SendSmsUtil;
|
||||||
|
import cn.iocoder.yudao.module.rescue.vo.RegisterVO;
|
||||||
import cn.iocoder.yudao.module.shop.entity.ShopConfig;
|
import cn.iocoder.yudao.module.shop.entity.ShopConfig;
|
||||||
import cn.iocoder.yudao.module.shop.entity.UserBalance;
|
import cn.iocoder.yudao.module.shop.entity.UserBalance;
|
||||||
import cn.iocoder.yudao.module.shop.service.IShopConfigService;
|
import cn.iocoder.yudao.module.shop.service.IShopConfigService;
|
||||||
@ -39,6 +41,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
|
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
@ -50,12 +53,13 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.security.spec.AlgorithmParameterSpec;
|
import java.security.spec.AlgorithmParameterSpec;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.*;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.module.rescue.utils.RescueSysLoginService.generateVerificationCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录验证
|
* 登录验证
|
||||||
@ -77,7 +81,8 @@ public class SysLoginController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PermissionApi permissionApi;
|
private PermissionApi permissionApi;
|
||||||
|
@Resource
|
||||||
|
private PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RoleApi roleApi;
|
private RoleApi roleApi;
|
||||||
@ -190,6 +195,73 @@ public class SysLoginController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汽修小程序登录方法
|
||||||
|
*
|
||||||
|
* @param loginBody 登录信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/loginQx")
|
||||||
|
@TenantIgnore
|
||||||
|
public CommonResult loginQx(@RequestBody LoginBody loginBody) throws Exception {
|
||||||
|
String userName = loginBody.getUsername();
|
||||||
|
AdminUserDO user = userService.getUserByUsername(userName);
|
||||||
|
if (ObjectUtil.isEmpty(user)) {
|
||||||
|
return error(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST);
|
||||||
|
}
|
||||||
|
AuthLoginReqVO authLoginReqVO = new AuthLoginReqVO();
|
||||||
|
authLoginReqVO.setUsername(loginBody.getUsername());
|
||||||
|
authLoginReqVO.setPassword(loginBody.getPassword());
|
||||||
|
return success(loginService.login(authLoginReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码
|
||||||
|
* @param phone
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/sendSmsQx")
|
||||||
|
@TenantIgnore
|
||||||
|
public CommonResult sendSmsQx(@RequestParam("phone") String phone) {
|
||||||
|
String msgCode = generateVerificationCode();
|
||||||
|
redisCache2.setCacheObject(phone+"-registerCode",msgCode,300, TimeUnit.SECONDS);
|
||||||
|
SendSmsUtil.sendMsg(msgCode,phone,"1400852709","机动车管家小程序","1917285");
|
||||||
|
return ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汽修小程序注册方法
|
||||||
|
*
|
||||||
|
* @param registerVO 登录信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/registerQx")
|
||||||
|
@TenantIgnore
|
||||||
|
public CommonResult registerQx(@RequestBody RegisterVO registerVO){
|
||||||
|
if(org.apache.commons.lang3.StringUtils.isEmpty(registerVO.getPhone())){
|
||||||
|
return error(500,"手机号不能为空");
|
||||||
|
}
|
||||||
|
if(org.apache.commons.lang3.StringUtils.isEmpty(registerVO.getPassword())){
|
||||||
|
return error(500,"密码不能为空");
|
||||||
|
}
|
||||||
|
if(org.apache.commons.lang3.StringUtils.isEmpty(registerVO.getCode())){
|
||||||
|
return error(500,"验证码不能为空");
|
||||||
|
}
|
||||||
|
Object registerCode = redisCache2.getCacheObject(registerVO.getPhone() + "-registerCode");
|
||||||
|
if(null==registerCode || !registerCode.equals(registerVO.getCode())){
|
||||||
|
return error(500,"验证码错误");
|
||||||
|
}
|
||||||
|
redisCache2.deleteObject(registerVO.getPhone() + "-registerCode");
|
||||||
|
|
||||||
|
UserSaveReqVO userSaveReqVO = new UserSaveReqVO();
|
||||||
|
userSaveReqVO.setUsername(registerVO.getPhone());
|
||||||
|
userSaveReqVO.setPassword(passwordEncoder.encode(registerVO.getPassword()));
|
||||||
|
userSaveReqVO.setMobile(registerVO.getPhone());
|
||||||
|
userService.createUser(userSaveReqVO);
|
||||||
|
return success("注册成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 司机登录方法
|
* 司机登录方法
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package cn.iocoder.yudao.module.rescue.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RegisterVO {
|
||||||
|
private String phone;
|
||||||
|
private String password;
|
||||||
|
private String code;
|
||||||
|
}
|
@ -225,6 +225,7 @@ yudao:
|
|||||||
- /admin-api/rescue/wxLoginRescue
|
- /admin-api/rescue/wxLoginRescue
|
||||||
- /admin-api/rescue/wxLoginJc
|
- /admin-api/rescue/wxLoginJc
|
||||||
- /admin-api/rescue/loginJcApp
|
- /admin-api/rescue/loginJcApp
|
||||||
|
- /admin-api/system/tenant/getListByWebsite
|
||||||
websocket:
|
websocket:
|
||||||
enable: true # websocket的开关
|
enable: true # websocket的开关
|
||||||
path: /infra/ws # 路径
|
path: /infra/ws # 路径
|
||||||
@ -274,6 +275,7 @@ yudao:
|
|||||||
- /admin-api/appInspection/goods/canLedCouponPlatform
|
- /admin-api/appInspection/goods/canLedCouponPlatform
|
||||||
- /admin-api/rescue/loginApp
|
- /admin-api/rescue/loginApp
|
||||||
- /admin-api/rescue/loginJcApp
|
- /admin-api/rescue/loginJcApp
|
||||||
|
- /admin-api/system/tenant/getListByWebsite
|
||||||
ignore-tables:
|
ignore-tables:
|
||||||
- system_tenant
|
- system_tenant
|
||||||
- system_tenant_package
|
- system_tenant_package
|
||||||
|
Loading…
Reference in New Issue
Block a user