diff --git a/.idea/encodings.xml b/.idea/encodings.xml index fb5b0c3..7d97e3a 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -7,6 +7,7 @@ + diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..bdb256b --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,39 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 132404b..4184518 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,6 +5,7 @@ diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/bwie-common/src/main/java/com/bwie/common/domain/Case.java b/bwie-common/src/main/java/com/bwie/common/domain/Case.java new file mode 100644 index 0000000..6d2c70d --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/Case.java @@ -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; + + +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/CaseRequest.java b/bwie-common/src/main/java/com/bwie/common/domain/CaseRequest.java new file mode 100644 index 0000000..9df76a0 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/CaseRequest.java @@ -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; +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/User.java b/bwie-common/src/main/java/com/bwie/common/domain/User.java new file mode 100644 index 0000000..5659d16 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/User.java @@ -0,0 +1,33 @@ +package com.bwie.common.domain; + +import lombok.Data; + +/** + * @author gxb + * @description TODO + * @date 2023-12-16 11:43 + */ +@Data +public class User { + /** + * Id + */ + private Integer id; + /** + * 用户名 + */ + private String username; + /** + * 密码 + */ + private String password; + /** + * 1 - 医生 2-用户 + */ + private Integer role; + /** + * 手机号 + */ + private String phone; + +} diff --git a/bwie-gateway/src/main/java/com/bwie/gateway/GatewayAppliction.java b/bwie-gateway/src/main/java/com/bwie/gateway/GatewayApplication.java similarity index 74% rename from bwie-gateway/src/main/java/com/bwie/gateway/GatewayAppliction.java rename to bwie-gateway/src/main/java/com/bwie/gateway/GatewayApplication.java index c97d03a..3dcaee3 100644 --- a/bwie-gateway/src/main/java/com/bwie/gateway/GatewayAppliction.java +++ b/bwie-gateway/src/main/java/com/bwie/gateway/GatewayApplication.java @@ -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); } -} \ No newline at end of file +} diff --git a/bwie-modules/bwie-cases/pom.xml b/bwie-modules/bwie-cases/pom.xml new file mode 100644 index 0000000..9599584 --- /dev/null +++ b/bwie-modules/bwie-cases/pom.xml @@ -0,0 +1,66 @@ + + + 4.0.0 + + com.bwie + bwie-modules + 1.0-SNAPSHOT + + + bwie-cases + + + 8 + 8 + UTF-8 + + + + + com.bwie + bwie-common + + + + org.springframework.boot + spring-boot-starter-web + + + + com.alibaba + druid-spring-boot-starter + 1.2.8 + + + + mysql + mysql-connector-java + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.2.2 + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.4.1 + + + + org.springframework.boot + spring-boot-starter-test + test + + + com.github.tobato + fastdfs-client + 1.26.5 + + + + diff --git a/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/CasesApplication.java b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/CasesApplication.java new file mode 100644 index 0000000..699b293 --- /dev/null +++ b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/CasesApplication.java @@ -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); + } +} diff --git a/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/controller/CaseController.java b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/controller/CaseController.java new file mode 100644 index 0000000..ce9e59b --- /dev/null +++ b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/controller/CaseController.java @@ -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 insertCase(@RequestBody Case cases) { + log.info(cases); + return caseService.insertCase(cases); + } + + + /** + * 删除病例 + * + * @param caseId; + */ + @DeleteMapping("/case/{caseId}") + public Result deleteCase(@PathVariable Integer caseId) { + return caseService.deleteCase(caseId); + } + + + /** + * 修改病例 + * + * @param cases; + */ + @PutMapping("/case") + public Result updateCase(@RequestBody Case cases) { + return caseService.updateCase(cases); + } + + + /** + * 查询病历表 + * + * @return ; + */ + @GetMapping("/case") + public Result> selCase(CaseRequest caseRequest) { + System.out.println(caseRequest + "---------"); + return caseService.selCase(caseRequest); + } + + +} diff --git a/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/mapper/CaseMapper.java b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/mapper/CaseMapper.java new file mode 100644 index 0000000..73c1f4d --- /dev/null +++ b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/mapper/CaseMapper.java @@ -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 selCase(CaseRequest caseRequest); +} diff --git a/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/service/CaseService.java b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/service/CaseService.java new file mode 100644 index 0000000..309ad99 --- /dev/null +++ b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/service/CaseService.java @@ -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 insertCase(Case cases); + + /** + * 删除病例 + * @return ; + * @param caseId; + */ + Result deleteCase(Integer caseId); + + /** + * 修改病例 + * @return ; + * @param cases; + */ + Result updateCase(Case cases); + + + /** + * 查询病例 + * @param caseRequest; + * @return ; + */ + Result> selCase(CaseRequest caseRequest); +} diff --git a/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/service/impl/CaseServiceImpl.java b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/service/impl/CaseServiceImpl.java new file mode 100644 index 0000000..c38ff82 --- /dev/null +++ b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/service/impl/CaseServiceImpl.java @@ -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 redisTemplate; + + public CaseServiceImpl(CaseMapper caseMapper, HttpServletRequest request, RedisTemplate redisTemplate) { + this.caseMapper = caseMapper; + this.request = request; + this.redisTemplate = redisTemplate; + } + + /** + * 添加病例 + * + * @param cases; + */ + @Override + public Result 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 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 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> 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 list = caseMapper.selCase(caseRequest); + // 调用PageInfo的构造方法,传入list参数 + PageInfo 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); + } + + +} diff --git a/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/util/FastUtil.java b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/util/FastUtil.java new file mode 100644 index 0000000..dcf375e --- /dev/null +++ b/bwie-modules/bwie-cases/src/main/java/com/bwie/xxxxxx/util/FastUtil.java @@ -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 "删除成功"; + } + +} diff --git a/bwie-modules/bwie-cases/src/main/resources/bootstrap.yml b/bwie-modules/bwie-cases/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..9aa5e59 --- /dev/null +++ b/bwie-modules/bwie-cases/src/main/resources/bootstrap.yml @@ -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 diff --git a/bwie-modules/bwie-cases/src/main/resources/mapper/XXXmapper.xml b/bwie-modules/bwie-cases/src/main/resources/mapper/XXXmapper.xml new file mode 100644 index 0000000..36f38e0 --- /dev/null +++ b/bwie-modules/bwie-cases/src/main/resources/mapper/XXXmapper.xml @@ -0,0 +1,35 @@ + + + + + + + insert into cases + values (null, #{caseName}, #{caseMessage}, #{caseTime}, #{userId}) + + + + + update cases + set case_name=#{caseName}, + case_message=#{caseMessage}, + case_Time=#{caseTime} + where case_id = #{caseId} + + + + + delete + from cases + where case_id = #{caseId} + + + + + + +