搭建整体框架和跨域配置
This commit is contained in:
parent
799eb44330
commit
6316dd2167
96
pom.xml
Normal file
96
pom.xml
Normal file
@ -0,0 +1,96 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.zoo</groupId>
|
||||
<artifactId>zooSystemDemo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>zooSystem</name>
|
||||
<description>zooSystem</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>2.7.6</spring-boot.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>com.ZooSystemApplication</mainClass>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
37
src/main/java/com/CodeGenerator.java
Normal file
37
src/main/java/com/CodeGenerator.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
||||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class CodeGenerator {
|
||||
public static void main(String[] args) {
|
||||
String url = "jdbc:mysql://localhost:3306/zoo";
|
||||
String username = "root";
|
||||
String password = "83363083a";
|
||||
String moduleName = "zoo";
|
||||
String table = "admin,animal,keeper,veterinary";
|
||||
String mapperLocation = "C:\\Users\\16058\\IdeaProjects\\zooSystem\\src\\main\\resources\\mapper\\";
|
||||
FastAutoGenerator.create(url, username, password)
|
||||
.globalConfig(builder -> {
|
||||
builder.author("DJ") // 设置作者
|
||||
// .enableSwagger() // 开启 swagger 模式
|
||||
// .fileOverride() // 覆盖已生成文件
|
||||
.outputDir("C:\\Users\\16058\\IdeaProjects\\zooSystem\\src\\main\\java"); // 指定输出目录
|
||||
})
|
||||
.packageConfig(builder -> {
|
||||
builder.parent("com") // 设置父包名
|
||||
.moduleName(moduleName) // 设置父包模块名
|
||||
.pathInfo(Collections.singletonMap(OutputFile.xml,mapperLocation)); // 设置mapperXml生成路径
|
||||
})
|
||||
.strategyConfig(builder -> {
|
||||
builder.addInclude(table) // 设置需要生成的表名
|
||||
.addTablePrefix(); // 设置过滤表前缀
|
||||
})
|
||||
.templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
|
||||
.execute();
|
||||
}
|
||||
}
|
15
src/main/java/com/ZooSystemApplication.java
Normal file
15
src/main/java/com/ZooSystemApplication.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.zoo.mapper")
|
||||
public class ZooSystemApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ZooSystemApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
27
src/main/java/com/zoo/config/MyCorsConfig.java
Normal file
27
src/main/java/com/zoo/config/MyCorsConfig.java
Normal file
@ -0,0 +1,27 @@
|
||||
package com.zoo.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
@Configuration
|
||||
public class MyCorsConfig {
|
||||
//跨越处理
|
||||
@Bean
|
||||
public CorsFilter corsFilter(){
|
||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
//允许跨域的地址
|
||||
corsConfiguration.addAllowedOrigin("http://localhost:8888");
|
||||
//http://localhost:8080
|
||||
//是否发送cookie信息
|
||||
corsConfiguration.setAllowCredentials(true);
|
||||
corsConfiguration.addAllowedMethod("*");
|
||||
corsConfiguration.addAllowedHeader("*");
|
||||
//添加映射路径,拦截一切请求
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**",corsConfiguration);
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
}
|
40
src/main/java/com/zoo/controller/AdminController.java
Normal file
40
src/main/java/com/zoo/controller/AdminController.java
Normal file
@ -0,0 +1,40 @@
|
||||
package com.zoo.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zoo.entity.Admin;
|
||||
import com.zoo.entity.Result;
|
||||
import com.zoo.service.IAdminService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/zoo/admin")
|
||||
public class AdminController {
|
||||
@Autowired
|
||||
IAdminService iAdminService;
|
||||
|
||||
@PostMapping("login")
|
||||
public Result login(Admin admin){
|
||||
if (admin.getUsername()==null || admin.getPassword() == null){
|
||||
return Result.error("用户名密码不能为空");
|
||||
}
|
||||
QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("username",admin.getUsername());
|
||||
queryWrapper.eq("password", admin.getPassword());
|
||||
Admin one = iAdminService.getOne(queryWrapper);
|
||||
if (one == null){
|
||||
return Result.error("用户名或密码错误,请重新登录");
|
||||
}
|
||||
return Result.ok(one,"登录成功");
|
||||
}
|
||||
|
||||
}
|
18
src/main/java/com/zoo/controller/AnimalController.java
Normal file
18
src/main/java/com/zoo/controller/AnimalController.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.zoo.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/zoo/animal")
|
||||
public class AnimalController {
|
||||
|
||||
}
|
18
src/main/java/com/zoo/controller/KeeperController.java
Normal file
18
src/main/java/com/zoo/controller/KeeperController.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.zoo.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/zoo/keeper")
|
||||
public class KeeperController {
|
||||
|
||||
}
|
18
src/main/java/com/zoo/controller/VeterinaryController.java
Normal file
18
src/main/java/com/zoo/controller/VeterinaryController.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.zoo.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/zoo/veterinary")
|
||||
public class VeterinaryController {
|
||||
|
||||
}
|
49
src/main/java/com/zoo/entity/Admin.java
Normal file
49
src/main/java/com/zoo/entity/Admin.java
Normal file
@ -0,0 +1,49 @@
|
||||
package com.zoo.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public class Admin implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 管理员用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 管理员密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Admin{" +
|
||||
"username=" + username +
|
||||
", password=" + password +
|
||||
"}";
|
||||
}
|
||||
}
|
166
src/main/java/com/zoo/entity/Animal.java
Normal file
166
src/main/java/com/zoo/entity/Animal.java
Normal file
@ -0,0 +1,166 @@
|
||||
package com.zoo.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public class Animal implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 动物ID
|
||||
*/
|
||||
private Integer aId;
|
||||
|
||||
/**
|
||||
* 动物名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 种类
|
||||
*/
|
||||
private String species;
|
||||
|
||||
/**
|
||||
* 体重
|
||||
*/
|
||||
private Double weight;
|
||||
|
||||
/**
|
||||
* 身高
|
||||
*/
|
||||
private Double height;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1异常)
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 饲养员ID
|
||||
*/
|
||||
private Integer kId;
|
||||
|
||||
/**
|
||||
* 颜色
|
||||
*/
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 特征
|
||||
*/
|
||||
private String features;
|
||||
|
||||
/**
|
||||
* 生活习性
|
||||
*/
|
||||
private String habit;
|
||||
|
||||
public Integer getaId() {
|
||||
return aId;
|
||||
}
|
||||
|
||||
public void setaId(Integer aId) {
|
||||
this.aId = aId;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
public String getSpecies() {
|
||||
return species;
|
||||
}
|
||||
|
||||
public void setSpecies(String species) {
|
||||
this.species = species;
|
||||
}
|
||||
public Double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(Double weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
public Double getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(Double height) {
|
||||
this.height = height;
|
||||
}
|
||||
public Integer getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(Integer state) {
|
||||
this.state = state;
|
||||
}
|
||||
public Integer getkId() {
|
||||
return kId;
|
||||
}
|
||||
|
||||
public void setkId(Integer kId) {
|
||||
this.kId = kId;
|
||||
}
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
public String getFeatures() {
|
||||
return features;
|
||||
}
|
||||
|
||||
public void setFeatures(String features) {
|
||||
this.features = features;
|
||||
}
|
||||
public String getHabit() {
|
||||
return habit;
|
||||
}
|
||||
|
||||
public void setHabit(String habit) {
|
||||
this.habit = habit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Animal{" +
|
||||
"aId=" + aId +
|
||||
", name=" + name +
|
||||
", sex=" + sex +
|
||||
", species=" + species +
|
||||
", weight=" + weight +
|
||||
", height=" + height +
|
||||
", state=" + state +
|
||||
", kId=" + kId +
|
||||
", color=" + color +
|
||||
", features=" + features +
|
||||
", habit=" + habit +
|
||||
"}";
|
||||
}
|
||||
}
|
88
src/main/java/com/zoo/entity/Keeper.java
Normal file
88
src/main/java/com/zoo/entity/Keeper.java
Normal file
@ -0,0 +1,88 @@
|
||||
package com.zoo.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public class Keeper implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 饲养员id
|
||||
*/
|
||||
private Integer kId;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 饲养员用户名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 饲养员密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
public Integer getkId() {
|
||||
return kId;
|
||||
}
|
||||
|
||||
public void setkId(Integer kId) {
|
||||
this.kId = kId;
|
||||
}
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Keeper{" +
|
||||
"kId=" + kId +
|
||||
", sex=" + sex +
|
||||
", userName=" + userName +
|
||||
", password=" + password +
|
||||
", phone=" + phone +
|
||||
"}";
|
||||
}
|
||||
}
|
101
src/main/java/com/zoo/entity/Result.java
Normal file
101
src/main/java/com/zoo/entity/Result.java
Normal file
@ -0,0 +1,101 @@
|
||||
package com.zoo.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author dj
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Data
|
||||
public class Result<T> {
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
private Integer code;
|
||||
/**
|
||||
* 提示信息,如果有错误时,前端可以获取该字段进行提示
|
||||
*/
|
||||
private String msg;
|
||||
/**
|
||||
* 查询到的结果数据,
|
||||
*/
|
||||
private T data;
|
||||
|
||||
public Result(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Result(Integer code, T data) {
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Result(Integer code, T data,String msg) {
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回通用成功
|
||||
* @return Result
|
||||
*/
|
||||
public static Result ok(){
|
||||
|
||||
return new Result(20000,"请求成功");
|
||||
}
|
||||
|
||||
|
||||
public static Result ok(Object data,String msg){
|
||||
|
||||
return new Result(20000,data,msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回通用失败,未知错误
|
||||
* @return Result
|
||||
*/
|
||||
public static Result error(){
|
||||
|
||||
return new Result(20001,"请求失败");
|
||||
}
|
||||
|
||||
public static Result error(String msg){
|
||||
|
||||
return new Result(20001,msg);
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Result(Integer code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
75
src/main/java/com/zoo/entity/Veterinary.java
Normal file
75
src/main/java/com/zoo/entity/Veterinary.java
Normal file
@ -0,0 +1,75 @@
|
||||
package com.zoo.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public class Veterinary implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 兽医id
|
||||
*/
|
||||
private Integer vId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 治疗记录
|
||||
*/
|
||||
private String record;
|
||||
|
||||
public Integer getvId() {
|
||||
return vId;
|
||||
}
|
||||
|
||||
public void setvId(Integer vId) {
|
||||
this.vId = vId;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
public String getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
public void setRecord(String record) {
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Veterinary{" +
|
||||
"vId=" + vId +
|
||||
", username=" + username +
|
||||
", password=" + password +
|
||||
", record=" + record +
|
||||
"}";
|
||||
}
|
||||
}
|
16
src/main/java/com/zoo/mapper/AdminMapper.java
Normal file
16
src/main/java/com/zoo/mapper/AdminMapper.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.zoo.mapper;
|
||||
|
||||
import com.zoo.entity.Admin;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public interface AdminMapper extends BaseMapper<Admin> {
|
||||
|
||||
}
|
16
src/main/java/com/zoo/mapper/AnimalMapper.java
Normal file
16
src/main/java/com/zoo/mapper/AnimalMapper.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.zoo.mapper;
|
||||
|
||||
import com.zoo.entity.Animal;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public interface AnimalMapper extends BaseMapper<Animal> {
|
||||
|
||||
}
|
16
src/main/java/com/zoo/mapper/KeeperMapper.java
Normal file
16
src/main/java/com/zoo/mapper/KeeperMapper.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.zoo.mapper;
|
||||
|
||||
import com.zoo.entity.Keeper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public interface KeeperMapper extends BaseMapper<Keeper> {
|
||||
|
||||
}
|
16
src/main/java/com/zoo/mapper/VeterinaryMapper.java
Normal file
16
src/main/java/com/zoo/mapper/VeterinaryMapper.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.zoo.mapper;
|
||||
|
||||
import com.zoo.entity.Veterinary;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public interface VeterinaryMapper extends BaseMapper<Veterinary> {
|
||||
|
||||
}
|
16
src/main/java/com/zoo/service/IAdminService.java
Normal file
16
src/main/java/com/zoo/service/IAdminService.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.zoo.service;
|
||||
|
||||
import com.zoo.entity.Admin;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public interface IAdminService extends IService<Admin> {
|
||||
|
||||
}
|
16
src/main/java/com/zoo/service/IAnimalService.java
Normal file
16
src/main/java/com/zoo/service/IAnimalService.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.zoo.service;
|
||||
|
||||
import com.zoo.entity.Animal;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public interface IAnimalService extends IService<Animal> {
|
||||
|
||||
}
|
16
src/main/java/com/zoo/service/IKeeperService.java
Normal file
16
src/main/java/com/zoo/service/IKeeperService.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.zoo.service;
|
||||
|
||||
import com.zoo.entity.Keeper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public interface IKeeperService extends IService<Keeper> {
|
||||
|
||||
}
|
16
src/main/java/com/zoo/service/IVeterinaryService.java
Normal file
16
src/main/java/com/zoo/service/IVeterinaryService.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.zoo.service;
|
||||
|
||||
import com.zoo.entity.Veterinary;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
public interface IVeterinaryService extends IService<Veterinary> {
|
||||
|
||||
}
|
20
src/main/java/com/zoo/service/impl/AdminServiceImpl.java
Normal file
20
src/main/java/com/zoo/service/impl/AdminServiceImpl.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.zoo.service.impl;
|
||||
|
||||
import com.zoo.entity.Admin;
|
||||
import com.zoo.mapper.AdminMapper;
|
||||
import com.zoo.service.IAdminService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
@Service
|
||||
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements IAdminService {
|
||||
|
||||
}
|
20
src/main/java/com/zoo/service/impl/AnimalServiceImpl.java
Normal file
20
src/main/java/com/zoo/service/impl/AnimalServiceImpl.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.zoo.service.impl;
|
||||
|
||||
import com.zoo.entity.Animal;
|
||||
import com.zoo.mapper.AnimalMapper;
|
||||
import com.zoo.service.IAnimalService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
@Service
|
||||
public class AnimalServiceImpl extends ServiceImpl<AnimalMapper, Animal> implements IAnimalService {
|
||||
|
||||
}
|
20
src/main/java/com/zoo/service/impl/KeeperServiceImpl.java
Normal file
20
src/main/java/com/zoo/service/impl/KeeperServiceImpl.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.zoo.service.impl;
|
||||
|
||||
import com.zoo.entity.Keeper;
|
||||
import com.zoo.mapper.KeeperMapper;
|
||||
import com.zoo.service.IKeeperService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
@Service
|
||||
public class KeeperServiceImpl extends ServiceImpl<KeeperMapper, Keeper> implements IKeeperService {
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.zoo.service.impl;
|
||||
|
||||
import com.zoo.entity.Veterinary;
|
||||
import com.zoo.mapper.VeterinaryMapper;
|
||||
import com.zoo.service.IVeterinaryService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author DJ
|
||||
* @since 2024-04-18
|
||||
*/
|
||||
@Service
|
||||
public class VeterinaryServiceImpl extends ServiceImpl<VeterinaryMapper, Veterinary> implements IVeterinaryService {
|
||||
|
||||
}
|
67
src/main/java/com/zoo/web/BasicController.java
Normal file
67
src/main/java/com/zoo/web/BasicController.java
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zoo.web;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
|
||||
*/
|
||||
@Controller
|
||||
public class BasicController {
|
||||
|
||||
// http://127.0.0.1:8080/hello?name=lisi
|
||||
@RequestMapping("/hello")
|
||||
@ResponseBody
|
||||
public String hello(@RequestParam(name = "name", defaultValue = "unknown user") String name) {
|
||||
return "Hello " + name;
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/user
|
||||
@RequestMapping("/user")
|
||||
@ResponseBody
|
||||
public User user() {
|
||||
User user = new User();
|
||||
user.setName("theonefx");
|
||||
user.setAge(666);
|
||||
return user;
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/save_user?name=newName&age=11
|
||||
@RequestMapping("/save_user")
|
||||
@ResponseBody
|
||||
public String saveUser(User u) {
|
||||
return "user will save: name=" + u.getName() + ", age=" + u.getAge();
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/html
|
||||
@RequestMapping("/html")
|
||||
public String html() {
|
||||
return "index.html";
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public void parseUser(@RequestParam(name = "name", defaultValue = "unknown user") String name
|
||||
, @RequestParam(name = "age", defaultValue = "12") Integer age, User user) {
|
||||
user.setName("zhangsan");
|
||||
user.setAge(18);
|
||||
}
|
||||
}
|
44
src/main/java/com/zoo/web/PathVariableController.java
Normal file
44
src/main/java/com/zoo/web/PathVariableController.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zoo.web;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
|
||||
*/
|
||||
@Controller
|
||||
public class PathVariableController {
|
||||
|
||||
// http://127.0.0.1:8080/user/123/roles/222
|
||||
@RequestMapping(value = "/user/{userId}/roles/{roleId}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public String getLogin(@PathVariable("userId") String userId, @PathVariable("roleId") String roleId) {
|
||||
return "User Id : " + userId + " Role Id : " + roleId;
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/javabeat/somewords
|
||||
@RequestMapping(value = "/javabeat/{regexp1:[a-z-]+}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public String getRegExp(@PathVariable("regexp1") String regexp1) {
|
||||
return "URI Part : " + regexp1;
|
||||
}
|
||||
}
|
43
src/main/java/com/zoo/web/User.java
Normal file
43
src/main/java/com/zoo/web/User.java
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zoo.web;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
|
||||
*/
|
||||
public class User {
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer age;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
}
|
8
src/main/resources/application.yml
Normal file
8
src/main/resources/application.yml
Normal file
@ -0,0 +1,8 @@
|
||||
# 应用服务 WEB 访问端口
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/zoo
|
||||
username: root
|
||||
password: 83363083a
|
||||
|
5
src/main/resources/mapper/AdminMapper.xml
Normal file
5
src/main/resources/mapper/AdminMapper.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?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.zoo.mapper.AdminMapper">
|
||||
|
||||
</mapper>
|
5
src/main/resources/mapper/AnimalMapper.xml
Normal file
5
src/main/resources/mapper/AnimalMapper.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?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.zoo.mapper.AnimalMapper">
|
||||
|
||||
</mapper>
|
5
src/main/resources/mapper/KeeperMapper.xml
Normal file
5
src/main/resources/mapper/KeeperMapper.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?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.zoo.mapper.KeeperMapper">
|
||||
|
||||
</mapper>
|
5
src/main/resources/mapper/VeterinaryMapper.xml
Normal file
5
src/main/resources/mapper/VeterinaryMapper.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?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.zoo.mapper.VeterinaryMapper">
|
||||
|
||||
</mapper>
|
6
src/main/resources/static/index.html
Normal file
6
src/main/resources/static/index.html
Normal file
@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>hello word!!!</h1>
|
||||
<p>this is a html page</p>
|
||||
</body>
|
||||
</html>
|
13
src/test/java/com/ZooSystemApplicationTests.java
Normal file
13
src/test/java/com/ZooSystemApplicationTests.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ZooSystemApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user