auth登录接口
parent
08c2dacb77
commit
b37198b733
|
@ -0,0 +1,16 @@
|
||||||
|
package doctor.system.api;
|
||||||
|
|
||||||
|
import doctor.common.core.constant.ServiceNameConstants;
|
||||||
|
import doctor.common.core.domain.R;
|
||||||
|
import doctor.system.api.factory.RemoteDoctorFallbackFactory;
|
||||||
|
import doctor.system.api.model.LoginUser;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
@FeignClient(contextId = "remoteDoctorService", value = ServiceNameConstants.FILE_DOCTOR, fallback = RemoteDoctorFallbackFactory.class)
|
||||||
|
public interface RemoteDoctorService {
|
||||||
|
|
||||||
|
@PostMapping("/doctor/getUser")
|
||||||
|
R<LoginUser> getDoctorUserInfo(@RequestParam("email") String email);
|
||||||
|
}
|
|
@ -1,11 +1,7 @@
|
||||||
package doctor.system.api;
|
package doctor.system.api;
|
||||||
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
|
||||||
import doctor.common.core.constant.SecurityConstants;
|
import doctor.common.core.constant.SecurityConstants;
|
||||||
import doctor.common.core.constant.ServiceNameConstants;
|
import doctor.common.core.constant.ServiceNameConstants;
|
||||||
import doctor.common.core.domain.R;
|
import doctor.common.core.domain.R;
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package doctor.system.api.factory;
|
||||||
|
|
||||||
|
import doctor.common.core.domain.R;
|
||||||
|
import doctor.system.api.RemoteDoctorService;
|
||||||
|
import doctor.system.api.model.LoginUser;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class RemoteDoctorFallbackFactory implements RemoteDoctorService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<LoginUser> getDoctorUserInfo(String email) {
|
||||||
|
return R.fail("登录超时");
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package doctor.system.api.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import doctor.system.api.domain.SysUser;
|
import doctor.system.api.domain.SysUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,6 +59,7 @@ public class LoginUser implements Serializable
|
||||||
*/
|
*/
|
||||||
private SysUser sysUser;
|
private SysUser sysUser;
|
||||||
|
|
||||||
|
|
||||||
public String getToken()
|
public String getToken()
|
||||||
{
|
{
|
||||||
return token;
|
return token;
|
||||||
|
@ -143,6 +145,7 @@ public class LoginUser implements Serializable
|
||||||
return sysUser;
|
return sysUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setSysUser(SysUser sysUser)
|
public void setSysUser(SysUser sysUser)
|
||||||
{
|
{
|
||||||
this.sysUser = sysUser;
|
this.sysUser = sysUser;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
doctor.system.api.factory.RemoteUserFallbackFactory
|
doctor.system.api.factory.RemoteUserFallbackFactory
|
||||||
doctor.system.api.factory.RemoteLogFallbackFactory
|
doctor.system.api.factory.RemoteLogFallbackFactory
|
||||||
doctor.system.api.factory.RemoteFileFallbackFactory
|
doctor.system.api.factory.RemoteFileFallbackFactory
|
||||||
|
doctor.system.api.factory.RemoteDoctorFallbackFactory
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package doctor.auth;
|
package doctor;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,13 +1,30 @@
|
||||||
package doctor.auth.controller;
|
package doctor.auth.controller;
|
||||||
|
|
||||||
import doctor.auth.service.HealthService;
|
import doctor.auth.service.HealthService;
|
||||||
|
import doctor.auth.vo.DoctorUserVo;
|
||||||
|
import doctor.common.core.domain.R;
|
||||||
|
import doctor.common.security.service.TokenService;
|
||||||
|
import doctor.system.api.model.LoginUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@RequestMapping("/doctor/v1")
|
||||||
public class HealthController {
|
public class HealthController {
|
||||||
// @Autowired
|
|
||||||
// private HealthService healthService;
|
@Autowired
|
||||||
|
private HealthService healthService;
|
||||||
|
|
||||||
|
@PostMapping("/login")
|
||||||
|
public R<?> login(@RequestParam String email,String pwd) {
|
||||||
|
DoctorUserVo userInfo = healthService.login(email,pwd);
|
||||||
|
return R.ok(userInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package doctor.auth.form;
|
||||||
|
|
||||||
|
public class DoctorUserBody {
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,47 @@
|
||||||
package doctor.auth.service;
|
package doctor.auth.service;
|
||||||
|
|
||||||
|
import doctor.auth.util.RSAUtils;
|
||||||
|
import doctor.auth.util.RsaKey;
|
||||||
|
import doctor.auth.vo.DoctorUserVo;
|
||||||
|
import doctor.common.core.domain.R;
|
||||||
|
import doctor.common.security.service.TokenService;
|
||||||
|
import doctor.system.api.RemoteDoctorService;
|
||||||
|
import doctor.system.api.model.LoginUser;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class HealthService {
|
public class HealthService {
|
||||||
|
@Autowired
|
||||||
|
private RemoteDoctorService remoteDoctorService;
|
||||||
|
@Autowired
|
||||||
|
private TokenService tokenService;
|
||||||
|
|
||||||
|
public DoctorUserVo login(String email, String pwd) {
|
||||||
|
DoctorUserVo doctorUserVo = new DoctorUserVo();
|
||||||
|
R<LoginUser> userResult = remoteDoctorService.getDoctorUserInfo(email);
|
||||||
|
LoginUser data = userResult.getData();
|
||||||
|
String s="";
|
||||||
|
try {
|
||||||
|
s = RSAUtils.rsaDecrypt(pwd, RsaKey.PRIVATE_KEY);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
Map<String, Object> token = tokenService.createToken(data);
|
||||||
|
String accessToken = (String) token.get("access_token");
|
||||||
|
doctorUserVo.setSessionId(accessToken);
|
||||||
|
doctorUserVo.setEmail(data.getSysUser().getEmail());
|
||||||
|
doctorUserVo.setUserId(data.getSysUser().getUserId().intValue());
|
||||||
|
doctorUserVo.setUserName(data.getSysUser().getUserName());
|
||||||
|
doctorUserVo.setNickName(data.getSysUser().getNickName());
|
||||||
|
doctorUserVo.setJiGuangPwd(s);
|
||||||
|
if (data.getSysUser().getSex()=="男"){
|
||||||
|
doctorUserVo.setSex(0);
|
||||||
|
}else {
|
||||||
|
doctorUserVo.setSex(1);
|
||||||
|
}
|
||||||
|
return doctorUserVo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
package doctor.auth.util;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
|
import javax.crypto.BadPaddingException;
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
|
import javax.crypto.NoSuchPaddingException;
|
||||||
|
import java.security.*;
|
||||||
|
import java.security.interfaces.RSAPrivateKey;
|
||||||
|
import java.security.interfaces.RSAPublicKey;
|
||||||
|
import java.security.spec.InvalidKeySpecException;
|
||||||
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA工具类 生成秘钥 加解密
|
||||||
|
* @author : WangZhanpeng
|
||||||
|
* @date : 2024/1/9 15:13
|
||||||
|
*/
|
||||||
|
public class RSAUtils {
|
||||||
|
|
||||||
|
|
||||||
|
private static Map<Integer, String> keyMap = new HashMap<Integer, String>();
|
||||||
|
|
||||||
|
public static void getKey() throws NoSuchAlgorithmException {
|
||||||
|
genKeyPair();
|
||||||
|
System.out.println("公钥===:"+keyMap.get(0));
|
||||||
|
System.out.println("私钥===:"+keyMap.get(1));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 随机生成密钥对
|
||||||
|
*
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
*/
|
||||||
|
public static void genKeyPair() throws NoSuchAlgorithmException {
|
||||||
|
// KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象
|
||||||
|
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
|
||||||
|
// 初始化密钥对生成器,密钥大小为96-1024位
|
||||||
|
keyPairGen.initialize(1024, new SecureRandom());
|
||||||
|
// 生成一个密钥对,保存在keyPair中
|
||||||
|
KeyPair keyPair = keyPairGen.generateKeyPair();
|
||||||
|
// 得到私钥
|
||||||
|
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
|
||||||
|
// 得到公钥
|
||||||
|
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
|
||||||
|
String publicKeyString = new String(Base64.encodeBase64(publicKey.getEncoded()));
|
||||||
|
// 得到私钥字符串
|
||||||
|
String privateKeyString = new String(Base64.encodeBase64((privateKey.getEncoded())));
|
||||||
|
// 将公钥和私钥保存到Map
|
||||||
|
//0表示公钥
|
||||||
|
keyMap.put(0, publicKeyString);
|
||||||
|
//1表示私钥
|
||||||
|
keyMap.put(1, privateKeyString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA私钥解密
|
||||||
|
* @param str 解密字符串
|
||||||
|
* @param privateKey 私钥
|
||||||
|
* @return 明文
|
||||||
|
*/
|
||||||
|
public static String rsaDecrypt(String str, String privateKey) throws Exception {
|
||||||
|
//base64编码的私钥
|
||||||
|
byte[] decoded = Base64.decodeBase64(privateKey);
|
||||||
|
RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded));
|
||||||
|
//RSA解密
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, priKey);
|
||||||
|
byte[] inputArray = Base64.decodeBase64(str.getBytes("UTF-8"));
|
||||||
|
int inputLength = inputArray.length;
|
||||||
|
// 最大加密字节数,超出最大字节数需要分组加密
|
||||||
|
int MAX_ENCRYPT_BLOCK = 128;
|
||||||
|
// 标识
|
||||||
|
int offSet = 0;
|
||||||
|
byte[] resultBytes = {};
|
||||||
|
byte[] cache;
|
||||||
|
while (inputLength - offSet > 0) {
|
||||||
|
if (inputLength - offSet > MAX_ENCRYPT_BLOCK) {
|
||||||
|
cache = cipher.doFinal(inputArray, offSet, MAX_ENCRYPT_BLOCK);
|
||||||
|
offSet += MAX_ENCRYPT_BLOCK;
|
||||||
|
} else {
|
||||||
|
cache = cipher.doFinal(inputArray, offSet, inputLength - offSet);
|
||||||
|
offSet = inputLength;
|
||||||
|
}
|
||||||
|
resultBytes = Arrays.copyOf(resultBytes, resultBytes.length + cache.length);
|
||||||
|
System.arraycopy(cache, 0, resultBytes, resultBytes.length - cache.length, cache.length);
|
||||||
|
}
|
||||||
|
String outStr = new String(resultBytes);
|
||||||
|
return outStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA公钥加密
|
||||||
|
* @param input 需要加密的字符串
|
||||||
|
* @param rsaPublicKey 公钥
|
||||||
|
* @return 密文
|
||||||
|
* @throws Exception 加密过程中的异常信息
|
||||||
|
*/
|
||||||
|
public static List<String> rsaEncrypt(String input, String rsaPublicKey) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
|
||||||
|
String result = "";
|
||||||
|
// 将Base64编码后的公钥转换成PublicKey对象
|
||||||
|
byte[] buffer = Base64.decodeBase64(rsaPublicKey);
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
|
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(buffer);
|
||||||
|
PublicKey publicKey = keyFactory.generatePublic(keySpec);
|
||||||
|
// 加密
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA");
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||||
|
byte[] inputArray = input.getBytes();
|
||||||
|
int inputLength = inputArray.length;
|
||||||
|
System.out.println("加密字节数:" + inputLength);
|
||||||
|
// 最大加密字节数,超出最大字节数需要分组加密
|
||||||
|
int MAX_ENCRYPT_BLOCK = 117;
|
||||||
|
// 标识
|
||||||
|
int offSet = 0;
|
||||||
|
List<String> results=new ArrayList<>();
|
||||||
|
byte[] cache;
|
||||||
|
while (inputLength - offSet > 0) {
|
||||||
|
if (inputLength - offSet > MAX_ENCRYPT_BLOCK) {
|
||||||
|
cache = cipher.doFinal(inputArray, offSet, MAX_ENCRYPT_BLOCK);
|
||||||
|
offSet += MAX_ENCRYPT_BLOCK;
|
||||||
|
} else {
|
||||||
|
cache = cipher.doFinal(inputArray, offSet, inputLength - offSet);
|
||||||
|
offSet = inputLength;
|
||||||
|
}
|
||||||
|
results.add(Base64.encodeBase64String(cache));
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package doctor.auth.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存放RSA 公钥和私钥
|
||||||
|
* @author : WangZhanpeng
|
||||||
|
* @date : 2024/1/9 15:49
|
||||||
|
*/
|
||||||
|
public class RsaKey {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公钥
|
||||||
|
*/
|
||||||
|
public static final String PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7xkwklONlHn8TGmTH6yyvv7Bv9AcxXgpkAhuPxpOCVHgkpGGJUJVc8JCMOAhmqI4zdJRqTJa1aOk1glcOaOWja28o6lqNzxn3X3fqdkcWoF/L9Znw1MSDK7oFeSsHqubc9wA2GKb4EFt2TWuaFB+dWfPUhFeJ1GoZhpjjgZLO9QIDAQAB";
|
||||||
|
/**
|
||||||
|
* 私钥
|
||||||
|
*/
|
||||||
|
public static final String PRIVATE_KEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALvGTCSU42UefxMaZMfrLK+/sG/0BzFeCmQCG4/Gk4JUeCSkYYlQlVzwkIw4CGaojjN0lGpMlrVo6TWCVw5o5aNrbyjqWo3PGfdfd+p2RxagX8v1mfDUxIMrugV5Kweq5tz3ADYYpvgQW3ZNa5oUH51Z89SEV4nUahmGmOOBks71AgMBAAECgYAQNJTts0vMtk0RQP3hoxJAOLLpdo4IXK1Y5DWsut6QKOoVf3pLd4DsfHZ9I3jWI0XievU0F1gKX/uAerc4ryTiR6dxHRyKQxhAamLCFqAgTd6GQf6nl7LlKJkHOKZ1/Un0l245zSLoUzNYxzLZhXfOX8lMNfnXpznfZV43nJJMIQJBAPEeKpEzK8/lEJCszBCXgAH75Qcwu+J/LjZFXChsEqx0ubbhg9orgwg+z5Z2uLXVbeScTkBIi+yY6Jd5RUbyhTsCQQDHXUUcylpo0vo9z/xMPTcd5m5UqTm6ZVacdnrkOQtGJJCKOLYTLhWGUPmE0s+cgn9/24H0H8FjOM/ta8tdTPmPAkEAyV5lNICk7WojzH/TqWOtb3q8yqWDtGR85qxEjCm96rNNSpPKt1ExjJhQbBvYpVuK/KshmwQ7f6wwTBjmp5rxcwJAVbJPAggtgr+l16ourmrl5VFm/bdcXDYxW8JGIxIuOXGAPBoSkf4OPJVUHHctzP3/Zmtp2hFIZKlIH6tlWG69GwJAUcnD0XMH8+h9mYUFdwgD0JtaEbeY3ofkO+RymFdcYO//ZjwnVWyGRIhi/lJ5URPiiDzt2MmX5G2a0NJPwP60Lg==";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
package doctor.auth.vo;
|
||||||
|
|
||||||
|
public class DoctorUserVo {
|
||||||
|
private Integer userId;
|
||||||
|
private String sessionId;
|
||||||
|
private String nickName;
|
||||||
|
private String userName;
|
||||||
|
private String jiGuangPwd;
|
||||||
|
private String headPic;
|
||||||
|
private Integer sex;
|
||||||
|
private Integer age;
|
||||||
|
private Integer height;
|
||||||
|
private Integer weight;
|
||||||
|
private String email;
|
||||||
|
private Integer whetherBingWeChat;
|
||||||
|
private String invitationCode;
|
||||||
|
private Integer faceFlag;
|
||||||
|
|
||||||
|
public Integer getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(Integer userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSessionId() {
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSessionId(String sessionId) {
|
||||||
|
this.sessionId = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickName() {
|
||||||
|
return nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickName(String nickName) {
|
||||||
|
this.nickName = nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJiGuangPwd() {
|
||||||
|
return jiGuangPwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJiGuangPwd(String jiGuangPwd) {
|
||||||
|
this.jiGuangPwd = jiGuangPwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHeadPic() {
|
||||||
|
return headPic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeadPic(String headPic) {
|
||||||
|
this.headPic = headPic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSex() {
|
||||||
|
return sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSex(Integer sex) {
|
||||||
|
this.sex = sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAge() {
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAge(Integer age) {
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeight(Integer height) {
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getWeight() {
|
||||||
|
return weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWeight(Integer weight) {
|
||||||
|
this.weight = weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getWhetherBingWeChat() {
|
||||||
|
return whetherBingWeChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWhetherBingWeChat(Integer whetherBingWeChat) {
|
||||||
|
this.whetherBingWeChat = whetherBingWeChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInvitationCode() {
|
||||||
|
return invitationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvitationCode(String invitationCode) {
|
||||||
|
this.invitationCode = invitationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getFaceFlag() {
|
||||||
|
return faceFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaceFlag(Integer faceFlag) {
|
||||||
|
this.faceFlag = faceFlag;
|
||||||
|
}
|
||||||
|
}
|
|
@ -113,6 +113,7 @@
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -21,4 +21,5 @@ public class ServiceNameConstants
|
||||||
* 文件服务的serviceid
|
* 文件服务的serviceid
|
||||||
*/
|
*/
|
||||||
public static final String FILE_SERVICE = "doctor-file";
|
public static final String FILE_SERVICE = "doctor-file";
|
||||||
|
public static final String FILE_DOCTOR = "doctor-health";
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package doctor.controller;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import doctor.common.core.domain.R;
|
||||||
|
import doctor.domain.entity.DoctorUser;
|
||||||
|
import doctor.service.IDoctorUserService;
|
||||||
|
import doctor.system.api.domain.SysUser;
|
||||||
|
import doctor.system.api.model.LoginUser;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/doctor")
|
||||||
|
@DS("slave")
|
||||||
|
public class SysDoctorController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IDoctorUserService iDoctorUserService;
|
||||||
|
|
||||||
|
@PostMapping("/getUser")
|
||||||
|
public R<LoginUser> getUser(String email) {
|
||||||
|
DoctorUser user = iDoctorUserService.getUser(email);
|
||||||
|
LoginUser loginUser = new LoginUser();
|
||||||
|
SysUser sysUser = new SysUser();
|
||||||
|
sysUser.setUserId(Long.valueOf(user.getId()));
|
||||||
|
sysUser.setNickName(user.getNickName());
|
||||||
|
sysUser.setUserName(user.getUserName());
|
||||||
|
sysUser.setPhonenumber(user.getPhone());
|
||||||
|
sysUser.setPassword(user.getPwd());
|
||||||
|
if (user.getSex()==0){
|
||||||
|
sysUser.setSex("男");
|
||||||
|
}else {
|
||||||
|
sysUser.setSex("女");
|
||||||
|
}
|
||||||
|
loginUser.setSysUser(sysUser);
|
||||||
|
return R.ok(loginUser);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
package doctor.domain.entity;
|
||||||
|
|
||||||
|
import java.security.Timestamp;
|
||||||
|
|
||||||
|
public class DoctorUser {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String phone;
|
||||||
|
private String pwd;
|
||||||
|
private String email;
|
||||||
|
private String nickName;
|
||||||
|
private String userName;
|
||||||
|
private String headPic;
|
||||||
|
private int sex;
|
||||||
|
private int age;
|
||||||
|
private int height;
|
||||||
|
private int weight;
|
||||||
|
private String invitationCode;
|
||||||
|
private Timestamp updateTime;
|
||||||
|
private Timestamp createTime;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPwd() {
|
||||||
|
return pwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPwd(String pwd) {
|
||||||
|
this.pwd = pwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickName() {
|
||||||
|
return nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickName(String nickName) {
|
||||||
|
this.nickName = nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHeadPic() {
|
||||||
|
return headPic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeadPic(String headPic) {
|
||||||
|
this.headPic = headPic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSex() {
|
||||||
|
return sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSex(int sex) {
|
||||||
|
this.sex = sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAge() {
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAge(int age) {
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeight(int height) {
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWeight() {
|
||||||
|
return weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWeight(int weight) {
|
||||||
|
this.weight = weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInvitationCode() {
|
||||||
|
return invitationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvitationCode(String invitationCode) {
|
||||||
|
this.invitationCode = invitationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Timestamp updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Timestamp createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package doctor.mapper;
|
||||||
|
|
||||||
|
import doctor.domain.entity.DoctorUser;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
|
||||||
|
@MapperScan
|
||||||
|
public interface IDoctorUserMapper {
|
||||||
|
DoctorUser selectDoctorUserByEmail(@Param("email") String email);
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package doctor.service;
|
||||||
|
|
||||||
|
import doctor.domain.entity.DoctorUser;
|
||||||
|
import doctor.system.api.model.LoginUser;
|
||||||
|
|
||||||
|
public interface IDoctorUserService {
|
||||||
|
DoctorUser getUser(String email);
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package doctor.service.impl;
|
||||||
|
|
||||||
|
import doctor.mapper.IDoctorUserMapper;
|
||||||
|
import doctor.domain.entity.DoctorUser;
|
||||||
|
import doctor.service.IDoctorUserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class IDoctorUserServiceImpl implements IDoctorUserService {
|
||||||
|
@Autowired
|
||||||
|
private IDoctorUserMapper iDoctorUserMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoctorUser getUser(String email) {
|
||||||
|
DoctorUser doctorUser = iDoctorUserMapper.selectDoctorUserByEmail(email);
|
||||||
|
return doctorUser;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="doctor.mapper.IDoctorUserMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectDoctorUserByEmail" resultType="doctor.domain.entity.DoctorUser">
|
||||||
|
select * from user where email = #{email}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue