pull/1/head
31353 2023-12-22 20:30:29 +08:00
parent 53b63e681e
commit 1b61bce8e1
10 changed files with 285 additions and 1 deletions

View File

@ -0,0 +1,32 @@
package com.bwie.common.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author gxb
* @description TODO
* @date 2023-12-22 20:28
*/
@Data
public class Manage {
// 管理员ID
private Integer manageId;
// 案件ID
private Integer caseId;
// 问题ID
private Integer id;
// 案件名称
private String caseName;
// 案件时间
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date caseTime;
// 案件信息
private String caseMessage;
// 用户名
private String username;
}

View File

@ -0,0 +1,56 @@
<?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-manage</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>
</dependencies>
</project>

View File

@ -0,0 +1,11 @@
package com.bwie.manage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ManageApp {
public static void main(String[] args) {
SpringApplication.run(ManageApp.class);
}
}

View File

@ -0,0 +1,36 @@
package com.bwie.manage.controller;
import com.bwie.common.domain.Case;
import com.bwie.common.domain.Manage;
import com.bwie.common.result.Result;
import com.bwie.manage.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ManageController {
@Autowired
private ManageService manageService;
@PostMapping("/list")
public Result list(){
return manageService.list();
}
@PostMapping("/add")
public Result add(@RequestBody Manage manage){
return manageService.add(manage);
}
@PostMapping("/upd")
public Result upd(@RequestBody Manage manage){
return manageService.upd(manage);
}
@PostMapping("/del")
public Result del(@RequestParam Integer manageId){
return manageService.del(manageId);
}
}

View File

@ -0,0 +1,22 @@
package com.bwie.manage.mapper;
import com.bwie.common.domain.Manage;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import java.util.List;
@Mapper
@Component
public interface ManageMapper {
List<Manage> list();
Integer add(Manage manage);
Integer upd(Manage manage);
Integer del(Integer manageId);
Manage findAll(Manage manage);
}

View File

@ -0,0 +1,14 @@
package com.bwie.manage.service;
import com.bwie.common.domain.Manage;
import com.bwie.common.result.Result;
public interface ManageService {
Result list();
Result add(Manage manage);
Result upd(Manage manage);
Result del(Integer manageId);
}

View File

@ -0,0 +1,60 @@
package com.bwie.manage.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.constants.TokenConstants;
import com.bwie.common.domain.Manage;
import com.bwie.common.domain.User;
import com.bwie.common.result.Result;
import com.bwie.common.utils.JwtUtils;
import com.bwie.manage.mapper.ManageMapper;
import com.bwie.manage.service.ManageService;
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 ManageServiceCs implements ManageService {
@Autowired
private ManageMapper manageMapper;
@Autowired
private RedisTemplate<String ,String > redisTemplate;
@Autowired
private HttpServletRequest request;
@Override
public Result list() {
List<Manage> list = manageMapper.list();
return Result.success(list,"列表");
}
@Override
public Result add(Manage manage) {
String token = request.getHeader("token");
String userKey = JwtUtils.getUserKey(token);
String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
User user = JSONObject.parseObject(s, User.class);
manage.setId(user.getId());
Manage all = manageMapper.findAll(manage);
if (all!=null){
return Result.error("存在此病人不能添加");
}
Integer add=manageMapper.add(manage);
return Result.success(add>0?200:500,add>0?"添加成功":"添加失败");
}
@Override
public Result upd(Manage manage) {
Integer upd=manageMapper.upd(manage);
return Result.success(upd>0?200:500,upd>0?"添加成功":"添加失败");
}
@Override
public Result del(Integer manageId) {
Integer del=manageMapper.del(manageId);
return Result.success(del>0?200:500,del>0?"添加成功":"添加失败");
}
}

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 9005
# Spring
spring:
main:
allow-circular-references: true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
application:
# 应用名称
name: bwie-manage
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}

View File

@ -0,0 +1,23 @@
<?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.manage.mapper.ManageMapper">
<insert id="add">
INSERT INTO `health`.`t_manage` (`case_id`, `id`)
VALUES (#{caseId}, #{id});
</insert>
<update id="upd">
UPDATE `health`.`t_manage` SET `case_id` = #{caseId},
`id` = #{id}
WHERE `manage_id` = #{manageId};
</update>
<delete id="del">
delete from t_manage where manage_id=#{manageId}
</delete>
<select id="list" resultType="com.bwie.common.domain.Manage">
select m.*,c.case_name,c.case_time,c.case_message,u.username from t_manage m left join cases c on m.case_id=c.case_id
left join user u on m.id=u.id
</select>
<select id="findAll" resultType="com.bwie.common.domain.Manage">
select *from t_manage where case_id=#{caseId} and id=#{id}
</select>
</mapper>

View File

@ -16,6 +16,7 @@
<module>bwie-health</module>
<module>bwie-formation</module>
<module>bwie-cases</module>
<module>bwie-manage</module>
</modules>
<properties>
@ -24,4 +25,4 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
</project>