Merge remote-tracking branch 'origin/ftx'
# Conflicts: # .idea/encodings.xml # .idea/inspectionProfiles/Project_Default.xml # .idea/workspace.xml # bwie-common/src/main/java/com/bwie/common/domain/User.javapull/1/head
commit
fe52549585
|
@ -4,6 +4,7 @@
|
|||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/bwie-modules/bwie-cases/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Handsome boy
|
||||
* @Package com.bwie.common.domain
|
||||
* @date 2023/12/8 20:22
|
||||
*/
|
||||
@Data
|
||||
public class Case {
|
||||
private Integer caseId;
|
||||
private Integer userId;
|
||||
|
||||
private String caseName;
|
||||
private String caseTime;
|
||||
private String caseMessage;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Handsome boy
|
||||
* @Package com.bwie.common.domain
|
||||
* @date 2023/12/16 11:51
|
||||
*/
|
||||
@Data
|
||||
public class CaseRequest {
|
||||
private Integer pageSize;
|
||||
private Integer pageNum;
|
||||
|
||||
|
||||
private Integer roleId;
|
||||
private Integer userId;
|
||||
}
|
|
@ -9,8 +9,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
* @date 2023-12-16 8:35
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class GatewayAppliction {
|
||||
public class GatewayApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GatewayAppliction.class,args);
|
||||
SpringApplication.run(GatewayApplication.class,args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
<?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>com.bwie</groupId>
|
||||
<artifactId>bwie-modules</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-cases</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>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
</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>
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.tobato</groupId>
|
||||
<artifactId>fastdfs-client</artifactId>
|
||||
<version>1.26.5</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
package com.bwie.xxxxxx;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @author Handsome boy
|
||||
* @Package com.bwie.xxxxxx
|
||||
* @date 2023/12/16 12:02
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class CasesApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CasesApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.bwie.xxxxxx.controller;
|
||||
|
||||
import com.bwie.common.domain.Case;
|
||||
import com.bwie.common.domain.CaseRequest;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.xxxxxx.service.CaseService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Handsome boy
|
||||
* @Package com.bwie.xxxxxx.controller
|
||||
* @date 2023/12/8 20:21
|
||||
*/
|
||||
@RestController
|
||||
@Log4j2
|
||||
public class CaseController {
|
||||
final CaseService caseService;
|
||||
|
||||
public CaseController(CaseService caseService) {
|
||||
this.caseService = caseService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加病例
|
||||
*
|
||||
* @param cases;
|
||||
*/
|
||||
@PostMapping("/case")
|
||||
public Result<Object> insertCase(@RequestBody Case cases) {
|
||||
log.info(cases);
|
||||
return caseService.insertCase(cases);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除病例
|
||||
*
|
||||
* @param caseId;
|
||||
*/
|
||||
@DeleteMapping("/case/{caseId}")
|
||||
public Result<Object> deleteCase(@PathVariable Integer caseId) {
|
||||
return caseService.deleteCase(caseId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改病例
|
||||
*
|
||||
* @param cases;
|
||||
*/
|
||||
@PutMapping("/case")
|
||||
public Result<Object> updateCase(@RequestBody Case cases) {
|
||||
return caseService.updateCase(cases);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询病历表
|
||||
*
|
||||
* @return ;
|
||||
*/
|
||||
@GetMapping("/case")
|
||||
public Result<PageResult<Case>> selCase(@RequestBody CaseRequest caseRequest) {
|
||||
System.out.println(caseRequest + "---------");
|
||||
return caseService.selCase(caseRequest);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.bwie.xxxxxx.mapper;
|
||||
|
||||
import com.bwie.common.domain.Case;
|
||||
import com.bwie.common.domain.CaseRequest;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Handsome boy
|
||||
* @Package com.bwie.xxxxxx.mapper
|
||||
* @date 2023/12/8 20:21
|
||||
*/
|
||||
@Mapper
|
||||
public interface CaseMapper {
|
||||
/**
|
||||
* 添加病历表
|
||||
* @return ;
|
||||
* @param cases;
|
||||
*/
|
||||
int insertCase(Case cases);
|
||||
|
||||
/**
|
||||
* 删除病例
|
||||
* @return ;
|
||||
* @param caseId;
|
||||
*/
|
||||
int deleteCase(Integer caseId);
|
||||
|
||||
/**
|
||||
* 修改病历
|
||||
* @param cases ;
|
||||
* @return ;
|
||||
*/
|
||||
int updateCase(Case cases);
|
||||
|
||||
/**
|
||||
* 查询病例表
|
||||
* @param caseRequest;
|
||||
* @return ;
|
||||
*/
|
||||
List<Case> selCase(CaseRequest caseRequest);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.bwie.xxxxxx.service;
|
||||
|
||||
import com.bwie.common.domain.Case;
|
||||
import com.bwie.common.domain.CaseRequest;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Handsome boy
|
||||
* @Package com.bwie.xxxxxx.service
|
||||
* @date 2023/12/8 20:21
|
||||
*/
|
||||
|
||||
public interface CaseService {
|
||||
/**
|
||||
* 添加病例
|
||||
* @return ;
|
||||
* @param cases;
|
||||
*/
|
||||
Result<Object> insertCase(Case cases);
|
||||
|
||||
/**
|
||||
* 删除病例
|
||||
* @return ;
|
||||
* @param caseId;
|
||||
*/
|
||||
Result<Object> deleteCase(Integer caseId);
|
||||
|
||||
/**
|
||||
* 修改病例
|
||||
* @return ;
|
||||
* @param cases;
|
||||
*/
|
||||
Result<Object> updateCase(Case cases);
|
||||
|
||||
|
||||
/**
|
||||
* 查询病例
|
||||
* @param caseRequest;
|
||||
* @return ;
|
||||
*/
|
||||
Result<PageResult<Case>> selCase(CaseRequest caseRequest);
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
package com.bwie.xxxxxx.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bwie.common.constants.TokenConstants;
|
||||
import com.bwie.common.domain.Case;
|
||||
import com.bwie.common.domain.CaseRequest;
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.common.utils.JwtUtils;
|
||||
import com.bwie.xxxxxx.mapper.CaseMapper;
|
||||
import com.bwie.xxxxxx.service.CaseService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
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.List;
|
||||
|
||||
/**
|
||||
* @author Handsome boy
|
||||
* @Package com.bwie.xxxxxx.service.impl
|
||||
* @date 2023/12/8 20:21
|
||||
*/
|
||||
@Service
|
||||
public class CaseServiceImpl implements CaseService {
|
||||
|
||||
final CaseMapper caseMapper;
|
||||
final HttpServletRequest request;
|
||||
final RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
public CaseServiceImpl(CaseMapper caseMapper, HttpServletRequest request, RedisTemplate<String, String> redisTemplate) {
|
||||
this.caseMapper = caseMapper;
|
||||
this.request = request;
|
||||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加病例
|
||||
*
|
||||
* @param cases;
|
||||
*/
|
||||
@Override
|
||||
public Result<Object> insertCase(Case cases) {
|
||||
int row;
|
||||
try {
|
||||
row = caseMapper.insertCase(cases);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (row == 0) {
|
||||
throw new IllegalAccessError("添加异常");
|
||||
}
|
||||
return Result.success("添加病例成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除病例
|
||||
*
|
||||
* @param caseId;
|
||||
*/
|
||||
@Override
|
||||
public Result<Object> deleteCase(Integer caseId) {
|
||||
int row;
|
||||
try {
|
||||
row = caseMapper.deleteCase(caseId);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (row == 0) {
|
||||
throw new IllegalAccessError("删除异常");
|
||||
}
|
||||
return Result.success("删除病例成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改病例
|
||||
*
|
||||
* @param cases;
|
||||
*/
|
||||
@Override
|
||||
public Result<Object> updateCase(Case cases) {
|
||||
int row;
|
||||
try {
|
||||
row = caseMapper.updateCase(cases);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (row == 0) {
|
||||
throw new IllegalAccessError("修改异常");
|
||||
}
|
||||
return Result.success("修改病例成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<PageResult<Case>> selCase(CaseRequest caseRequest) {
|
||||
// 调用PageHelper的startPage方法,传入当前页码和每页条数
|
||||
PageHelper.startPage(caseRequest.getPageNum(), caseRequest.getPageSize());
|
||||
//获取登录人信息
|
||||
User user = getToken();
|
||||
if (user == null){
|
||||
return Result.error("未登录");
|
||||
}
|
||||
caseRequest.setRoleId(user.getRole());
|
||||
// 调用caseMapper的selCase方法,传入CaseRequest参数
|
||||
List<Case> list = caseMapper.selCase(caseRequest);
|
||||
// 调用PageInfo的构造方法,传入list参数
|
||||
PageInfo<Case> page = new PageInfo<>(list);
|
||||
// 调用Result的success方法,传入PageResult.toPageResult方法,传入page.getTotal()和list参数
|
||||
return PageResult.toResult(page.getTotal() ,list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取登录人信息
|
||||
*
|
||||
* @return ;
|
||||
*/
|
||||
private User getToken() {
|
||||
//获取token
|
||||
String token = request.getHeader("token");
|
||||
//获取用户key
|
||||
String userKey = JwtUtils.getUserKey(token);
|
||||
//从redis中获取用户信息
|
||||
String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||
//将用户信息转换为User对象
|
||||
return JSON.parseObject(s, User.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.bwie.xxxxxx.util;
|
||||
|
||||
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @BelongsProject: 0107day02
|
||||
* @BelongsPackage: com.bw.config
|
||||
* @Author: zhupengfei
|
||||
* @CreateTime: 2023-02-01 08:52
|
||||
*/
|
||||
@Component
|
||||
public class FastUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(FastUtil.class);
|
||||
|
||||
@Resource
|
||||
private FastFileStorageClient storageClient ;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
public String upload(MultipartFile multipartFile) throws Exception{
|
||||
String originalFilename = multipartFile.getOriginalFilename().
|
||||
substring(multipartFile.getOriginalFilename().
|
||||
lastIndexOf(".") + 1);
|
||||
StorePath storePath = this.storageClient.uploadImageAndCrtThumbImage(
|
||||
multipartFile.getInputStream(),
|
||||
multipartFile.getSize(),originalFilename , null);
|
||||
return storePath.getFullPath() ;
|
||||
}
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
public String deleteFile(String fileUrl) {
|
||||
if (StringUtils.isEmpty(fileUrl)) {
|
||||
log.info("fileUrl == >>文件路径为空...");
|
||||
return "文件路径不能为空";
|
||||
}
|
||||
try {
|
||||
StorePath storePath = StorePath.parseFromUrl(fileUrl);
|
||||
storageClient.deleteFile(storePath.getGroup(), storePath.getPath());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return "删除成功";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9099
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-case
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 43.143.161.183:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 43.143.161.183:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
fdfs:
|
||||
so-timeout: 1500 # socket 连接时长
|
||||
connect-timeout: 600 # 连接 tracker 服务器超时时长
|
||||
# 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
|
||||
tracker-list: 43.143.161.183:22122
|
||||
web-server-url: 43.143.161.183:8888
|
||||
pool:
|
||||
jmx-enabled: false
|
||||
# 生成缩略图
|
||||
thumb-image:
|
||||
height: 500
|
||||
width: 500
|
|
@ -0,0 +1,35 @@
|
|||
<?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.xxxxxx.mapper.CaseMapper">
|
||||
|
||||
<!-- 添加病历表 -->
|
||||
<insert id="insertCase">
|
||||
insert into cases
|
||||
values (null, #{caseName}, #{caseMessage}, #{caseTime}, #{userId})
|
||||
</insert>
|
||||
|
||||
<!-- 修改病历表 -->
|
||||
<update id="updateCase">
|
||||
update cases
|
||||
set case_name=#{caseName},
|
||||
case_message=#{caseMessage},
|
||||
case_Time=#{caseTime}
|
||||
where case_id = #{caseId}
|
||||
</update>
|
||||
|
||||
<!-- 删除病例表 -->
|
||||
<delete id="deleteCase">
|
||||
delete
|
||||
from cases
|
||||
where case_id = #{caseId}
|
||||
</delete>
|
||||
|
||||
<!-- 查询病历表 -->
|
||||
<select id="selCase" resultType="com.bwie.common.domain.Case">
|
||||
select *
|
||||
from cases
|
||||
where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue