auth登录接口

jpz
chenbingxuan 2024-01-10 11:35:39 +08:00 committed by zmyYYDS
parent f21632aeda
commit 9b30e365ca
3 changed files with 24 additions and 16 deletions

View File

@ -2,6 +2,7 @@ package doctor.auth.controller;
import doctor.auth.service.HealthService; import doctor.auth.service.HealthService;
import doctor.auth.vo.DoctorUserVo; import doctor.auth.vo.DoctorUserVo;
import doctor.common.core.domain.HealthR;
import doctor.common.core.domain.R; import doctor.common.core.domain.R;
import doctor.common.security.service.TokenService; import doctor.common.security.service.TokenService;
import doctor.system.api.model.LoginUser; import doctor.system.api.model.LoginUser;
@ -21,9 +22,13 @@ public class HealthController {
private HealthService healthService; private HealthService healthService;
@PostMapping("/login") @PostMapping("/login")
public R<?> login(@RequestParam String email,String pwd) { public HealthR<?> login(@RequestParam String email, @RequestParam String pwd) {
DoctorUserVo userInfo = healthService.login(email,pwd); DoctorUserVo userInfo = healthService.login(email,pwd);
return R.ok(userInfo); if (userInfo!=null){
return HealthR.ok(userInfo);
}else {
return HealthR.fail();
}
} }

View File

@ -29,6 +29,7 @@ public class HealthService {
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
if (s.equals(data.getSysUser().getPassword())){
Map<String, Object> token = tokenService.createToken(data); Map<String, Object> token = tokenService.createToken(data);
String accessToken = (String) token.get("access_token"); String accessToken = (String) token.get("access_token");
doctorUserVo.setSessionId(accessToken); doctorUserVo.setSessionId(accessToken);
@ -44,4 +45,6 @@ public class HealthService {
} }
return doctorUserVo; return doctorUserVo;
} }
return null;
}
} }

View File

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/doctor") @RequestMapping("/doctor")
@DS("slave") @DS("master")
public class SysDoctorController { public class SysDoctorController {
@Autowired @Autowired