Compare commits
3 Commits
b7c3a1f09e
...
72fbfd4649
Author | SHA1 | Date |
---|---|---|
|
72fbfd4649 | |
|
d507b1b95f | |
|
3b4600db02 |
|
@ -137,6 +137,36 @@
|
|||
<version>${mapstruct.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 其他依赖 ... -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.4.0</version> <!-- 根据最新版本调整 -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.80</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>facebody20191230</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,13 @@ package doctor.controller;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.api.model.v2.Result;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import doctor.common.core.domain.HealthR;
|
||||
import doctor.domain.entity.SickCircleEntity;
|
||||
import doctor.service.CollectSickService;
|
||||
|
@ -15,9 +22,21 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.MessageDigest;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -54,11 +73,13 @@ public class CollectSickController {
|
|||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* orc身份证识别
|
||||
* @param file
|
||||
*/
|
||||
@PostMapping("/file")
|
||||
@PostMapping("/files")
|
||||
public void file(MultipartFile file) {
|
||||
|
||||
String s = OssUtil.uploadMultipartFile(file);
|
||||
|
@ -145,4 +166,197 @@ public class CollectSickController {
|
|||
return imgBase64;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static final String AES_KEY = "1234567890123456";
|
||||
|
||||
@PostMapping("file")
|
||||
public HealthR<String> hao(@RequestParam("file") String hao){
|
||||
// // 验证主机号长度
|
||||
// if (hao.length() != 32) {
|
||||
// HealthR.fail("主机号长度不合法,操作失败!");
|
||||
// }
|
||||
// // AES加密
|
||||
// String encryptedHostNumber = encryptAES(hao, AES_KEY);
|
||||
// // Base64编码
|
||||
// String base64Encoded = java.util.Base64.getEncoder().encodeToString(encryptedHostNumber.getBytes(StandardCharsets.UTF_8));
|
||||
// // MD5加密
|
||||
// String md5Hash = generateMD5Hash(base64Encoded);
|
||||
|
||||
String s = OssUtil.uploadFile(hao);
|
||||
// 生成二维码(这里省略生成二维码的步骤)
|
||||
try {
|
||||
// 二维码内容
|
||||
String qrCodeData =s;
|
||||
|
||||
// 设置二维码的宽度和高度
|
||||
int width = 300;
|
||||
int height = 300;
|
||||
|
||||
// 设置二维码图片保存路径
|
||||
String filePath = "C:\\Users\\栗永斌\\Desktop\\二维码.png";//自己的
|
||||
|
||||
|
||||
String endpoint="oss-cn-shanghai.aliyuncs.com";//自己的
|
||||
String accessKeyId="LTAI5tLE4XbyvvbuT7D2stCk";//自己的
|
||||
String accessKeySecret="W7ZeT4dMrMPP0c8BBwcyIPnhe3P4E8";//自己的
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
|
||||
try {
|
||||
File file = new File(filePath);
|
||||
String objectName = "身份证"; // OSS 对象名称
|
||||
|
||||
String bucketName="lyb1314";
|
||||
// 上传文件
|
||||
ossClient.putObject(bucketName, objectName, file);
|
||||
|
||||
System.out.println("文件上传成功!");
|
||||
|
||||
// 如果需要获取上传后的文件 URL,可以使用以下代码
|
||||
String fileUrl = "https://" + bucketName + "." + endpoint + "/" + objectName;
|
||||
System.out.println("文件访问地址:" + fileUrl);
|
||||
} finally {
|
||||
// 关闭 OSS 客户端
|
||||
ossClient.shutdown();
|
||||
}
|
||||
|
||||
// 存储到数据库
|
||||
// saveToDatabase(hao, md5Hash,filePath);
|
||||
// System.out.println("操作成功!生成的序列号为:" + md5Hash);
|
||||
|
||||
// 设置二维码图片格式
|
||||
String fileType = "png";
|
||||
|
||||
// 创建 BitMatrix 对象
|
||||
BitMatrix bitMatrix = new QRCodeWriter().encode(qrCodeData, BarcodeFormat.QR_CODE, width, height);
|
||||
|
||||
// 将 BitMatrix 转换为 BufferedImage
|
||||
Path path = Paths.get(filePath);
|
||||
CollectSickController.MatrixToImageWriter.writeToPath(bitMatrix, fileType, path);
|
||||
|
||||
|
||||
} catch (WriterException e) {
|
||||
throw new RuntimeException("生成二维码失败", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class MatrixToImageWriter {
|
||||
private static final int BLACK = 0xFF000000;
|
||||
private static final int WHITE = 0xFFFFFFFF;
|
||||
|
||||
private MatrixToImageWriter() {}
|
||||
|
||||
public static void writeToPath(BitMatrix matrix, String format, Path path) {
|
||||
try {
|
||||
CollectSickController.MatrixToImageWriter.MatrixToImageConfig config = new CollectSickController.MatrixToImageWriter.MatrixToImageConfig(BLACK, WHITE);
|
||||
CollectSickController.MatrixToImageWriter.writeToPath(matrix, format, path, config);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("写入二维码图片失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeToPath(BitMatrix matrix, String format, Path path, CollectSickController.MatrixToImageWriter.MatrixToImageConfig config) {
|
||||
try {
|
||||
BufferedImage image = toBufferedImage(matrix, config);
|
||||
if (!ImageIO.write(image, format, path.toFile())) {
|
||||
throw new RuntimeException("写入二维码图片失败");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("写入二维码图片失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static BufferedImage toBufferedImage(BitMatrix matrix, CollectSickController.MatrixToImageWriter.MatrixToImageConfig config) {
|
||||
int width = matrix.getWidth();
|
||||
int height = matrix.getHeight();
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
image.setRGB(x, y, matrix.get(x, y) ? config.getPixelOnColor() : config.getPixelOffColor());
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
public static class MatrixToImageConfig {
|
||||
private final int onColor;
|
||||
private final int offColor;
|
||||
|
||||
public MatrixToImageConfig(int onColor, int offColor) {
|
||||
this.onColor = onColor;
|
||||
this.offColor = offColor;
|
||||
}
|
||||
|
||||
public int getPixelOnColor() {
|
||||
return onColor;
|
||||
}
|
||||
|
||||
public int getPixelOffColor() {
|
||||
return offColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void saveToDatabase(String hostNumber, String serialNumber,String filePath) {
|
||||
try {
|
||||
// 假设你有一个数据库连接,并且有一个表用于存储主机号和序列号
|
||||
String jdbcUrl = "jdbc:mysql://101.34.77.101:3306/dome1";
|
||||
String username = "root";
|
||||
String password = "cbx@123";
|
||||
|
||||
Connection connection = DriverManager.getConnection(jdbcUrl, username, password);
|
||||
|
||||
// 插入数据
|
||||
String sql = "INSERT INTO `dome1`.`t_list` ( `host_number`, `serial_number`,`img`) VALUES (?, ?,?)";
|
||||
|
||||
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||
preparedStatement.setString(1, hostNumber);
|
||||
preparedStatement.setString(2, serialNumber);
|
||||
preparedStatement.setString(3, filePath);
|
||||
preparedStatement.executeUpdate();
|
||||
|
||||
}
|
||||
|
||||
connection.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("存储到数据库失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static String encryptAES(String input, String key) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||
return new String(cipher.doFinal(input.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("AES加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String generateMD5Hash(String input) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] hashBytes = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte b : hashBytes) {
|
||||
String hex = Integer.toHexString(0xFF & b);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("MD5加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
* @Author 栗永斌
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sickCircle/v1/")
|
||||
@RequestMapping("/user/sickCircle/v1/")
|
||||
public class PatientController {
|
||||
|
||||
@Autowired
|
||||
|
@ -46,17 +46,7 @@ public class PatientController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 点采
|
||||
* @param opinion
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("expressOpinion")
|
||||
public HealthR expressOpinion(@RequestParam("opinion") Integer opinion){
|
||||
// return sickCircleServer.expressOpinion(commentId, opinion);
|
||||
System.out.println(opinion);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增病友圈
|
||||
|
@ -69,7 +59,6 @@ public class PatientController {
|
|||
|
||||
/**
|
||||
* 病友圈列表
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
|
@ -77,6 +66,7 @@ public class PatientController {
|
|||
public HealthR<List<SickCircleEntity>> sickCircleList(@RequestParam(value = "departmentId",required = false) Integer departmentId,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "count") Integer count) {
|
||||
|
||||
return patientService.sickCircleList(departmentId,page,count);
|
||||
}
|
||||
|
||||
|
@ -104,7 +94,7 @@ public class PatientController {
|
|||
|
||||
|
||||
/**
|
||||
* 查询病友圈评论列表
|
||||
* 病友圈评论列表
|
||||
*/
|
||||
@GetMapping("/findSickCircleCommentList")
|
||||
public HealthR<List<SickCommentEntity>> findSickCircleCommentList(@RequestParam(value = "sickCircleId",required = false) Integer sickCircleId,
|
||||
|
@ -123,6 +113,13 @@ public class PatientController {
|
|||
@GetMapping("searchSickCircle")
|
||||
public HealthR<List<SickCircleEntity>> searchSickCircle(@RequestParam(value = "keyWord",required = false) String keyWord){
|
||||
return patientService.searchSickCircle(keyWord);
|
||||
}
|
||||
|
||||
@GetMapping("/findPatientSickCircleList")
|
||||
public HealthR<List<SickCircleEntity>> findPatientSickCircleList(@RequestParam(value = "patientUserId",required = false) Integer patientUserId,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "count") Integer count) {
|
||||
|
||||
return patientService.findPatientSickCircleList(patientUserId,page,count);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,12 +32,11 @@ public class SickCommentEntity {
|
|||
private Date createTime;
|
||||
private Integer patientUserId;
|
||||
private Integer whetherDoctor;
|
||||
private Integer commentId;
|
||||
private Integer commentUserId;
|
||||
private Integer opposeNum;
|
||||
private Integer supportNum;
|
||||
private Integer opinion;
|
||||
|
||||
|
||||
private String headPic;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -38,4 +38,6 @@ public interface PatientMapper {
|
|||
List<SickCircleEntity> searchSickCircle(@Param("keyWord") String keyWord);
|
||||
|
||||
|
||||
List<SickCircleEntity> findPatientSickCircleList(@Param("patientUserId") Integer patientUserId);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,4 +21,17 @@ public interface SickCircleMapper {
|
|||
|
||||
|
||||
void expressOpinion(@Param("commentId") Integer commentId, @Param("opinion") Integer opinion, @Param("userid") Long userid);
|
||||
|
||||
void ins(@Param("sickCircleId") Integer sickCircleId);
|
||||
|
||||
void inss(@Param("sickCircleId") Integer sickCircleId, @Param("userid") Long userid);
|
||||
|
||||
void jia(@Param("commentId") Integer commentId);
|
||||
|
||||
void jian(@Param("commentId") Integer commentId);
|
||||
|
||||
void jiann(@Param("commentId") Integer commentId);
|
||||
|
||||
void jiaa(@Param("commentId") Integer commentId);
|
||||
|
||||
}
|
||||
|
|
|
@ -30,4 +30,7 @@ public interface PatientService {
|
|||
|
||||
HealthR<List<SickCircleEntity>> searchSickCircle(String keyWord);
|
||||
|
||||
HealthR<List<SickCircleEntity>> findPatientSickCircleList(Integer patientUserId, Integer page, Integer count);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -63,6 +63,13 @@ public class PatientServiceImpl extends BaseController implements PatientService
|
|||
return HealthR.ok(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HealthR<List<SickCircleEntity>> findPatientSickCircleList(Integer patientUserId, Integer page, Integer count) {
|
||||
startPage(page,count);
|
||||
List<SickCircleEntity> sickCircleEntity = patientMapper.findPatientSickCircleList(patientUserId);
|
||||
return HealthR.ok(sickCircleEntity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SickCircleEntity findSickCircleInfo(Integer id) {
|
||||
|
|
|
@ -97,10 +97,16 @@ public class SickCircleServerImpl implements SickCircleServer {
|
|||
|
||||
@Override
|
||||
public HealthR expressOpinion(Integer commentId, Integer opinion) {
|
||||
if(opinion==1){
|
||||
mapper.jia(commentId);
|
||||
mapper.jiann(commentId);
|
||||
}
|
||||
if(opinion==2){
|
||||
mapper.jiaa(commentId);
|
||||
mapper.jian(commentId);
|
||||
}
|
||||
LoginUser login = Login();
|
||||
Long userid = login.getUserid();
|
||||
mapper.expressOpinion(commentId, opinion,userid);
|
||||
|
||||
return HealthR.ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,11 @@ public class SickCircleServiceImpl extends BaseController implements SickCircleS
|
|||
LoginUser login = Login();
|
||||
//获取用户id
|
||||
Long userid = login.getUserid();
|
||||
//病友圈评论计树
|
||||
sickCircleMapper.ins(sickCircleId);
|
||||
//病友圈评论试图
|
||||
sickCircleMapper.inss(sickCircleId,userid);
|
||||
|
||||
sickCircleMapper.publishComment(sickCircleId,userid, content);
|
||||
|
||||
return Result.success(null);
|
||||
|
|
|
@ -35,14 +35,18 @@
|
|||
sick_circle_comment.create_time,
|
||||
sick_circle_comment.patient_user_id,
|
||||
sick_circle_comment.whether_doctor,
|
||||
sick_circle_comment_count.comment_id,
|
||||
sick_circle_comment_count.comment_id as commentUserId,
|
||||
sick_circle_comment_count.oppose_num,
|
||||
sick_circle_comment_count.support_num,
|
||||
sick_circle_comment_view.opinion
|
||||
sick_circle_comment_view.opinion ,
|
||||
`user`.head_pic
|
||||
FROM
|
||||
sick_circle_comment
|
||||
LEFT JOIN sick_circle_comment_count ON sick_circle_comment.patient_user_id = sick_circle_comment_count.comment_id LEFT JOIN sick_circle_comment_view on sick_circle_comment.patient_user_id=sick_circle_comment_view.opinion where
|
||||
sick_circle_comment.sick_circle_id=#{sickCircleId}
|
||||
LEFT JOIN sick_circle_comment_count ON sick_circle_comment.patient_user_id = sick_circle_comment_count.comment_id
|
||||
LEFT JOIN sick_circle_comment_view ON sick_circle_comment.patient_user_id = sick_circle_comment_view.comment_id
|
||||
LEFT JOIN `user` on sick_circle_comment_view.user_id=`user`.id
|
||||
WHERE
|
||||
sick_circle_comment.sick_circle_id =#{sickCircleId}
|
||||
</select>
|
||||
|
||||
<select id="searchSickCircle" resultType="doctor.domain.entity.SickCircleEntity">
|
||||
|
@ -51,4 +55,9 @@
|
|||
|
||||
</select>
|
||||
|
||||
<select id="findPatientSickCircleList" resultType="doctor.domain.entity.SickCircleEntity">
|
||||
select sick_circle_id , `user_id`, `title`, `department_id`, `adopt_comment_id`, `disease`, `detail`, `treatment_hospital`, `treatment_start_time`, `treatment_end_time`, `treatment_process`, `picture`, `release_time`, `adopt_time`, `amount`, `create_time`, `collection_num`, `comment_num`
|
||||
from sick_circle where user_id=#{patientUserId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -3,6 +3,21 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="doctor.mapper.SickCircleMapper">
|
||||
<update id="jia">
|
||||
update sick_circle_comment_count set support_num = support_num + 1 where comment_id=#{commentId}
|
||||
</update>
|
||||
|
||||
<update id="jian">
|
||||
update sick_circle_comment_count set support_num = support_num - 1 where comment_id=#{commentId}
|
||||
</update>
|
||||
|
||||
<update id="jiann">
|
||||
update sick_circle_comment_count set oppose_num = oppose_num - 1 where comment_id=#{commentId}
|
||||
</update>
|
||||
|
||||
<update id="jiaa">
|
||||
update sick_circle_comment_count set oppose_num = oppose_num + 1 where comment_id=#{commentId}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="findSickCircleList" resultType="doctor.domain.entity.SickCircleEntity">
|
||||
|
@ -21,11 +36,23 @@
|
|||
</insert>
|
||||
|
||||
<insert id="publishComment">
|
||||
INSERT INTO `doctor`.`sick_circle_comment` ( `sick_circle_id`, `user_id`, `content`, `comment_time`, `whether_doctor`, `create_time`)
|
||||
INSERT INTO `doctor`.`sick_circle_comment` ( `sick_circle_id`, `patient_user_id`, `content`, `comment_time`, `whether_doctor`, `create_time`)
|
||||
VALUES (#{sickCircleId},#{userid},#{content},now(),1,now())
|
||||
</insert>
|
||||
|
||||
<insert id="expressOpinion">
|
||||
UPDATE sick_circle_comment_view set opinion=#{opinion} ,user_id=#{userid} WHERE comment_id=#{commentId}
|
||||
</insert>
|
||||
|
||||
<insert id="ins">
|
||||
INSERT INTO `doctor`.`sick_circle_comment_count` ( `comment_id`, `support_num`, `oppose_num`, `create_time`)
|
||||
VALUES (#{sickCircleId},0,0,now());
|
||||
|
||||
</insert>
|
||||
<insert id="inss">
|
||||
INSERT INTO `doctor`.`sick_circle_comment_view` ( `comment_id`, `user_id`, `opinion`, `create_time`)
|
||||
VALUES (#{sickCircleId},#{userid},0,now());
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue