|
@@ -62,9 +62,9 @@ public class AdminController {
|
|
|
private static final List<String> SEND_LIST = List.of("o_i5g6V5z5uDpx_SBhJ4ePek8g8k","o_i5g6X99wu2OmC4DcQKXKNmJexA");
|
|
private static final List<String> SEND_LIST = List.of("o_i5g6V5z5uDpx_SBhJ4ePek8g8k","o_i5g6X99wu2OmC4DcQKXKNmJexA");
|
|
|
|
|
|
|
|
@PostMapping(value = "/login")
|
|
@PostMapping(value = "/login")
|
|
|
- public Result<AdminInfo> login(@RequestBody Admin adminRequest) throws Exception {
|
|
|
|
|
|
|
+ public Result<String> login(@RequestBody Admin adminRequest) throws Exception {
|
|
|
Admin admin = adminService.getOne(
|
|
Admin admin = adminService.getOne(
|
|
|
- new QueryWrapper<Admin>().lambda().eq(Admin::getUserName,adminRequest.getUserName()));
|
|
|
|
|
|
|
+ new QueryWrapper<Admin>().lambda().eq(Admin::getPhone,adminRequest.getPhone()));
|
|
|
|
|
|
|
|
if (null == admin) {
|
|
if (null == admin) {
|
|
|
throw BusinessRuntimeException.getInstance("该用户不存在.");
|
|
throw BusinessRuntimeException.getInstance("该用户不存在.");
|
|
@@ -79,19 +79,7 @@ public class AdminController {
|
|
|
if (!StringUtils.equals(admin.getPassWord(), encodePasscode)) {
|
|
if (!StringUtils.equals(admin.getPassWord(), encodePasscode)) {
|
|
|
throw BusinessRuntimeException.getInstance("密码有误.");
|
|
throw BusinessRuntimeException.getInstance("密码有误.");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 生成token
|
|
|
|
|
-
|
|
|
|
|
- StpUtil.login(admin.getId());
|
|
|
|
|
-
|
|
|
|
|
- String token = StpUtil.getTokenValue();
|
|
|
|
|
-
|
|
|
|
|
- admin.setPassWord("");
|
|
|
|
|
-
|
|
|
|
|
- AdminInfo info = new AdminInfo();
|
|
|
|
|
- info.setInfo(admin);
|
|
|
|
|
- info.setToken(token);
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(info);
|
|
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/post")
|
|
@PostMapping("/post")
|
|
@@ -144,17 +132,15 @@ public class AdminController {
|
|
|
* 校验手机号获取登录信息
|
|
* 校验手机号获取登录信息
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/get/loginInfo")
|
|
@GetMapping("/get/loginInfo")
|
|
|
- public Result<AdminInfo> getLoginInfo(String phone, String code, Long adminId) {
|
|
|
|
|
- Admin admin = adminService.getById(adminId);
|
|
|
|
|
- if (admin == null) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("账号不存在");
|
|
|
|
|
|
|
+ public Result<AdminInfo> getLoginInfo(String phone, String code) {
|
|
|
|
|
+ Admin admin = adminService.getOne(
|
|
|
|
|
+ new QueryWrapper<Admin>().lambda().eq(Admin::getPhone, phone));
|
|
|
|
|
+ if (null == admin) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该用户不存在.");
|
|
|
}
|
|
}
|
|
|
if (StrUtil.hasEmpty(phone, code)) {
|
|
if (StrUtil.hasEmpty(phone, code)) {
|
|
|
throw BusinessRuntimeException.getInstance("请输入对应信息");
|
|
throw BusinessRuntimeException.getInstance("请输入对应信息");
|
|
|
}
|
|
}
|
|
|
- if (!phone.equals(admin.getPhone())) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("输入手机号与账号配置登录手机号不一致");
|
|
|
|
|
- }
|
|
|
|
|
DateTime now = DateTime.now();
|
|
DateTime now = DateTime.now();
|
|
|
PhoneCode phoneCode = phoneCodeMapper.selectOne(Wrappers.lambdaQuery(PhoneCode.class).eq(PhoneCode::getPhone, phone).last("limit 1"));
|
|
PhoneCode phoneCode = phoneCodeMapper.selectOne(Wrappers.lambdaQuery(PhoneCode.class).eq(PhoneCode::getPhone, phone).last("limit 1"));
|
|
|
if (phoneCode == null || StrUtil.isEmpty(phoneCode.getCode())) {
|
|
if (phoneCode == null || StrUtil.isEmpty(phoneCode.getCode())) {
|