commit d81742c8732bdaa596068cdf0f5d9edc347f927c Author: BLRTTX <2232721325@qq.com> Date: Tue Dec 17 22:05:03 2024 +0800 后端代码主体 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/common/.gitignore b/common/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/common/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 0000000..c8f8072 --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,104 @@ + + + 4.0.0 + + com.atjy + hassle_free + 0.0.1-SNAPSHOT + + + common + + + 17 + 17 + UTF-8 + + + + + + ch.qos.logback + logback-classic + + + + org.springframework.boot + spring-boot-starter + + + + + org.springframework.boot + spring-boot-starter-web + + + org.slf4j + slf4j-log4j12 + + + + + + org.projectlombok + lombok + true + + + + + com.baomidou + mybatis-plus-spring-boot3-starter + + + + com.mysql + mysql-connector-j + + + + org.junit.jupiter + junit-jupiter-api + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + com.github.whvcse + easy-captcha + + + + io.jsonwebtoken + jjwt-api + + + + io.jsonwebtoken + jjwt-impl + runtime + + + + io.jsonwebtoken + jjwt-jackson + runtime + + + + com.aliyun + dysmsapi20170525 + + + + io.minio + minio + + + + \ No newline at end of file diff --git a/common/src/main/java/com/atjy/common/constant/RedisConstant.java b/common/src/main/java/com/atjy/common/constant/RedisConstant.java new file mode 100644 index 0000000..556849f --- /dev/null +++ b/common/src/main/java/com/atjy/common/constant/RedisConstant.java @@ -0,0 +1,9 @@ +package com.atjy.common.constant; + +public class RedisConstant { + public static final String ADMIN_LOGIN_PREFIX = "admin:login:"; + public static final Integer ADMIN_LOGIN_CAPTCHA_TTL_SEC = 60; + public static final String APP_LOGIN_PREFIX = "app:login:"; + public static final Integer APP_LOGIN_CODE_RESEND_TIME_SEC = 60; + public static final Integer APP_LOGIN_CODE_TTL_SEC = 60; +} \ No newline at end of file diff --git a/common/src/main/java/com/atjy/common/exception/HassleFreeException.java b/common/src/main/java/com/atjy/common/exception/HassleFreeException.java new file mode 100644 index 0000000..dd5e13c --- /dev/null +++ b/common/src/main/java/com/atjy/common/exception/HassleFreeException.java @@ -0,0 +1,15 @@ +package com.atjy.common.exception; + +import com.atjy.common.result.ResultCodeEnum; +import lombok.Data; + +@Data +public class HassleFreeException extends RuntimeException { + + private Integer status; + + public HassleFreeException(ResultCodeEnum resultCodeEnum) { + super(resultCodeEnum.getMessage()); + this.status = resultCodeEnum.getStatus(); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/atjy/common/login/LoginUser.java b/common/src/main/java/com/atjy/common/login/LoginUser.java new file mode 100644 index 0000000..87b9304 --- /dev/null +++ b/common/src/main/java/com/atjy/common/login/LoginUser.java @@ -0,0 +1,12 @@ +package com.atjy.common.login; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class LoginUser { + + private Long userId; + private String username; +} diff --git a/common/src/main/java/com/atjy/common/login/LoginUserHolder.java b/common/src/main/java/com/atjy/common/login/LoginUserHolder.java new file mode 100644 index 0000000..3532ce9 --- /dev/null +++ b/common/src/main/java/com/atjy/common/login/LoginUserHolder.java @@ -0,0 +1,17 @@ +package com.atjy.common.login; + +public class LoginUserHolder { + public static ThreadLocal threadLocal = new ThreadLocal<>(); + + public static void setLoginUser(LoginUser loginUser) { + threadLocal.set(loginUser); + } + + public static LoginUser getLoginUser() { + return threadLocal.get(); + } + + public static void clear() { + threadLocal.remove(); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/atjy/common/minio/MinioProperties.java b/common/src/main/java/com/atjy/common/minio/MinioProperties.java new file mode 100644 index 0000000..6d2ff54 --- /dev/null +++ b/common/src/main/java/com/atjy/common/minio/MinioProperties.java @@ -0,0 +1,17 @@ +package com.atjy.common.minio; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@Data +@ConfigurationProperties(prefix = "minio") +public class MinioProperties { + + private String endpoint; + + private String accessKey; + + private String secretKey; + + private String bucketName; +} \ No newline at end of file diff --git a/common/src/main/java/com/atjy/common/redis/RedisConfiguration.java b/common/src/main/java/com/atjy/common/redis/RedisConfiguration.java new file mode 100644 index 0000000..a1add45 --- /dev/null +++ b/common/src/main/java/com/atjy/common/redis/RedisConfiguration.java @@ -0,0 +1,20 @@ +package com.atjy.common.redis; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.RedisSerializer; + +@Configuration +public class RedisConfiguration { + + @Bean + public RedisTemplate stringObjectRedisTemplate(RedisConnectionFactory redisConnectionFactory) { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(redisConnectionFactory); + template.setKeySerializer(RedisSerializer.string()); + template.setValueSerializer(RedisSerializer.java()); + return template; + } +} \ No newline at end of file diff --git a/common/src/main/java/com/atjy/common/result/Result.java b/common/src/main/java/com/atjy/common/result/Result.java new file mode 100644 index 0000000..c0b8629 --- /dev/null +++ b/common/src/main/java/com/atjy/common/result/Result.java @@ -0,0 +1,56 @@ +package com.atjy.common.result; + +import lombok.Data; + +/** + * 全局统一返回结果类 + */ +@Data +public class Result { + + //返回码 + private Integer status; + + //返回消息 + private String message; + + //返回数据 + private T data; + + public Result() { + } + + private static Result build(T data) { + Result result = new Result<>(); + if (data != null) + result.setData(data); + return result; + } + + public static Result build(T body, ResultCodeEnum resultCodeEnum) { + Result result = build(body); + result.setStatus(resultCodeEnum.getStatus()); + result.setMessage(resultCodeEnum.getMessage()); + return result; + } + + + public static Result ok(T data) { + return build(data, ResultCodeEnum.SUCCESS); + } + + public static Result ok() { + return Result.ok(null); + } + + public static Result fail() { + return build(null, ResultCodeEnum.FAIL); + } + + public static Result fail(Integer status, String message) { + Result result = build(null); + result.setStatus(status); + result.setMessage(message); + return result; + } +} diff --git a/common/src/main/java/com/atjy/common/result/ResultCodeEnum.java b/common/src/main/java/com/atjy/common/result/ResultCodeEnum.java new file mode 100644 index 0000000..af1af85 --- /dev/null +++ b/common/src/main/java/com/atjy/common/result/ResultCodeEnum.java @@ -0,0 +1,51 @@ +package com.atjy.common.result; + +import lombok.Getter; + +@Getter +public enum ResultCodeEnum { + + SUCCESS(200, "成功"), + FAIL(201, "失败"), + PARAM_ERROR(202, "参数不正确"), + SERVICE_ERROR(203, "服务异常"), + DATA_ERROR(204, "数据异常"), + ILLEGAL_REQUEST(205, "非法请求"), + REPEAT_SUBMIT(206, "重复提交"), + DELETE_ERROR(207, "请先删除子集"), + + ADMIN_ACCOUNT_EXIST_ERROR(301, "账号已存在"), + ADMIN_CAPTCHA_CODE_ERROR(302, "验证码错误"), + ADMIN_CAPTCHA_CODE_EXPIRED(303, "验证码已过期"), + ADMIN_CAPTCHA_CODE_NOT_FOUND(304, "未输入验证码"), + + + ADMIN_LOGIN_AUTH(305, "未登陆"), + ADMIN_ACCOUNT_NOT_EXIST_ERROR(306, "账号不存在"), + ADMIN_ACCOUNT_ERROR(307, "用户名或密码错误"), + ADMIN_ACCOUNT_DISABLED_ERROR(308, "该用户已被禁用"), + ADMIN_ACCESS_FORBIDDEN(309, "无访问权限"), + + + APP_LOGIN_AUTH(501, "未登陆"), + APP_LOGIN_PHONE_EMPTY(502, "手机号码为空"), + APP_LOGIN_CODE_EMPTY(503, "验证码为空"), + APP_SEND_SMS_TOO_OFTEN(504, "验证法发送过于频繁"), + APP_LOGIN_CODE_EXPIRED(505, "验证码已过期"), + APP_LOGIN_CODE_ERROR(506, "验证码错误"), + APP_ACCOUNT_DISABLED_ERROR(507, "该用户已被禁用"), + + + TOKEN_EXPIRED(601, "token过期"), + TOKEN_INVALID(602, "token非法"); + + + private final Integer status; + + private final String message; + + ResultCodeEnum(Integer status, String message) { + this.status = status; + this.message = message; + } +} diff --git a/common/src/main/java/com/atjy/common/utils/CodeUtil.java b/common/src/main/java/com/atjy/common/utils/CodeUtil.java new file mode 100644 index 0000000..e68c9aa --- /dev/null +++ b/common/src/main/java/com/atjy/common/utils/CodeUtil.java @@ -0,0 +1,14 @@ +package com.atjy.common.utils; + +import java.util.*; + +public class CodeUtil { + public static String getRandomCode(int length) { + StringBuilder builder = new StringBuilder(); + Random random = new Random(); + for (int i = 0; i < length; i++) { + builder.append(random.nextInt(10)); + } + return builder.toString(); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/atjy/common/utils/JwtUtil.java b/common/src/main/java/com/atjy/common/utils/JwtUtil.java new file mode 100644 index 0000000..a57c8d9 --- /dev/null +++ b/common/src/main/java/com/atjy/common/utils/JwtUtil.java @@ -0,0 +1,48 @@ +package com.atjy.common.utils; + +import com.atjy.common.exception.HassleFreeException; +import com.atjy.common.result.ResultCodeEnum; +import io.jsonwebtoken.*; +import io.jsonwebtoken.security.Keys; + +import javax.crypto.SecretKey; +import java.util.Date; + +public class JwtUtil { + + private static long tokenExpiration = 60 * 60 * 1000L; + private static SecretKey secretKey = Keys.hmacShaKeyFor("Zv95JuIHKadVbSJBqqTbrnAZxXf4ixVZ".getBytes()); + + public static String createToken(Long userId, String username) { + + String jwt = Jwts.builder() + .setExpiration(new Date(System.currentTimeMillis() + tokenExpiration)) + .setSubject("LOGIN_USER") + .claim("userId", userId) + .claim("username", username) + .signWith(secretKey, SignatureAlgorithm.HS256) + .compact(); + + return jwt; + } + + public static Claims parseToken(String token) { + + if (token == null) { + throw new HassleFreeException(ResultCodeEnum.ADMIN_LOGIN_AUTH); + } + + try { + JwtParser jwtParser = Jwts.parserBuilder().setSigningKey(secretKey).build(); + return jwtParser.parseClaimsJws(token).getBody(); + } catch (ExpiredJwtException e) { + throw new HassleFreeException(ResultCodeEnum.TOKEN_EXPIRED); + } catch (JwtException e) { + throw new HassleFreeException(ResultCodeEnum.TOKEN_INVALID); + } + } + + public static void main(String[] args) { + System.out.println(createToken(8L, "15674675667")); + } +} \ No newline at end of file diff --git a/model/.gitignore b/model/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/model/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/model/pom.xml b/model/pom.xml new file mode 100644 index 0000000..03b7cd4 --- /dev/null +++ b/model/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + com.atjy + hassle_free + 0.0.1-SNAPSHOT + + + model + + + 17 + 17 + UTF-8 + + + + + + com.baomidou + mybatis-plus-spring-boot3-starter + + + + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter + + + + + \ No newline at end of file diff --git a/model/src/main/java/com/atjy/model/entity/AppointmentInfo.java b/model/src/main/java/com/atjy/model/entity/AppointmentInfo.java new file mode 100644 index 0000000..4c77796 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/AppointmentInfo.java @@ -0,0 +1,18 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "预约信息") +@TableName(value = "appointment_info") +public class AppointmentInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "预约日期") + @TableField(value = "appointment_date") + private String appointmentDate; +} diff --git a/model/src/main/java/com/atjy/model/entity/ArticleInfo.java b/model/src/main/java/com/atjy/model/entity/ArticleInfo.java new file mode 100644 index 0000000..5deb6af --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/ArticleInfo.java @@ -0,0 +1,48 @@ +package com.atjy.model.entity; + +import com.atjy.model.enums.ArticleItemType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +@Data +@Schema(description = "医说信息") +@TableName(value = "article_info") +public class ArticleInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "大标题") + @TableField(value = "title_big") + private String titleBig; + + @Schema(description = "小标题") + @TableField(value = "title_small") + private String titleSmall; + + @Schema(description = "阅读量") + @TableField(value = "number") + private Integer number; + + @Schema(description = "发布时间") + @TableField(value = "publish_time") + @JsonIgnore + private Date publishTime; + + @Schema(description = "医生id") + @TableField(value = "doctor_id") + private Long doctorId; + + @Schema(description = "内容") + @TableField(value = "content") + private String content; + + @Schema(description = "医说所属类型") + @TableField(value = "type") + private ArticleItemType type; + +} diff --git a/model/src/main/java/com/atjy/model/entity/BaseEntity.java b/model/src/main/java/com/atjy/model/entity/BaseEntity.java new file mode 100644 index 0000000..3b6f4b1 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/BaseEntity.java @@ -0,0 +1,38 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BaseEntity implements Serializable { + + @Schema(description = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @Schema(description = "创建时间") + @TableField(value = "create_time", fill = FieldFill.INSERT) + @JsonIgnore + private LocalDateTime createTime; + + @Schema(description = "更新时间") + @TableField(value = "update_time", fill = FieldFill.UPDATE) + @JsonIgnore + private LocalDateTime updateTime; + + @Schema(description = "逻辑删除") + @TableField("is_deleted") + @TableLogic + @JsonIgnore + private Byte isDeleted; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atjy/model/entity/CityInfo.java b/model/src/main/java/com/atjy/model/entity/CityInfo.java new file mode 100644 index 0000000..67dd1a6 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/CityInfo.java @@ -0,0 +1,23 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "城市信息") +@TableName(value = "city_info") +@Data +public class CityInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "城市名称") + @TableField(value = "name") + private String name; + + @Schema(description = "所属省份id") + @TableField(value = "province_id") + private Integer provinceId; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atjy/model/entity/ConsultInfo.java b/model/src/main/java/com/atjy/model/entity/ConsultInfo.java new file mode 100644 index 0000000..af8ba60 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/ConsultInfo.java @@ -0,0 +1,29 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "咨询信息") +@TableName(value = "consultation_info") +public class ConsultInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "用户id") + @TableField(value = "user_id") + private Long userId; + + @Schema(description = "问题") + @TableField(value = "problem") + private String problem; + + @Schema(description = "解答") + @TableField(value = "answer") + private String answer; + + @Schema(description = "编号") + @TableField(value = "number") + private Integer number; +} diff --git a/model/src/main/java/com/atjy/model/entity/DepartmentInfo.java b/model/src/main/java/com/atjy/model/entity/DepartmentInfo.java new file mode 100644 index 0000000..fd9f80d --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/DepartmentInfo.java @@ -0,0 +1,22 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "科室信息") +@TableName(value = "department_info") +@Data +public class DepartmentInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "科室名称") + @TableField(value = "name") + private String name; + + @Schema(description = "所属科室") + @TableField(value = "belong") + private String belong; +} diff --git a/model/src/main/java/com/atjy/model/entity/DistrictInfo.java b/model/src/main/java/com/atjy/model/entity/DistrictInfo.java new file mode 100644 index 0000000..b153474 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/DistrictInfo.java @@ -0,0 +1,23 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "地区信息") +@TableName(value = "district_info") +@Data +public class DistrictInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "区域名称") + @TableField(value = "name") + private String name; + + @Schema(description = "所属城市id") + @TableField(value = "city_id") + private Integer cityId; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atjy/model/entity/DoctorAppointment.java b/model/src/main/java/com/atjy/model/entity/DoctorAppointment.java new file mode 100644 index 0000000..1dde7f3 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/DoctorAppointment.java @@ -0,0 +1,26 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "医生-预约信息") +@TableName(value = "doctor_appointment") +public class DoctorAppointment extends BaseEntity{ + + private static final long serialVersionUID = 1L; + + @Schema(description = "医生id") + @TableField(value = "doctor_id") + private Long doctorId; + + @Schema(description = "预约时间id") + @TableField(value = "appointment_id") + private Long appointmentId; + + @Schema(description = "费用") + @TableField(value = "fees") + private Long fees; +} diff --git a/model/src/main/java/com/atjy/model/entity/DoctorInfo.java b/model/src/main/java/com/atjy/model/entity/DoctorInfo.java new file mode 100644 index 0000000..fb506ba --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/DoctorInfo.java @@ -0,0 +1,47 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "医生信息") +@TableName(value = "doctor_info") +@Data +public class DoctorInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "医生姓名") + @TableField(value = "doctor_name") + private String doctorName; + + @Schema(description = "医院id") + @TableField(value = "hospital_id") + private Long hospitalId; + + @Schema(description = "级别") + @TableField(value = "level") + private String level; + + @Schema(description = "擅长领域") + @TableField(value = "expertise") + private String expertise; + + @Schema(description = "头衔") + @TableField(value = "source") + private String source; + + @Schema(description = "预约量") + @TableField(value = "appointment_number") + private Integer appointmentNumber; + + @Schema(description = "科室id") + @TableField(value = "department_id") + private String departmentId; + + @Schema(description = "简介") + @TableField(value = "briefly") + private String briefly; + +} diff --git a/model/src/main/java/com/atjy/model/entity/GraphInfo.java b/model/src/main/java/com/atjy/model/entity/GraphInfo.java new file mode 100644 index 0000000..891df52 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/GraphInfo.java @@ -0,0 +1,32 @@ +package com.atjy.model.entity; + +import com.atjy.model.enums.GraphItemType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "图片信息表") +@TableName(value = "graph_info") +@Data +public class GraphInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "图片名称") + @TableField(value = "name") + private String name; + + @Schema(description = "图片所属对象类型") + @TableField(value = "item_type") + private GraphItemType itemType; + + @Schema(description = "图片所属对象id") + @TableField(value = "item_id") + private Long itemId; + + @Schema(description = "图片地址") + @TableField(value = "url") + private String url; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atjy/model/entity/HospitalDepartment.java b/model/src/main/java/com/atjy/model/entity/HospitalDepartment.java new file mode 100644 index 0000000..32e91b9 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/HospitalDepartment.java @@ -0,0 +1,22 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "医院-科室信息") +@TableName(value = "hospital_department") +@Data +public class HospitalDepartment extends BaseEntity{ + + private static final long serialVersionUID = 1L; + + @Schema(description = "医院id") + @TableField(value = "hospital_id") + private Long hospitalId; + + @Schema(description = "科室id") + @TableField(value = "department_id") + private Long departmentId; +} diff --git a/model/src/main/java/com/atjy/model/entity/HospitalInfo.java b/model/src/main/java/com/atjy/model/entity/HospitalInfo.java new file mode 100644 index 0000000..1572707 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/HospitalInfo.java @@ -0,0 +1,62 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "医院信息") +@TableName(value = "hospital_info") +@Data +public class HospitalInfo extends BaseEntity{ + + private static final long serialVersionUID = 1L; + + @Schema(description = "医院名称") + @TableField(value = "hospital_name") + private String hospitalName; + + @Schema(description = "所处区域id") + @TableField(value = "district_id") + private Long districtId; + + @Schema(description = "所处区域名称") + @TableField(value = "district_name") + private String districtName; + + @Schema(description = "所处城市id") + @TableField(value = "city_id") + private Long cityId; + + @Schema(description = "所处城市名称") + @TableField(value = "city_name") + private String cityName; + + @Schema(description = "所处省份id") + @TableField(value = "province_id") + private Long provinceId; + + @Schema(description = "所处省份名称") + @TableField(value = "province_name") + private String provinceName; + + @Schema(description = "地址") + @TableField(value = "address") + private String address; + + @Schema(description = "介绍") + @TableField(value = "introduction") + private String introduction; + + @Schema(description = "预约量") + @TableField(value = "appointment_number") + private Long appointmentNumber; + + @Schema(description = "预约电话") + @TableField(value = "phone") + private String phone; + + @Schema(description = "等级") + @TableField(value = "level") + private String level; +} diff --git a/model/src/main/java/com/atjy/model/entity/HospitalLabel.java b/model/src/main/java/com/atjy/model/entity/HospitalLabel.java new file mode 100644 index 0000000..8894004 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/HospitalLabel.java @@ -0,0 +1,22 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "医院-标签信息") +@TableName(value = "hospital_label") +@Data +public class HospitalLabel extends BaseEntity{ + + private static final long serialVersionUID = 1L; + + @Schema(description = "标签名称") + @TableField(value = "label_name") + private String labelName; + + @Schema(description = "医院id") + @TableField(value = "hospital_id") + private Long hospitalId; +} diff --git a/model/src/main/java/com/atjy/model/entity/ProvinceInfo.java b/model/src/main/java/com/atjy/model/entity/ProvinceInfo.java new file mode 100644 index 0000000..99c7437 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/ProvinceInfo.java @@ -0,0 +1,18 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "省份信息") +@TableName(value = "province_info") +@Data +public class ProvinceInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "省份名称") + @TableField(value = "name") + private String name; +} diff --git a/model/src/main/java/com/atjy/model/entity/SystemUser.java b/model/src/main/java/com/atjy/model/entity/SystemUser.java new file mode 100644 index 0000000..31ddf8a --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/SystemUser.java @@ -0,0 +1,44 @@ +package com.atjy.model.entity; + +import com.atjy.model.enums.BaseStatus; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理员信息") +@TableName(value = "system_user") +@Data +public class SystemUser extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "用户名") + @TableField(value = "username") + private String username; + + @Schema(description = "密码") + @TableField(value = "password", select = false) + private String password; + + @Schema(description = "姓名") + @TableField(value = "name") + private String name; + + @Schema(description = "手机号码") + @TableField(value = "phone") + private String phone; + + @Schema(description = "头像地址") + @TableField(value = "avatar_url") + private String avatarUrl; + + @Schema(description = "备注信息") + @TableField(value = "additional_info") + private String additionalInfo; + + @Schema(description = "账号状态") + @TableField(value = "state") + private BaseStatus state; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atjy/model/entity/UserAppointment.java b/model/src/main/java/com/atjy/model/entity/UserAppointment.java new file mode 100644 index 0000000..2b8b923 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/UserAppointment.java @@ -0,0 +1,46 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "用户-预约信息") +@TableName(value = "user_appointment") +public class UserAppointment extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "用户id") + @TableField(value = "user_id") + private Long userId; + + @Schema(description = "预约时间id") + @TableField(value = "appointment_id") + private Long appointmentId; + + @Schema(description = "状态") + @TableField(value = "state") + private Byte state; + + @Schema(description = "医生id") + @TableField(value = "doctor_id") + private Long doctorId; + + @Schema(description = "费用") + @TableField(value = "fees") + private Long fees; + + @Schema(description = "就诊人姓名") + @TableField(value = "name") + private String name; + + @Schema(description = "就诊人手机号") + @TableField(value = "phone") + private String phone; + + @Schema(description = "备注") + @TableField(value = "memo") + private String memo; +} diff --git a/model/src/main/java/com/atjy/model/entity/UserCollection.java b/model/src/main/java/com/atjy/model/entity/UserCollection.java new file mode 100644 index 0000000..c843d64 --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/UserCollection.java @@ -0,0 +1,26 @@ +package com.atjy.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "用户-收藏信息") +@TableName(value = "user_collection") +@Data +public class UserCollection extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "用户id") + @TableField(value = "user_id") + private Long userId; + + @Schema(description = "收藏id") + @TableField(value = "collection_id") + private Long collectionId; + + @Schema(description = "类型") + @TableField(value = "type") + private Byte type; +} diff --git a/model/src/main/java/com/atjy/model/entity/UserInfo.java b/model/src/main/java/com/atjy/model/entity/UserInfo.java new file mode 100644 index 0000000..9b53cbc --- /dev/null +++ b/model/src/main/java/com/atjy/model/entity/UserInfo.java @@ -0,0 +1,39 @@ +package com.atjy.model.entity; + +import com.atjy.model.enums.BaseStatus; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "用户信息") +@TableName(value = "user_info") +@Data +public class UserInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(description = "手机号码(用做登录用户名)") + @TableField(value = "phone") + private String phone; + + @Schema(description = "密码") + @TableField(value = "password", select = false) + private String password; + + @Schema(description = "头像id") + @TableField(value = "avatar_id") + private Long avatarId; + + @Schema(description = "昵称") + @TableField(value = "nickname") + private String nickname; + + @Schema(description = "账号状态") + @TableField(value = "state") + private BaseStatus state; + + @Schema(description = "咨询数量") + @TableField(value = "consultation_number") + private Integer consultationNumber; +} \ No newline at end of file diff --git a/model/src/main/java/com/atjy/model/enums/ArticleItemType.java b/model/src/main/java/com/atjy/model/enums/ArticleItemType.java new file mode 100644 index 0000000..1cb6859 --- /dev/null +++ b/model/src/main/java/com/atjy/model/enums/ArticleItemType.java @@ -0,0 +1,33 @@ +package com.atjy.model.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ArticleItemType implements BaseEnum { + + + USER(1, "抗疫专区"), + DOCTOR(2, "健康养生"), + HOSPITAL(3, "医疗动态"); + + @EnumValue + @JsonValue + private Integer code; + private String name; + + @Override + public Integer getCode() { + return this.code; + } + + + @Override + public String getName() { + return name; + } + + ArticleItemType(Integer code, String name) { + this.code = code; + this.name = name; + } +} diff --git a/model/src/main/java/com/atjy/model/enums/BaseEnum.java b/model/src/main/java/com/atjy/model/enums/BaseEnum.java new file mode 100644 index 0000000..632e897 --- /dev/null +++ b/model/src/main/java/com/atjy/model/enums/BaseEnum.java @@ -0,0 +1,8 @@ +package com.atjy.model.enums; + +public interface BaseEnum { + + Integer getCode(); + + String getName(); +} \ No newline at end of file diff --git a/model/src/main/java/com/atjy/model/enums/BaseStatus.java b/model/src/main/java/com/atjy/model/enums/BaseStatus.java new file mode 100644 index 0000000..0a074ad --- /dev/null +++ b/model/src/main/java/com/atjy/model/enums/BaseStatus.java @@ -0,0 +1,34 @@ +package com.atjy.model.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum BaseStatus implements BaseEnum { + + + ENABLE(1, "正常"), + + DISABLE(0, "禁用"); + + + @EnumValue + @JsonValue + private Integer code; + + private String name; + + BaseStatus(Integer code, String name) { + this.code = code; + this.name = name; + } + + @Override + public Integer getCode() { + return this.code; + } + + @Override + public String getName() { + return this.name; + } +} diff --git a/model/src/main/java/com/atjy/model/enums/GraphItemType.java b/model/src/main/java/com/atjy/model/enums/GraphItemType.java new file mode 100644 index 0000000..31dcec1 --- /dev/null +++ b/model/src/main/java/com/atjy/model/enums/GraphItemType.java @@ -0,0 +1,35 @@ +package com.atjy.model.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum GraphItemType implements BaseEnum { + + USER(1, "用户"), + HOSPITAL(2, "医院"), + DOCTOR(3, "医生"), + ARTICLE(4, "医说"); + + + @EnumValue + @JsonValue + private Integer code; + private String name; + + @Override + public Integer getCode() { + return this.code; + } + + + @Override + public String getName() { + return name; + } + + GraphItemType(Integer code, String name) { + this.code = code; + this.name = name; + } + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..27f5dcf --- /dev/null +++ b/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + + com.atjy + hassle_free + 0.0.1-SNAPSHOT + pom + hassle_free + hassle_free + + + + + + + + + model + web + common + + + + + + + + + + + org.springframework.boot + spring-boot-starter-parent + 3.3.3 + + + + + 17 + 17 + UTF-8 + 2.9.2 + 5.10.2 + 3.5.7 + 0.11.2 + 1.6.2 + 8.3.4 + 4.1.0 + 2.0.23 + 2.13.0 + + + + + + + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + + + + + + com.baomidou + mybatis-plus-spring-boot3-starter + ${mybatis-plus.version} + + + + + + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter + ${knife4j.version} + + + + + + io.jsonwebtoken + jjwt-api + ${jwt.version} + + + io.jsonwebtoken + jjwt-impl + runtime + ${jwt.version} + + + io.jsonwebtoken + jjwt-jackson + runtime + ${jwt.version} + + + + + + com.github.whvcse + easy-captcha + ${easycaptcha.version} + + + + + + com.aliyun + dysmsapi20170525 + ${aliyun.sms.version} + + + + + + io.minio + minio + ${minio.version} + + + + + + com.alibaba + dashscope-sdk-java + ${dashscope-sdk.version} + + + + + + diff --git a/web/.gitignore b/web/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/web/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/web/pom.xml b/web/pom.xml new file mode 100644 index 0000000..12b57da --- /dev/null +++ b/web/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + com.atjy + hassle_free + 0.0.1-SNAPSHOT + + + web + pom + + web-admin + web-app + + + + 17 + 17 + UTF-8 + + + + com.atjy + model + 0.0.1-SNAPSHOT + + + + com.atjy + common + 0.0.1-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-web + + + org.slf4j + slf4j-log4j12 + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/web/web-admin/.gitignore b/web/web-admin/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/web/web-admin/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/web/web-admin/pom.xml b/web/web-admin/pom.xml new file mode 100644 index 0000000..dc73677 --- /dev/null +++ b/web/web-admin/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + com.atjy + web + 0.0.1-SNAPSHOT + + + web-admin + + + 17 + 17 + UTF-8 + + + + \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/WebAdminApplication.java b/web/web-admin/src/main/java/com/atjy/web/admin/WebAdminApplication.java new file mode 100644 index 0000000..2e85e23 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/WebAdminApplication.java @@ -0,0 +1,16 @@ +package com.atjy.web.admin; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; + +@MapperScan("com.atjy.web.admin.mapper") +@SpringBootApplication +@EnableScheduling +public class WebAdminApplication { + + public static void main(String[] args) { + SpringApplication.run(WebAdminApplication.class, args); + } +} diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/controller/graph/GraphController.java b/web/web-admin/src/main/java/com/atjy/web/admin/controller/graph/GraphController.java new file mode 100644 index 0000000..27541a8 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/controller/graph/GraphController.java @@ -0,0 +1,33 @@ +package com.atjy.web.admin.controller.graph; + +import com.atjy.common.result.Result; +import com.atjy.web.admin.service.FileService; +import io.minio.errors.*; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +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 org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +@Tag(name = "图片管理") +@RequestMapping("/admin/graph") +@RestController +public class GraphController { + + @Autowired + private FileService service; + + @Operation(summary = "上传文件") + @PostMapping("upload") + public Result upload(@RequestParam MultipartFile file) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException { + String url = service.upload(file); + return Result.ok(url); + } +} diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/controller/login/LoginController.java b/web/web-admin/src/main/java/com/atjy/web/admin/controller/login/LoginController.java new file mode 100644 index 0000000..4084639 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/controller/login/LoginController.java @@ -0,0 +1,44 @@ +package com.atjy.web.admin.controller.login; + +import com.atjy.common.login.LoginUserHolder; +import com.atjy.common.result.Result; +import com.atjy.common.utils.JwtUtil; +import com.atjy.web.admin.service.LoginService; +import com.atjy.web.admin.vo.login.CaptchaVo; +import com.atjy.web.admin.vo.login.LoginVo; +import com.atjy.web.admin.vo.system.user.SystemUserInfoVo; +import io.jsonwebtoken.Claims; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; + +@Tag(name = "登录管理") +@RestController +@RequestMapping("/admin") +public class LoginController { + + @Autowired + private LoginService service; + + @Operation(summary = "登录") + @PostMapping("login") + public Result login(@RequestBody LoginVo loginVo) { + return service.login(loginVo); + } + + @Operation(summary = "获取图形验证码") + @GetMapping("login/captcha") + public Result getCaptcha() { + CaptchaVo captcha = service.getCaptcha(); + return Result.ok(captcha); + } + + @Operation(summary = "获取登陆用户个人信息") + @GetMapping("info") + public Result info() { + SystemUserInfoVo userInfo = service.getLoginUserInfo(LoginUserHolder.getLoginUser().getUserId()); + return Result.ok(userInfo); + } +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/custom/config/Knife4jConfiguration.java b/web/web-admin/src/main/java/com/atjy/web/admin/custom/config/Knife4jConfiguration.java new file mode 100644 index 0000000..9459239 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/custom/config/Knife4jConfiguration.java @@ -0,0 +1,47 @@ +package com.atjy.web.admin.custom.config; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class Knife4jConfiguration { + + @Bean + public OpenAPI customOpenAPI() { + + return new OpenAPI() + .info(new Info() + .title("医路无忧后端管理系统API") + .version("1.0") + .description("后端管理系统接口") + .termsOfService("http://doc.xiaominfo.com") + .license(new License().name("Apache 2.0") + .url("http://doc.xiaominfo.com"))); + + } + + @Bean + public GroupedOpenApi loginAPI() { + + return GroupedOpenApi.builder().group("登录信息"). + pathsToMatch( + "/admin/login/**", + "/admin/info" + ). + build(); + } + + @Bean + public GroupedOpenApi graphAPI() { + + return GroupedOpenApi.builder().group("图片管理"). + pathsToMatch( + "/admin/graph/**" + ). + build(); + } +} diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/custom/config/MinioConfiguration.java b/web/web-admin/src/main/java/com/atjy/web/admin/custom/config/MinioConfiguration.java new file mode 100644 index 0000000..08f3a26 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/custom/config/MinioConfiguration.java @@ -0,0 +1,26 @@ +package com.atjy.web.admin.custom.config; + +import com.atjy.common.minio.MinioProperties; +import io.minio.MinioClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableConfigurationProperties(MinioProperties.class) +@ConditionalOnProperty(name = "minio.endpoint") +public class MinioConfiguration { + + @Autowired + private MinioProperties properties; + + @Bean + public MinioClient minioClient(){ + return MinioClient.builder() + .endpoint(properties.getEndpoint()) + .credentials(properties.getAccessKey(),properties.getSecretKey()) + .build(); + } +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/custom/config/WebMvcConfiguration.java b/web/web-admin/src/main/java/com/atjy/web/admin/custom/config/WebMvcConfiguration.java new file mode 100644 index 0000000..4718756 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/custom/config/WebMvcConfiguration.java @@ -0,0 +1,32 @@ +package com.atjy.web.admin.custom.config; + +import com.atjy.web.admin.custom.converter.StringToBaseEnumConverterFactory; +import com.atjy.web.admin.custom.interceptor.AuthenticationInterceptor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.format.FormatterRegistry; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebMvcConfiguration implements WebMvcConfigurer { + + @Autowired + private StringToBaseEnumConverterFactory stringToBaseEnumConverterFactory; + + @Autowired + private AuthenticationInterceptor authenticationInterceptor; + + @Override + public void addFormatters(FormatterRegistry registry) { + + registry.addConverterFactory(this.stringToBaseEnumConverterFactory); + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(this.authenticationInterceptor) + .addPathPatterns("/admin/**") + .excludePathPatterns("/admin/login/**"); + } +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/custom/converter/StringToBaseEnumConverterFactory.java b/web/web-admin/src/main/java/com/atjy/web/admin/custom/converter/StringToBaseEnumConverterFactory.java new file mode 100644 index 0000000..ebeaf78 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/custom/converter/StringToBaseEnumConverterFactory.java @@ -0,0 +1,25 @@ +package com.atjy.web.admin.custom.converter; + +import com.atjy.model.enums.BaseEnum; +import org.springframework.core.convert.converter.Converter; +import org.springframework.core.convert.converter.ConverterFactory; +import org.springframework.stereotype.Component; + +@Component +public class StringToBaseEnumConverterFactory implements ConverterFactory { + @Override + public Converter getConverter(Class targetType) { + return new Converter() { + @Override + public T convert(String code) { + T[] enumConstants = targetType.getEnumConstants(); + for (T enumConstant : enumConstants) { + if (enumConstant.getCode().equals(Integer.valueOf(code))) { + return enumConstant; + } + } + throw new IllegalArgumentException("code" + code + "非法"); + } + }; + } +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/custom/interceptor/AuthenticationInterceptor.java b/web/web-admin/src/main/java/com/atjy/web/admin/custom/interceptor/AuthenticationInterceptor.java new file mode 100644 index 0000000..1fe9802 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/custom/interceptor/AuthenticationInterceptor.java @@ -0,0 +1,33 @@ +package com.atjy.web.admin.custom.interceptor; + +import com.atjy.common.login.LoginUser; +import com.atjy.common.login.LoginUserHolder; +import com.atjy.common.utils.JwtUtil; +import io.jsonwebtoken.Claims; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; + +@Component +public class AuthenticationInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + + String token = request.getHeader("token"); + + Claims claims = JwtUtil.parseToken(token); + Long userId = claims.get("userId", Long.class); + String username = claims.get("username", String.class); + LoginUserHolder.setLoginUser(new LoginUser(userId, username)); + + return true; + + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + LoginUserHolder.clear(); + } +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/mapper/GraphInfoMapper.java b/web/web-admin/src/main/java/com/atjy/web/admin/mapper/GraphInfoMapper.java new file mode 100644 index 0000000..6c22098 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/mapper/GraphInfoMapper.java @@ -0,0 +1,13 @@ +package com.atjy.web.admin.mapper; + +import com.atjy.model.entity.GraphInfo; +import com.atjy.model.enums.GraphItemType; +import com.atjy.web.admin.vo.graph.GraphVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface GraphInfoMapper extends BaseMapper { + + List selectListByItemTypeAndId(GraphItemType itemType, Long id); +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/mapper/SystemUserMapper.java b/web/web-admin/src/main/java/com/atjy/web/admin/mapper/SystemUserMapper.java new file mode 100644 index 0000000..2e6206c --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/mapper/SystemUserMapper.java @@ -0,0 +1,9 @@ +package com.atjy.web.admin.mapper; + +import com.atjy.model.entity.SystemUser; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface SystemUserMapper extends BaseMapper { + SystemUser selectOneByUsername(String username); + +} diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/mybatisplus/MybatisMetaObjectHandler.java b/web/web-admin/src/main/java/com/atjy/web/admin/mybatisplus/MybatisMetaObjectHandler.java new file mode 100644 index 0000000..3c1a542 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/mybatisplus/MybatisMetaObjectHandler.java @@ -0,0 +1,21 @@ +package com.atjy.web.admin.mybatisplus; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +@Component +public class MybatisMetaObjectHandler implements MetaObjectHandler { + @Override + public void insertFill(MetaObject metaObject) { + this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now()); + } + + @Override + public void updateFill(MetaObject metaObject) { + this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); + } +} diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/mybatisplus/MybatisPlusConfiguration.java b/web/web-admin/src/main/java/com/atjy/web/admin/mybatisplus/MybatisPlusConfiguration.java new file mode 100644 index 0000000..197dae1 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/mybatisplus/MybatisPlusConfiguration.java @@ -0,0 +1,20 @@ +package com.atjy.web.admin.mybatisplus; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@MapperScan("com.atjy.web.admin.mapper") +public class MybatisPlusConfiguration { + + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + return interceptor; + } +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/service/FileService.java b/web/web-admin/src/main/java/com/atjy/web/admin/service/FileService.java new file mode 100644 index 0000000..41bfd6a --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/service/FileService.java @@ -0,0 +1,13 @@ +package com.atjy.web.admin.service; + +import io.minio.errors.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +public interface FileService { + + String upload(MultipartFile file) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException; +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/service/GraphInfoService.java b/web/web-admin/src/main/java/com/atjy/web/admin/service/GraphInfoService.java new file mode 100644 index 0000000..22158d1 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/service/GraphInfoService.java @@ -0,0 +1,7 @@ +package com.atjy.web.admin.service; + +import com.atjy.model.entity.GraphInfo; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface GraphInfoService extends IService { +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/service/LoginService.java b/web/web-admin/src/main/java/com/atjy/web/admin/service/LoginService.java new file mode 100644 index 0000000..b3a0779 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/service/LoginService.java @@ -0,0 +1,14 @@ +package com.atjy.web.admin.service; + +import com.atjy.common.result.Result; +import com.atjy.web.admin.vo.login.CaptchaVo; +import com.atjy.web.admin.vo.login.LoginVo; +import com.atjy.web.admin.vo.system.user.SystemUserInfoVo; + +public interface LoginService { + Result login(LoginVo loginVo); + + CaptchaVo getCaptcha(); + + SystemUserInfoVo getLoginUserInfo(Long userId); +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/FileServiceImpl.java b/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/FileServiceImpl.java new file mode 100644 index 0000000..e8e6503 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/FileServiceImpl.java @@ -0,0 +1,71 @@ +package com.atjy.web.admin.service.impl; + +import com.atjy.web.admin.service.FileService; +import com.atjy.common.minio.MinioProperties; +import io.minio.*; +import io.minio.errors.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.ErrorResponseException; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.UUID; + +@Service +public class FileServiceImpl implements FileService { + + @Autowired + private MinioClient minioClient; + + @Autowired + private MinioProperties properties; + + @Override + public String upload(MultipartFile file) throws InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException, io.minio.errors.ServerException, io.minio.errors.ErrorResponseException { + + boolean bucketExists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(properties.getBucketName()).build()); + if (!bucketExists) { + minioClient.makeBucket( + MakeBucketArgs.builder() + .bucket(properties.getBucketName()) + .build()); + minioClient.setBucketPolicy( + SetBucketPolicyArgs.builder() + .bucket(properties.getBucketName()) + .config(createBucketPolicyConfig(properties.getBucketName())) + .build()); + } + String filename = new SimpleDateFormat("yyyyMMdd").format(new Date()) + + "/" + UUID.randomUUID() + "-" + file.getOriginalFilename(); + minioClient.putObject( + PutObjectArgs.builder() + .bucket(properties.getBucketName()) + .stream(file.getInputStream(), file.getSize(), -1) + .object(filename) + .contentType(file.getContentType()) + .build()); + String result = String.join("/", properties.getEndpoint(), properties.getBucketName(), filename); + + return result; + } + + private String createBucketPolicyConfig(String bucketName) { + + return """ + { + "Statement" : [ { + "Action" : "s3:GetObject", + "Effect" : "Allow", + "Principal" : "*", + "Resource" : "arn:aws:s3:::%s/*" + } ], + "Version" : "2012-10-17" + } + """.formatted(bucketName); + } +} diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/GraphInfoServiceImpl.java b/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/GraphInfoServiceImpl.java new file mode 100644 index 0000000..a608d3c --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/GraphInfoServiceImpl.java @@ -0,0 +1,13 @@ +package com.atjy.web.admin.service.impl; + +import com.atjy.model.entity.GraphInfo; +import com.atjy.web.admin.mapper.GraphInfoMapper; +import com.atjy.web.admin.service.GraphInfoService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +@Service +public class GraphInfoServiceImpl extends ServiceImpl + implements GraphInfoService { + +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/LoginServiceImpl.java b/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/LoginServiceImpl.java new file mode 100644 index 0000000..8a5c88d --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/LoginServiceImpl.java @@ -0,0 +1,95 @@ +package com.atjy.web.admin.service.impl; + + +import com.atjy.common.constant.RedisConstant; +import com.atjy.common.exception.HassleFreeException; +import com.atjy.common.result.Result; +import com.atjy.common.result.ResultCodeEnum; +import com.atjy.common.utils.JwtUtil; +import com.atjy.model.entity.SystemUser; +import com.atjy.model.enums.BaseStatus; +import com.atjy.web.admin.mapper.SystemUserMapper; +import com.atjy.web.admin.service.LoginService; +import com.atjy.web.admin.vo.login.CaptchaVo; +import com.atjy.web.admin.vo.login.LoginVo; +import com.atjy.web.admin.vo.system.user.SystemUserInfoVo; +import org.apache.commons.codec.digest.DigestUtils; +import com.wf.captcha.SpecCaptcha; +import com.wf.captcha.base.Captcha; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +@Service +public class LoginServiceImpl implements LoginService { + + @Autowired + private StringRedisTemplate redisTemplate; + + @Autowired + private SystemUserMapper systemUserMapper; + + @Override + public Result login(LoginVo loginVo) { + //1.判断是否输入了验证码 + if (!StringUtils.hasText(loginVo.getCaptchaCode())) { + throw new HassleFreeException(ResultCodeEnum.ADMIN_CAPTCHA_CODE_NOT_FOUND); + } + + //2.校验验证码 + String code = redisTemplate.opsForValue().get(loginVo.getCaptchaKey()); + if (code == null) { + return Result.fail(303, "验证码已过期"); + } + + if (!code.equals(loginVo.getCaptchaCode().toLowerCase())) { + return Result.fail(302, "验证码错误"); + } + + //3.校验用户是否存在 + SystemUser systemUser = systemUserMapper.selectOneByUsername(loginVo.getUsername()); + + if (systemUser == null) { + return Result.fail(306, "用户不存在"); + } + + //4.校验用户是否被禁 + if (systemUser.getState() == BaseStatus.DISABLE) { + return Result.fail(308, "该用户已被禁用"); + } + + //5.校验用户密码 + if (!systemUser.getPassword().equals(DigestUtils.md5Hex(loginVo.getPassword()))) { + return Result.fail(307, "密码错误"); + } + + //6.创建并返回TOKEN + return Result.ok(JwtUtil.createToken(systemUser.getId(), systemUser.getUsername())); + } + + @Override + public CaptchaVo getCaptcha() { + SpecCaptcha specCaptcha = new SpecCaptcha(130, 48, 4); + specCaptcha.setCharType(Captcha.TYPE_DEFAULT); + + String code = specCaptcha.text().toLowerCase(); + String key = RedisConstant.ADMIN_LOGIN_PREFIX + UUID.randomUUID(); + String image = specCaptcha.toBase64(); + redisTemplate.opsForValue().set(key, code, RedisConstant.ADMIN_LOGIN_CAPTCHA_TTL_SEC, TimeUnit.SECONDS); + + return new CaptchaVo(image, key); + } + + @Override + public SystemUserInfoVo getLoginUserInfo(Long userId) { + SystemUser systemUser = systemUserMapper.selectById(userId); + SystemUserInfoVo systemUserInfoVo = new SystemUserInfoVo(); + systemUserInfoVo.setName(systemUser.getName()); + systemUserInfoVo.setAvatarUrl(systemUser.getAvatarUrl()); + return systemUserInfoVo; + } +} diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/vo/graph/GraphVo.java b/web/web-admin/src/main/java/com/atjy/web/admin/vo/graph/GraphVo.java new file mode 100644 index 0000000..5bfe8ec --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/vo/graph/GraphVo.java @@ -0,0 +1,24 @@ +package com.atjy.web.admin.vo.graph; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Schema(description = "图片信息") +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class GraphVo { + + + @Schema(description = "图片名称") + private String name; + + @Schema(description = "图片地址") + private String url; + +} diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/vo/login/CaptchaVo.java b/web/web-admin/src/main/java/com/atjy/web/admin/vo/login/CaptchaVo.java new file mode 100644 index 0000000..947d4af --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/vo/login/CaptchaVo.java @@ -0,0 +1,17 @@ +package com.atjy.web.admin.vo.login; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@Schema(description = "图像验证码") +@AllArgsConstructor +public class CaptchaVo { + + @Schema(description = "验证码图片信息") + private String image; + + @Schema(description = "验证码key") + private String key; +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/vo/login/LoginVo.java b/web/web-admin/src/main/java/com/atjy/web/admin/vo/login/LoginVo.java new file mode 100644 index 0000000..488230c --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/vo/login/LoginVo.java @@ -0,0 +1,21 @@ +package com.atjy.web.admin.vo.login; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "后台管理系统登录信息") +public class LoginVo { + + @Schema(description = "用户名") + private String username; + + @Schema(description = "密码") + private String password; + + @Schema(description = "验证码key") + private String captchaKey; + + @Schema(description = "验证码code") + private String captchaCode; +} \ No newline at end of file diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/vo/login/loginResult.java b/web/web-admin/src/main/java/com/atjy/web/admin/vo/login/loginResult.java new file mode 100644 index 0000000..ae8bec8 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/vo/login/loginResult.java @@ -0,0 +1,8 @@ +package com.atjy.web.admin.vo.login; + +public class loginResult { + + public String data(String result) { + return result; + } +} diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/vo/system/user/SystemUserInfoVo.java b/web/web-admin/src/main/java/com/atjy/web/admin/vo/system/user/SystemUserInfoVo.java new file mode 100644 index 0000000..98a8c01 --- /dev/null +++ b/web/web-admin/src/main/java/com/atjy/web/admin/vo/system/user/SystemUserInfoVo.java @@ -0,0 +1,16 @@ +package com.atjy.web.admin.vo.system.user; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理员基本信息") +@Data +public class SystemUserInfoVo { + + @Schema(description = "用户姓名") + private String name; + + @Schema(description = "用户头像") + private String avatarUrl; + +} \ No newline at end of file diff --git a/web/web-admin/src/main/resources/application.yml b/web/web-admin/src/main/resources/application.yml new file mode 100644 index 0000000..63568ec --- /dev/null +++ b/web/web-admin/src/main/resources/application.yml @@ -0,0 +1,38 @@ +server: + port: 8080 +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: Atjy.000000 + url: jdbc:mysql://192.168.47.101:3306/hassle_free?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2b8 + hikari: + connection-test-query: SELECT 1 # 自动检测连接 + connection-timeout: 60000 #数据库连接超时时间,默认30秒 + idle-timeout: 500000 #空闲连接存活最大时间,默认600000(10分钟) + max-lifetime: 540000 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟 + maximum-pool-size: 12 #连接池最大连接数,默认是10 + minimum-idle: 10 #最小空闲连接数量 + pool-name: SPHHikariPool # 连接池名称 + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + + data: + redis: + host: 192.168.47.101 + port: 6379 + database: 0 + +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + +springdoc: + default-flat-param-object: true + +minio: + endpoint: http://192.168.47.101:9000 + access-key: minioadmin + secret-key: minioadmin + bucket-name: hassle-free \ No newline at end of file diff --git a/web/web-admin/src/main/resources/mapper/GraphInfoMapper.xml b/web/web-admin/src/main/resources/mapper/GraphInfoMapper.xml new file mode 100644 index 0000000..567c5df --- /dev/null +++ b/web/web-admin/src/main/resources/mapper/GraphInfoMapper.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/web/web-admin/src/main/resources/mapper/SystemUserMapper.xml b/web/web-admin/src/main/resources/mapper/SystemUserMapper.xml new file mode 100644 index 0000000..f180514 --- /dev/null +++ b/web/web-admin/src/main/resources/mapper/SystemUserMapper.xml @@ -0,0 +1,22 @@ + + + + + + \ No newline at end of file diff --git a/web/web-app/.gitignore b/web/web-app/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/web/web-app/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/web/web-app/pom.xml b/web/web-app/pom.xml new file mode 100644 index 0000000..9750210 --- /dev/null +++ b/web/web-app/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + com.atjy + web + 0.0.1-SNAPSHOT + + + web-app + + + 17 + 17 + UTF-8 + + + + + + ch.qos.logback + logback-classic + + + + com.alibaba + dashscope-sdk-java + + + + org.apache.httpcomponents + httpclient + 4.5.14 + + + + + \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/WebAppApplication.java b/web/web-app/src/main/java/com/atjy/web/app/WebAppApplication.java new file mode 100644 index 0000000..7ede7a7 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/WebAppApplication.java @@ -0,0 +1,17 @@ +package com.atjy.web.app; + + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableAsync; + +@MapperScan("com.atjy.web.app.mapper") +@SpringBootApplication +@EnableAsync +public class WebAppApplication { + + public static void main(String[] args) { + SpringApplication.run(WebAppApplication.class, args); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/ai/Ai.java b/web/web-app/src/main/java/com/atjy/web/app/ai/Ai.java new file mode 100644 index 0000000..1065900 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/ai/Ai.java @@ -0,0 +1,60 @@ +package com.atjy.web.app.ai; + +import com.alibaba.dashscope.aigc.generation.Generation; +import com.alibaba.dashscope.aigc.generation.GenerationParam; +import com.alibaba.dashscope.aigc.generation.GenerationResult; +import com.alibaba.dashscope.common.Message; +import com.alibaba.dashscope.common.Role; +import com.alibaba.dashscope.exception.ApiException; +import com.alibaba.dashscope.exception.InputRequiredException; +import com.alibaba.dashscope.exception.NoApiKeyException; +import com.atjy.web.app.mapper.ConsultMapper; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Ai { + + public static List messages = new ArrayList<>(); + + public static boolean flag = true; + + public static GenerationParam createGenerationParam(List messages) { + return GenerationParam.builder() + .model("qwen-plus") + .messages(messages) + .resultFormat(GenerationParam.ResultFormat.MESSAGE) + .build(); + } + + public static GenerationResult callGenerationWithMessages(GenerationParam param) throws ApiException, NoApiKeyException, InputRequiredException { + Generation gen = new Generation(); + return gen.call(param); + } + + private static Message createMessage(Role role, String content) { + return Message.builder().role(role.getValue()).content(content).build(); + } + + public static void addMessage() { + messages.add(createMessage(Role.SYSTEM, "You are a helpful assistant.")); + } + + + public static String getAnswer(String problem) { + try { + messages.add(createMessage(Role.USER, problem)); + GenerationParam param = createGenerationParam(messages); + GenerationResult result = callGenerationWithMessages(param); + messages.add(result.getOutput().getChoices().get(0).getMessage()); + + return result.getOutput().getChoices().get(0).getMessage().getContent(); + } catch (ApiException | NoApiKeyException | InputRequiredException e) { + e.printStackTrace(); + } + System.exit(0); + return null; + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/controller/appointment/Appointment.java b/web/web-app/src/main/java/com/atjy/web/app/controller/appointment/Appointment.java new file mode 100644 index 0000000..d0947eb --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/controller/appointment/Appointment.java @@ -0,0 +1,34 @@ +package com.atjy.web.app.controller.appointment; + +import com.atjy.common.result.Result; +import com.atjy.web.app.service.AppointmentInfoService; +import com.atjy.web.app.vo.appointment.AppointmentInfoVo; +import com.atjy.web.app.vo.appointment.AppointmentOrderVo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +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; + +@Tag(name = "预约信息") +@RestController +@RequestMapping("/app/appointment") +public class Appointment { + + @Autowired + private AppointmentInfoService service; + + @Operation(summary = "获取预约详情") + @PostMapping("getAppointmentByIdAndTime") + public Result getAppointmentByIdAndTime(@RequestParam Long id, @RequestParam String date) { + return Result.ok(service.getAppointmentByIdAndTime(id, date)); + } + + @Operation(summary = "获取预约订单") + @PostMapping("getAppointmentOrderByIdAndTime") + public Result getAppointmentOrderByIdAndTime(@RequestParam Long id, @RequestParam String date) { + return Result.ok(service.getAppointmentOrderByIdAndTime(id,date)); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/controller/article/ArticleController.java b/web/web-app/src/main/java/com/atjy/web/app/controller/article/ArticleController.java new file mode 100644 index 0000000..9307d13 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/controller/article/ArticleController.java @@ -0,0 +1,45 @@ +package com.atjy.web.app.controller.article; + +import com.atjy.common.result.Result; +import com.atjy.model.entity.ArticleInfo; +import com.atjy.model.enums.ArticleItemType; +import com.atjy.web.app.service.ArticleService; +import com.atjy.web.app.vo.article.ArticleInfoVo; +import com.atjy.web.app.vo.article.ArticleVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Tag(name = "医说信息") +@RestController +@RequestMapping("/app/article") +public class ArticleController { + + @Autowired + private ArticleService service; + + @Operation(summary = "根据内容获取医说") + @PostMapping("getArticleByContent") + public Result> getArticleByContent(@RequestParam(required = false) String content) { + return Result.ok(service.getArticleByContent(content)); + } + + @Operation(summary = "获取医说详情") + @PostMapping("getArticleInfo") + public Result getArticleInfo(@RequestParam Long articleId) { + ArticleInfoVo result = service.getArticle(articleId); + return Result.ok(result); + } + + @Operation(summary = "获取不同类型医说") + @PostMapping("getArticleByType") + public Result> getArticleByType(@RequestParam String type) { + return Result.ok(service.getArticleByType(type)); + } + +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/controller/consult/AiConsultController.java b/web/web-app/src/main/java/com/atjy/web/app/controller/consult/AiConsultController.java new file mode 100644 index 0000000..8fe5ad5 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/controller/consult/AiConsultController.java @@ -0,0 +1,28 @@ +package com.atjy.web.app.controller.consult; + +import com.atjy.common.login.LoginUserHolder; +import com.atjy.common.result.Result; +import com.atjy.web.app.service.ConsultService; +import com.atjy.web.app.vo.consult.ProblemVo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@Tag(name = "问诊管理") +@RestController +@RequestMapping("/app/ai") +public class AiConsultController { + + @Autowired + private ConsultService service; + + @Operation(summary = "ai咨询") + @PostMapping("Consult") + public Result getAnswer(@RequestBody ProblemVo problem) { + Integer consultationNumber = service.getNumberByUserId(LoginUserHolder.getLoginUser().getUserId()) + 1; + String result = service.getAnswerToAi(problem.getProblem(), consultationNumber); + return Result.ok(result); + } + +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/controller/doctor/DoctorController.java b/web/web-app/src/main/java/com/atjy/web/app/controller/doctor/DoctorController.java new file mode 100644 index 0000000..fa2f839 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/controller/doctor/DoctorController.java @@ -0,0 +1,46 @@ +package com.atjy.web.app.controller.doctor; + +import com.atjy.common.result.Result; +import com.atjy.web.app.service.DoctorService; +import com.atjy.web.app.vo.doctor.DoctorInfoVo; +import com.atjy.web.app.vo.doctor.DoctorTermsVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Tag(name = "医生管理") +@RestController +@RequestMapping("/app/doctor") +public class DoctorController { + + @Autowired + private DoctorService service; + + @Operation(summary = "根据姓名获取医生") + @PostMapping("getDoctorByName") + public Result> getDoctorByName(@RequestParam(required = false) String name) { + return Result.ok(service.getDoctorByName(name)); + } + + @Operation(summary = "根据条件筛选医生") + @PostMapping("getDoctorByTerms") + public Result> getDoctorByTerms(@RequestBody DoctorTermsVo doctorTermsVo) { + return Result.ok(service.getDoctorByTerms(doctorTermsVo)); + } + + @Operation(summary = "获取医生详情") + @PostMapping("getDoctorById") + public Result getDoctorById(@RequestParam Long doctorId) { + return Result.ok(service.getDoctorById(doctorId)); + } + + @Operation(summary = "根据医院id和科室和时间获取医生") + @PostMapping("getDoctorByIdAndDepartmentAndTime") + public Result> getDoctorByIdAndDepartmentAndTime(@RequestParam Long hospitalId, @RequestParam String department, @RequestParam(required = false) String date) { + return Result.ok(service.getDoctorByIdAndDepartmentAndTime(hospitalId, department, date)); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/controller/homepage/HomepageController.java b/web/web-app/src/main/java/com/atjy/web/app/controller/homepage/HomepageController.java new file mode 100644 index 0000000..067d2ea --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/controller/homepage/HomepageController.java @@ -0,0 +1,30 @@ +package com.atjy.web.app.controller.homepage; + +import com.atjy.common.result.Result; +import com.atjy.web.app.service.HomepageService; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.atjy.web.app.vo.homepage.HomepageVo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +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.List; + +@Tag(name = "首页管理") +@RestController +@RequestMapping("/app/homepage") +public class HomepageController { + + @Autowired + private HomepageService service; + + @Operation(summary = "根据区域id获取首页列表") + @PostMapping("getHomepageByDistrictId") + public Result getHomepageByDistrictId(@RequestParam Long districtId) { + return Result.ok(service.getHomepageByDistrictId(districtId)); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/controller/hospital/HospitalController.java b/web/web-app/src/main/java/com/atjy/web/app/controller/hospital/HospitalController.java new file mode 100644 index 0000000..52ad5bc --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/controller/hospital/HospitalController.java @@ -0,0 +1,51 @@ +package com.atjy.web.app.controller.hospital; + +import com.atjy.common.result.Result; +import com.atjy.model.entity.HospitalInfo; +import com.atjy.web.app.service.HospitalService; +import com.atjy.web.app.vo.hospital.HospitalInfoVo; +import com.atjy.web.app.vo.hospital.HospitalTermsVo; +import com.atjy.web.app.vo.hospital.HospitalVo; +import com.atjy.web.app.vo.hospital.RegisteredVo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Tag(name = "医院管理") +@RestController +@RequestMapping("/app/hospital") +public class HospitalController { + + @Autowired + private HospitalService service; + + @Operation(summary = "根据名称获取医院") + @PostMapping("getHospitalByName") + public Result> getHospitalByName(@RequestParam(required = false) String name) { + List result = service.getHospitalByName(name); + return Result.ok(result); + } + + @Operation(summary = "根据条件筛选医院") + @PostMapping("getHospitalByTerms") + public Result> getHospitalByTerms(@RequestBody HospitalTermsVo hospitalTerms) { + List result = service.getHospitalByTerms(hospitalTerms); + return Result.ok(result); + } + + @Operation(summary = "获取医院详情") + @PostMapping("getHospitalById") + public Result getHospitalById(@RequestParam Long hospitalId) { + return Result.ok(service.getHospitalById(hospitalId)); + } + + @Operation(summary = "获取挂号详情") + @PostMapping("getRegisteredById") + public Result getRegisteredById(@RequestParam Long hospitalId) { + return Result.ok(service.getRegisteredById(hospitalId)); + } + +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/controller/login/LoginController.java b/web/web-app/src/main/java/com/atjy/web/app/controller/login/LoginController.java new file mode 100644 index 0000000..eb2deff --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/controller/login/LoginController.java @@ -0,0 +1,41 @@ +package com.atjy.web.app.controller.login; + + +import com.atjy.common.login.LoginUserHolder; +import com.atjy.common.result.Result; +import com.atjy.web.app.service.LoginService; +import com.atjy.web.app.vo.login.LoginVo; +import com.atjy.web.app.vo.login.UserInfoVo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +@Tag(name = "登录管理") +@RestController +@RequestMapping("/app") +public class LoginController { + + @Autowired + private LoginService service; + + @Operation(summary = "登录") + @PostMapping("login") + public Result login(@RequestBody LoginVo loginVo) { + return service.login(loginVo); + } + + @GetMapping("login/getCode") + @Operation(summary = "获取短信验证码") + public Result getCode(@RequestParam String phone) { + return service.getSMSCode(phone); + } + + @GetMapping("info") + @Operation(summary = "获取登录用户信息") + public Result info() { + UserInfoVo info = service.getUserInfoById(LoginUserHolder.getLoginUser().getUserId()); + return Result.ok(info); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/controller/myself/AppointmentController.java b/web/web-app/src/main/java/com/atjy/web/app/controller/myself/AppointmentController.java new file mode 100644 index 0000000..18108cc --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/controller/myself/AppointmentController.java @@ -0,0 +1,47 @@ +package com.atjy.web.app.controller.myself; + + +import com.atjy.common.login.LoginUserHolder; +import com.atjy.common.result.Result; +import com.atjy.web.app.service.UserAppointmentService; +import com.atjy.web.app.vo.appointment.AppointmentVo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +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.ArrayList; +import java.util.List; + +@Tag(name = "就诊信息") +@RestController +@RequestMapping("/app/center/appointment") +public class AppointmentController { + + @Autowired + private UserAppointmentService service; + + @Operation(summary = "获取全部就诊详情") + @GetMapping("getAllDiagnosis") + public Result> getAllDiagnosis() { + List waitDiagnosis = service.getWaitDiagnosis(LoginUserHolder.getLoginUser().getUserId()); + List alreadyDiagnosis = service.getAlreadyDiagnosis(LoginUserHolder.getLoginUser().getUserId()); + alreadyDiagnosis.addAll(waitDiagnosis); + + return Result.ok(alreadyDiagnosis); + } + + @Operation(summary = "获取待就诊详情") + @GetMapping("getWaitDiagnosis") + public Result> getWaitDiagnosis() { + return Result.ok(service.getWaitDiagnosis(LoginUserHolder.getLoginUser().getUserId())); + } + + @Operation(summary = "获取已就诊详情") + @GetMapping("getAlreadyDiagnosis") + public Result> getAlreadyDiagnosis() { + return Result.ok(service.getAlreadyDiagnosis(LoginUserHolder.getLoginUser().getUserId())); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/controller/myself/CollectionController.java b/web/web-app/src/main/java/com/atjy/web/app/controller/myself/CollectionController.java new file mode 100644 index 0000000..12cb795 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/controller/myself/CollectionController.java @@ -0,0 +1,47 @@ +package com.atjy.web.app.controller.myself; + +import com.atjy.common.login.LoginUserHolder; +import com.atjy.common.result.Result; +import com.atjy.web.app.service.CollectionService; +import com.atjy.web.app.vo.article.ArticleVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.atjy.web.app.vo.hospital.HospitalVo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +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; + + +@Tag(name = "收藏信息") +@RestController +@RequestMapping("/app/center/collection") +public class CollectionController { + + @Autowired + private CollectionService service; + + @Operation(summary = "获取医院详情") + @GetMapping("hospital") + public Result> getHospitalInfo() { + List result = service.selectHospitalInfoListByUserId(LoginUserHolder.getLoginUser().getUserId()); + return Result.ok(result); + } + + @Operation(summary = "获取医生详情") + @GetMapping("doctor") + public Result> getDoctorInfo() { + List result = service.selectDoctorInfoListByUserId(LoginUserHolder.getLoginUser().getUserId()); + return Result.ok(result); + } + + @Operation(summary = "获取医说详情") + @GetMapping("article") + public Result> getArticleInfo() { + List result = service.selectArticleInfoListByUserId(LoginUserHolder.getLoginUser().getUserId()); + return Result.ok(result); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/controller/myself/ConsultController.java b/web/web-app/src/main/java/com/atjy/web/app/controller/myself/ConsultController.java new file mode 100644 index 0000000..b55b7b1 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/controller/myself/ConsultController.java @@ -0,0 +1,30 @@ +package com.atjy.web.app.controller.myself; + +import com.atjy.common.login.LoginUserHolder; +import com.atjy.common.result.Result; +import com.atjy.web.app.service.ConsultService; +import com.atjy.web.app.vo.consult.ConsultInfoVo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +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; + +@Tag(name = "咨询信息") +@RestController +@RequestMapping("/app/center/logs") +public class ConsultController { + + @Autowired + private ConsultService service; + + @Operation(summary = "获取全部咨询详情") + @GetMapping("consult") + public Result> getAllConsult() { + List result = service.getAllConsultByUserId(LoginUserHolder.getLoginUser().getUserId()); + return Result.ok(result); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/custom/config/Knife4jConfiguration.java b/web/web-app/src/main/java/com/atjy/web/app/custom/config/Knife4jConfiguration.java new file mode 100644 index 0000000..c62bbc9 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/custom/config/Knife4jConfiguration.java @@ -0,0 +1,81 @@ +package com.atjy.web.app.custom.config; + + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class Knife4jConfiguration { + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("医路无忧App系统API") + .version("1.0") + .description("用户端APP接口") + .termsOfService("http://doc.xiaominfo.com") + .license(new License().name("Apache 2.0") + .url("http://doc.xiaominfo.com"))); + } + + @Bean + public GroupedOpenApi loginAPI() { + return GroupedOpenApi.builder().group("登录信息"). + pathsToMatch("/app/login/**", "/app/info"). + build(); + } + + @Bean + public GroupedOpenApi interrogationAPI() { + return GroupedOpenApi.builder().group("问诊信息"). + pathsToMatch("/app/ai/**"). + build(); + } + + @Bean + public GroupedOpenApi myselfAPI() { + return GroupedOpenApi.builder().group("个人中心信息"). + pathsToMatch("/app/center/**"). + build(); + } + + @Bean + public GroupedOpenApi articleAPI() { + return GroupedOpenApi.builder().group("医说信息"). + pathsToMatch("/app/article/**"). + build(); + } + + @Bean + public GroupedOpenApi doctorAPI() { + return GroupedOpenApi.builder().group("医生信息"). + pathsToMatch("/app/doctor/**"). + build(); + } + + @Bean + public GroupedOpenApi hospitalAPI() { + return GroupedOpenApi.builder().group("医院信息"). + pathsToMatch("/app/hospital/**"). + build(); + } + + @Bean + public GroupedOpenApi homepageAPI() { + return GroupedOpenApi.builder().group("首页信息"). + pathsToMatch("/app/homepage/**"). + build(); + } + + @Bean + public GroupedOpenApi appointmentAPI() { + return GroupedOpenApi.builder().group("预约信息"). + pathsToMatch("/app/appointment/**"). + build(); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/custom/config/WebMvcConfiguration.java b/web/web-app/src/main/java/com/atjy/web/app/custom/config/WebMvcConfiguration.java new file mode 100644 index 0000000..a22f98c --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/custom/config/WebMvcConfiguration.java @@ -0,0 +1,21 @@ +package com.atjy.web.app.custom.config; + +import com.atjy.web.app.custom.interceptor.AuthenticationInterceptor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebMvcConfiguration implements WebMvcConfigurer { + + @Autowired + private AuthenticationInterceptor authenticationInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(this.authenticationInterceptor) + .addPathPatterns("/app/**") + .excludePathPatterns("/app/login/**"); + } +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/custom/interceptor/AuthenticationInterceptor.java b/web/web-app/src/main/java/com/atjy/web/app/custom/interceptor/AuthenticationInterceptor.java new file mode 100644 index 0000000..2a3853e --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/custom/interceptor/AuthenticationInterceptor.java @@ -0,0 +1,31 @@ +package com.atjy.web.app.custom.interceptor; + +import com.atjy.common.login.LoginUser; +import com.atjy.common.login.LoginUserHolder; +import com.atjy.common.utils.JwtUtil; +import io.jsonwebtoken.Claims; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; + +@Component +public class AuthenticationInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + String token = request.getHeader("token"); + + Claims claims = JwtUtil.parseToken(token); + Long userId = claims.get("userId", Long.class); + String username = claims.get("username", String.class); + LoginUserHolder.setLoginUser(new LoginUser(userId, username)); + + return true; + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + LoginUserHolder.clear(); + } +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/AppointmentInfoMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/AppointmentInfoMapper.java new file mode 100644 index 0000000..b76729c --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/AppointmentInfoMapper.java @@ -0,0 +1,7 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.AppointmentInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface AppointmentInfoMapper extends BaseMapper { +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/ArticleMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/ArticleMapper.java new file mode 100644 index 0000000..fd251bf --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/ArticleMapper.java @@ -0,0 +1,13 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.ArticleInfo; +import com.atjy.web.app.vo.article.ArticleVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface ArticleMapper extends BaseMapper { + List selectListByDoctorId(Long doctorId); + + List selectListByDoctorIdList(List doctorIdList); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/CityInfoMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/CityInfoMapper.java new file mode 100644 index 0000000..625309e --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/CityInfoMapper.java @@ -0,0 +1,12 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.CityInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface CityInfoMapper extends BaseMapper { + +} + + + + diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/CollectionMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/CollectionMapper.java new file mode 100644 index 0000000..ed7f4ca --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/CollectionMapper.java @@ -0,0 +1,17 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.UserCollection; +import com.atjy.web.app.vo.article.ArticleVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.atjy.web.app.vo.hospital.HospitalVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface CollectionMapper extends BaseMapper { + List selectHospitalListByUserId(Long userId); + + List selectArticleInfoListByUserId(Long userId); + + List selectDoctorInfoListByUserId(Long userId); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/ConsultMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/ConsultMapper.java new file mode 100644 index 0000000..c4c92dc --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/ConsultMapper.java @@ -0,0 +1,16 @@ +package com.atjy.web.app.mapper; + + +import com.atjy.model.entity.ConsultInfo; +import com.atjy.web.app.vo.consult.ConsultInfoVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface ConsultMapper extends BaseMapper { + + List getAllConsultByUserId(Long userId); + + Integer getNumberByUserId(Long userId); + +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/DepartmentInfoMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/DepartmentInfoMapper.java new file mode 100644 index 0000000..2976e02 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/DepartmentInfoMapper.java @@ -0,0 +1,10 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.DepartmentInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface DepartmentInfoMapper extends BaseMapper { + List selectListByHospitalId(Long hospitalId); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/DepartmentMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/DepartmentMapper.java new file mode 100644 index 0000000..9906e09 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/DepartmentMapper.java @@ -0,0 +1,7 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.DepartmentInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface DepartmentMapper extends BaseMapper { +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/DistrictInfoMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/DistrictInfoMapper.java new file mode 100644 index 0000000..99c26f0 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/DistrictInfoMapper.java @@ -0,0 +1,12 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.DistrictInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface DistrictInfoMapper extends BaseMapper { + +} + + + + diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/DoctorAppointmentMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/DoctorAppointmentMapper.java new file mode 100644 index 0000000..fdea573 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/DoctorAppointmentMapper.java @@ -0,0 +1,12 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.DoctorAppointment; +import com.atjy.web.app.vo.appointment.AppointmentTimeVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface DoctorAppointmentMapper extends BaseMapper { + List selectListByDoctorId(Long doctorId); + +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/DoctorMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/DoctorMapper.java new file mode 100644 index 0000000..7a875e5 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/DoctorMapper.java @@ -0,0 +1,28 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.DoctorInfo; +import com.atjy.web.app.vo.doctor.DoctorSmallVo; +import com.atjy.web.app.vo.doctor.DoctorTermsVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.atjy.web.app.vo.hospital.HospitalVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface DoctorMapper extends BaseMapper { + + List selectListDoctorSmallVo(Long hospitalId); + + List getDoctorByTerms(DoctorTermsVo doctorTermsVo); + + List selectListByHospitalIdList(List list); + + List selectListByHospitalIdListAndExpertise(List list, String expertise); + + List getDoctorByIdAndDepartment(Long hospitalId, String department); + + List getDoctorByIdAndDepartmentAndTime(Long hospitalId, String department, List list); + + String selectDepartment(Long id); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/GraphInfoMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/GraphInfoMapper.java new file mode 100644 index 0000000..cccaf18 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/GraphInfoMapper.java @@ -0,0 +1,14 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.GraphInfo; +import com.atjy.model.enums.GraphItemType; +import com.atjy.web.app.vo.graph.GraphVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface GraphInfoMapper extends BaseMapper { + + + List selectListByItemTypeAndId(GraphItemType itemType, Long id); +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/HospitalDepartmentMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/HospitalDepartmentMapper.java new file mode 100644 index 0000000..bccc0d5 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/HospitalDepartmentMapper.java @@ -0,0 +1,10 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.HospitalDepartment; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface HospitalDepartmentMapper extends BaseMapper { + List selectDepartmentList(Long hospitalId); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/HospitalLabelMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/HospitalLabelMapper.java new file mode 100644 index 0000000..76cf3b5 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/HospitalLabelMapper.java @@ -0,0 +1,10 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.HospitalLabel; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface HospitalLabelMapper extends BaseMapper { + List selectListByHospitalId(Long id); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/HospitalMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/HospitalMapper.java new file mode 100644 index 0000000..7bf19bc --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/HospitalMapper.java @@ -0,0 +1,13 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.HospitalInfo; +import com.atjy.web.app.vo.hospital.HospitalTermsVo; +import com.atjy.web.app.vo.hospital.HospitalVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface HospitalMapper extends BaseMapper { + + List getHospitalByTerms(HospitalTermsVo hospitalTerms); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/ProvinceInfoMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/ProvinceInfoMapper.java new file mode 100644 index 0000000..cdc59ef --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/ProvinceInfoMapper.java @@ -0,0 +1,12 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.ProvinceInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface ProvinceInfoMapper extends BaseMapper { + +} + + + + diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/UserAppointmentMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/UserAppointmentMapper.java new file mode 100644 index 0000000..53e7b10 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/UserAppointmentMapper.java @@ -0,0 +1,15 @@ +package com.atjy.web.app.mapper; + + +import com.atjy.model.entity.UserAppointment; +import com.atjy.web.app.vo.appointment.AppointmentVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface UserAppointmentMapper extends BaseMapper { + + List getWaitDiagnosis(Long userId); + + List getAlreadyDiagnosis(Long userId); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mapper/UserMapper.java b/web/web-app/src/main/java/com/atjy/web/app/mapper/UserMapper.java new file mode 100644 index 0000000..7712630 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mapper/UserMapper.java @@ -0,0 +1,8 @@ +package com.atjy.web.app.mapper; + +import com.atjy.model.entity.UserInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface UserMapper extends BaseMapper { + +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mybatisplus/MybatisMetaObjectHandler.java b/web/web-app/src/main/java/com/atjy/web/app/mybatisplus/MybatisMetaObjectHandler.java new file mode 100644 index 0000000..6a10a8b --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mybatisplus/MybatisMetaObjectHandler.java @@ -0,0 +1,20 @@ +package com.atjy.web.app.mybatisplus; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +@Component +public class MybatisMetaObjectHandler implements MetaObjectHandler { + @Override + public void insertFill(MetaObject metaObject) { + this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now()); + } + + @Override + public void updateFill(MetaObject metaObject) { + this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/mybatisplus/MybatisPlusConfiguration.java b/web/web-app/src/main/java/com/atjy/web/app/mybatisplus/MybatisPlusConfiguration.java new file mode 100644 index 0000000..7cb1d97 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/mybatisplus/MybatisPlusConfiguration.java @@ -0,0 +1,20 @@ +package com.atjy.web.app.mybatisplus; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@MapperScan("com.atjy.web.app.mapper") +public class MybatisPlusConfiguration { + + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + return interceptor; + } +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/AppointmentInfoService.java b/web/web-app/src/main/java/com/atjy/web/app/service/AppointmentInfoService.java new file mode 100644 index 0000000..115b517 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/AppointmentInfoService.java @@ -0,0 +1,13 @@ +package com.atjy.web.app.service; + +import com.atjy.common.result.Result; +import com.atjy.model.entity.AppointmentInfo; +import com.atjy.web.app.vo.appointment.AppointmentInfoVo; +import com.atjy.web.app.vo.appointment.AppointmentOrderVo; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface AppointmentInfoService extends IService { + AppointmentInfoVo getAppointmentByIdAndTime(Long id, String date); + + AppointmentOrderVo getAppointmentOrderByIdAndTime(Long id, String date); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/ArticleService.java b/web/web-app/src/main/java/com/atjy/web/app/service/ArticleService.java new file mode 100644 index 0000000..565bb73 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/ArticleService.java @@ -0,0 +1,16 @@ +package com.atjy.web.app.service; + +import com.atjy.model.entity.ArticleInfo; +import com.atjy.web.app.vo.article.ArticleInfoVo; +import com.atjy.web.app.vo.article.ArticleVo; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +public interface ArticleService extends IService { + ArticleInfoVo getArticle(Long articleId); + + List getArticleByContent(String content); + + List getArticleByType(String type); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/CityInfoService.java b/web/web-app/src/main/java/com/atjy/web/app/service/CityInfoService.java new file mode 100644 index 0000000..dbd1b01 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/CityInfoService.java @@ -0,0 +1,8 @@ +package com.atjy.web.app.service; + +import com.atjy.model.entity.CityInfo; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface CityInfoService extends IService { + +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/CollectionService.java b/web/web-app/src/main/java/com/atjy/web/app/service/CollectionService.java new file mode 100644 index 0000000..56e8fa4 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/CollectionService.java @@ -0,0 +1,16 @@ +package com.atjy.web.app.service; + +import com.atjy.web.app.vo.article.ArticleVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.atjy.web.app.vo.hospital.HospitalVo; + +import java.util.List; + +public interface CollectionService { + + List selectHospitalInfoListByUserId(Long userId); + + List selectDoctorInfoListByUserId(Long userId); + + List selectArticleInfoListByUserId(Long userId); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/ConsultService.java b/web/web-app/src/main/java/com/atjy/web/app/service/ConsultService.java new file mode 100644 index 0000000..2852147 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/ConsultService.java @@ -0,0 +1,16 @@ +package com.atjy.web.app.service; + +import com.atjy.model.entity.ConsultInfo; +import com.atjy.web.app.vo.consult.ConsultInfoVo; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +public interface ConsultService extends IService { + + String getAnswerToAi(String problem,Integer consultationNumber); + + List getAllConsultByUserId(Long userId); + + Integer getNumberByUserId(Long userId); +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/DistrictInfoService.java b/web/web-app/src/main/java/com/atjy/web/app/service/DistrictInfoService.java new file mode 100644 index 0000000..b6c14cf --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/DistrictInfoService.java @@ -0,0 +1,8 @@ +package com.atjy.web.app.service; + +import com.atjy.model.entity.DistrictInfo; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface DistrictInfoService extends IService { + +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/DoctorService.java b/web/web-app/src/main/java/com/atjy/web/app/service/DoctorService.java new file mode 100644 index 0000000..ffa1b3d --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/DoctorService.java @@ -0,0 +1,19 @@ +package com.atjy.web.app.service; + +import com.atjy.model.entity.DoctorInfo; +import com.atjy.web.app.vo.doctor.DoctorInfoVo; +import com.atjy.web.app.vo.doctor.DoctorTermsVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +public interface DoctorService extends IService { + List getDoctorByName(String name); + + List getDoctorByTerms(DoctorTermsVo doctorTermsVo); + + DoctorInfoVo getDoctorById(Long doctorId); + + List getDoctorByIdAndDepartmentAndTime(Long hospitalId, String department, String date); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/GraphInfoService.java b/web/web-app/src/main/java/com/atjy/web/app/service/GraphInfoService.java new file mode 100644 index 0000000..efb3bb7 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/GraphInfoService.java @@ -0,0 +1,7 @@ +package com.atjy.web.app.service; + +import com.atjy.model.entity.GraphInfo; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface GraphInfoService extends IService { +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/HomepageService.java b/web/web-app/src/main/java/com/atjy/web/app/service/HomepageService.java new file mode 100644 index 0000000..7e8f10b --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/HomepageService.java @@ -0,0 +1,11 @@ +package com.atjy.web.app.service; + +import com.atjy.common.result.Result; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.atjy.web.app.vo.homepage.HomepageVo; + +import java.util.List; + +public interface HomepageService { + HomepageVo getHomepageByDistrictId(Long districtId); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/HospitalService.java b/web/web-app/src/main/java/com/atjy/web/app/service/HospitalService.java new file mode 100644 index 0000000..7b91af3 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/HospitalService.java @@ -0,0 +1,21 @@ +package com.atjy.web.app.service; + +import com.atjy.common.result.Result; +import com.atjy.model.entity.HospitalInfo; +import com.atjy.web.app.vo.hospital.HospitalInfoVo; +import com.atjy.web.app.vo.hospital.HospitalTermsVo; +import com.atjy.web.app.vo.hospital.HospitalVo; +import com.atjy.web.app.vo.hospital.RegisteredVo; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +public interface HospitalService extends IService { + List getHospitalByName(String name); + + List getHospitalByTerms(HospitalTermsVo hospitalTerms); + + HospitalInfoVo getHospitalById(Long hospitalId); + + RegisteredVo getRegisteredById(Long hospitalId); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/LoginService.java b/web/web-app/src/main/java/com/atjy/web/app/service/LoginService.java new file mode 100644 index 0000000..a61d87c --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/LoginService.java @@ -0,0 +1,13 @@ +package com.atjy.web.app.service; + +import com.atjy.common.result.Result; +import com.atjy.web.app.vo.login.LoginVo; +import com.atjy.web.app.vo.login.UserInfoVo; + +public interface LoginService { + Result login(LoginVo loginVo); + + Result getSMSCode(String phone); + + UserInfoVo getUserInfoById(Long userId); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/ProvinceInfoService.java b/web/web-app/src/main/java/com/atjy/web/app/service/ProvinceInfoService.java new file mode 100644 index 0000000..c0c76d2 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/ProvinceInfoService.java @@ -0,0 +1,8 @@ +package com.atjy.web.app.service; + +import com.atjy.model.entity.ProvinceInfo; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface ProvinceInfoService extends IService { + +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/SmsService.java b/web/web-app/src/main/java/com/atjy/web/app/service/SmsService.java new file mode 100644 index 0000000..48d47a8 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/SmsService.java @@ -0,0 +1,6 @@ +package com.atjy.web.app.service; + +public interface SmsService { + + void sendCode(String phone, String code); +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/UserAppointmentService.java b/web/web-app/src/main/java/com/atjy/web/app/service/UserAppointmentService.java new file mode 100644 index 0000000..0987b6c --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/UserAppointmentService.java @@ -0,0 +1,12 @@ +package com.atjy.web.app.service; + +import com.atjy.web.app.vo.appointment.AppointmentVo; + +import java.util.List; + +public interface UserAppointmentService { + + List getWaitDiagnosis(Long userId); + + List getAlreadyDiagnosis(Long userId); +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/UserService.java b/web/web-app/src/main/java/com/atjy/web/app/service/UserService.java new file mode 100644 index 0000000..f0df006 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/UserService.java @@ -0,0 +1,7 @@ +package com.atjy.web.app.service; + +import com.atjy.model.entity.UserInfo; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface UserService extends IService { +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/AppointmentInfoServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/AppointmentInfoServiceImpl.java new file mode 100644 index 0000000..c3bb532 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/AppointmentInfoServiceImpl.java @@ -0,0 +1,87 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.common.login.LoginUser; +import com.atjy.common.login.LoginUserHolder; +import com.atjy.model.entity.*; +import com.atjy.web.app.controller.appointment.Appointment; +import com.atjy.web.app.mapper.*; +import com.atjy.web.app.service.AppointmentInfoService; +import com.atjy.web.app.vo.appointment.AppointmentInfoVo; +import com.atjy.web.app.vo.appointment.AppointmentOrderVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class AppointmentInfoServiceImpl extends ServiceImpl implements AppointmentInfoService { + + @Autowired + private UserAppointmentMapper userAppointmentMapper; + + @Autowired + private DoctorMapper doctorMapper; + + @Autowired + private HospitalMapper hospitalMapper; + + @Autowired + private DoctorAppointmentMapper doctorAppointmentMapper; + + @Autowired + private AppointmentInfoMapper appointmentInfoMapper; + + @Override + public AppointmentInfoVo getAppointmentByIdAndTime(Long id, String date) { + + HospitalInfo hospitalInfo = hospitalMapper.selectOne(new LambdaQueryWrapper() + .eq(HospitalInfo::getId, doctorMapper.selectOne(new LambdaQueryWrapper() + .eq(DoctorInfo::getId, id)) + .getHospitalId())); + + AppointmentInfoVo appointmentInfoVo = new AppointmentInfoVo(); + + appointmentInfoVo.setDoctorName(doctorMapper.selectOne(new LambdaQueryWrapper().eq(DoctorInfo::getId, id)).getDoctorName()); + appointmentInfoVo.setDepartment(doctorMapper.selectDepartment(id)); + appointmentInfoVo.setFees(doctorAppointmentMapper.selectOne(new LambdaQueryWrapper() + .eq(DoctorAppointment::getDoctorId, id) + .eq(DoctorAppointment::getAppointmentId, appointmentInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(AppointmentInfo::getAppointmentDate, date)) + .getId())) + .getFees()); + appointmentInfoVo.setHospitalName(hospitalInfo.getHospitalName()); + appointmentInfoVo.setAddress(hospitalInfo.getAddress()); + + return appointmentInfoVo; + } + + @Override + public AppointmentOrderVo getAppointmentOrderByIdAndTime(Long id, String date) { + + UserAppointment userAppointment = userAppointmentMapper.selectOne(new LambdaQueryWrapper() + .eq(UserAppointment::getUserId, LoginUserHolder.getLoginUser().getUserId()) + .eq(UserAppointment::getDoctorId, id) + .eq(UserAppointment::getAppointmentId, appointmentInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(AppointmentInfo::getAppointmentDate, date)) + .getId())); + + HospitalInfo hospitalInfo = hospitalMapper.selectOne(new LambdaQueryWrapper() + .eq(HospitalInfo::getId, doctorMapper.selectOne(new LambdaQueryWrapper() + .eq(DoctorInfo::getId, id)) + .getHospitalId())); + + AppointmentOrderVo appointmentOrderVo = new AppointmentOrderVo(); + + appointmentOrderVo.setHospitalName(hospitalInfo.getHospitalName()); + appointmentOrderVo.setAddress(hospitalInfo.getAddress()); + appointmentOrderVo.setHospitalPhone(hospitalInfo.getPhone()); + appointmentOrderVo.setDoctorName(doctorMapper.selectOne(new LambdaQueryWrapper().eq(DoctorInfo::getId, id)).getDoctorName()); + appointmentOrderVo.setDepartment(doctorMapper.selectDepartment(id)); + appointmentOrderVo.setFees(userAppointment.getFees()); + appointmentOrderVo.setMemo(userAppointment.getMemo()); + appointmentOrderVo.setName(userAppointment.getName()); + appointmentOrderVo.setPhone(userAppointment.getPhone()); + + return appointmentOrderVo; + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/ArticleServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/ArticleServiceImpl.java new file mode 100644 index 0000000..0a0773c --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/ArticleServiceImpl.java @@ -0,0 +1,110 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.model.entity.ArticleInfo; +import com.atjy.model.entity.GraphInfo; +import com.atjy.model.entity.UserCollection; +import com.atjy.model.enums.GraphItemType; +import com.atjy.web.app.mapper.ArticleMapper; +import com.atjy.web.app.mapper.CollectionMapper; +import com.atjy.web.app.mapper.DoctorMapper; +import com.atjy.web.app.mapper.GraphInfoMapper; +import com.atjy.web.app.service.ArticleService; +import com.atjy.web.app.vo.article.ArticleInfoVo; +import com.atjy.web.app.vo.article.ArticleVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class ArticleServiceImpl extends ServiceImpl implements ArticleService { + + @Autowired + private ArticleMapper articleMapper; + + @Autowired + private DoctorMapper doctorMapper; + + @Autowired + private GraphInfoMapper graphInfoMapper; + + @Autowired + private CollectionMapper collectionMapper; + + @Override + public ArticleInfoVo getArticle(Long articleId) { + ArticleInfoVo articleInfoVo = new ArticleInfoVo(); + ArticleInfo articleInfo = articleMapper.selectById(articleId); + + BeanUtils.copyProperties(articleInfo, articleInfoVo); + articleInfoVo.setDoctorInfo(doctorMapper.selectById(articleInfo.getDoctorId())); + articleInfoVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.ARTICLE) + .eq(GraphInfo::getItemId, articleInfo.getId())) + .getUrl()); + articleInfoVo.setDoctorUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.DOCTOR) + .eq(GraphInfo::getItemId, articleInfo.getDoctorId())) + .getUrl()); + if (collectionMapper.selectOne(new LambdaQueryWrapper().eq(UserCollection::getType, GraphItemType.ARTICLE).eq(UserCollection::getCollectionId, articleId)) != null) { + articleInfoVo.setIsCollection(true); + } + + return articleInfoVo; + } + + @Override + public List getArticleByContent(String content) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (!StringUtils.isEmpty(content)) { + queryWrapper.like(ArticleInfo::getContent, content); + } + List articleInfoList = articleMapper.selectList(queryWrapper); + + List articleVoList = new ArrayList<>(); + for (ArticleInfo articleInfo : articleInfoList) { + ArticleVo articleVo = new ArticleVo(); + articleVo.setId(articleInfo.getId()); + articleVo.setTitleBig(articleInfo.getTitleBig()); + articleVo.setTitleSmall(articleInfo.getTitleSmall()); + articleVo.setNumber(articleInfo.getNumber()); + articleVo.setPublishTime(articleInfo.getPublishTime()); + articleVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.ARTICLE) + .eq(GraphInfo::getItemId, articleInfo.getId())) + .getUrl()); + articleVoList.add(articleVo); + } + + return articleVoList; + } + + @Override + public List getArticleByType(String type) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ArticleInfo::getType, type); + List articleInfoList = articleMapper.selectList(queryWrapper); + + List articleVoList = new ArrayList<>(); + for (ArticleInfo articleInfo : articleInfoList) { + ArticleVo articleVo = new ArticleVo(); + articleVo.setId(articleInfo.getId()); + articleVo.setTitleBig(articleInfo.getTitleBig()); + articleVo.setTitleSmall(articleInfo.getTitleSmall()); + articleVo.setNumber(articleInfo.getNumber()); + articleVo.setPublishTime(articleInfo.getPublishTime()); + articleVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.ARTICLE) + .eq(GraphInfo::getItemId, articleInfo.getId())) + .getUrl()); + articleVoList.add(articleVo); + } + + return articleVoList; + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/CityInfoServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/CityInfoServiceImpl.java new file mode 100644 index 0000000..6b282e7 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/CityInfoServiceImpl.java @@ -0,0 +1,18 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.model.entity.CityInfo; +import com.atjy.web.app.mapper.CityInfoMapper; +import com.atjy.web.app.service.CityInfoService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + + +@Service +public class CityInfoServiceImpl extends ServiceImpl + implements CityInfoService { + +} + + + + diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/CollectionServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/CollectionServiceImpl.java new file mode 100644 index 0000000..2e50652 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/CollectionServiceImpl.java @@ -0,0 +1,81 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.model.entity.DoctorInfo; +import com.atjy.model.entity.GraphInfo; +import com.atjy.model.entity.HospitalLabel; +import com.atjy.model.entity.UserCollection; +import com.atjy.model.enums.GraphItemType; +import com.atjy.web.app.mapper.CollectionMapper; +import com.atjy.web.app.mapper.GraphInfoMapper; +import com.atjy.web.app.mapper.HospitalLabelMapper; +import com.atjy.web.app.service.CollectionService; +import com.atjy.web.app.vo.article.ArticleVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.atjy.web.app.vo.hospital.HospitalVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class CollectionServiceImpl implements CollectionService { + + @Autowired + private CollectionMapper collectionMapper; + + @Autowired + private HospitalLabelMapper labelMapper; + + @Autowired + private GraphInfoMapper graphInfoMapper; + + @Override + public List selectHospitalInfoListByUserId(Long userId) { + + List list = collectionMapper.selectHospitalListByUserId(userId); + for (HospitalVo collectionHospitalVo : list) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HospitalLabel::getHospitalId, collectionHospitalVo.getId()); + List hospitalLabels = labelMapper.selectList(queryWrapper); + + List labels = new ArrayList<>(); + for (HospitalLabel hospitalLabel : hospitalLabels) { + labels.add(hospitalLabel.getLabelName()); + } + collectionHospitalVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.HOSPITAL) + .eq(GraphInfo::getItemId, collectionHospitalVo.getId())) + .getUrl()); + collectionHospitalVo.setLabelList(labels); + } + return list; + } + + @Override + public List selectDoctorInfoListByUserId(Long userId) { + List list = collectionMapper.selectDoctorInfoListByUserId(userId); + + for (DoctorVo doctorVo : list) { + doctorVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.DOCTOR) + .eq(GraphInfo::getItemId, doctorVo.getId())) + .getUrl()); + } + return list; + } + + @Override + public List selectArticleInfoListByUserId(Long userId) { + List list = collectionMapper.selectArticleInfoListByUserId(userId); + + for (ArticleVo articleVo : list) { + articleVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.ARTICLE) + .eq(GraphInfo::getItemId, articleVo.getId())) + .getUrl()); + } + return list; + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/ConsultServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/ConsultServiceImpl.java new file mode 100644 index 0000000..4be7e18 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/ConsultServiceImpl.java @@ -0,0 +1,66 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.common.login.LoginUserHolder; +import com.atjy.model.entity.ConsultInfo; +import com.atjy.model.entity.UserInfo; +import com.atjy.web.app.mapper.ConsultMapper; +import com.atjy.web.app.mapper.UserMapper; +import com.atjy.web.app.service.ConsultService; +import com.atjy.web.app.vo.consult.ConsultInfoVo; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +import static com.atjy.web.app.ai.Ai.*; + + +@Service +public class ConsultServiceImpl extends ServiceImpl implements ConsultService { + + @Autowired + private ConsultMapper consultMapper; + + @Autowired + private UserMapper userInfoMapper; + + @Override + public String getAnswerToAi(String problem, Integer consultationNumber) { + if ("exit".equalsIgnoreCase(problem)) { + messages.clear(); + if (!flag) { + userInfoMapper.update(new UserInfo(), new UpdateWrapper().set("consultation_number", consultationNumber).eq("id", LoginUserHolder.getLoginUser().getUserId())); + } + flag = true; + return problem; + } + if (flag) { + addMessage(); + } + String answer = getAnswer(problem); + + ConsultInfo consultInfo = new ConsultInfo(); + consultInfo.setUserId(LoginUserHolder.getLoginUser().getUserId()); + consultInfo.setProblem(problem); + consultInfo.setAnswer(answer); + consultInfo.setNumber(consultationNumber); + consultInfo.setIsDeleted((byte) 0); + + consultMapper.insert(consultInfo); + + flag = false; + return answer; + } + + @Override + public List getAllConsultByUserId(Long userId) { + return consultMapper.getAllConsultByUserId(userId); + } + + @Override + public Integer getNumberByUserId(Long userId) { + return consultMapper.getNumberByUserId(userId); + } +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/DistrictInfoServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/DistrictInfoServiceImpl.java new file mode 100644 index 0000000..27d3922 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/DistrictInfoServiceImpl.java @@ -0,0 +1,17 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.model.entity.DistrictInfo; +import com.atjy.web.app.mapper.DistrictInfoMapper; +import com.atjy.web.app.service.DistrictInfoService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +@Service +public class DistrictInfoServiceImpl extends ServiceImpl + implements DistrictInfoService { + +} + + + + diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/DoctorServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/DoctorServiceImpl.java new file mode 100644 index 0000000..ce6bd32 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/DoctorServiceImpl.java @@ -0,0 +1,151 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.model.entity.*; +import com.atjy.model.enums.GraphItemType; +import com.atjy.web.app.mapper.*; +import com.atjy.web.app.service.DoctorService; +import com.atjy.web.app.vo.appointment.AppointmentTimeVo; +import com.atjy.web.app.vo.article.ArticleVo; +import com.atjy.web.app.vo.doctor.DoctorInfoVo; +import com.atjy.web.app.vo.doctor.DoctorTermsVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + + +@Service +public class DoctorServiceImpl extends ServiceImpl implements DoctorService { + + @Autowired + private DoctorMapper doctorMapper; + + @Autowired + private GraphInfoMapper graphInfoMapper; + + @Autowired + private HospitalMapper hospitalMapper; + + @Autowired + private DepartmentMapper departmentMapper; + + @Autowired + private CollectionMapper collectionMapper; + + @Autowired + private DoctorAppointmentMapper doctorAppointmentMapper; + + @Autowired + private ArticleMapper articleMapper; + + @Autowired + private AppointmentInfoMapper appointmentInfoMapper; + + @Autowired + private UserAppointmentMapper userAppointmentMapper; + + @Override + public List getDoctorByName(String name) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (!StringUtils.isEmpty(name)) { + queryWrapper.like(DoctorInfo::getDoctorName, name); + } + List doctorInfoList = doctorMapper.selectList(queryWrapper); + + List doctorVoList = new ArrayList<>(); + for (DoctorInfo doctorInfo : doctorInfoList) { + DoctorVo doctorVo = new DoctorVo(); + doctorVo.setId(doctorInfo.getId()); + doctorVo.setDoctorName(doctorInfo.getDoctorName()); + doctorVo.setLevel(doctorInfo.getLevel()); + doctorVo.setBriefly(doctorInfo.getBriefly()); + doctorVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.DOCTOR) + .eq(GraphInfo::getItemId, doctorInfo.getId())) + .getUrl()); + doctorVo.setHospitalName(hospitalMapper.selectOne(new LambdaQueryWrapper() + .eq(HospitalInfo::getId, doctorInfo.getHospitalId())) + .getHospitalName()); + doctorVo.setName(departmentMapper.selectOne(new LambdaQueryWrapper() + .eq(DepartmentInfo::getId, doctorInfo.getDepartmentId())) + .getName()); + + doctorVoList.add(doctorVo); + } + + return doctorVoList; + } + + @Override + public List getDoctorByTerms(DoctorTermsVo doctorTermsVo) { + return doctorMapper.getDoctorByTerms(doctorTermsVo); + } + + @Override + public DoctorInfoVo getDoctorById(Long doctorId) { + DoctorInfo doctorInfo = doctorMapper.selectOne(new LambdaQueryWrapper().eq(DoctorInfo::getId, doctorId)); + + List list = doctorAppointmentMapper.selectListByDoctorId(doctorId); + List userAppointmentList = userAppointmentMapper.selectList(new LambdaQueryWrapper().eq(UserAppointment::getDoctorId, doctorId)); + ArrayList dateIds = new ArrayList<>(); + if (!userAppointmentList.isEmpty()) { + for (UserAppointment userAppointment : userAppointmentList) { + dateIds.add(userAppointment.getAppointmentId()); + } + } + + List appointmentTimeList = new ArrayList<>(); + String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + for (AppointmentTimeVo appointmentTimeVo : list) { + if (!dateIds.contains(appointmentTimeVo.getId()) && appointmentTimeVo.getAppointmentDate().compareTo(date) > 0) { + appointmentTimeList.add(appointmentTimeVo); + } + } + + List articleVoList = articleMapper.selectListByDoctorId(doctorId); + + DoctorInfoVo doctorInfoVo = new DoctorInfoVo(); + BeanUtils.copyProperties(doctorInfo, doctorInfoVo); + doctorInfoVo.setArticleVoList(articleVoList); + doctorInfoVo.setAppointmentTimeList(appointmentTimeList); + if (collectionMapper.selectOne(new LambdaQueryWrapper().eq(UserCollection::getType, GraphItemType.DOCTOR).eq(UserCollection::getCollectionId, doctorId)) != null) { + doctorInfoVo.setIsCollection(true); + } + doctorInfoVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.DOCTOR) + .eq(GraphInfo::getItemId, doctorInfo.getId())) + .getUrl()); + doctorInfoVo.setHospitalName(hospitalMapper.selectOne(new LambdaQueryWrapper().eq(HospitalInfo::getId, doctorInfo.getHospitalId())).getHospitalName()); + + return doctorInfoVo; + } + + @Override + public List getDoctorByIdAndDepartmentAndTime(Long hospitalId, String department, String date) { + List doctorVoList; + if (!StringUtils.isEmpty(date)) { + List appointmentInfoList = appointmentInfoMapper.selectList(new LambdaQueryWrapper().like(AppointmentInfo::getAppointmentDate, date)); + + if (!appointmentInfoList.isEmpty()) { + List timeId = new ArrayList<>(); + for (AppointmentInfo appointmentInfo : appointmentInfoList) { + timeId.add(appointmentInfo.getId()); + } + doctorVoList = doctorMapper.getDoctorByIdAndDepartmentAndTime(hospitalId, department, timeId); + } else return null; + + } else { + doctorVoList = doctorMapper.getDoctorByIdAndDepartment(hospitalId, department); + } + + return doctorVoList; + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/GraphInfoServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/GraphInfoServiceImpl.java new file mode 100644 index 0000000..030fa19 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/GraphInfoServiceImpl.java @@ -0,0 +1,13 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.model.entity.GraphInfo; +import com.atjy.web.app.mapper.GraphInfoMapper; +import com.atjy.web.app.service.GraphInfoService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +@Service +public class GraphInfoServiceImpl extends ServiceImpl + implements GraphInfoService { + +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/HomepageServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/HomepageServiceImpl.java new file mode 100644 index 0000000..322eed5 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/HomepageServiceImpl.java @@ -0,0 +1,91 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.model.entity.GraphInfo; +import com.atjy.model.entity.HospitalInfo; +import com.atjy.model.enums.GraphItemType; +import com.atjy.web.app.mapper.*; +import com.atjy.web.app.service.HomepageService; +import com.atjy.web.app.vo.article.ArticleVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.atjy.web.app.vo.homepage.HomepageVo; +import com.atjy.web.app.vo.hospital.HospitalVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class HomepageServiceImpl implements HomepageService { + + @Autowired + private HospitalMapper hospitalMapper; + + @Autowired + private GraphInfoMapper graphInfoMapper; + + @Autowired + private HospitalLabelMapper labelMapper; + + @Autowired + private DoctorMapper doctorMapper; + + @Autowired + private ArticleMapper articleMapper; + + @Override + public HomepageVo getHomepageByDistrictId(Long districtId) { + //医院列表 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HospitalInfo::getDistrictId, districtId); + List hospitalInfoList = hospitalMapper.selectList(queryWrapper); + + if (hospitalInfoList.isEmpty()) { + return null; + } + + List hospitalVoList = new ArrayList<>(); + List hospitalIdList = new ArrayList<>(); + + for (HospitalInfo hospitalInfo : hospitalInfoList) { + hospitalIdList.add(hospitalInfo.getId()); + + HospitalVo hospitalVo = new HospitalVo(); + hospitalVo.setId(hospitalInfo.getId()); + hospitalVo.setHospitalName(hospitalInfo.getHospitalName()); + hospitalVo.setAddress(hospitalInfo.getAddress()); + hospitalVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.HOSPITAL) + .eq(GraphInfo::getItemId, hospitalInfo.getId())) + .getUrl()); + hospitalVo.setLevel(hospitalInfo.getLevel()); + hospitalVo.setAppointmentNumber(hospitalInfo.getAppointmentNumber()); + hospitalVo.setLabelList(labelMapper.selectListByHospitalId(hospitalInfo.getId())); + + hospitalVoList.add(hospitalVo); + } + + //医生列表 + List doctorVoList = doctorMapper.selectListByHospitalIdList(hospitalIdList); + List doctorIdList = new ArrayList<>(); + + for (DoctorVo doctorVo : doctorVoList) { + doctorIdList.add(doctorVo.getId()); + } + + //医说列表 + List articleVoList; + if (doctorIdList.isEmpty()) { + articleVoList = null; + } else { + articleVoList = articleMapper.selectListByDoctorIdList(doctorIdList); + } + + HomepageVo homepageVo = new HomepageVo(); + homepageVo.setHospitalVoList(hospitalVoList); + homepageVo.setDoctorVoList(doctorVoList); + homepageVo.setArticleVoList(articleVoList); + return homepageVo; + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/HospitalServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/HospitalServiceImpl.java new file mode 100644 index 0000000..85b26b0 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/HospitalServiceImpl.java @@ -0,0 +1,137 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.common.result.Result; +import com.atjy.model.entity.*; +import com.atjy.model.enums.GraphItemType; +import com.atjy.web.app.mapper.*; +import com.atjy.web.app.service.HospitalService; +import com.atjy.web.app.vo.doctor.DoctorSmallVo; +import com.atjy.web.app.vo.hospital.HospitalInfoVo; +import com.atjy.web.app.vo.hospital.HospitalTermsVo; +import com.atjy.web.app.vo.hospital.HospitalVo; +import com.atjy.web.app.vo.hospital.RegisteredVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.*; + +@Service +public class HospitalServiceImpl extends ServiceImpl implements HospitalService { + + @Autowired + private HospitalMapper hospitalMapper; + + @Autowired + private HospitalLabelMapper labelMapper; + + @Autowired + private GraphInfoMapper graphInfoMapper; + + @Autowired + private DoctorMapper doctorMapper; + + @Autowired + private HospitalDepartmentMapper HospitalDepartmentMapper; + + @Autowired + private CollectionMapper collectionMapper; + + @Autowired + private DepartmentInfoMapper departmentInfoMapper; + + @Override + public List getHospitalByName(String name) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + if (!StringUtils.isEmpty(name)) { + lambdaQueryWrapper.like(HospitalInfo::getHospitalName, name); + } + List hospitalInfoList = hospitalMapper.selectList(lambdaQueryWrapper); + List hospitalVoList = new ArrayList<>(); + + for (HospitalInfo hospitalInfo : hospitalInfoList) { + HospitalVo hospitalVo = new HospitalVo(); + hospitalVo.setId(hospitalInfo.getId()); + hospitalVo.setHospitalName(hospitalInfo.getHospitalName()); + hospitalVo.setAddress(hospitalInfo.getAddress()); + hospitalVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.HOSPITAL) + .eq(GraphInfo::getItemId, hospitalInfo.getId())) + .getUrl()); + hospitalVo.setLabelList(labelMapper.selectListByHospitalId(hospitalInfo.getId())); + + hospitalVoList.add(hospitalVo); + } + return hospitalVoList; + } + + @Override + public List getHospitalByTerms(HospitalTermsVo hospitalTerms) { + + List hospitalVoList = hospitalMapper.getHospitalByTerms(hospitalTerms); + + for (HospitalVo hospitalVo : hospitalVoList) { + hospitalVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.HOSPITAL) + .eq(GraphInfo::getItemId, hospitalVo.getId())) + .getUrl()); + hospitalVo.setLabelList(labelMapper.selectListByHospitalId(hospitalVo.getId())); + } + return hospitalVoList; + } + + @Override + public HospitalInfoVo getHospitalById(Long hospitalId) { + HospitalInfo hospitalInfo = hospitalMapper.selectOne(new LambdaQueryWrapper().eq(HospitalInfo::getId, hospitalId)); + + List doctorInfoList = doctorMapper.selectListDoctorSmallVo(hospitalId); + for (DoctorSmallVo doctorSmallVo : doctorInfoList) { + doctorSmallVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.DOCTOR) + .eq(GraphInfo::getItemId, doctorSmallVo.getId())) + .getUrl()); + } + + List departmentList = HospitalDepartmentMapper.selectDepartmentList(hospitalId); + + HospitalInfoVo hospitalInfoVo = new HospitalInfoVo(); + + BeanUtils.copyProperties(hospitalInfo, hospitalInfoVo); + hospitalInfoVo.setUrl(graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.HOSPITAL) + .eq(GraphInfo::getItemId, hospitalId)) + .getUrl()); + hospitalInfoVo.setDoctorInfoList(doctorInfoList); + hospitalInfoVo.setDepartmentList(departmentList); + if (collectionMapper.selectOne(new LambdaQueryWrapper().eq(UserCollection::getType, GraphItemType.HOSPITAL).eq(UserCollection::getCollectionId, hospitalId)) != null) { + hospitalInfoVo.setIsCollection(true); + } + + return hospitalInfoVo; + } + + @Override + public RegisteredVo getRegisteredById(Long hospitalId) { + List departmentInfoList = departmentInfoMapper.selectListByHospitalId(hospitalId); + + RegisteredVo registeredVo = new RegisteredVo(); + Map> stringListMap = new HashMap<>(); + for (DepartmentInfo departmentInfo : departmentInfoList) { + if (stringListMap.containsKey(departmentInfo.getBelong())) { + List list = stringListMap.get(departmentInfo.getBelong()); + list.add(departmentInfo.getName()); + } else { + List list = new ArrayList<>(); + list.add(departmentInfo.getName()); + stringListMap.put(departmentInfo.getBelong(), list); + } + } + + registeredVo.setStringListMap(stringListMap); + + return registeredVo; + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/LoginServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/LoginServiceImpl.java new file mode 100644 index 0000000..df1a682 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/LoginServiceImpl.java @@ -0,0 +1,123 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.common.constant.RedisConstant; +import com.atjy.common.exception.HassleFreeException; +import com.atjy.common.result.Result; +import com.atjy.common.result.ResultCodeEnum; +import com.atjy.common.utils.CodeUtil; +import com.atjy.common.utils.JwtUtil; +import com.atjy.model.entity.GraphInfo; +import com.atjy.model.entity.UserInfo; +import com.atjy.model.enums.BaseStatus; +import com.atjy.model.enums.GraphItemType; +import com.atjy.web.app.mapper.GraphInfoMapper; +import com.atjy.web.app.mapper.UserMapper; +import com.atjy.web.app.service.LoginService; +import com.atjy.web.app.service.SmsService; +import com.atjy.web.app.vo.login.LoginVo; +import com.atjy.web.app.vo.login.UserInfoVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.concurrent.TimeUnit; + + +@Service +public class LoginServiceImpl implements LoginService { + + @Autowired + private SmsService smsService; + + @Autowired + private StringRedisTemplate redisTemplate; + + @Autowired + private UserMapper userInfoMapper; + + @Autowired + private GraphInfoMapper graphInfoMapper; + + + @Override + public Result login(LoginVo loginVo) { + + //1.判断手机号码和验证码是否为空 + if (!StringUtils.hasText(loginVo.getPhone())) { + throw new HassleFreeException(ResultCodeEnum.APP_LOGIN_PHONE_EMPTY); + } + + if (!StringUtils.hasText(loginVo.getCode())) { + throw new HassleFreeException(ResultCodeEnum.APP_LOGIN_CODE_EMPTY); + } + + //2.校验验证码 + String key = RedisConstant.APP_LOGIN_PREFIX + loginVo.getPhone(); + String code = redisTemplate.opsForValue().get(key); + if (code == null) { + return Result.fail(505, "验证码已过期"); + } + + if (!code.equals(loginVo.getCode())) { + return Result.fail(506, "验证码错误"); + } + + //3.判断用户是否存在,不存在则注册(创建用户) + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(UserInfo::getPhone, loginVo.getPhone()); + UserInfo userInfo = userInfoMapper.selectOne(queryWrapper); + + if (userInfo == null) { + //注册 + userInfo = new UserInfo(); + userInfo.setPhone(loginVo.getPhone()); + userInfo.setState(BaseStatus.ENABLE); + userInfo.setConsultationNumber(0); + userInfo.setNickname("用户-" + loginVo.getPhone().substring(7)); + + userInfoMapper.insert(userInfo); + } + + //4.判断用户是否被禁 + if (userInfo.getState().equals(BaseStatus.DISABLE)) { + return Result.fail(507, "该用户已被禁用"); + } + + //5.创建并返回TOKEN + return Result.ok(JwtUtil.createToken(userInfo.getId(), loginVo.getPhone())); + } + + @Override + public Result getSMSCode(String phone) { + + String code = CodeUtil.getRandomCode(6); + String key = RedisConstant.APP_LOGIN_PREFIX + phone; + + Boolean hasKey = redisTemplate.hasKey(key); + if (hasKey) { + Long ttl = redisTemplate.getExpire(key, TimeUnit.SECONDS); + if (RedisConstant.APP_LOGIN_CODE_TTL_SEC - ttl < RedisConstant.APP_LOGIN_CODE_RESEND_TIME_SEC) { + return Result.fail(504, "验证法发送过于频繁"); + } + } + + smsService.sendCode(phone, code); + redisTemplate.opsForValue().set(key, code, RedisConstant.APP_LOGIN_CODE_TTL_SEC, TimeUnit.SECONDS); + return Result.ok(); + } + + @Override + public UserInfoVo getUserInfoById(Long userId) { + UserInfo userInfo = userInfoMapper.selectById(userId); + UserInfoVo userInfoVo = new UserInfoVo( + userInfo.getNickname(), + graphInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(GraphInfo::getItemType, GraphItemType.USER) + .eq(GraphInfo::getItemId, userInfo.getAvatarId())) + .getUrl()); + + return userInfoVo; + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/ProvinceInfoServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/ProvinceInfoServiceImpl.java new file mode 100644 index 0000000..285e088 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/ProvinceInfoServiceImpl.java @@ -0,0 +1,17 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.model.entity.ProvinceInfo; +import com.atjy.web.app.mapper.ProvinceInfoMapper; +import com.atjy.web.app.service.ProvinceInfoService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +@Service +public class ProvinceInfoServiceImpl extends ServiceImpl + implements ProvinceInfoService { + +} + + + + diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/SmsServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/SmsServiceImpl.java new file mode 100644 index 0000000..ac16858 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/SmsServiceImpl.java @@ -0,0 +1,31 @@ +package com.atjy.web.app.service.impl; + + +import com.aliyun.dysmsapi20170525.Client; +import com.aliyun.dysmsapi20170525.models.SendSmsRequest; +import com.atjy.web.app.service.SmsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SmsServiceImpl implements SmsService { + + @Autowired + private Client client; + + @Override + public void sendCode(String phone, String code) { + SendSmsRequest request = new SendSmsRequest(); + request.setPhoneNumbers(phone); + request.setSignName("阿里云短信测试"); + request.setTemplateCode("SMS_154950909"); + request.setTemplateParam("{\"code\":\"" + code + "\"}"); + + try { + client.sendSms(request); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/UserAppointmentServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/UserAppointmentServiceImpl.java new file mode 100644 index 0000000..bb40a6a --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/UserAppointmentServiceImpl.java @@ -0,0 +1,42 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.model.entity.GraphInfo; +import com.atjy.model.enums.GraphItemType; +import com.atjy.web.app.mapper.GraphInfoMapper; +import com.atjy.web.app.mapper.UserAppointmentMapper; +import com.atjy.web.app.service.UserAppointmentService; +import com.atjy.web.app.vo.appointment.AppointmentVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Service +public class UserAppointmentServiceImpl implements UserAppointmentService { + + @Autowired + private UserAppointmentMapper userAppointmentMapper; + + @Override + public List getWaitDiagnosis(Long userId) { + List list = userAppointmentMapper.getWaitDiagnosis(userId); + String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + List result = new ArrayList<>(); + + for (AppointmentVo appointmentVo : list) { + if (appointmentVo.getAppointmentDate().compareTo(date) > 0) { + result.add(appointmentVo); + } + } + return result; + } + + @Override + public List getAlreadyDiagnosis(Long userId) { + return userAppointmentMapper.getAlreadyDiagnosis(userId); + } +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/service/impl/UserServiceImpl.java b/web/web-app/src/main/java/com/atjy/web/app/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..2ec0996 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/service/impl/UserServiceImpl.java @@ -0,0 +1,12 @@ +package com.atjy.web.app.service.impl; + +import com.atjy.model.entity.UserInfo; +import com.atjy.web.app.mapper.UserMapper; +import com.atjy.web.app.service.UserService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +@Service +public class UserServiceImpl extends ServiceImpl implements UserService { + +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/sms/AliyunSMSConfiguration.java b/web/web-app/src/main/java/com/atjy/web/app/sms/AliyunSMSConfiguration.java new file mode 100644 index 0000000..5012d63 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/sms/AliyunSMSConfiguration.java @@ -0,0 +1,33 @@ +package com.atjy.web.app.sms; + +import com.aliyun.dysmsapi20170525.Client; +import com.aliyun.teaopenapi.models.Config; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableConfigurationProperties(AliyunSMSProperties.class) +@ConditionalOnProperty(name = "aliyun.sms.endpoint") +public class AliyunSMSConfiguration { + + @Autowired + private AliyunSMSProperties properties; + + @Bean + public Client createClient() { + Config config = new Config(); + config.setAccessKeyId(properties.getAccessKeyId()); + config.setAccessKeySecret(properties.getAccessKeySecret()); + config.setEndpoint(properties.getEndpoint()); + + + try { + return new Client(config); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/sms/AliyunSMSProperties.java b/web/web-app/src/main/java/com/atjy/web/app/sms/AliyunSMSProperties.java new file mode 100644 index 0000000..927f03e --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/sms/AliyunSMSProperties.java @@ -0,0 +1,15 @@ +package com.atjy.web.app.sms; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@Data +@ConfigurationProperties(prefix = "aliyun.sms") +public class AliyunSMSProperties { + + private String accessKeyId; + + private String accessKeySecret; + + private String endpoint; +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentInfoVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentInfoVo.java new file mode 100644 index 0000000..a10e5e6 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentInfoVo.java @@ -0,0 +1,24 @@ +package com.atjy.web.app.vo.appointment; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "预约详情实体") +public class AppointmentInfoVo { + + @Schema(description = "所属医院") + private String hospitalName; + + @Schema(description = "医生姓名") + private String doctorName; + + @Schema(description = "地址") + private String address; + + @Schema(description = "所属科室") + private String department; + + @Schema(description = "就诊费用") + private Long fees; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentOrderVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentOrderVo.java new file mode 100644 index 0000000..ab9d452 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentOrderVo.java @@ -0,0 +1,36 @@ +package com.atjy.web.app.vo.appointment; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "预约订单实体") +public class AppointmentOrderVo { + + @Schema(description = "所属医院") + private String hospitalName; + + @Schema(description = "医生姓名") + private String doctorName; + + @Schema(description = "地址") + private String address; + + @Schema(description = "医院电话") + private String hospitalPhone; + + @Schema(description = "所属科室") + private String department; + + @Schema(description = "就诊费用") + private Long fees; + + @Schema(description = "就诊人姓名") + private String name; + + @Schema(description = "就诊人手机号") + private String phone; + + @Schema(description = "备注") + private String memo; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentTimeVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentTimeVo.java new file mode 100644 index 0000000..7bd963c --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentTimeVo.java @@ -0,0 +1,15 @@ +package com.atjy.web.app.vo.appointment; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "预约时间实体") +public class AppointmentTimeVo { + + @Schema(description = "预约id") + private Long id; + + @Schema(description = "预约日期") + private String appointmentDate; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentVo.java new file mode 100644 index 0000000..8818bb5 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/appointment/AppointmentVo.java @@ -0,0 +1,42 @@ +package com.atjy.web.app.vo.appointment; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "预约列表实体") +public class AppointmentVo { + + @Schema(description = "医生id") + private Long id; + + @Schema(description = "医生姓名") + private String doctorName; + + @Schema(description = "医生图片") + private String url; + + @Schema(description = "医生级别") + private String level; + + @Schema(description = "所属医院") + private String hospitalName; + + @Schema(description = "所属科室") + private String department; + + @Schema(description = "就诊状态") + private Byte state; + + @Schema(description = "个人简介") + private String briefly; + + @Schema(description = "就诊费用") + private String fees; + + @Schema(description = "预约日期") + private String appointmentDate; + + @Schema(description = "就诊人") + private String name; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/article/ArticleInfoVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/article/ArticleInfoVo.java new file mode 100644 index 0000000..021be33 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/article/ArticleInfoVo.java @@ -0,0 +1,22 @@ +package com.atjy.web.app.vo.article; + +import com.atjy.model.entity.ArticleInfo; +import com.atjy.model.entity.DoctorInfo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class ArticleInfoVo extends ArticleInfo { + + @Schema(description = "医生信息") + private DoctorInfo doctorInfo; + + @Schema(description = "图片") + private String url; + + @Schema(description = "头像") + private String doctorUrl; + + @Schema(description = "是否收藏") + private Boolean isCollection; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/article/ArticleVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/article/ArticleVo.java new file mode 100644 index 0000000..107d9ee --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/article/ArticleVo.java @@ -0,0 +1,31 @@ +package com.atjy.web.app.vo.article; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +@Data +@Schema(description = "医说列表实体") +public class ArticleVo { + + @Schema(description = "医说id") + private Long id; + + @Schema(description = "图片") + private String url; + + @Schema(description = "大标题") + private String titleBig; + + @Schema(description = "小标题") + private String titleSmall; + + @Schema(description = "阅读量") + private Integer number; + + @Schema(description = "发布时间") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date publishTime; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/consult/ConsultInfoVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/consult/ConsultInfoVo.java new file mode 100644 index 0000000..86a60c4 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/consult/ConsultInfoVo.java @@ -0,0 +1,24 @@ +package com.atjy.web.app.vo.consult; + + +import com.atjy.model.entity.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "咨询详情实体") +public class ConsultInfoVo { + + @Schema(description = "问诊记录id") + private Long id; + + @Schema(description = "问题") + private String problem; + + @Schema(description = "解答") + private String answer; + + @Schema(description = "编号") + private Integer number; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/consult/ProblemVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/consult/ProblemVo.java new file mode 100644 index 0000000..7baceef --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/consult/ProblemVo.java @@ -0,0 +1,12 @@ +package com.atjy.web.app.vo.consult; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "问诊问题实体") +public class ProblemVo { + + @Schema(description = "问诊问题") + private String problem; +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorInfoVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorInfoVo.java new file mode 100644 index 0000000..e1fae65 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorInfoVo.java @@ -0,0 +1,29 @@ +package com.atjy.web.app.vo.doctor; + +import com.atjy.model.entity.DoctorInfo; +import com.atjy.web.app.vo.appointment.AppointmentTimeVo; +import com.atjy.web.app.vo.article.ArticleVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "医生详情页实体") +public class DoctorInfoVo extends DoctorInfo { + + @Schema(description = "图片") + private String url; + + @Schema(description = "医院名称") + private String hospitalName; + + @Schema(description = "是否收藏") + private Boolean isCollection; + + @Schema(description = "预约时间列表") + private List appointmentTimeList; + + @Schema(description = "医说列表") + private List articleVoList; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorSmallVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorSmallVo.java new file mode 100644 index 0000000..0dbfddf --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorSmallVo.java @@ -0,0 +1,18 @@ +package com.atjy.web.app.vo.doctor; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "医生简略列表实体") +public class DoctorSmallVo { + + @Schema(description = "医生id") + private Long id; + + @Schema(description = "图片") + private String url; + + @Schema(description = "医生姓名") + private String doctorName; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorTermsVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorTermsVo.java new file mode 100644 index 0000000..2e92311 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorTermsVo.java @@ -0,0 +1,18 @@ +package com.atjy.web.app.vo.doctor; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "医生筛选条件实体") +public class DoctorTermsVo { + + @Schema(description = "预约量排序方式", allowableValues = {"desc", "asc"}) + private String orderType; + + @Schema(description = "级别") + private String level; + + @Schema(description = "科室") + private String name; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorVo.java new file mode 100644 index 0000000..0dbfdb8 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/doctor/DoctorVo.java @@ -0,0 +1,38 @@ +package com.atjy.web.app.vo.doctor; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "医生列表实体") +public class DoctorVo { + + @Schema(description = "医生id") + private Long id; + + @Schema(description = "医生姓名") + private String doctorName; + + @Schema(description = "级别") + private String level; + + @Schema(description = "医院名称") + private String hospitalName; + + @Schema(description = "科室") + private String name; + + @Schema(description = "简介") + private String briefly; + + @Schema(description = "图片") + private String url; + + @Schema(description = "预约量") + private Long appointmentNumber; + + @Schema(description = "擅长领域") + private String expertise; + +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/graph/GraphVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/graph/GraphVo.java new file mode 100644 index 0000000..602fbb1 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/graph/GraphVo.java @@ -0,0 +1,25 @@ +package com.atjy.web.app.vo.graph; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Schema(description = "图片信息") +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class GraphVo implements Serializable { + + + @Schema(description = "图片名称") + private String name; + + @Schema(description = "图片地址") + private String url; + +} \ No newline at end of file diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/homepage/HomepageVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/homepage/HomepageVo.java new file mode 100644 index 0000000..ce9ed39 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/homepage/HomepageVo.java @@ -0,0 +1,23 @@ +package com.atjy.web.app.vo.homepage; + +import com.atjy.web.app.vo.article.ArticleVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import com.atjy.web.app.vo.hospital.HospitalVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "首页信息") +public class HomepageVo { + + @Schema(description = "医院列表") + private List hospitalVoList; + + @Schema(description = "医生列表") + private List doctorVoList; + + @Schema(description = "医说列表") + private List articleVoList; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/HospitalInfoVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/HospitalInfoVo.java new file mode 100644 index 0000000..88890a1 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/HospitalInfoVo.java @@ -0,0 +1,26 @@ +package com.atjy.web.app.vo.hospital; + +import com.atjy.model.entity.HospitalInfo; +import com.atjy.web.app.vo.doctor.DoctorSmallVo; +import com.atjy.web.app.vo.doctor.DoctorVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "医院详情页实体") +public class HospitalInfoVo extends HospitalInfo { + + @Schema(description = "图片") + private String url; + + @Schema(description = "是否收藏") + private Boolean isCollection; + + @Schema(description = "医生列表") + private List doctorInfoList; + + @Schema(description = "科室列表") + private List departmentList; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/HospitalTermsVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/HospitalTermsVo.java new file mode 100644 index 0000000..e98c648 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/HospitalTermsVo.java @@ -0,0 +1,18 @@ +package com.atjy.web.app.vo.hospital; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "医院筛选条件实体") +public class HospitalTermsVo { + + @Schema(description = "区域id") + private Long districtId; + + @Schema(description = "等级") + private String level; + + @Schema(description = "科室") + private String name; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/HospitalVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/HospitalVo.java new file mode 100644 index 0000000..3a2c027 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/HospitalVo.java @@ -0,0 +1,32 @@ +package com.atjy.web.app.vo.hospital; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "医院列表实体") +public class HospitalVo { + + @Schema(description = "医院id") + private Long id; + + @Schema(description = "医院名称") + private String hospitalName; + + @Schema(description = "地址") + private String address; + + @Schema(description = "图片") + private String url; + + @Schema(description = "等级") + private String level; + + @Schema(description = "预约量") + private Long appointmentNumber; + + @Schema(description = "标签列表") + private List labelList; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/RegisteredVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/RegisteredVo.java new file mode 100644 index 0000000..2447a19 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/hospital/RegisteredVo.java @@ -0,0 +1,15 @@ +package com.atjy.web.app.vo.hospital; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +@Schema(description = "医院挂号实体") +public class RegisteredVo { + + @Schema(description = "科室集合") + Map> stringListMap; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/login/LoginVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/login/LoginVo.java new file mode 100644 index 0000000..ec9ea88 --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/login/LoginVo.java @@ -0,0 +1,16 @@ +package com.atjy.web.app.vo.login; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + + +@Data +@Schema(description = "APP端登录实体") +public class LoginVo { + + @Schema(description = "手机号码") + private String phone; + + @Schema(description = "短信验证码") + private String code; +} diff --git a/web/web-app/src/main/java/com/atjy/web/app/vo/login/UserInfoVo.java b/web/web-app/src/main/java/com/atjy/web/app/vo/login/UserInfoVo.java new file mode 100644 index 0000000..7a6b4db --- /dev/null +++ b/web/web-app/src/main/java/com/atjy/web/app/vo/login/UserInfoVo.java @@ -0,0 +1,18 @@ +package com.atjy.web.app.vo.login; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Schema(description = "用户基本信息") +@Data +@AllArgsConstructor +public class UserInfoVo { + + @Schema(description = "用户昵称") + private String nickname; + + @Schema(description = "用户头像") + private String avatarUrl; + +} \ No newline at end of file diff --git a/web/web-app/src/main/resources/application.yml b/web/web-app/src/main/resources/application.yml new file mode 100644 index 0000000..668435a --- /dev/null +++ b/web/web-app/src/main/resources/application.yml @@ -0,0 +1,39 @@ +server: + port: 8081 +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: Atjy.000000 + url: jdbc:mysql://192.168.47.101:3306/hassle_free?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2b8 + hikari: + connection-test-query: SELECT 1 # 自动检测连接 + connection-timeout: 60000 #数据库连接超时时间,默认30秒 + idle-timeout: 500000 #空闲连接存活最大时间,默认600000(10分钟) + max-lifetime: 540000 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟 + maximum-pool-size: 12 #连接池最大连接数,默认是10 + minimum-idle: 10 #最小空闲连接数量 + pool-name: SPHHikariPool # 连接池名称 + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + + data: + redis: + host: 192.168.47.101 + port: 6379 + database: 0 + +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + +springdoc: + default-flat-param-object: true + +aliyun: + sms: + access-key-id: LTAI5tFs3HPj3CvKTTxj5HA7 + access-key-secret: uuy4Fe0zGoF5WsBod4IEwrB1O7vR6d + endpoint: dysmsapi.aliyuncs.com + diff --git a/web/web-app/src/main/resources/mapper/ArticleMapper.xml b/web/web-app/src/main/resources/mapper/ArticleMapper.xml new file mode 100644 index 0000000..c9bb3da --- /dev/null +++ b/web/web-app/src/main/resources/mapper/ArticleMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + \ No newline at end of file diff --git a/web/web-app/src/main/resources/mapper/CollectionMapper.xml b/web/web-app/src/main/resources/mapper/CollectionMapper.xml new file mode 100644 index 0000000..8ebf30f --- /dev/null +++ b/web/web-app/src/main/resources/mapper/CollectionMapper.xml @@ -0,0 +1,52 @@ + + + + + + + + + + \ No newline at end of file diff --git a/web/web-app/src/main/resources/mapper/ConsultMapper.xml b/web/web-app/src/main/resources/mapper/ConsultMapper.xml new file mode 100644 index 0000000..8016377 --- /dev/null +++ b/web/web-app/src/main/resources/mapper/ConsultMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + \ No newline at end of file diff --git a/web/web-app/src/main/resources/mapper/DepartmentInfoMapper.xml b/web/web-app/src/main/resources/mapper/DepartmentInfoMapper.xml new file mode 100644 index 0000000..b38d847 --- /dev/null +++ b/web/web-app/src/main/resources/mapper/DepartmentInfoMapper.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/web/web-app/src/main/resources/mapper/DoctorAppointmentMapper.xml b/web/web-app/src/main/resources/mapper/DoctorAppointmentMapper.xml new file mode 100644 index 0000000..e26ffd0 --- /dev/null +++ b/web/web-app/src/main/resources/mapper/DoctorAppointmentMapper.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/web/web-app/src/main/resources/mapper/DoctorMapper.xml b/web/web-app/src/main/resources/mapper/DoctorMapper.xml new file mode 100644 index 0000000..c320256 --- /dev/null +++ b/web/web-app/src/main/resources/mapper/DoctorMapper.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/web-app/src/main/resources/mapper/GraphInfoMapper.xml b/web/web-app/src/main/resources/mapper/GraphInfoMapper.xml new file mode 100644 index 0000000..76a3a64 --- /dev/null +++ b/web/web-app/src/main/resources/mapper/GraphInfoMapper.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/web/web-app/src/main/resources/mapper/HospitalDepartmentMapper.xml b/web/web-app/src/main/resources/mapper/HospitalDepartmentMapper.xml new file mode 100644 index 0000000..1a47ccc --- /dev/null +++ b/web/web-app/src/main/resources/mapper/HospitalDepartmentMapper.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/web/web-app/src/main/resources/mapper/HospitalLabelMapper.xml b/web/web-app/src/main/resources/mapper/HospitalLabelMapper.xml new file mode 100644 index 0000000..e563987 --- /dev/null +++ b/web/web-app/src/main/resources/mapper/HospitalLabelMapper.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/web/web-app/src/main/resources/mapper/HospitalMapper.xml b/web/web-app/src/main/resources/mapper/HospitalMapper.xml new file mode 100644 index 0000000..83f488a --- /dev/null +++ b/web/web-app/src/main/resources/mapper/HospitalMapper.xml @@ -0,0 +1,27 @@ + + + + + + \ No newline at end of file diff --git a/web/web-app/src/main/resources/mapper/UserAppointmentMapper.xml b/web/web-app/src/main/resources/mapper/UserAppointmentMapper.xml new file mode 100644 index 0000000..489a46b --- /dev/null +++ b/web/web-app/src/main/resources/mapper/UserAppointmentMapper.xml @@ -0,0 +1,75 @@ + + + + + + + + + \ No newline at end of file diff --git a/web/web-app/src/test/java/com/atjy/web/app/WebAppApplicationTest.java b/web/web-app/src/test/java/com/atjy/web/app/WebAppApplicationTest.java new file mode 100644 index 0000000..a6d83f1 --- /dev/null +++ b/web/web-app/src/test/java/com/atjy/web/app/WebAppApplicationTest.java @@ -0,0 +1,78 @@ +package com.atjy.web.app; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import java.io.BufferedReader; +import java.io.InputStreamReader; + +@SpringBootTest +class WebAppApplicationTest { + + // OpenAI API 密钥 + private static final String API_KEY = "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"; // 替换成你的 API 密钥 + private static final String API_URL = "https://api.openai.com/v1/chat/completions"; + + @Test + public void Ai() { + try { + // 创建 HTTP 客户端 + CloseableHttpClient httpClient = HttpClients.createDefault(); + + // 创建 HTTP 请求对象 + HttpPost httpPost = new HttpPost(API_URL); + + // 设置请求头 + httpPost.setHeader("Content-Type", "application/json"); + httpPost.setHeader("Authorization", "Bearer " + API_KEY); + + // 构造请求体(这里我们使用 ChatGPT 的 API 请求格式) + String jsonBody = "{" + + "\"model\": \"gpt-4o-mini\"," + + "\"messages\": [" + + "{\"role\": \"system\", \"content\": \"You are a helpful assistant.\"}" + + "{\"role\": \"user\", \"content\": \"我有点头痛\"}" + + "]" + + "}"; + + // 设置请求体 + StringEntity entity = new StringEntity(jsonBody); + httpPost.setEntity(entity); + + // 执行请求并获取响应 + HttpResponse response = httpClient.execute(httpPost); + + // 读取响应内容 + BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); + StringBuilder responseString = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + responseString.append(line); + } + + // 解析 JSON 响应 + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode responseJson = objectMapper.readTree(responseString.toString()); + + System.out.println(responseJson); + + // 输出 ChatGPT 的回应 +// String chatGPTResponse = responseJson.get("message").get("content").get("richText").get(0).get("children").get(0).get("text").toString(); +// System.out.println("ChatGPT Response: " + chatGPTResponse); + + // 关闭客户端 + httpClient.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file