# Conflicts:
#	doctor-api/doctor-api-system/src/main/java/doctor/system/api/domain/User.java
cbx
fjj 2024-01-14 16:14:58 +08:00
commit 16bc23b2a2
13 changed files with 300 additions and 230 deletions

View File

@ -1,10 +1,11 @@
package doctor.system.api.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class Doctor {
private Integer id;
private Integer departmentId;
@ -34,115 +35,4 @@ public class Doctor {
@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 getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
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,15 +1,11 @@
package doctor.system.api.domain;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @ClassName : User
* @Description :
* @Author : FJJ
* @Date: 2024-01-10 20:46
*/
@Data
public class User {
private Integer id;
private String phone;
@ -24,117 +20,6 @@ public class User {
private Integer weight;
private String invitationCode;
private Date updateTime;
private long createTime;
private Date createTime;
public Integer getId() {
return id;
}
public void setId(Integer 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 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 getInvitationCode() {
return invitationCode;
}
public void setInvitationCode(String invitationCode) {
this.invitationCode = invitationCode;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
}

View File

@ -30,6 +30,9 @@ public class HealthDoctorService {
} catch (Exception e) {
throw new RuntimeException(e);
}
if (data==null){
return null;
}
if (s.equals(data.getDoctor().getPwd())){
Map<String, Object> token = tokenService.createToken(data);
String accessToken = (String) token.get("access_token");

View File

@ -30,6 +30,9 @@ public class HealthUserService {
} catch (Exception e) {
throw new RuntimeException(e);
}
if (data==null){
return null;
}
if (s.equals(data.getUser().getPwd())){
Map<String, Object> token = tokenService.createToken(data);
String accessToken = (String) token.get("access_token");

View File

@ -14,6 +14,13 @@
<dependencies>
<!-- Oss上传 -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>

View File

@ -4,10 +4,13 @@ import doctor.common.core.domain.HealthR;
import doctor.domain.dto.ApplyJoinDto;
import doctor.domain.entity.Banners;
import doctor.domain.entity.DoctorJobTitleEntity;
import doctor.domain.vo.DoctorVo;
import doctor.domain.vo.FindImagePicVo;
import doctor.service.BannersService;
import doctor.service.HealthJobTitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -42,4 +45,22 @@ public class HealthJobTitleController {
HealthR healthR= healthJobTitleService.applyJoin(applyJoinDto);
return HealthR.ok(healthR);
}
@GetMapping("/findDoctorById")
public HealthR<DoctorVo> findDoctorById(@RequestHeader Integer doctorId,
@RequestHeader String sessionId) {
return HealthR.ok(healthJobTitleService.findDoctorById(doctorId));
}
@GetMapping("/findSystemImagePic")
public HealthR<List<FindImagePicVo>> findSystemImagePic() {
return HealthR.ok(healthJobTitleService.findSystemImagePic());
}
@PostMapping("/uploadImagePic")
public HealthR uploadImagePic(@RequestParam("imagePic") MultipartFile imagePic,
@RequestHeader String sessionId,
@RequestHeader Integer doctorId) {
return HealthR.ok(healthJobTitleService.uploadImagePic(imagePic,doctorId,sessionId));
}
}

View File

@ -0,0 +1,16 @@
package doctor.domain.vo;
import lombok.Data;
@Data
public class DoctorVo {
private Integer departmentId;
private String departmentName;
private String goodField;
private Integer id;
private String imagePic;
private String inauguralHospital;
private String jobTitle;
private String name;
private String personalProfile;
}

View File

@ -0,0 +1,8 @@
package doctor.domain.vo;
import lombok.Data;
@Data
public class FindImagePicVo {
private String imagePic;
}

View File

@ -1,8 +1,10 @@
package doctor.mapper;
import doctor.domain.entity.DoctorJobTitleEntity;
import doctor.system.api.domain.Department;
import doctor.system.api.domain.Doctor;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -11,4 +13,14 @@ public interface HealthJobTitleMapper {
List<DoctorJobTitleEntity> findJobTitleList();
void insertDoctor(Doctor doctor);
Doctor findDoctorById(Integer id);
Department findDepartmentById(Integer departmentId);
DoctorJobTitleEntity findDoctorJobTitleById(Integer id);
List<String> findDoctorImgPic();
void updDoctorImgPicBuyId(@Param("doctorId") Integer doctorId, @Param("s") String s);
}

View File

@ -3,6 +3,10 @@ package doctor.service;
import doctor.common.core.domain.HealthR;
import doctor.domain.dto.ApplyJoinDto;
import doctor.domain.entity.DoctorJobTitleEntity;
import doctor.domain.vo.DoctorVo;
import doctor.domain.vo.FindImagePicVo;
import io.swagger.models.auth.In;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -12,4 +16,10 @@ public interface HealthJobTitleService {
HealthR sendEmailCode(String email);
HealthR applyJoin(ApplyJoinDto applyJoinDto);
DoctorVo findDoctorById(Integer doctorId);
List<FindImagePicVo> findSystemImagePic();
HealthR uploadImagePic(MultipartFile imagePic, Integer doctorId, String sessionId);
}

View File

@ -1,11 +1,17 @@
package doctor.service.impl;
import doctor.common.core.domain.HealthR;
import doctor.common.security.service.TokenService;
import doctor.domain.dto.ApplyJoinDto;
import doctor.domain.entity.DoctorJobTitleEntity;
import doctor.domain.vo.DoctorVo;
import doctor.domain.vo.FindImagePicVo;
import doctor.mapper.HealthJobTitleMapper;
import doctor.service.HealthJobTitleService;
import doctor.system.api.domain.Department;
import doctor.system.api.domain.Doctor;
import doctor.system.api.model.LoginUser;
import doctor.util.OssUtil;
import doctor.util.RSAUtils;
import doctor.util.RsaKey;
import doctor.util.SendEmail;
@ -14,8 +20,10 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
@ -27,6 +35,8 @@ public class HealthJobTitleServiceImpl implements HealthJobTitleService {
private HealthJobTitleMapper healthJobTitleMapper;
@Autowired
private SendEmail sendEmail;
@Autowired
private TokenService tokenService;
@Resource
private RedisTemplate<String,Integer> redisTemplate;
@ -80,8 +90,44 @@ public class HealthJobTitleServiceImpl implements HealthJobTitleService {
Doctor doctor = new Doctor();
BeanUtils.copyProperties(applyJoinDto,doctor);
doctor.setCreateTime(new Date());
Integer jobTitleId = applyJoinDto.getJobTitleId();
DoctorJobTitleEntity doctorJobTitleEntity=healthJobTitleMapper.findDoctorJobTitleById(jobTitleId);
doctor.setJobTitle(doctorJobTitleEntity.getJobTitle());
healthJobTitleMapper.insertDoctor(doctor);
redisTemplate.delete(applyJoinDto.getEmail());
return HealthR.ok();
}
@Override
public DoctorVo findDoctorById(Integer doctorId) {
DoctorVo doctorVo = new DoctorVo();
Doctor doctor=healthJobTitleMapper.findDoctorById(doctorId);
Department department=healthJobTitleMapper.findDepartmentById(doctor.getDepartmentId());
BeanUtils.copyProperties(doctor,doctorVo);
BeanUtils.copyProperties(department,doctorVo);
return doctorVo;
}
@Override
public List<FindImagePicVo> findSystemImagePic() {
ArrayList<FindImagePicVo> findImagePicVos = new ArrayList<>();
FindImagePicVo findImagePicVo = new FindImagePicVo();
List<String> imgPics= healthJobTitleMapper.findDoctorImgPic();
for (String imgPic : imgPics) {
findImagePicVo.setImagePic(imgPic);
findImagePicVos.add(findImagePicVo);
}
return findImagePicVos;
}
@Override
public HealthR uploadImagePic(MultipartFile imagePic,Integer doctorId,String sessionId) {
String s = OssUtil.uploadMultipartFile(imagePic);
healthJobTitleMapper.updDoctorImgPicBuyId(doctorId,s);
LoginUser loginUser = tokenService.getLoginUser(sessionId);
Doctor doctor = loginUser.getDoctor();
doctor.setImagePic(s);
tokenService.createToken(loginUser);
return HealthR.ok(s);
}
}

View File

@ -0,0 +1,154 @@
package doctor.util;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.GetObjectRequest;
import com.aliyun.oss.model.PutObjectRequest;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.time.LocalDateTime;
import java.util.UUID;
/**
* Oss
*/
@Log4j2
public class OssUtil {
/**
* Endpoint AccessKeyaccessKeySecretAPI访 访
*/
private static String endPoint = "oss-cn-shanghai.aliyuncs.com";
private static String accessKeyId = "LTAI5tLE4XbyvvbuT7D2stCk";
private static String accessKeySecret = "W7ZeT4dMrMPP0c8BBwcyIPnhe3P4E8";
private static String accessPre = "https://lyb1314.oss-cn-shanghai.aliyuncs.com/";
/**
* bucket
* @return
*/
private static String bucketName = "lyb1314";
private static OSS ossClient ;
static {
ossClient = new OSSClientBuilder().build(
endPoint,
accessKeyId,
accessKeySecret);
log.info("oss服务连接成功");
}
/**
*
* @param filePath
*/
public static String uploadFile(String filePath){
return uploadFileForBucket(bucketName,getOssFilePath(filePath) ,filePath);
}
/**
* multipartFile
* @param multipartFile
*/
public static String uploadMultipartFile(MultipartFile multipartFile) {
return uploadMultipartFile(bucketName,getOssFilePath(multipartFile.getOriginalFilename()),multipartFile);
}
/**
* multipartFile
* @param bucketName
* @param ossPath
* @param multipartFile
*/
public static String uploadMultipartFile(String bucketName , String ossPath , MultipartFile multipartFile){
InputStream inputStream = null;
try {
inputStream = multipartFile.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
return accessPre+ossPath;
}
/**
* 使FilePutObject ** 使
* @param bucketName
* @param ossPath oss
* @param filePath
*/
public static String uploadFileForBucket(String bucketName , String ossPath , String filePath) {
// 创建PutObjectRequest对象。
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, ossPath, new File(filePath));
// 上传
ossClient.putObject(putObjectRequest);
return accessPre+ossPath;
}
/**
* 使bucket
* @param bucketName
* @param ossPath oss
* @param filePath
*/
public static String uploadFileInputStreamForBucket(String bucketName , String ossPath , String filePath){
// 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。
InputStream inputStream = null;
try {
inputStream = new FileInputStream(filePath);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
// 填写Bucket名称和Object完整路径。Object完整路径中不能包含Bucket名称。
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
return accessPre+ossPath;
}
public static void uploadFileInputStreamForBucket(String bucketName , String ossPath , InputStream inputStream ){
ossClient.putObject(bucketName, ossPath, inputStream);
}
/**
*
* @param ossFilePath
* @param filePath
*/
public static void downloadFile(String ossFilePath , String filePath ){
downloadFileForBucket(bucketName , ossFilePath , filePath);
}
/**
*
* @param bucketName
* @param ossFilePath oss
* @param filePath
*/
public static void downloadFileForBucket(String bucketName , String ossFilePath , String filePath ){
ossClient.getObject(new GetObjectRequest(bucketName, ossFilePath), new File(filePath));
}
/**
*
* @return
*/
public static String getOssDefaultPath(){
LocalDateTime now = LocalDateTime.now();
String url =
now.getYear()+"/"+
now.getMonth()+"/"+
now.getDayOfMonth()+"/"+
now.getHour()+"/"+
now.getMinute()+"/";
return url;
}
public static String getOssFilePath(String filePath){
String fileSuf = filePath.substring(filePath.indexOf(".") + 1);
return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf;
}
}

View File

@ -8,9 +8,24 @@
VALUES (0,#{departmentId},#{email},#{userName},#{reviewStatus},#{phone},#{pwd},#{name},#{imagePic},#{jobTitle},#{inauguralHospital},#{personalProfile},#{goodField},#{createTime});
</insert>
<update id="updDoctorImgPicBuyId">
update doctor set image_pic=#{s} where id=#{doctorId}
</update>
<select id="findJobTitleList" resultType="doctor.domain.entity.DoctorJobTitleEntity">
select * from doctor_job_title
</select>
<select id="findDoctorById" resultType="doctor.system.api.domain.Doctor">
select * from doctor where id=#{id}
</select>
<select id="findDepartmentById" resultType="doctor.system.api.domain.Department">
select * from department where id=#{id}
</select>
<select id="findDoctorJobTitleById" resultType="doctor.domain.entity.DoctorJobTitleEntity">
select * from doctor_job_title where id=#{id}
</select>
<select id="findDoctorImgPic" resultType="java.lang.String">
select image_pic from doctor
</select>
</mapper>