申请入驻完结撒花

cbx
chenbingxuan 2024-01-12 21:47:55 +08:00
parent 2c07292727
commit bb50f5a2b9
44 changed files with 548 additions and 188 deletions

View File

@ -15,11 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
config:
# 配置中心地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,11 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
config:
# 配置中心地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,11 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
config:
# 配置中心地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,11 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
config:
# 配置中心地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -84,6 +84,11 @@
<artifactId>doctor-api-system</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
</dependencies>

View File

@ -0,0 +1,25 @@
package doctor.controller;
import doctor.common.core.domain.HealthR;
import doctor.domain.entity.DepartmentEntity;
import doctor.service.HealthDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/knowledgeBase/v1")
public class HealthDepartmentController {
@Autowired
private HealthDepartmentService healthV1Service;
@GetMapping("/findDepartment")
public HealthR<List<DepartmentEntity>> findDepartment(){
List<DepartmentEntity> departmentEntities=healthV1Service.findDepartment();
return HealthR.ok(departmentEntities);
}
}

View File

@ -0,0 +1,35 @@
package doctor.controller;
import doctor.common.core.domain.HealthR;
import doctor.domain.dto.ApplyJoinDto;
import doctor.domain.entity.DoctorJobTitleEntity;
import doctor.service.HealthJobTitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/v1")
public class HealthJobTitleController {
@Autowired
private HealthJobTitleService healthJobTitleService;
@GetMapping("/findJobTitleList")
public HealthR<List<DoctorJobTitleEntity>> findJobTitleList() {
List<DoctorJobTitleEntity> doctorJobTitleEntities=healthJobTitleService.findJobTitleList();
return HealthR.ok(doctorJobTitleEntities);
}
@PostMapping("/sendEmailCode")
public HealthR sendEmailCode(@RequestParam("email") String email) {
HealthR healthR= healthJobTitleService.sendEmailCode(email);
return HealthR.ok(healthR);
}
@PostMapping("/applyJoin")
public HealthR applyJoin(@RequestBody ApplyJoinDto applyJoinDto) {
HealthR healthR= healthJobTitleService.applyJoin(applyJoinDto);
return HealthR.ok(healthR);
}
}

View File

@ -1,9 +1,9 @@
package doctor.controller;
import doctor.common.core.domain.R;
import doctor.domain.entity.UserVideoBuy;
import doctor.domain.entity.UserVideoCollection;
import doctor.domain.entity.UserWallet;
import doctor.domain.entity.UserVideoBuyEntity;
import doctor.domain.entity.UserVideoCollectionEntity;
import doctor.domain.entity.UserWalletEntity;
import doctor.service.UserVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -24,8 +24,8 @@ public class UserVideoController {
//用户视频收藏列表
@GetMapping("/findVideoCollectionList")
public R<List<UserVideoCollection>>findVideoCollectionList(){
List<UserVideoCollection> userVideoCollectionList =userVideoService.findVideoCollectionList();
public R<List<UserVideoCollectionEntity>>findVideoCollectionList(){
List<UserVideoCollectionEntity> userVideoCollectionList =userVideoService.findVideoCollectionList();
return R.ok(userVideoCollectionList);
}
//用户取消视频收藏
@ -36,8 +36,8 @@ public class UserVideoController {
}
//用户购买视频列表
@GetMapping("/findUserVideoBuyList")
public R<List<UserVideoBuy>>findUserVideoBuyList(){
List<UserVideoBuy> userVideoBuys =userVideoService.findUserVideoBuyList();
public R<List<UserVideoBuyEntity>>findUserVideoBuyList(){
List<UserVideoBuyEntity> userVideoBuys =userVideoService.findUserVideoBuyList();
return R.ok(userVideoBuys);
}
//用户删除购买的视频
@ -49,8 +49,8 @@ public class UserVideoController {
//我的钱包
@GetMapping("/findUserWallet")
public R<List<UserWallet>> findUserWallet(){
List<UserWallet> userWallets = userVideoService.findUserWallet();
public R<List<UserWalletEntity>> findUserWallet(){
List<UserWalletEntity> userWallets = userVideoService.findUserWallet();
return R.ok(userWallets);
}

View File

@ -21,13 +21,13 @@ public class VideoController {
private VideoService videoService;
//收藏健康讲堂视频列表
@PostMapping("/verify/v1/addUserVideoCollection")
public R addUserVideoCollection(@RequestBody UserVideoCollection userVideoCollection){
public R addUserVideoCollection(@RequestBody UserVideoCollectionEntity userVideoCollection){
videoService.addUserVideoCollection(userVideoCollection);
return R.ok();
}
//购买健康讲堂视频
@PostMapping("/verify/v1/videoBuy")
public R videoBuy(@RequestBody UserVideoBuy userVideoBuy){
public R videoBuy(@RequestBody UserVideoBuyEntity userVideoBuy){
videoService.videoBuy(userVideoBuy);
return R.ok();
}

View File

@ -3,7 +3,7 @@ package doctor.domain.dto;
import lombok.Data;
@Data
public class applyJoinDto {
public class ApplyJoinDto {
private String email;
private String code;
private String pwd1;

View File

@ -0,0 +1,20 @@
package doctor.domain.entity;
import lombok.Data;
import java.util.Date;
@Data
public class DepartmentEntity {
private Integer id;
private String departmentName;
private String pic;
private Integer rank;
private Date createTime;
}

View File

@ -0,0 +1,18 @@
package doctor.domain.entity;
import lombok.Data;
import java.util.Date;
@Data
public class DoctorJobTitleEntity {
private Integer id;
private String jobTitle;
private Date createTime;
}

View File

@ -1,9 +1,8 @@
package doctor.domain.entity;
import java.security.Timestamp;
import java.util.Date;
public class DoctorUser {
public class DoctorUserEntity {
private int id;
private String phone;

View File

@ -1,7 +1,5 @@
package doctor.domain.entity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
@ -10,7 +8,7 @@ import java.util.Date;
* @Author : FJJ
* @Date: 2024-01-10 20:46
*/
public class User {
public class UserEntity {
private Integer id;
private String phone;
private String pwd;

View File

@ -6,7 +6,7 @@ package doctor.domain.entity;
* @Author : FJJ
* @Date: 2024-01-10 15:20
*/
public class UserVideoBuy {
public class UserVideoBuyEntity {
private Integer id;
private Integer userId;
private Integer videoId;
@ -44,13 +44,13 @@ public class UserVideoBuy {
this.createTime = createTime;
}
public UserVideoBuy(Integer id, Integer userId, Integer videoId, Long createTime) {
public UserVideoBuyEntity(Integer id, Integer userId, Integer videoId, Long createTime) {
this.id = id;
this.userId = userId;
this.videoId = videoId;
this.createTime = createTime;
}
public UserVideoBuy() {
public UserVideoBuyEntity() {
}
}

View File

@ -1,10 +1,5 @@
package doctor.domain.entity;
import io.swagger.models.auth.In;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @ClassName : UserVideoCollection
* @Description :
@ -12,7 +7,7 @@ import java.util.Date;
* @Date: 2024-01-10 14:28
*/
public class UserVideoCollection {
public class UserVideoCollectionEntity {
private Integer id;
private Integer userId;
private Integer videoId;
@ -50,13 +45,13 @@ public class UserVideoCollection {
this.createTime = createTime;
}
public UserVideoCollection(Integer id, Integer userId, Integer videoId, Long createTime) {
public UserVideoCollectionEntity(Integer id, Integer userId, Integer videoId, Long createTime) {
this.id = id;
this.userId = userId;
this.videoId = videoId;
this.createTime = createTime;
}
public UserVideoCollection() {
public UserVideoCollectionEntity() {
}
}

View File

@ -1,16 +1,12 @@
package doctor.domain.entity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @ClassName : UserWallet
* @Description :
* @Author : FJJ
* @Date: 2024-01-10 20:30
*/
public class UserWallet {
public class UserWalletEntity {
private Integer id;
private Integer userId;
private Integer balance;

View File

@ -1,5 +1,6 @@
package doctor.domain.entity;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@ -10,6 +11,7 @@ import java.util.Date;
* @Author : FJJ
* @Date: 2024-01-10 15:59
*/
@Data
public class Video {
private Integer id;
private String title;
@ -21,90 +23,4 @@ public class Video {
private Integer price;
private Long createTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getCategoryId() {
return categoryId;
}
public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}
public String getShearUrl() {
return shearUrl;
}
public void setShearUrl(String shearUrl) {
this.shearUrl = shearUrl;
}
public String getAbstracts() {
return abstracts;
}
public void setAbstracts(String abstracts) {
this.abstracts = abstracts;
}
public String getOriginalUrl() {
return originalUrl;
}
public void setOriginalUrl(String originalUrl) {
this.originalUrl = originalUrl;
}
public Integer getDuration() {
return duration;
}
public void setDuration(Integer duration) {
this.duration = duration;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public Video(Integer id, String title, Integer categoryId, String shearUrl, String abstracts, String originalUrl, Integer duration, Integer price, Long createTime) {
this.id = id;
this.title = title;
this.categoryId = categoryId;
this.shearUrl = shearUrl;
this.abstracts = abstracts;
this.originalUrl = originalUrl;
this.duration = duration;
this.price = price;
this.createTime = createTime;
}
public Video() {
}
}

View File

@ -0,0 +1,12 @@
package doctor.mapper;
import doctor.domain.entity.DepartmentEntity;
import org.mybatis.spring.annotation.MapperScan;
import java.util.List;
@MapperScan
public interface HealthDepartmentMapper {
List<DepartmentEntity> findDepartments();
}

View File

@ -0,0 +1,14 @@
package doctor.mapper;
import doctor.domain.entity.DoctorJobTitleEntity;
import doctor.system.api.domain.Doctor;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface HealthJobTitleMapper {
List<DoctorJobTitleEntity> findJobTitleList();
void insertDoctor(Doctor doctor);
}

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

@ -1,8 +1,8 @@
package doctor.mapper;
import doctor.domain.entity.UserVideoBuy;
import doctor.domain.entity.UserVideoCollection;
import doctor.domain.entity.UserWallet;
import doctor.domain.entity.UserVideoBuyEntity;
import doctor.domain.entity.UserVideoCollectionEntity;
import doctor.domain.entity.UserWalletEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -16,13 +16,13 @@ import java.util.List;
*/
@Mapper
public interface UserVideoMapper {
List<UserVideoCollection> findVideoCollectionList();
List<UserVideoCollectionEntity> findVideoCollectionList();
void cancelVideoCollection(@Param("id") Integer id);
List<UserVideoBuy> findUserVideoBuyList();
List<UserVideoBuyEntity> findUserVideoBuyList();
void deleteVideoBuy(@Param("id") Integer id);
List<UserWallet> findUserWallet();
List<UserWalletEntity> findUserWallet();
}

View File

@ -16,7 +16,7 @@ import java.util.List;
public interface VideoMapper {
void addUserVideoCollection(UserVideoCollection userVideoCollection);
void addUserVideoCollection(UserVideoCollectionEntity userVideoCollection);
Video findById(@Param("videoId") Integer videoId);
@ -24,9 +24,9 @@ public interface VideoMapper {
void updateVideoCount(VideoCount videoCount);
User FindById(@Param("userId") Integer userId);
UserEntity FindById(@Param("userId") Integer userId);
UserWallet FindUserWallet(@Param("id") Integer id);
UserWalletEntity FindUserWallet(@Param("id") Integer id);
Video findByVideoId(@Param("videoId") Integer videoId);

View File

@ -0,0 +1,10 @@
package doctor.service;
import doctor.domain.entity.DepartmentEntity;
import java.util.List;
public interface HealthDepartmentService {
List<DepartmentEntity> findDepartment();
}

View File

@ -0,0 +1,15 @@
package doctor.service;
import doctor.common.core.domain.HealthR;
import doctor.domain.dto.ApplyJoinDto;
import doctor.domain.entity.DoctorJobTitleEntity;
import java.util.List;
public interface HealthJobTitleService {
List<DoctorJobTitleEntity> findJobTitleList();
HealthR sendEmailCode(String email);
HealthR applyJoin(ApplyJoinDto applyJoinDto);
}

View File

@ -1,8 +1,8 @@
package doctor.service;
import doctor.domain.entity.UserVideoBuy;
import doctor.domain.entity.UserVideoCollection;
import doctor.domain.entity.UserWallet;
import doctor.domain.entity.UserVideoBuyEntity;
import doctor.domain.entity.UserVideoCollectionEntity;
import doctor.domain.entity.UserWalletEntity;
import java.util.List;
@ -13,13 +13,13 @@ import java.util.List;
* @Date: 2024-01-10 14:33
*/
public interface UserVideoService {
List<UserVideoCollection> findVideoCollectionList();
List<UserVideoCollectionEntity> findVideoCollectionList();
void cancelVideoCollection(Integer id);
List<UserVideoBuy> findUserVideoBuyList();
List<UserVideoBuyEntity> findUserVideoBuyList();
void deleteVideoBuy(Integer id);
List<UserWallet> findUserWallet();
List<UserWalletEntity> findUserWallet();
}

View File

@ -12,10 +12,10 @@ import java.util.List;
*/
public interface VideoService {
void addUserVideoCollection(UserVideoCollection userVideoCollection);
void addUserVideoCollection(UserVideoCollectionEntity userVideoCollection);
void videoBuy(UserVideoBuy userVideoBuy);
void videoBuy(UserVideoBuyEntity userVideoBuy);
List<VideoComment> findVideoCommentList();
}

View File

@ -0,0 +1,20 @@
package doctor.service.impl;
import doctor.domain.entity.DepartmentEntity;
import doctor.mapper.HealthDepartmentMapper;
import doctor.service.HealthDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class HealthDepartmentServiceImpl implements HealthDepartmentService {
@Autowired
private HealthDepartmentMapper healthV1Mapper;
@Override
public List<DepartmentEntity> findDepartment() {
return healthV1Mapper.findDepartments();
}
}

View File

@ -0,0 +1,86 @@
package doctor.service.impl;
import doctor.common.core.domain.HealthR;
import doctor.domain.dto.ApplyJoinDto;
import doctor.domain.entity.DoctorJobTitleEntity;
import doctor.mapper.HealthJobTitleMapper;
import doctor.service.HealthJobTitleService;
import doctor.system.api.domain.Doctor;
import doctor.util.RSAUtils;
import doctor.util.RsaKey;
import doctor.util.SendEmail;
import org.bouncycastle.jcajce.provider.asymmetric.rsa.RSAUtil;
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 javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
@Service
public class HealthJobTitleServiceImpl implements HealthJobTitleService {
@Autowired
private HealthJobTitleMapper healthJobTitleMapper;
@Autowired
private SendEmail sendEmail;
@Resource
private RedisTemplate<String,Integer> redisTemplate;
@Override
public List<DoctorJobTitleEntity> findJobTitleList() {
return healthJobTitleMapper.findJobTitleList();
}
@Override
public HealthR sendEmailCode(String email) {
if (!redisTemplate.hasKey(email)){
Integer integer = redisTemplate.opsForValue().get(email);
sendEmail.sendEmail(email,integer);
}
if (email==null){
return HealthR.fail();
}
Integer code=0;
Random random = new Random();
for (int i = 0; i < 4; i++) {
int i1 = random.nextInt();
code=i+=i1;
}
sendEmail.sendEmail(email,code);
redisTemplate.opsForValue().set(email,code,2, TimeUnit.MINUTES);
return HealthR.ok();
}
@Override
public HealthR applyJoin(ApplyJoinDto applyJoinDto) {
if (applyJoinDto==null){
return HealthR.fail("参数为空");
}
String s="";
try {
s= RSAUtils.rsaDecrypt(applyJoinDto.getPwd1(), RsaKey.PRIVATE_KEY);
String s2 = RSAUtils.rsaDecrypt(applyJoinDto.getPwd2(), RsaKey.PRIVATE_KEY);
if (!s.equals(s2)){
return HealthR.fail("请输入相同的密码");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
if (!redisTemplate.hasKey(applyJoinDto.getEmail())){
return HealthR.fail("验证码过去请重新发送");
}
Integer integer = redisTemplate.opsForValue().get(applyJoinDto.getEmail());
if (!String.valueOf(integer).equals(applyJoinDto.getCode())){
return HealthR.fail("验车码错误");
}
Doctor doctor = new Doctor();
BeanUtils.copyProperties(applyJoinDto,doctor);
doctor.setCreateTime(new Date());
healthJobTitleMapper.insertDoctor(doctor);
return HealthR.ok();
}
}

View File

@ -1,8 +1,8 @@
package doctor.service.impl;
import doctor.domain.entity.UserVideoBuy;
import doctor.domain.entity.UserVideoCollection;
import doctor.domain.entity.UserWallet;
import doctor.domain.entity.UserVideoBuyEntity;
import doctor.domain.entity.UserVideoCollectionEntity;
import doctor.domain.entity.UserWalletEntity;
import doctor.mapper.UserVideoMapper;
import doctor.service.UserVideoService;
import org.springframework.beans.factory.annotation.Autowired;
@ -21,7 +21,7 @@ public class UserVideoServiceImpl implements UserVideoService {
@Autowired
private UserVideoMapper userVideoMapper;
@Override
public List<UserVideoCollection> findVideoCollectionList() {
public List<UserVideoCollectionEntity> findVideoCollectionList() {
return userVideoMapper.findVideoCollectionList();
}
@ -31,7 +31,7 @@ public class UserVideoServiceImpl implements UserVideoService {
}
@Override
public List<UserVideoBuy> findUserVideoBuyList() {
public List<UserVideoBuyEntity> findUserVideoBuyList() {
return userVideoMapper.findUserVideoBuyList();
}
@ -41,7 +41,7 @@ public class UserVideoServiceImpl implements UserVideoService {
}
@Override
public List<UserWallet> findUserWallet() {
public List<UserWalletEntity> findUserWallet() {
return userVideoMapper.findUserWallet();
}
}

View File

@ -20,7 +20,7 @@ public class VideoServiceImpl implements VideoService {
private VideoMapper videoMapper;
@Override
public void addUserVideoCollection(UserVideoCollection userVideoCollection) {
public void addUserVideoCollection(UserVideoCollectionEntity userVideoCollection) {
// 添加收藏
videoMapper.addUserVideoCollection(userVideoCollection);
// 更新视频收藏数
@ -30,13 +30,13 @@ public class VideoServiceImpl implements VideoService {
}
@Override
public void videoBuy(UserVideoBuy userVideoBuy) {
public void videoBuy(UserVideoBuyEntity userVideoBuy) {
//查询用户信息
User user = videoMapper.FindById(userVideoBuy.getUserId());
UserEntity user = videoMapper.FindById(userVideoBuy.getUserId());
//查询视频信息
Video video = videoMapper.findByVideoId(userVideoBuy.getVideoId());
//查询用户钱包
UserWallet userWallet = videoMapper.FindUserWallet(user.getId());
UserWalletEntity userWallet = videoMapper.FindUserWallet(user.getId());
//判断用户钱包是否足够
if (userWallet.getBalance() >= video.getPrice()) {
//更新用户钱包

View File

@ -0,0 +1,133 @@
package doctor.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;
}
}

View File

@ -0,0 +1,20 @@
package doctor.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==";
}

View File

@ -0,0 +1,26 @@
package doctor.util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;
import javax.mail.internet.MimeMessage;
@Component
public class SendEmail {
@Autowired
private JavaMailSender javaMailSender;
public void sendEmail(String email,Integer code){
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true);
mimeMessageHelper.setTo(email);
mimeMessageHelper.setFrom("3581044601@qq.com");
mimeMessageHelper.setSubject("发送验证码");
mimeMessageHelper.setText("验证码为:"+code);
javaMailSender.send(mimeMessage);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -15,13 +15,24 @@ spring:
discovery:
# 服务注册地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
config:
# 配置中心地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
mail:
host: smtp.qq.com
port: 587
username: 3581044601@qq.com
password: bwscqgqpkagjciih
default-encoding: UTF8
properties:
mail:
smtp:
socketFactoryClass: javax.net.ssl.SSLSocketFactory
debug: true

View File

@ -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.HealthDepartmentMapper">
<select id="findDepartments" resultType="doctor.domain.entity.DepartmentEntity">
select * from department
</select>
</mapper>

View File

@ -0,0 +1,16 @@
<?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.HealthJobTitleMapper">
<insert id="insertDoctor">
INSERT INTO doctor (id, department_id, email, user_name, review_status, phone, pwd, name, image_pic, job_title, inaugural_hospital, personal_profile, good_field, create_time)
VALUES (0,#{departmentId},#{email},#{userName},#{reviewStatus},#{phone},#{pwd},#{name},#{imagePic},#{jobTitle},#{inauguralHospital},#{personalProfile},#{goodField},#{createTime});
</insert>
<select id="findJobTitleList" resultType="doctor.domain.entity.DoctorJobTitleEntity">
select * from doctor_job_title
</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

@ -13,15 +13,15 @@
from user_video_buy
where id = #{id}
</delete>
<select id="findVideoCollectionList" resultType="doctor.domain.entity.UserVideoCollection">
<select id="findVideoCollectionList" resultType="doctor.domain.entity.UserVideoCollectionEntity">
select *
from user_video_collection
</select>
<select id="findUserVideoBuyList" resultType="doctor.domain.entity.UserVideoBuy">
<select id="findUserVideoBuyList" resultType="doctor.domain.entity.UserVideoBuyEntity">
select *
from user_video_buy
</select>
<select id="findUserWallet" resultType="doctor.domain.entity.UserWallet">
<select id="findUserWallet" resultType="doctor.domain.entity.UserWalletEntity">
select *
from user_wallet
</select>

View File

@ -35,13 +35,13 @@
from video_count
where id = #{id}
</select>
<select id="FindById" resultType="doctor.domain.entity.User">
<select id="FindById" resultType="doctor.domain.entity.UserEntity">
SELECT user.*
FROM user_video_buy
LEFT JOIN user ON user.id = user_video_buy.user_id
WHERE user_video_buy.user_id = #{userId}
</select>
<select id="FindUserWallet" resultType="doctor.domain.entity.UserWallet">
<select id="FindUserWallet" resultType="doctor.domain.entity.UserWalletEntity">
SELECT user.*
FROM user_wallet
LEFT JOIN user ON user.id = user_wallet.user_id

View File

@ -15,11 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
config:
# 配置中心地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,11 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
config:
# 配置中心地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,11 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
config:
# 配置中心地址
server-addr: 101.34.77.101:8848
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
# 配置文件格式
file-extension: yml
# 共享配置