From cfdb39acde97534c56af97fedc36faea3e2fb6cd Mon Sep 17 00:00:00 2001 From: Zhangyao <3538764418@qq.com> Date: Sun, 17 Dec 2023 10:43:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=81=A5=E5=BA=B7=E6=95=99=E8=82=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/encodings.xml | 1 + .idea/uiDesigner.xml | 124 ++++++++++++++++ .idea/vcs.xml | 6 + .idea/workspace.xml | 132 ++++++++++++++++++ .../java/com/bwie/common/domain/Health.java | 24 ++++ bwie-modules/bwie-health/.gitignore | 38 +++++ bwie-modules/bwie-health/pom.xml | 54 +++++++ .../com/bwie/health/HealthApplication.java | 13 ++ .../health/controller/HealthController.java | 38 +++++ .../com/bwie/health/mapper/HealthMapper.java | 18 +++ .../bwie/health/service/HealthService.java | 15 ++ .../service/impl/HealthServiceImpl.java | 65 +++++++++ .../src/main/resources/bootstrap.yml | 43 ++++++ .../main/resources/mapper/HealthMapper.xml | 32 +++++ bwie-modules/pom.xml | 4 + 15 files changed, 607 insertions(+) create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/Health.java create mode 100644 bwie-modules/bwie-health/.gitignore create mode 100644 bwie-modules/bwie-health/pom.xml create mode 100644 bwie-modules/bwie-health/src/main/java/com/bwie/health/HealthApplication.java create mode 100644 bwie-modules/bwie-health/src/main/java/com/bwie/health/controller/HealthController.java create mode 100644 bwie-modules/bwie-health/src/main/java/com/bwie/health/mapper/HealthMapper.java create mode 100644 bwie-modules/bwie-health/src/main/java/com/bwie/health/service/HealthService.java create mode 100644 bwie-modules/bwie-health/src/main/java/com/bwie/health/service/impl/HealthServiceImpl.java create mode 100644 bwie-modules/bwie-health/src/main/resources/bootstrap.yml create mode 100644 bwie-modules/bwie-health/src/main/resources/mapper/HealthMapper.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml index fb5b0c3..1a81b16 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -7,6 +7,7 @@ + diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..9791238 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1702775369535 + + + + + + \ No newline at end of file diff --git a/bwie-common/src/main/java/com/bwie/common/domain/Health.java b/bwie-common/src/main/java/com/bwie/common/domain/Health.java new file mode 100644 index 0000000..3c2ed2e --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/Health.java @@ -0,0 +1,24 @@ +package com.bwie.common.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Health{ + private Integer healthId; + private String healthTitle; + private String healthContent; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date healthDate; + private Integer userId; + private Integer isDele; + + private Integer pageNum; + private Integer pageSize; +} diff --git a/bwie-modules/bwie-health/.gitignore b/bwie-modules/bwie-health/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/bwie-modules/bwie-health/.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/bwie-modules/bwie-health/pom.xml b/bwie-modules/bwie-health/pom.xml new file mode 100644 index 0000000..d8486a0 --- /dev/null +++ b/bwie-modules/bwie-health/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + + com.bwie + bwie-modules + 1.0-SNAPSHOT + + + bwie-health + + + 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 + + + \ No newline at end of file diff --git a/bwie-modules/bwie-health/src/main/java/com/bwie/health/HealthApplication.java b/bwie-modules/bwie-health/src/main/java/com/bwie/health/HealthApplication.java new file mode 100644 index 0000000..05945d5 --- /dev/null +++ b/bwie-modules/bwie-health/src/main/java/com/bwie/health/HealthApplication.java @@ -0,0 +1,13 @@ +package com.bwie.health; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class HealthApplication{ + public static void main(String[] args) { + SpringApplication.run(HealthApplication.class,args); + } +} diff --git a/bwie-modules/bwie-health/src/main/java/com/bwie/health/controller/HealthController.java b/bwie-modules/bwie-health/src/main/java/com/bwie/health/controller/HealthController.java new file mode 100644 index 0000000..a75d47c --- /dev/null +++ b/bwie-modules/bwie-health/src/main/java/com/bwie/health/controller/HealthController.java @@ -0,0 +1,38 @@ +package com.bwie.health.controller; + +import com.bwie.common.domain.Health; +import com.bwie.common.result.Result; +import com.bwie.health.service.HealthService; +import com.github.pagehelper.PageInfo; +import io.lettuce.core.pubsub.RedisPubSubListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/health") +public class HealthController{ + @Autowired + private HealthService healthService; + + @PostMapping("/list") + public Result> list(@RequestBody Health health){ + return healthService.list(health); + } + + @PostMapping("/addHealth") + public Result addHealth(@RequestBody Health health){ + return healthService.addHealth(health); + } + + @PostMapping("/updateHealth") + public Result updateHealth(@RequestBody Health health){ + return healthService.updateHealth(health); + } + + @PostMapping("/deleteHealth") + public Result deleteHealth(@RequestParam String healthId){ + return healthService.deleteHealth(healthId); + } +} diff --git a/bwie-modules/bwie-health/src/main/java/com/bwie/health/mapper/HealthMapper.java b/bwie-modules/bwie-health/src/main/java/com/bwie/health/mapper/HealthMapper.java new file mode 100644 index 0000000..000767d --- /dev/null +++ b/bwie-modules/bwie-health/src/main/java/com/bwie/health/mapper/HealthMapper.java @@ -0,0 +1,18 @@ +package com.bwie.health.mapper; + +import com.bwie.common.domain.Health; +import com.bwie.common.result.Result; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface HealthMapper{ + List list(Health health); + + Integer addHealth(Health health); + + Integer updateHealth(Health health); + + Integer deleteHealth(String healthId); +} diff --git a/bwie-modules/bwie-health/src/main/java/com/bwie/health/service/HealthService.java b/bwie-modules/bwie-health/src/main/java/com/bwie/health/service/HealthService.java new file mode 100644 index 0000000..6cc8b0a --- /dev/null +++ b/bwie-modules/bwie-health/src/main/java/com/bwie/health/service/HealthService.java @@ -0,0 +1,15 @@ +package com.bwie.health.service; + +import com.bwie.common.domain.Health; +import com.bwie.common.result.Result; +import com.github.pagehelper.PageInfo; + +public interface HealthService{ + Result> list(Health health); + + Result addHealth(Health health); + + Result updateHealth(Health health); + + Result deleteHealth(String healthId); +} diff --git a/bwie-modules/bwie-health/src/main/java/com/bwie/health/service/impl/HealthServiceImpl.java b/bwie-modules/bwie-health/src/main/java/com/bwie/health/service/impl/HealthServiceImpl.java new file mode 100644 index 0000000..c7fa252 --- /dev/null +++ b/bwie-modules/bwie-health/src/main/java/com/bwie/health/service/impl/HealthServiceImpl.java @@ -0,0 +1,65 @@ +package com.bwie.health.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.bwie.common.constants.TokenConstants; +import com.bwie.common.domain.Health; +import com.bwie.common.result.Result; +import com.bwie.common.utils.JwtUtils; +import com.bwie.health.mapper.HealthMapper; +import com.bwie.health.service.HealthService; +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; + +@Service +public class HealthServiceImpl implements HealthService{ + @Autowired + private HealthMapper healthMapper; + + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private HttpServletRequest request; + + /*查看内容*/ + @Override + public Result> list(Health health) { + PageHelper.startPage(health.getPageNum(),health.getPageSize()); + List list = healthMapper.list(health); + PageInfo info = new PageInfo<>(list); + return Result.success(info); + } + + /*健康教育信息录入*/ + @Override + public Result addHealth(Health health) { +// String token1 = request.getHeader("token"); +// String userKey = JwtUtils.getUserKey(token1); +// String token = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY+userKey); +// User o = JSONObject.parseObject(token, User.class); +// health.setUserId(o.Id); + + Integer i = healthMapper.addHealth(health); + + return Result.success(i,i>0?"录入成功":"录入失败"); + } + + /*健康教育记录修改*/ + @Override + public Result updateHealth(Health health) { + Integer i = healthMapper.updateHealth(health); + return Result.success(i,i>0?"修改成功":"修改失败"); + } + + /*健康教育记录删除*/ + @Override + public Result deleteHealth(String healthId) { + Integer i = healthMapper.deleteHealth(healthId); + return Result.success(i,i>0?"删除成功":"删除失败"); + } +} diff --git a/bwie-modules/bwie-health/src/main/resources/bootstrap.yml b/bwie-modules/bwie-health/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..b5e57d8 --- /dev/null +++ b/bwie-modules/bwie-health/src/main/resources/bootstrap.yml @@ -0,0 +1,43 @@ +# Tomcat +server: + port: 9003 +# Spring +spring: + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: bwie-health + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 124.221.211.96:8848 + config: + # 配置中心地址 + server-addr: 124.221.211.96: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: 124.221.211.96:22122 + web-server-url: 124.221.211.96:8888 + pool: + jmx-enabled: false + # 生成缩略图 + thumb-image: + height: 500 + width: 500 \ No newline at end of file diff --git a/bwie-modules/bwie-health/src/main/resources/mapper/HealthMapper.xml b/bwie-modules/bwie-health/src/main/resources/mapper/HealthMapper.xml new file mode 100644 index 0000000..07c5ad7 --- /dev/null +++ b/bwie-modules/bwie-health/src/main/resources/mapper/HealthMapper.xml @@ -0,0 +1,32 @@ + + + + + INSERT INTO `health`.`health` + (`health_title`, `health_content`, `health_date`, `user_id`, `is_dele`) + VALUES + (#{healthTitle}, #{healthContent}, now(), #{userId}, 1) + + + UPDATE `health`.`health` SET + `health_title` = #{healthTitle}, + `health_content` = #{healthContent}, + `health_date` = #{healthDate}, + `user_id` = 1, + `is_dele` = 1 + WHERE `health_id` = #{healthId} + + + + + + + + \ No newline at end of file diff --git a/bwie-modules/pom.xml b/bwie-modules/pom.xml index 820a8b0..5d6d35d 100644 --- a/bwie-modules/pom.xml +++ b/bwie-modules/pom.xml @@ -10,6 +10,10 @@ bwie-modules + pom + + bwie-health + 8