commit
f0b6529741
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.example</groupId>
|
||||||
|
<artifactId>health-zxd</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>bwie-auth</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<!-- 项目公共 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.example</groupId>
|
||||||
|
<artifactId>bwie-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- SpringBoot Web-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--rabbitMQ-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.kafka</groupId>
|
||||||
|
<artifactId>spring-kafka</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.kafka</groupId>
|
||||||
|
<artifactId>kafka-clients</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- lombok依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.bwie.auth.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.bwie.auth.service.AuthService;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bwie.common.domain.User;
|
||||||
|
import com.bwie.common.domain.request.UserLogin;
|
||||||
|
import com.bwie.common.domain.response.JwtResponse;
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
@RestController
|
||||||
|
@Component
|
||||||
|
public class AuthController {
|
||||||
|
@Autowired
|
||||||
|
private AuthService service;
|
||||||
|
@Autowired
|
||||||
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
@PostMapping("/userLogin")
|
||||||
|
public Result<JwtResponse> userLogin(@RequestBody UserLogin login){
|
||||||
|
log.info("功能名称:【邮箱密码登录】,请求路径:【{}】,请求方式:【{}】,请求参数:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(login));
|
||||||
|
Result<JwtResponse> result = service.userLogin(login);
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/info")
|
||||||
|
public Result<Object> info(){
|
||||||
|
log.info("功能名称:【获取token】,请求路径:【{}】,请求方式:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod());
|
||||||
|
Result<Object> result = service.info();
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/logout")
|
||||||
|
public Result<Object> logout(){
|
||||||
|
return service.logout();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.bwie.auth.feign;
|
||||||
|
|
||||||
|
import com.bwie.common.domain.User;
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
@FeignClient("bwie-system")
|
||||||
|
public interface AuthFeign {
|
||||||
|
@PostMapping("/getUserByEmailNumber/{emailNumber}")
|
||||||
|
public Result<User> getUserByEmailNumber(@PathVariable String emailNumber);
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.bwie.auth.service;
|
||||||
|
|
||||||
|
import com.bwie.common.domain.request.UserLogin;
|
||||||
|
import com.bwie.common.domain.response.JwtResponse;
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
|
||||||
|
public interface AuthService {
|
||||||
|
Result<JwtResponse> userLogin(UserLogin login);
|
||||||
|
|
||||||
|
Result<Object> info();
|
||||||
|
|
||||||
|
Result<Object> logout();
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
package com.bwie.auth.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.bwie.auth.feign.AuthFeign;
|
||||||
|
import com.bwie.auth.service.AuthService;
|
||||||
|
import com.bwie.common.constants.JwtConstants;
|
||||||
|
import com.bwie.common.constants.TokenConstants;
|
||||||
|
import com.bwie.common.domain.User;
|
||||||
|
import com.bwie.common.domain.request.UserLogin;
|
||||||
|
import com.bwie.common.domain.response.JwtResponse;
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
import com.bwie.common.utils.JwtUtils;
|
||||||
|
import com.bwie.common.utils.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AuthServiceImpl implements AuthService {
|
||||||
|
@Autowired
|
||||||
|
private AuthFeign feign;
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String,String> redisTemplate;
|
||||||
|
@Autowired
|
||||||
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<JwtResponse> userLogin(UserLogin login) {
|
||||||
|
boolean emailMatches = Pattern.matches("^[0-9a-zA-Z_-]+@[0-9a-zA-Z_-]+\\.(com|cn|net|vip|cloud)$",login.getEmailNumber());
|
||||||
|
if (!emailMatches) {
|
||||||
|
throw new IllegalArgumentException("邮箱格式错误,请重新输入");
|
||||||
|
}
|
||||||
|
Result<User> user = feign.getUserByEmailNumber(login.getEmailNumber());
|
||||||
|
User data = user.getData();
|
||||||
|
if (null==data){
|
||||||
|
return Result.error("对不起您还未注册,请先注册完成后进行登录");
|
||||||
|
}
|
||||||
|
if (!login.getPassword().equals(data.getPassword())){
|
||||||
|
return Result.error("密码错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
String userKey = UUID.randomUUID().toString();
|
||||||
|
map.put(JwtConstants.USER_KEY,userKey);
|
||||||
|
map.put(JwtConstants.DETAILS_USER_ID,data.getUserId());
|
||||||
|
String token = JwtUtils.createToken(map);
|
||||||
|
redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+userKey, JSONObject.toJSONString(data),1500, TimeUnit.MINUTES);
|
||||||
|
JwtResponse jwtResponse = new JwtResponse();
|
||||||
|
jwtResponse.setToken(token);
|
||||||
|
return Result.success(jwtResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<Object> info() {
|
||||||
|
String token = request.getHeader(TokenConstants.TOKEN);
|
||||||
|
|
||||||
|
// 添加参数校验
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
// Token为空,可以根据业务需求返回错误信息或进行其他处理
|
||||||
|
return Result.error("Token cannot be null or empty");
|
||||||
|
}
|
||||||
|
String userKey = JwtUtils.getUserKey(token);
|
||||||
|
String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||||
|
User user = JSONObject.parseObject(s, User.class);
|
||||||
|
System.out.println(userKey);
|
||||||
|
return Result.success(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<Object> logout() {
|
||||||
|
String token = request.getHeader(TokenConstants.TOKEN);
|
||||||
|
String userKey = JwtUtils.getUserKey(token);
|
||||||
|
redisTemplate.delete(TokenConstants.LOGIN_TOKEN_KEY+userKey);
|
||||||
|
return Result.success("退出成功");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9001
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
main:
|
||||||
|
allow-circular-references: true
|
||||||
|
jackson:
|
||||||
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
|
time-zone: GMT+8
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: bwie-auth
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 106.54.220.85:8848
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 106.54.220.85:8848
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
rabbitmq:
|
||||||
|
host: 106.54.220.85
|
||||||
|
port: 5672
|
||||||
|
username: guest
|
||||||
|
password: guest
|
||||||
|
virtual-host: /
|
||||||
|
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
|
||||||
|
publisher-returns: true #确认消息已发送到队列(Queue)
|
||||||
|
listener:
|
||||||
|
simple:
|
||||||
|
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
|
||||||
|
acknowledge-mode: manual # 设置消费端手动ack确认
|
||||||
|
retry:
|
||||||
|
enabled: true # 是否支持重试
|
||||||
|
template:
|
||||||
|
# 只要消息抵达Queue,就会异步发送优先回调return firm
|
||||||
|
mandatory: true
|
||||||
|
kafka:
|
||||||
|
bootstrap-servers: 106.54.220.85:9092
|
||||||
|
producer:
|
||||||
|
key-serializer: org.apache.kafka.common.serialization.StringSerializer
|
||||||
|
value-serializer: org.apache.kafka.common.serialization.StringSerializer
|
||||||
|
retries: 3
|
||||||
|
acks: all
|
||||||
|
compression-type: lz4
|
||||||
|
consumer:
|
||||||
|
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
|
||||||
|
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
|
||||||
|
group-id: bw-gp
|
||||||
|
enable-auto-commit: false
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.bwie.common.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Banner {
|
||||||
|
private Integer bannerId;
|
||||||
|
private String bannerImage;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.bwie.common.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DrugType {
|
||||||
|
private Integer drugTypeId;
|
||||||
|
private String drugTypeName;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.bwie.common.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SymptomDetails {
|
||||||
|
private Integer detailsId;
|
||||||
|
private Integer symptomId;
|
||||||
|
private String symptomName;
|
||||||
|
private String pathology;
|
||||||
|
private String symptom;
|
||||||
|
private String suitableFood;
|
||||||
|
private String avoidFood;
|
||||||
|
private String traditionalMedicineTreatment;
|
||||||
|
private String westernMedicineTreatment;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.bwie.common.domain.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserLogin {
|
||||||
|
private String emailNumber;
|
||||||
|
private String password;
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.example</groupId>
|
||||||
|
<artifactId>health-zxd</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>bwie-system</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<!-- 系统公共 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.example</groupId>
|
||||||
|
<artifactId>bwie-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- SpringBoot Web-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Druid -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
|
<version>1.2.8</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Mybatis 依赖配置 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.2.2</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Pagehelper -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
<version>1.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.example</groupId>
|
||||||
|
<artifactId>bwie-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,107 @@
|
||||||
|
package com.bwie.system.controller;
|
||||||
|
|
||||||
|
import com.bwie.common.domain.*;
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
import com.bwie.system.service.SystemService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Log4j2
|
||||||
|
public class SystemController {
|
||||||
|
@Autowired
|
||||||
|
private SystemService service;
|
||||||
|
@Autowired
|
||||||
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
@PostMapping("/getUserByEmailNumber/{emailNumber}")
|
||||||
|
public Result<User> getUserByEmailNumber(@PathVariable String emailNumber){
|
||||||
|
log.info("功能名称:【根据邮箱账号】,请求路径:【{}】,请求发送:【{}】,请求参数:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod(),emailNumber);
|
||||||
|
Result<User> result = service.getUserByEmailNumber(emailNumber);
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/departmentList")
|
||||||
|
public Result<List<Department>> departmentList(){
|
||||||
|
log.info("功能名称:【科室列表】,请求路径:【{}】,请求发送:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod());
|
||||||
|
Result<List<Department>> result = service.departmentList();
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/findSymptomByDepartmentId/{departmentId}")
|
||||||
|
public Result<List<Symptom>> findSymptomByDepartmentId (@PathVariable Integer departmentId){
|
||||||
|
log.info("功能名称:【病状列表】,请求路径:【{}】,请求发送:【{}】,请求参数:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod(),departmentId);
|
||||||
|
Result<List<Symptom>> result = service.findSymptomByDepartmentId(departmentId);
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/findSymptomDetailsByDepartmentId/{symptomId}")
|
||||||
|
public Result<SymptomDetails> findSymptomDetailsByDepartmentId (@PathVariable Integer symptomId){
|
||||||
|
log.info("功能名称:【病状详情列表】,请求路径:【{}】,请求发送:【{}】,请求参数:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod(),symptomId);
|
||||||
|
Result<SymptomDetails> result = service.findSymptomDetailsByDepartmentId(symptomId);
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/ossUpLoad")
|
||||||
|
public Result<String> ossUpLoad(@RequestParam("file") MultipartFile file){
|
||||||
|
log.info("功能名称:【图片上传】,请求路径:【{}】,请求发送:【{}】,请求参数:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod(),file);
|
||||||
|
Result<String> result = service.ossUpLoad(file);
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/bannerList")
|
||||||
|
public Result<List<Banner>> bannerList(){
|
||||||
|
log.info("功能名称:【banner列表】,请求路径:【{}】,请求发送:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod());
|
||||||
|
Result<List<Banner>> result = service.bannerList();
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/drugTypeList")
|
||||||
|
public Result<List<DrugType>> drugTypeList(){
|
||||||
|
log.info("功能名称:【药品类型列表】,请求路径:【{}】,请求发送:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod());
|
||||||
|
Result<List<DrugType>> result = service.drugTypeList();
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/findDrugByDrugTypeId/{drugTypeId}")
|
||||||
|
public Result<List<Drug>> findDrugByDrugTypeId(@PathVariable Integer drugTypeId){
|
||||||
|
log.info("功能名称:【药品列表】,请求路径:【{}】,请求发送:【{}】,请求参数:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod(),drugTypeId);
|
||||||
|
Result<List<Drug>> result = service.findDrugByDrugTypeId(drugTypeId);
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/findDrugDetailsByDrugId/{drugId}")
|
||||||
|
public Result<List<DrugDetails>> findDrugDetailsByDrugId(@PathVariable Integer drugId){
|
||||||
|
log.info("功能名称:【可用药品】,请求路径:【{}】,请求发送:【{}】,请求参数:【{}】",
|
||||||
|
request.getRequestURI(),request.getMethod(),drugId);
|
||||||
|
Result<List<DrugDetails>> result = service.findDrugDetailsByDrugId(drugId);
|
||||||
|
log.info("返回结果:【{}】",result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.bwie.system.mapper;
|
||||||
|
|
||||||
|
import com.bwie.common.domain.*;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface SystemMapper {
|
||||||
|
|
||||||
|
|
||||||
|
List<Department> departmentList();
|
||||||
|
|
||||||
|
List<Symptom> findSymptomByDepartmentId(@Param("departmentId") Integer departmentId);
|
||||||
|
|
||||||
|
SymptomDetails findSymptomDetailsByDepartmentId(@Param("symptomId") Integer symptomId);
|
||||||
|
|
||||||
|
List<Banner> bannerList();
|
||||||
|
|
||||||
|
User getUser(@Param("emailNumber") String emailNumber);
|
||||||
|
|
||||||
|
List<DrugType> drugTypeList();
|
||||||
|
|
||||||
|
List<Drug> findDrugByDrugTypeId(@Param("drugTypeId") Integer drugTypeId);
|
||||||
|
|
||||||
|
List<DrugDetails> findDrugDetailsByDrugId(@Param("drugId") Integer drugId);
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.bwie.system.service;
|
||||||
|
|
||||||
|
import com.bwie.common.domain.*;
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SystemService {
|
||||||
|
Result<User> getUserByEmailNumber(String emailNumber);
|
||||||
|
|
||||||
|
Result<List<Department>> departmentList();
|
||||||
|
|
||||||
|
Result<List<Symptom>> findSymptomByDepartmentId(Integer departmentId);
|
||||||
|
|
||||||
|
Result<SymptomDetails> findSymptomDetailsByDepartmentId(Integer symptomId);
|
||||||
|
|
||||||
|
Result<String> ossUpLoad(MultipartFile file);
|
||||||
|
|
||||||
|
Result<List<Banner>> bannerList();
|
||||||
|
|
||||||
|
Result<List<DrugType>> drugTypeList();
|
||||||
|
|
||||||
|
Result<List<Drug>> findDrugByDrugTypeId(Integer drugTypeId);
|
||||||
|
|
||||||
|
Result<List<DrugDetails>> findDrugDetailsByDrugId(Integer drugId);
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.bwie.system.service.impl;
|
||||||
|
|
||||||
|
import com.bwie.common.domain.*;
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
import com.bwie.common.utils.OssUtil;
|
||||||
|
import com.bwie.system.mapper.SystemMapper;
|
||||||
|
import com.bwie.system.service.SystemService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SystemServiceImpl implements SystemService {
|
||||||
|
@Autowired
|
||||||
|
private SystemMapper mapper;
|
||||||
|
@Override
|
||||||
|
public Result<User> getUserByEmailNumber(String emailNumber) {
|
||||||
|
User user1 = mapper.getUser(emailNumber);
|
||||||
|
return Result.success(user1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<Department>> departmentList() {
|
||||||
|
List<Department> departments = mapper.departmentList();
|
||||||
|
return Result.success(departments);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<Symptom>> findSymptomByDepartmentId(Integer departmentId) {
|
||||||
|
List<Symptom> symptom = mapper.findSymptomByDepartmentId(departmentId);
|
||||||
|
return Result.success(symptom);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<SymptomDetails> findSymptomDetailsByDepartmentId(Integer symptomId) {
|
||||||
|
SymptomDetails details = mapper.findSymptomDetailsByDepartmentId(symptomId);
|
||||||
|
return Result.success(details);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> ossUpLoad(MultipartFile file) {
|
||||||
|
if (file.isEmpty()){
|
||||||
|
return Result.error("文件不能为空");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String s = OssUtil.uploadMultipartFile(file);
|
||||||
|
return Result.success(s);
|
||||||
|
} catch (MaxUploadSizeExceededException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return Result.error("上传的文件大小超过了20MB,请选择大小不超过20MB的文件上传");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<Banner>> bannerList() {
|
||||||
|
List<Banner> banners = mapper.bannerList();
|
||||||
|
return Result.success(banners);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<DrugType>> drugTypeList() {
|
||||||
|
List<DrugType> drugTypes = mapper.drugTypeList();
|
||||||
|
return Result.success(drugTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<Drug>> findDrugByDrugTypeId(Integer drugTypeId) {
|
||||||
|
List<Drug> drugs = mapper.findDrugByDrugTypeId(drugTypeId);
|
||||||
|
return Result.success(drugs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<DrugDetails>> findDrugDetailsByDrugId(Integer drugId) {
|
||||||
|
List<DrugDetails> drugDetails = mapper.findDrugDetailsByDrugId(drugId);
|
||||||
|
return Result.success(drugDetails);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9002
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
main:
|
||||||
|
allow-circular-references: true
|
||||||
|
jackson:
|
||||||
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
|
time-zone: GMT+8
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: bwie-system
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 106.54.220.85:8848
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 106.54.220.85:8848
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.bwie.system.mapper.SystemMapper">
|
||||||
|
|
||||||
|
<select id="departmentList" resultType="com.bwie.common.domain.Department">
|
||||||
|
SELECT
|
||||||
|
department_id,
|
||||||
|
department_name
|
||||||
|
FROM
|
||||||
|
t_department
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="findSymptomDetailsByDepartmentId" resultType="com.bwie.common.domain.SymptomDetails">
|
||||||
|
SELECT
|
||||||
|
d.details_id,
|
||||||
|
d.symptom_id,
|
||||||
|
d.pathology,
|
||||||
|
d.symptom,
|
||||||
|
s.symptom_name,
|
||||||
|
d.suitable_food,
|
||||||
|
d.avoid_food,
|
||||||
|
d.traditional_medicine_treatment,
|
||||||
|
d.western_medicine_treatment
|
||||||
|
FROM
|
||||||
|
t_symptom_details d
|
||||||
|
LEFT JOIN t_symptom s ON d.symptom_id = s.symptom_id
|
||||||
|
WHERE d.symptom_id = #{symptomId}
|
||||||
|
</select>
|
||||||
|
<select id="bannerList" resultType="com.bwie.common.domain.Banner">
|
||||||
|
SELECT
|
||||||
|
banner_id,
|
||||||
|
banner_image
|
||||||
|
FROM
|
||||||
|
t_banner
|
||||||
|
</select>
|
||||||
|
<select id="getUser" resultType="com.bwie.common.domain.User">
|
||||||
|
SELECT
|
||||||
|
user_id,
|
||||||
|
email_number,
|
||||||
|
password,
|
||||||
|
name
|
||||||
|
FROM
|
||||||
|
t_user
|
||||||
|
WHERE
|
||||||
|
email_number = #{emailNumber}
|
||||||
|
</select>
|
||||||
|
<select id="findSymptomByDepartmentId" resultType="com.bwie.common.domain.Symptom">
|
||||||
|
SELECT
|
||||||
|
symptom_id,
|
||||||
|
department_id,
|
||||||
|
symptom_name
|
||||||
|
FROM
|
||||||
|
t_symptom
|
||||||
|
WHERE
|
||||||
|
department_id = #{departmentId}
|
||||||
|
</select>
|
||||||
|
<select id="drugTypeList" resultType="com.bwie.common.domain.DrugType">
|
||||||
|
SELECT
|
||||||
|
drugtype_id,
|
||||||
|
drugtype_name
|
||||||
|
FROM
|
||||||
|
t_drugtype
|
||||||
|
</select>
|
||||||
|
<select id="findDrugByDrugTypeId" resultType="com.bwie.common.domain.Drug">
|
||||||
|
SELECT
|
||||||
|
drug_id,
|
||||||
|
drugtype_id,
|
||||||
|
drug_name,
|
||||||
|
drug_image
|
||||||
|
FROM
|
||||||
|
t_drug
|
||||||
|
WHERE
|
||||||
|
drugtype_id = #{drugTypeId}
|
||||||
|
</select>
|
||||||
|
<select id="findDrugDetailsByDrugId" resultType="com.bwie.common.domain.DrugDetails">
|
||||||
|
SELECT
|
||||||
|
d.details_id,
|
||||||
|
d.drug_id,
|
||||||
|
d.ingredient,
|
||||||
|
d.taboo,
|
||||||
|
d.indications,
|
||||||
|
d.dosage,
|
||||||
|
d.drug_character,
|
||||||
|
d.packaging,
|
||||||
|
d.adverse_reaction,
|
||||||
|
t.drug_name
|
||||||
|
FROM
|
||||||
|
t_drug_details d
|
||||||
|
JOIN t_drug t ON d.drug_id = t.drug_id
|
||||||
|
WHERE
|
||||||
|
d.drug_id = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue