Compare commits
No commits in common. "72ebcefef77b0ff76c1dd4043cf86c7323c1a482" and "916a9868c53f6c7568b71600dbac076a17e94a0b" have entirely different histories.
72ebcefef7
...
916a9868c5
@ -7,7 +7,6 @@ import com.example.caseData.dto.publicDto.LoginDto;
|
|||||||
import com.example.caseData.dto.user.UserDto;
|
import com.example.caseData.dto.user.UserDto;
|
||||||
import com.example.caseData.extend.aliyun.Oss;
|
import com.example.caseData.extend.aliyun.Oss;
|
||||||
import com.example.caseData.request.publicRequest.GetOssSignRequest;
|
import com.example.caseData.request.publicRequest.GetOssSignRequest;
|
||||||
import com.example.caseData.request.publicRequest.LoginHcpRequest;
|
|
||||||
import com.example.caseData.request.publicRequest.LoginRequest;
|
import com.example.caseData.request.publicRequest.LoginRequest;
|
||||||
import com.example.caseData.request.UserRequest.UserRequest;
|
import com.example.caseData.request.UserRequest.UserRequest;
|
||||||
import com.example.caseData.service.UserService;
|
import com.example.caseData.service.UserService;
|
||||||
@ -32,7 +31,7 @@ public class PublicController {
|
|||||||
|
|
||||||
// 登陆
|
// 登陆
|
||||||
@PostMapping("/login/wechat/mobile")
|
@PostMapping("/login/wechat/mobile")
|
||||||
public Response<LoginDto> loginWechatMobile(@Validated({LoginRequest.Login.class}) @ModelAttribute LoginRequest request) {
|
public Response<LoginDto> login(@Validated({LoginRequest.Login.class}) @ModelAttribute LoginRequest request) {
|
||||||
// 微信手机号授权登录
|
// 微信手机号授权登录
|
||||||
// 获取手机号
|
// 获取手机号
|
||||||
// 获取用户openid
|
// 获取用户openid
|
||||||
@ -41,19 +40,11 @@ public class PublicController {
|
|||||||
String phone = "18221234167";
|
String phone = "18221234167";
|
||||||
|
|
||||||
// 用户登陆
|
// 用户登陆
|
||||||
LoginDto g = userService.UserLoginWithMobile(phone);
|
LoginDto g = userService.UserLogin(phone);
|
||||||
|
|
||||||
return Response.success(g);
|
return Response.success(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登陆
|
|
||||||
@PostMapping("/login/hcp")
|
|
||||||
public Response<LoginDto> loginHcp(@Validated() @ModelAttribute LoginHcpRequest request) {
|
|
||||||
// 用户登陆
|
|
||||||
LoginDto g = userService.UserLoginWithApp(request.getToken());
|
|
||||||
return Response.success(g);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取签名
|
// 获取签名
|
||||||
@GetMapping("/sign/oss")
|
@GetMapping("/sign/oss")
|
||||||
public Response<GetOssSignDto> GetOssSign(
|
public Response<GetOssSignDto> GetOssSign(
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.example.caseData.extend.app.Hospital;
|
package com.example.caseData.extend.app.Hospital;
|
||||||
|
|
||||||
|
import com.example.caseData.extend.app.UserInfo.GetUserInfoByMobileResponse;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package com.example.caseData.extend.app.UserInfo;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class GetUserInfoResponse {
|
public class GetUserInfoByMobileResponse {
|
||||||
/** 接口调用状态。200:正常;其它值:调用出错 */
|
/** 接口调用状态。200:正常;其它值:调用出错 */
|
||||||
private int code;
|
private int code;
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ public class GetUserInfoResponse {
|
|||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
/** 接口返回的用户信息数据 */
|
/** 接口返回的用户信息数据 */
|
||||||
private ResponsData data;
|
private GetUserInfoByMobileData data;
|
||||||
|
|
||||||
/** 接口是否调用成功 */
|
/** 接口是否调用成功 */
|
||||||
private boolean success;
|
private boolean success;
|
||||||
@ -20,8 +20,11 @@ public class GetUserInfoResponse {
|
|||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据手机号获取医生信息 - 详细数据
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public static class ResponsData {
|
public static class GetUserInfoByMobileData {
|
||||||
|
|
||||||
/** app唯一标识 */
|
/** app唯一标识 */
|
||||||
private String uuid;
|
private String uuid;
|
||||||
@ -21,7 +21,7 @@ public class UserInfo extends Base {
|
|||||||
private AppConfig appConfig;
|
private AppConfig appConfig;
|
||||||
|
|
||||||
// 根据手机号获取信息V3
|
// 根据手机号获取信息V3
|
||||||
public GetUserInfoResponse getUserInfoByMobile(String mobile) throws BusinessException {
|
public GetUserInfoByMobileResponse getUserInfoByMobile(String mobile) throws BusinessException {
|
||||||
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
|
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
// 处理参数
|
// 处理参数
|
||||||
@ -48,53 +48,7 @@ public class UserInfo extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 反序列化 JSON
|
// 反序列化 JSON
|
||||||
GetUserInfoResponse result = JSONUtil.toBean(response.body(), GetUserInfoResponse.class);
|
GetUserInfoByMobileResponse result = JSONUtil.toBean(response.body(), GetUserInfoByMobileResponse.class);
|
||||||
log.info("获取app数据返回:{}",result);
|
|
||||||
if (result.getCode() != 200){
|
|
||||||
if (!Objects.equals(result.getMsg(), "")){
|
|
||||||
throw new BusinessException(result.getMsg());
|
|
||||||
}else{
|
|
||||||
throw new BusinessException("失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.getData() == null){
|
|
||||||
throw new BusinessException("失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据token获取信息V3
|
|
||||||
public GetUserInfoResponse getUserInfoByToken(String appToken) throws BusinessException {
|
|
||||||
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
|
|
||||||
|
|
||||||
// 处理参数
|
|
||||||
Map<String, Object> requestData = new HashMap<>();
|
|
||||||
requestData.put("token", appToken);
|
|
||||||
requestData.put("platform", appConfig.getPlatform());
|
|
||||||
requestData.put("timestamp", timestamp);
|
|
||||||
|
|
||||||
// 生成签名
|
|
||||||
String sign = genSignature(requestData,appConfig.getSecretKey());
|
|
||||||
|
|
||||||
String url = appConfig.getApiUrl() + "/expert-api/getInfoByToken";
|
|
||||||
String jsonBody = JSONUtil.toJsonStr(requestData);
|
|
||||||
log.info("获取app数据参数:{}",jsonBody);
|
|
||||||
|
|
||||||
try(HttpResponse response = HttpRequest.post(url)
|
|
||||||
.header("Content-Type", "application/json")
|
|
||||||
.header("sign", sign)
|
|
||||||
.body(jsonBody)
|
|
||||||
.execute()){
|
|
||||||
|
|
||||||
if (response.getStatus() != 200) {
|
|
||||||
throw new BusinessException("失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 反序列化 JSON
|
|
||||||
GetUserInfoResponse result = JSONUtil.toBean(response.body(), GetUserInfoResponse.class);
|
|
||||||
log.info("获取app数据返回:{}",result);
|
log.info("获取app数据返回:{}",result);
|
||||||
if (result.getCode() != 200){
|
if (result.getCode() != 200){
|
||||||
if (!Objects.equals(result.getMsg(), "")){
|
if (!Objects.equals(result.getMsg(), "")){
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
package com.example.caseData.request.publicRequest;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class LoginHcpRequest {
|
|
||||||
@NotEmpty(message = "错误请求")
|
|
||||||
private String token;
|
|
||||||
}
|
|
||||||
@ -9,7 +9,7 @@ import com.example.caseData.dto.publicDto.LoginDto;
|
|||||||
import com.example.caseData.exception.BusinessException;
|
import com.example.caseData.exception.BusinessException;
|
||||||
import com.example.caseData.extend.app.Hospital.GetHospitalByUuidResponse;
|
import com.example.caseData.extend.app.Hospital.GetHospitalByUuidResponse;
|
||||||
import com.example.caseData.extend.app.Hospital.Hospital;
|
import com.example.caseData.extend.app.Hospital.Hospital;
|
||||||
import com.example.caseData.extend.app.UserInfo.GetUserInfoResponse;
|
import com.example.caseData.extend.app.UserInfo.GetUserInfoByMobileResponse;
|
||||||
import com.example.caseData.extend.app.UserInfo.UserInfo;
|
import com.example.caseData.extend.app.UserInfo.UserInfo;
|
||||||
import com.example.caseData.model.BasicHospitalModel;
|
import com.example.caseData.model.BasicHospitalModel;
|
||||||
import com.example.caseData.model.CaseClinicalDoctorModel;
|
import com.example.caseData.model.CaseClinicalDoctorModel;
|
||||||
@ -46,14 +46,13 @@ public class UserService {
|
|||||||
private JwtUtil jwtUtil;
|
private JwtUtil jwtUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登陆-手机号
|
* 用户登陆
|
||||||
* @return UserModel
|
* @return UserModel
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public LoginDto UserLoginWithMobile(String phone) throws BusinessException {
|
public LoginDto UserLogin(String phone) throws BusinessException {
|
||||||
// 获取app用户数据
|
// 获取app用户数据
|
||||||
GetUserInfoResponse result = userInfo.getUserInfoByMobile(phone);
|
UserModel user = GetAppUserInfoByPhone(phone);
|
||||||
UserModel user = GetAppUserInfo(result);
|
|
||||||
|
|
||||||
// 生成jwt
|
// 生成jwt
|
||||||
String token = jwtUtil.createToken(String.valueOf(user.getUserId()));
|
String token = jwtUtil.createToken(String.valueOf(user.getUserId()));
|
||||||
@ -76,47 +75,19 @@ public class UserService {
|
|||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户登陆-app
|
|
||||||
* @param appToken 1
|
|
||||||
*/
|
|
||||||
@Transactional
|
|
||||||
public LoginDto UserLoginWithApp(String appToken) throws BusinessException {
|
|
||||||
GetUserInfoResponse result = userInfo.getUserInfoByToken(appToken);
|
|
||||||
UserModel user = GetAppUserInfo(result);
|
|
||||||
|
|
||||||
// 生成jwt
|
|
||||||
String token = jwtUtil.createToken(String.valueOf(user.getUserId()));
|
|
||||||
|
|
||||||
// 获取对应医生数据
|
|
||||||
LambdaQueryWrapper<CaseClinicalDoctorModel> caseClinicalDoctorWrapper = new LambdaQueryWrapper<>();
|
|
||||||
caseClinicalDoctorWrapper.eq(CaseClinicalDoctorModel::getDoctorIden, user.getUserIden());
|
|
||||||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectOne(caseClinicalDoctorWrapper);
|
|
||||||
|
|
||||||
// 处理返回值
|
|
||||||
LoginDto g = new LoginDto();
|
|
||||||
g.setUserId(String.valueOf(user.getUserId()));
|
|
||||||
g.setUserName(user.getUserName());
|
|
||||||
g.setAvatar(Replace.addOssDomain(user.getAvatar()));
|
|
||||||
g.setToken(token);
|
|
||||||
|
|
||||||
if (caseClinicalDoctor != null) {
|
|
||||||
g.setDoctorId(String.valueOf(caseClinicalDoctor.getDoctorId()));
|
|
||||||
}
|
|
||||||
return g;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取app用户数据
|
* 获取app用户数据
|
||||||
|
* @param phone 手机号
|
||||||
* @return UserModel
|
* @return UserModel
|
||||||
*/
|
*/
|
||||||
public UserModel GetAppUserInfo(GetUserInfoResponse r) throws BusinessException {
|
public UserModel GetAppUserInfoByPhone(String phone) throws BusinessException {
|
||||||
GetUserInfoResponse.ResponsData data = r.getData();
|
// 请求接口获取数据
|
||||||
|
GetUserInfoByMobileResponse result = userInfo.getUserInfoByMobile(phone);
|
||||||
|
GetUserInfoByMobileResponse.GetUserInfoByMobileData data = result.getData();
|
||||||
|
|
||||||
// 查询数据库用户信息
|
// 查询数据库用户信息
|
||||||
LambdaQueryWrapper<UserModel> userModelWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<UserModel> userModelWrapper = new LambdaQueryWrapper<>();
|
||||||
userModelWrapper.eq(UserModel::getUserIden, r.getData().getUuid());
|
userModelWrapper.eq(UserModel::getUserIden, result.getData().getUuid());
|
||||||
UserModel user = userDao.selectOne(userModelWrapper);
|
UserModel user = userDao.selectOne(userModelWrapper);
|
||||||
if (user == null){
|
if (user == null){
|
||||||
// 构造 UserModel 对象
|
// 构造 UserModel 对象
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user