Parcourir la source

fix 手机号登录

zoujiajian il y a 3 ans
Parent
commit
80c2e3742b

+ 8 - 22
netflix-web/src/main/java/com/cyksj/web/controller/manage/AdminController.java

@@ -62,9 +62,9 @@ public class AdminController {
     private static final List<String> SEND_LIST = List.of("o_i5g6V5z5uDpx_SBhJ4ePek8g8k","o_i5g6X99wu2OmC4DcQKXKNmJexA");
 
     @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(
-                new QueryWrapper<Admin>().lambda().eq(Admin::getUserName,adminRequest.getUserName()));
+                new QueryWrapper<Admin>().lambda().eq(Admin::getPhone,adminRequest.getPhone()));
 
         if (null == admin) {
             throw BusinessRuntimeException.getInstance("该用户不存在.");
@@ -79,19 +79,7 @@ public class AdminController {
         if (!StringUtils.equals(admin.getPassWord(), encodePasscode)) {
             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")
@@ -144,17 +132,15 @@ public class AdminController {
      * 校验手机号获取登录信息
      */
     @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)) {
             throw BusinessRuntimeException.getInstance("请输入对应信息");
         }
-        if (!phone.equals(admin.getPhone())) {
-            throw BusinessRuntimeException.getInstance("输入手机号与账号配置登录手机号不一致");
-        }
         DateTime now = DateTime.now();
         PhoneCode phoneCode = phoneCodeMapper.selectOne(Wrappers.lambdaQuery(PhoneCode.class).eq(PhoneCode::getPhone, phone).last("limit 1"));
         if (phoneCode == null || StrUtil.isEmpty(phoneCode.getCode())) {