医生微信登录接口

master
heminjian502 2 years ago
parent 639341ebf9
commit 21329e21c3

@ -9,7 +9,7 @@ ruoyi:
# 实例演示开关 # 实例演示开关
demoEnabled: true demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath # 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath/tongue profile: C:/ruoyi/uploadPath/tongue/
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: false addressEnabled: false
# 验证码类型 math 数组计算 char 字符验证 # 验证码类型 math 数组计算 char 字符验证

@ -1,10 +1,16 @@
package com.ruoyi.common.utils.file; package com.ruoyi.common.utils.file;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Base64;
import java.util.Objects; import java.util.Objects;
import java.util.UUID;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
@ -15,6 +21,8 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.Seq; import com.ruoyi.common.utils.uuid.Seq;
import javax.servlet.http.HttpServletRequest;
/** /**
* *
* *
@ -230,4 +238,32 @@ public class FileUploadUtils
} }
return extension; return extension;
} }
public static String generateImage(String file, String uploadFilePath) {
// 解密
try {
// 图片分类路径+图片名+图片后缀
String imgClassPath = UUID.randomUUID().toString().concat(".jpg");
// 解密
Base64.Decoder decoder = Base64.getDecoder();
// 去掉base64前缀 data:image/jpeg;base64,
file = file.substring(file.indexOf(",", 1) + 1, file.length());
byte[] b = decoder.decode(file);
// 处理数据
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
// 保存图片
OutputStream out = new FileOutputStream(uploadFilePath.concat(imgClassPath));
out.write(b);
out.flush();
out.close();
// 返回图片的相对路径 = 图片分类路径+图片名+图片后缀
return imgClassPath;
} catch (IOException e) {
return null;
}
}
} }

@ -5,6 +5,7 @@ import javax.annotation.Resource;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.UserStatus; import com.ruoyi.common.enums.UserStatus;
import com.ruoyi.common.utils.*; import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.system.domain.TDoctor; import com.ruoyi.system.domain.TDoctor;
import com.ruoyi.system.domain.req.AppRegisterReq; import com.ruoyi.system.domain.req.AppRegisterReq;
import com.ruoyi.system.mapper.TDoctorMapper; import com.ruoyi.system.mapper.TDoctorMapper;
@ -12,6 +13,7 @@ import com.ruoyi.system.service.impl.UserTokenService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@ -44,6 +46,9 @@ import java.util.Objects;
public class SysLoginService public class SysLoginService
{ {
private static final Logger log = LoggerFactory.getLogger(SysLoginService.class); private static final Logger log = LoggerFactory.getLogger(SysLoginService.class);
@Value("${ruoyi.profile}")
private String uploadFilePath;
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
@ -141,6 +146,9 @@ public class SysLoginService
} }
public AjaxResult loginForAppFillInfo(AppRegisterReq req) { public AjaxResult loginForAppFillInfo(AppRegisterReq req) {
if (StringUtils.isNotEmpty(req.getMedicalLicense())) {
req.setMedicalLicense(FileUploadUtils.generateImage(req.getMedicalLicense(), uploadFilePath));
}
// 查询sys_user数据 // 查询sys_user数据
SysUser sysUser = userService.selectUserByPhone(req.getPhone()); SysUser sysUser = userService.selectUserByPhone(req.getPhone());
if (Objects.nonNull(sysUser)) { if (Objects.nonNull(sysUser)) {

@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.http.HttpUtils; import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.ip.IpUtils; import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.common.utils.wechat.WechatKeys; import com.ruoyi.common.utils.wechat.WechatKeys;
@ -55,6 +56,9 @@ public class WechatServiceImpl implements IWechatService {
@Value("${wx.wechatSecret}") @Value("${wx.wechatSecret}")
private String wechatSecret; private String wechatSecret;
@Value("${ruoyi.profile}")
private String uploadFilePath;
@Resource @Resource
private TWechatUserMapper tWechatUserMapper; private TWechatUserMapper tWechatUserMapper;
@ -144,6 +148,9 @@ public class WechatServiceImpl implements IWechatService {
public String loginForApp(LoginForAppReq req) { public String loginForApp(LoginForAppReq req) {
// 查询手机号是否存在医生信息 // 查询手机号是否存在医生信息
TDoctor tDoctor = new TDoctor(); TDoctor tDoctor = new TDoctor();
if (StringUtils.isNotEmpty(req.getMedicalLicense())) {
req.setMedicalLicense(FileUploadUtils.generateImage(req.getMedicalLicense(), uploadFilePath));
}
BeanUtils.copyProperties(req, tDoctor); BeanUtils.copyProperties(req, tDoctor);
TDoctor currentDoctor = tDoctorMapper.selectTDoctorByPhone(req.getPhone()); TDoctor currentDoctor = tDoctorMapper.selectTDoctorByPhone(req.getPhone());
TWechatUser wechatUser = new TWechatUser(); TWechatUser wechatUser = new TWechatUser();

Loading…
Cancel
Save