forked from pt4ebqrwy/Epidemic
Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
fe9433ba45 | 1 year ago |
|
|
46dfc795d2 | 1 year ago |
@ -0,0 +1 @@
|
||||
Subproject commit df30c6ee517297783b8f1e46eba280b0300862b7
|
||||
@ -0,0 +1,14 @@
|
||||
package com.liu.covid;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.liu.covid.mapper")
|
||||
public class CovidApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CovidApplication.class, args);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.liu.covid.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
// 配置类,用于设置 MyBatis Plus 的拦截器
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
// 声明一个 MybatisPlusInterceptor Bean
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
// 创建 MybatisPlusInterceptor 对象
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
// 添加分页拦截器,指定数据库类型为 MySQL
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
// 返回配置完成的拦截器实例
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.liu.covid.controller;
|
||||
|
||||
|
||||
import com.liu.covid.entity.Department;
|
||||
import com.liu.covid.mapper.DepartMapper;
|
||||
import com.liu.covid.service.DepartService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// 控制器类,用于处理与部门相关的请求
|
||||
@RestController
|
||||
@RequestMapping("/depart")
|
||||
public class DepartController {
|
||||
|
||||
// 自动注入 DepartService 服务
|
||||
@Autowired
|
||||
DepartService service;
|
||||
|
||||
// 处理 GET 请求,返回所有部门信息的列表// 处理 GET 请求,返回所有部门信息的列表
|
||||
@GetMapping("/findAll")
|
||||
private List<String> findAll(){
|
||||
return service.getAll();
|
||||
}// 调用服务层方法获取所有部门信息
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.liu.covid.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.liu.covid.entity.EmpHealth;
|
||||
import com.liu.covid.mapper.EmpMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
// 控制器类,用于处理与员工健康信息相关的请求
|
||||
@RestController
|
||||
@RequestMapping("/emp")
|
||||
public class EmpController {
|
||||
// 自动注入 EmpMapper 对象
|
||||
@Autowired
|
||||
private EmpMapper mapper;
|
||||
|
||||
// 分页查询员工健康信息
|
||||
@GetMapping("/findAll/{page}/{size}")
|
||||
public Page<EmpHealth> findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size){
|
||||
// 创建查询条件,按创建时间降序排列
|
||||
QueryWrapper<EmpHealth> wrapper=new QueryWrapper<>();
|
||||
wrapper.orderByDesc("createTime");
|
||||
// 创建分页对象
|
||||
Page<EmpHealth> page1= new Page<>(page,size);
|
||||
// 执行分页查询并返回结果
|
||||
Page<EmpHealth> result=mapper.selectPage(page1,wrapper).addOrder();
|
||||
return result;
|
||||
}
|
||||
|
||||
// 保存员工健康信息
|
||||
@PostMapping("/save")
|
||||
public String save(@RequestBody EmpHealth emp){
|
||||
// 插入数据并返回操作结果
|
||||
int result = mapper.insert(emp);
|
||||
if (result==1){
|
||||
return "success";
|
||||
}else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
// 根据员工 ID 查询健康信息
|
||||
@GetMapping("/findById/{id}")
|
||||
public EmpHealth findById(@PathVariable("id") Integer id){
|
||||
return mapper.selectById(id);
|
||||
}// 根据 ID 查询数据并返回
|
||||
|
||||
// 更新员工健康信息
|
||||
@PutMapping("/update")
|
||||
public String update(@RequestBody EmpHealth emp){
|
||||
// 更新数据并返回操作结果
|
||||
int result=mapper.updateById(emp);
|
||||
if (result==1){
|
||||
return "success";
|
||||
}else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
// 根据员工 ID 删除健康信息
|
||||
@DeleteMapping("/deleteById/{id}")
|
||||
public void deleteById(@PathVariable("id")Long id){
|
||||
mapper.deleteById(id+"L");
|
||||
}// 删除指定 ID 的数据
|
||||
|
||||
// 根据指定字段和内容搜索员工健康信息
|
||||
@GetMapping("/search/{searchkey}/{stext}")
|
||||
public List<EmpHealth> search(@PathVariable("searchkey")String searchkey, @PathVariable("stext")String stext){
|
||||
// 创建查询条件,按指定字段进行模糊搜索
|
||||
QueryWrapper<EmpHealth> userQueryWrapper = Wrappers.query();
|
||||
userQueryWrapper.like(searchkey,stext);
|
||||
// 返回符合条件的数据列表
|
||||
return mapper.selectList(userQueryWrapper);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.liu.covid.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Department {
|
||||
@TableId
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String charge;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.liu.covid.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class User {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
private String username;
|
||||
private String password;
|
||||
private String depart;
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.liu.covid.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.liu.covid.entity.Department;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface DepartMapper extends BaseMapper<Department> {
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.liu.covid.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.liu.covid.entity.EmpIden;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EmpIdenMapper extends BaseMapper<EmpIden> {
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.liu.covid.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.liu.covid.entity.EmpIs;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EmpIsMapper extends BaseMapper<EmpIs> {
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.liu.covid.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.liu.covid.entity.EmpHealth;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EmpMapper extends BaseMapper<EmpHealth> {
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.liu.covid.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.liu.covid.entity.MaterialManage;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface MaterialMapper extends BaseMapper<MaterialManage> {
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.liu.covid.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.liu.covid.entity.User;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.liu.covid.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.liu.covid.entity.EmpIden;
|
||||
import com.liu.covid.vo.LineVO;
|
||||
import com.liu.covid.vo.PieVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ChartService extends IService<EmpIden> {
|
||||
public LineVO lineVOList();
|
||||
public List<PieVo> pieVOMap();
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.liu.covid.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.liu.covid.entity.Department;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DepartService extends IService<Department> {
|
||||
public List<String> getAll();
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.liu.covid.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.liu.covid.entity.User;
|
||||
|
||||
public interface UserService extends IService<User> {
|
||||
public String login(User user);
|
||||
public String register(User user);
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.liu.covid.util;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class test{
|
||||
public static void main(String[] args) throws SQLException {
|
||||
JDBCUtils jdbcConnection=new JDBCUtils();
|
||||
Connection connection=jdbcConnection.getConnection();
|
||||
if(connection!=null){
|
||||
System.out.println("数据库连接成功");
|
||||
}else {
|
||||
System.out.println("数据库连接失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.liu.covid.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class LineVO {
|
||||
private List<String> month;
|
||||
private Map<String,List> status;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.liu.covid.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PieVo {
|
||||
private String name;
|
||||
private Integer value;
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package org.example;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@ -0,0 +1,15 @@
|
||||
# 应用名称
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/covid?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: 123456
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
server:
|
||||
port: 8080
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
type-enums-package:
|
||||
com.liu.covid.entity
|
||||
@ -0,0 +1,13 @@
|
||||
package com.liu.covid;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class CovidApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.liu.covid.controller;
|
||||
|
||||
import com.liu.covid.entity.EmpHealth;
|
||||
import com.liu.covid.entity.User;
|
||||
import com.liu.covid.mapper.EmpMapper;
|
||||
import com.liu.covid.mapper.UserMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@SpringBootTest
|
||||
class LoginServiceTest {
|
||||
@Autowired
|
||||
private UserMapper mapper;
|
||||
@Test
|
||||
void register(){
|
||||
User user=new User();
|
||||
String pw=DigestUtils.md5DigestAsHex("99409".getBytes());
|
||||
user.setUsername("994091246");
|
||||
user.setPassword(pw);
|
||||
int message= mapper.insert(user);
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package com.liu.covid.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.liu.covid.entity.EmpIden;
|
||||
import com.liu.covid.entity.EmpIs;
|
||||
|
||||
import com.liu.covid.mapper.EmpIdenMapper;
|
||||
import com.liu.covid.mapper.EmpIsMapper;
|
||||
import com.liu.covid.vo.LineVO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.sql.Wrapper;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@SpringBootTest
|
||||
class MaterialControllerTest {
|
||||
@Autowired
|
||||
private EmpIdenMapper mapper;
|
||||
|
||||
@Test
|
||||
void find() {
|
||||
LineVO lineVO=new LineVO();
|
||||
Date date=new Date();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
List<String> month=new ArrayList<>();
|
||||
Map<String,Integer> status=new HashMap<>();
|
||||
Map<String,Map> all=new HashMap<>();
|
||||
String type[]={"确诊","疑似","治愈","死亡"};
|
||||
|
||||
for (int i=0;i<7;i++) {
|
||||
cal.setTime(date);
|
||||
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - i);
|
||||
SimpleDateFormat ft=new SimpleDateFormat("yyyy-MM");
|
||||
String mon=ft.format(cal.getTime());
|
||||
month.add(mon);
|
||||
}
|
||||
//设置折线图月份
|
||||
lineVO.setMonth(month);
|
||||
// 设置 类型-数量 键值对
|
||||
for (String t : type) {
|
||||
int j=0;
|
||||
while (j<7){
|
||||
QueryWrapper<EmpIden> userQueryWrapper = Wrappers.query();
|
||||
userQueryWrapper.like("status", t).likeRight("idate", month.get(j));
|
||||
Integer count = mapper.selectCount(userQueryWrapper);
|
||||
status.put(month.get(j++),count);
|
||||
userQueryWrapper.clear();
|
||||
}
|
||||
all.put(t,status);
|
||||
|
||||
}
|
||||
System.out.println(all.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package org.example;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="main" />
|
||||
</component>
|
||||
</module>
|
||||
Loading…
Reference in new issue