Merge pull request 'auth登录接口' (#2) from cbx into master

Reviewed-on: #2
jpz
cbx 2024-01-10 22:28:10 +08:00
commit a563d325e9
34 changed files with 764 additions and 221 deletions

View File

@ -11,6 +11,9 @@ import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(contextId = "remoteDoctorService", value = ServiceNameConstants.FILE_DOCTOR, fallback = RemoteDoctorFallbackFactory.class)
public interface RemoteDoctorService {
@PostMapping("/doctor/getDoctor")
public R<LoginUser> getDoctorInfo(@RequestParam("email") String email);
@PostMapping("/doctor/getUser")
R<LoginUser> getDoctorUserInfo(@RequestParam("email") String email);
public R<LoginUser> getUser(@RequestParam("email") String email);
}

View File

@ -36,4 +36,8 @@ public interface RemoteUserService
*/
@PostMapping("/user/register")
public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@PostMapping("/user/getUser/{email}")
public R<LoginUser> getUser(@PathVariable("email") String email);
}

View File

@ -0,0 +1,51 @@
package doctor.system.api.domain;
import java.util.Date;
public class Department {
private int id;
private String departmentName;
private String pic;
private int rank;
private Date createTime;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public String getPic() {
return pic;
}
public void setPic(String pic) {
this.pic = pic;
}
public int getRank() {
return rank;
}
public void setRank(int rank) {
this.rank = rank;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@ -0,0 +1,148 @@
package doctor.system.api.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
public class Doctor {
private Integer id;
private Integer departmentId;
private String email;
private String userName;
private Integer reviewStatus;
private String phone;
private String password;
private String name;
private String imagePic;
private String jobTitle;
private String inauguralHospital;
private String personalProfile;
private String goodField;
private Department department;
public Department getDepartment() {
return department;
}
public void setDepartment(Department department) {
this.department = department;
}
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date createTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getDepartmentId() {
return departmentId;
}
public void setDepartmentId(Integer departmentId) {
this.departmentId = departmentId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getReviewStatus() {
return reviewStatus;
}
public void setReviewStatus(Integer reviewStatus) {
this.reviewStatus = reviewStatus;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getImagePic() {
return imagePic;
}
public void setImagePic(String imagePic) {
this.imagePic = imagePic;
}
public String getJobTitle() {
return jobTitle;
}
public void setJobTitle(String jobTitle) {
this.jobTitle = jobTitle;
}
public String getInauguralHospital() {
return inauguralHospital;
}
public void setInauguralHospital(String inauguralHospital) {
this.inauguralHospital = inauguralHospital;
}
public String getPersonalProfile() {
return personalProfile;
}
public void setPersonalProfile(String personalProfile) {
this.personalProfile = personalProfile;
}
public String getGoodField() {
return goodField;
}
public void setGoodField(String goodField) {
this.goodField = goodField;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@ -1,8 +1,8 @@
package doctor.domain.entity;
package doctor.system.api.domain;
import java.security.Timestamp;
public class DoctorUser {
public class User {
private int id;
private String phone;

View File

@ -3,13 +3,43 @@ package doctor.system.api.factory;
import doctor.common.core.domain.R;
import doctor.system.api.RemoteDoctorService;
import doctor.system.api.model.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
public class RemoteDoctorFallbackFactory implements RemoteDoctorService {
private static final Logger log = LoggerFactory.getLogger(RemoteDoctorFallbackFactory.class);
@Override
public R<LoginUser> getDoctorUserInfo(String email) {
public R<LoginUser> getDoctorInfo(String email) {
log.error("文件服务调用失败");
return R.fail("登录超时");
}
@Override
public R<LoginUser> getUser(String email) {
log.error("文件服务调用失败");
return R.fail("登录超时");
}
// @Override
// public RemoteDoctorService create(Throwable throwable)
// {
// log.error("文件服务调用失败:{}", throwable.getMessage());
// return new RemoteDoctorService() {
// @Override
// public R<LoginUser> getDoctorInfo(String email) {
// return R.fail("登录超时");
// }
//
// @Override
// public R<LoginUser> getUser(String email) {
// return R.fail("登录失败");
// }
//
//
// };
// }
}

View File

@ -36,6 +36,13 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
{
return R.fail("注册用户失败:" + throwable.getMessage());
}
@Override
public R<LoginUser> getUser(String email) {
return R.fail("登录失败:" + throwable.getMessage());
}
};
}
}

View File

@ -3,7 +3,10 @@ package doctor.system.api.model;
import java.io.Serializable;
import java.util.Set;
import doctor.system.api.domain.Department;
import doctor.system.api.domain.Doctor;
import doctor.system.api.domain.SysUser;
import doctor.system.api.domain.User;
/**
*
@ -59,6 +62,10 @@ public class LoginUser implements Serializable
*/
private SysUser sysUser;
private Doctor doctor;
private User user;
public String getToken()
{
@ -85,6 +92,22 @@ public class LoginUser implements Serializable
return username;
}
public Doctor getDoctor() {
return doctor;
}
public void setDoctor(Doctor doctor) {
this.doctor = doctor;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public void setUsername(String username)
{
this.username = username;

View File

@ -0,0 +1,31 @@
package doctor.auth.controller;
import doctor.auth.service.HealthDoctorService;
import doctor.auth.service.HealthUserService;
import doctor.auth.vo.DoctorVo;
import doctor.common.core.domain.HealthR;
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;
@RestController
@RequestMapping("/doctor/v1")
public class HealthDoctorController {
@Autowired
private HealthDoctorService healthDoctorService;
@PostMapping("/login")
public HealthR<?> login(@RequestParam String email, @RequestParam String pwd) {
DoctorVo userInfo = healthDoctorService.login(email,pwd);
if (userInfo!=null){
return HealthR.ok(userInfo,"登录成功");
}else {
return HealthR.fail("登录失败");
}
}
}

View File

@ -1,29 +1,24 @@
package doctor.auth.controller;
import doctor.auth.service.HealthService;
import doctor.auth.vo.DoctorUserVo;
import doctor.auth.service.HealthUserService;
import doctor.auth.vo.UserVo;
import doctor.common.core.domain.HealthR;
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.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 java.util.Map;
@RestController
@RequestMapping("/doctor/v1")
public class HealthController {
@RequestMapping("/user/v1")
public class HealthUserController {
@Autowired
private HealthService healthService;
private HealthUserService healthService;
@PostMapping("/login")
public HealthR<?> login(@RequestParam String email, @RequestParam String pwd) {
DoctorUserVo userInfo = healthService.login(email,pwd);
UserVo userInfo = healthService.login(email,pwd);
if (userInfo!=null){
return HealthR.ok(userInfo);
}else {

View File

@ -0,0 +1,52 @@
package doctor.auth.service;
import doctor.auth.util.RSAUtils;
import doctor.auth.util.RsaKey;
import doctor.auth.vo.DoctorVo;
import doctor.auth.vo.UserVo;
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;
import java.util.UUID;
@Component
public class HealthDoctorService {
@Autowired
private RemoteDoctorService remoteDoctorService;
@Autowired
private TokenService tokenService;
public DoctorVo login(String email, String pwd) {
DoctorVo doctorVo = new DoctorVo();
R<LoginUser> userResult = remoteDoctorService.getDoctorInfo(email);
LoginUser data = userResult.getData();
String s="";
try {
s = RSAUtils.rsaDecrypt(pwd, RsaKey.PRIVATE_KEY);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (s.equals(data.getSysUser().getPassword())){
Map<String, Object> token = tokenService.createToken(data);
String accessToken = (String) token.get("access_token");
doctorVo.setSessionId(accessToken);
doctorVo.setDoctorId(data.getSysUser().getUserId().intValue());
doctorVo.setUserName(data.getSysUser().getUserName());
doctorVo.setImagePic(data.getDoctor().getImagePic());
doctorVo.setJobTitle(data.getDoctor().getJobTitle());
doctorVo.setDepartmentId(data.getDoctor().getDepartmentId().intValue());
doctorVo.setInauguralHospital(data.getDoctor().getInauguralHospital());
doctorVo.setDepartmentName(data.getDoctor().getDepartment().getDepartmentName());
doctorVo.setInauguralHospital(data.getDoctor().getInauguralHospital());
doctorVo.setJiGuangPwd(s);
doctorVo.setWhetherHaveImagePic(2);
return doctorVo;
}
return null;
}
}

View File

@ -1,50 +0,0 @@
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 {
@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);
}
if (s.equals(data.getSysUser().getPassword())){
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;
}
return null;
}
}

View File

@ -0,0 +1,58 @@
package doctor.auth.service;
import doctor.auth.util.RSAUtils;
import doctor.auth.util.RsaKey;
import doctor.auth.vo.UserVo;
import doctor.common.core.domain.R;
import doctor.common.security.service.TokenService;
import doctor.system.api.RemoteDoctorService;
import doctor.system.api.RemoteUserService;
import doctor.system.api.factory.RemoteUserFallbackFactory;
import doctor.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.UUID;
@Component
public class HealthUserService {
@Autowired
private RemoteDoctorService remoteDoctorUserService;
@Autowired
private TokenService tokenService;
public UserVo login(String email, String pwd) {
UserVo doctorUserVo = new UserVo();
R<LoginUser> userResult = remoteDoctorUserService.getUser(email);
LoginUser data = userResult.getData();
String s="";
try {
s = RSAUtils.rsaDecrypt(pwd, RsaKey.PRIVATE_KEY);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (s.equals(data.getSysUser().getPassword())){
Map<String, Object> token = tokenService.createToken(data);
String accessToken = (String) token.get("access_token");
doctorUserVo.setSessionId(accessToken);
doctorUserVo.setEmail(data.getUser().getEmail());
doctorUserVo.setUserId(data.getUser().getId());
doctorUserVo.setUserName(data.getUser().getUserName());
doctorUserVo.setNickName(data.getUser().getNickName());
doctorUserVo.setAge(data.getUser().getAge());
doctorUserVo.setJiGuangPwd(s);
doctorUserVo.setHeadPic(data.getUser().getHeadPic());
doctorUserVo.setSex(data.getUser().getSex());
doctorUserVo.setHeight(data.getUser().getHeight());
doctorUserVo.setWeight(data.getUser().getWeight());
doctorUserVo.setFaceFlag(1);
UUID uuid = UUID.randomUUID();
String inviteCode = uuid.toString().replaceAll("-", "").substring(0, 8);
doctorUserVo.setInvitationCode(inviteCode);
doctorUserVo.setWhetherBingWeChat(2);
return doctorUserVo;
}
return null;
}
}

View File

@ -0,0 +1,112 @@
package doctor.auth.vo;
public class DoctorVo {
private int doctorId;
private String sessionId;
private String name;
private String userName;
private int reviewStatus;
private String jiGuangPwd;
private String imagePic;
private String inauguralHospital;
private String jobTitle;
private int departmentId;
private String departmentName;
private int whetherHaveImagePic;
public int getDoctorId() {
return doctorId;
}
public void setDoctorId(int doctorId) {
this.doctorId = doctorId;
}
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public int getReviewStatus() {
return reviewStatus;
}
public void setReviewStatus(int reviewStatus) {
this.reviewStatus = reviewStatus;
}
public String getJiGuangPwd() {
return jiGuangPwd;
}
public void setJiGuangPwd(String jiGuangPwd) {
this.jiGuangPwd = jiGuangPwd;
}
public String getImagePic() {
return imagePic;
}
public void setImagePic(String imagePic) {
this.imagePic = imagePic;
}
public String getInauguralHospital() {
return inauguralHospital;
}
public void setInauguralHospital(String inauguralHospital) {
this.inauguralHospital = inauguralHospital;
}
public String getJobTitle() {
return jobTitle;
}
public void setJobTitle(String jobTitle) {
this.jobTitle = jobTitle;
}
public int getDepartmentId() {
return departmentId;
}
public void setDepartmentId(int departmentId) {
this.departmentId = departmentId;
}
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public int getWhetherHaveImagePic() {
return whetherHaveImagePic;
}
public void setWhetherHaveImagePic(int whetherHaveImagePic) {
this.whetherHaveImagePic = whetherHaveImagePic;
}
}

View File

@ -1,6 +1,6 @@
package doctor.auth.vo;
public class DoctorUserVo {
public class UserVo {
private Integer userId;
private String sessionId;
private String nickName;

View File

@ -25,3 +25,11 @@ spring:
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
# feign 配置
feign:
compression:
request:
enabled: true
min-request-size: 10000
response:
enabled: true

View File

@ -21,5 +21,6 @@ public class ServiceNameConstants
* serviceid
*/
public static final String FILE_SERVICE = "doctor-file";
public static final String FILE_DOCTOR = "doctor-health";
}

View File

@ -75,6 +75,11 @@
<artifactId>doctor-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>doctor</groupId>
<artifactId>doctor-api-system</artifactId>
</dependency>
</dependencies>

View File

@ -0,0 +1,46 @@
package doctor.controller;
import com.baomidou.dynamic.datasource.annotation.DS;
import doctor.common.core.domain.R;
import doctor.system.api.domain.Doctor;
import doctor.system.api.domain.User;
import doctor.service.DoctorUserService;
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.*;
@RestController
@RequestMapping("/doctor")
@DS("master")
public class HealthLoginController {
@Autowired
private DoctorUserService iDoctorUserService;
@PostMapping("/getUser")
public R<LoginUser> getUser(@RequestParam String email) {
User user = iDoctorUserService.getUser(email);
LoginUser loginUser = new LoginUser();
SysUser sysUser = new SysUser();
sysUser.setUserId(Long.valueOf(user.getId()));
sysUser.setUserName(user.getNickName());
loginUser.setUser(user);
loginUser.setSysUser(sysUser);
return R.ok(loginUser);
}
@PostMapping("/getDoctor")
public R<LoginUser> getDoctor(@RequestParam String email) {
Doctor user = iDoctorUserService.getDoctor(email);
LoginUser loginUser = new LoginUser();
SysUser sysUser = new SysUser();
sysUser.setUserId(Long.valueOf(user.getId()));
sysUser.setUserName(user.getName());
loginUser.setDoctor(user);
loginUser.setSysUser(sysUser);
return R.ok(loginUser);
}
}

View File

@ -1,40 +0,0 @@
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("master")
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);
}
}

View File

@ -0,0 +1,16 @@
package doctor.mapper;
import doctor.system.api.domain.Department;
import doctor.system.api.domain.Doctor;
import doctor.system.api.domain.User;
import org.apache.ibatis.annotations.Param;
import org.mybatis.spring.annotation.MapperScan;
@MapperScan
public interface DoctorUserMapper {
User selectUserByEmail(@Param("email") String email);
Doctor selectDoctorByEmail(String email);
Department findDepartmentByDoctorDepartmentId(Integer departmentId);
}

View File

@ -1,10 +0,0 @@
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);
}

View File

@ -0,0 +1,10 @@
package doctor.service;
import doctor.system.api.domain.Doctor;
import doctor.system.api.domain.User;
public interface DoctorUserService {
User getUser(String email);
Doctor getDoctor(String email);
}

View File

@ -1,8 +0,0 @@
package doctor.service;
import doctor.domain.entity.DoctorUser;
import doctor.system.api.model.LoginUser;
public interface IDoctorUserService {
DoctorUser getUser(String email);
}

View File

@ -0,0 +1,29 @@
package doctor.service.impl;
import doctor.system.api.domain.Department;
import doctor.system.api.domain.Doctor;
import doctor.system.api.domain.User;
import doctor.mapper.DoctorUserMapper;
import doctor.service.DoctorUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DoctorUserServiceImpl implements DoctorUserService {
@Autowired
private DoctorUserMapper iDoctorUserMapper;
@Override
public User getUser(String email) {
User doctorUser = iDoctorUserMapper.selectUserByEmail(email);
return doctorUser;
}
@Override
public Doctor getDoctor(String email) {
Doctor doctor = iDoctorUserMapper.selectDoctorByEmail(email);
Department department=iDoctorUserMapper.findDepartmentByDoctorDepartmentId(doctor.getDepartmentId());
doctor.setDepartment(department);
return doctor;
}
}

View File

@ -1,19 +0,0 @@
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;
}
}

View File

@ -25,3 +25,11 @@ spring:
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
# feign 配置
feign:
compression:
request:
enabled: true
min-request-size: 10000
response:
enabled: true

View File

@ -0,0 +1,17 @@
<?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.DoctorUserMapper">
<select id="selectUserByEmail" resultType="doctor.system.api.domain.User">
select * from user where email = #{email}
</select>
<select id="selectDoctorByEmail" resultType="doctor.system.api.domain.Doctor">
select * from doctor where email = #{email}
</select>
<select id="findDepartmentByDoctorDepartmentId" resultType="doctor.system.api.domain.Department">
select * from department where id = #{doctor.departmentId}
</select>
</mapper>

View File

@ -1,11 +0,0 @@
<?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>

View File

@ -5,17 +5,12 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import doctor.system.api.domain.User;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import doctor.common.core.domain.R;
import doctor.common.core.utils.StringUtils;
@ -78,6 +73,18 @@ public class SysUserController extends BaseController
return getDataTable(list);
}
@PostMapping("/getUser/{email}")
public R<LoginUser> getUser(@PathVariable String email) {
User user = userService.getUser(email);
LoginUser loginUser = new LoginUser();
SysUser sysUser = new SysUser();
sysUser.setUserId(Long.valueOf(user.getId()));
loginUser.setUser(user);
loginUser.setSysUser(sysUser);
return R.ok(loginUser);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:user:export")
@PostMapping("/export")

View File

@ -1,7 +1,10 @@
package doctor.system.mapper;
import java.util.List;
import doctor.system.api.domain.User;
import doctor.system.domain.SysUserPost;
import org.apache.ibatis.annotations.Param;
/**
*
@ -41,4 +44,7 @@ public interface SysUserPostMapper
* @return
*/
public int batchUserPost(List<SysUserPost> userPostList);
User selectUserByEmail(@Param("email") String email);
}

View File

@ -2,6 +2,7 @@ package doctor.system.service;
import java.util.List;
import doctor.system.api.domain.SysUser;
import doctor.system.api.domain.User;
/**
*
@ -203,4 +204,6 @@ public interface ISysUserService
* @return
*/
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
User getUser(String email);
}

View File

@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.validation.Validator;
import doctor.system.api.domain.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -542,4 +544,10 @@ public class SysUserServiceImpl implements ISysUserService
return successMsg.toString();
}
@Override
public User getUser(String email) {
User doctorUser = userPostMapper.selectUserByEmail(email);
return doctorUser;
}
}

View File

@ -16,6 +16,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="countUserPostById" resultType="Integer">
select count(1) from sys_user_post where post_id=#{postId}
</select>
<select id="selectUserByEmail" resultType="doctor.system.api.domain.User">
select u.* from user u where u.email=#{email}
</select>
<delete id="deleteUserPost" parameterType="Long">
delete from sys_user_post where user_id in