完成所有信息的增删改查操作,基础的业务逻辑已经完成

This commit is contained in:
dongjie 2024-06-07 18:26:04 +08:00
parent 165b0e9ea8
commit 99b24e35ec
41 changed files with 795 additions and 20 deletions

141
README.md
View File

@ -1,8 +1,143 @@
# ZooSystem
登录接口
#### **登录接口**
请求post请求
```
url: http://localhost:8080/zoo/login/login
```
输入参数 usernameadmin password123
返回类型为R
账户正确返回数据: {"code": 1,"msg": null,"data": {"roleid": 1,"name": "管理员","permissions": 0 },"map": {} }
错误使返回数据: {"code": 0,"msg": "账号密码错误","data": null,"map": {} }
账户正确返回数据:
```
{"code": 1,"msg": null,"data": {"roleid": 1,"name": "管理员","permissions": 0 },"map": {} }
```
错误使返回数据:
```
{"code": 0,"msg": "账号密码错误","data": null,"map": {} }
```
输入参数 usernameadmin password123
返回类型为R
账户正确返回数据:
```
{"code": 1,"msg": null,"data": {"roleid": 1,"name": "管理员","permissions": 0 },"map": {} }
```
错误使返回数据:
```
{"code": 0,"msg": "账号密码错误","data": null,"map": {} }
```
#### **动物信息管理接口**
###### **查询接口**
```
GET http://localhost:8888/zoo/animal/info
```
当请求头带有查找的aid时就只查出对应id的动物信息
###### 返回如下:
```
{
"code": 1,
"msg": null,
"data": [
{
"aId": 1,
"name": "旺财",
"sex": "1",
"species": "中华田园犬",
"weight": 20,
"height": 90,
"state": 0,
"roleid": 1,
"color": "黄",
"features": "亲人,性格温和",
"phase": "成年期"
},
{
"aId": 2,
"name": "小黑",
"sex": "1",
"species": "蓝猫",
"weight": 10,
"height": 40,
"state": 0,
"roleid": 1,
"color": "蓝黑",
"features": "不爱动",
"phase": "幼年期"
}
],
"map": {}
}
```
#### 添加接口:
```
POST : http://localhost:8888/zoo/animal/add
```
在请求体中输入数据各个属性的值
返回如下:
```
{
"code": 1,
"msg": null,
"data": "添加成功",
"map": {}
}
```
#### 修改接口:
```
POST:http://localhost:8888/zoo/animal/update
```
在请求体中输入数据各个属性的值
返回如下:
```
{
"code": 1,
"msg": null,
"data": "修改成功",
"map": {}
}
```
#### 删除接口:
```
GET:http://localhost:8888/zoo/animal/delete?aid=3
```
返回数据
```
{
"code": 1,
"msg": null,
"data": "删除成功",
"map": {}
}
```
**其他各种接口信息都如以上接口一般实现了基本的增删改查接口当操作成功时返回码code为1失败时为0**

View File

@ -13,7 +13,7 @@ public class CodeGenerator {
String username = "root";
String password = "83363083a";
String moduleName = "com/zoo";
String table = "account,admin,animal,keeper,veterinary,breedingplan";
String table = "account,admin,animal,keeper,veterinary,breedingplan,health,archive";
String mapperLocation = "C:\\Users\\16058\\IdeaProjects\\zooSystem\\src\\main\\resources\\mapper\\";
FastAutoGenerator.create(url, username, password)
.globalConfig(builder -> {

View File

@ -1,7 +1,9 @@
package com.zoo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zoo.common.R;
import com.zoo.entity.Admin;
import com.zoo.entity.Animal;
import com.zoo.entity.Keeper;
import com.zoo.entity.Veterinary;
import com.zoo.service.IAdminService;
@ -29,8 +31,11 @@ public class AdminController {
IAdminService iAdminService;
@GetMapping("/info")
public R info(Integer id){
QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
if (id!=null){
Admin admin = iAdminService.selectById(id);
queryWrapper.eq("roleid",id);
Admin admin = iAdminService.getOne(queryWrapper);
return R.success(admin);
}
List<Admin> list = iAdminService.list();
@ -47,15 +52,19 @@ public class AdminController {
@PostMapping("/update")
public R update(Admin admin){
boolean b = iAdminService.updateById(admin);
QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleid",admin.getRoleid());
boolean b = iAdminService.update(admin,queryWrapper);
if (b){
return R.success("修改成功");
}
return R.error("修改失败");
}
@GetMapping("/delete")
public R delete(Integer id){
boolean b = iAdminService.removeById(id);
public R delete(Integer roleid){
QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleid",roleid);
boolean b = iAdminService.remove(queryWrapper);
if (b){
return R.success("删除成功");
}

View File

@ -29,7 +29,7 @@ public class AnimalController {
public R info(Integer aid){
if (aid != null){
QueryWrapper<Animal> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("aid",aid);
queryWrapper.eq("a_id",aid);
Animal one = iAnimalService.getOne(queryWrapper);
R.success(one);
}
@ -47,7 +47,9 @@ public class AnimalController {
@PostMapping("/update")
public R update(Animal animal){
boolean b = iAnimalService.updateById(animal);
QueryWrapper<Animal> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("a_id",animal.getaId());
boolean b = iAnimalService.update(animal,queryWrapper);
if (b){
return R.success("修改成功");
}
@ -55,7 +57,9 @@ public class AnimalController {
}
@GetMapping("/delete")
public R delete(Integer aid){
boolean b = iAnimalService.removeById(aid);
QueryWrapper<Animal> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("a_id",aid);
boolean b = iAnimalService.remove(queryWrapper);
if (b){
return R.success("删除成功");
}

View File

@ -0,0 +1,79 @@
package com.zoo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zoo.common.R;
import com.zoo.entity.Archive;
import com.zoo.entity.Breedingplan;
import com.zoo.entity.Veterinary;
import com.zoo.service.IArchiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author DJ
* @since 2024-06-07
*/
@RestController
@RequestMapping("/com/zoo/archive")
public class ArchiveController {
@Autowired
IArchiveService iArchiveService;
@GetMapping("info")
public R info(Integer id,Integer animallId){
QueryWrapper<Archive> queryWrapper = new QueryWrapper<>();
if (id!=null){
queryWrapper.eq("id",id);
Archive one = iArchiveService.getOne(queryWrapper);
return R.success(one);
}
if (animallId!=null){
queryWrapper.eq("animallId",animallId);
List<Archive> list = iArchiveService.list(queryWrapper);
return R.success(list);
}
return R.success(iArchiveService.list());
}
@PostMapping("/add")
public R add(Archive archive){
boolean save = iArchiveService.save(archive);
if (save){
return R.success("添加成功");
}
return R.error("添加失败");
}
@PostMapping("/update")
public R update(Archive archive){
QueryWrapper<Archive> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",archive.getId());
boolean update = iArchiveService.update(archive,queryWrapper);
if (update){
return R.success("修改成功");
}
return R.error("修改失败");
}
@GetMapping("/delete")
public R delete(Integer id){
QueryWrapper<Archive> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",id);
boolean remove = iArchiveService.remove(queryWrapper);
if (remove){
return R.success("删除成功");
}
return R.error("删除失败");
}
}

View File

@ -43,7 +43,9 @@ public class BreedingplanController {
@PostMapping("/update")
public R update(Breedingplan breedingplan){
boolean b = iBreedingplanService.updateById(breedingplan);
QueryWrapper<Breedingplan> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",breedingplan.getId());
boolean b = iBreedingplanService.update(breedingplan,queryWrapper);
if (b){
return R.success("修改成功");
}
@ -51,7 +53,9 @@ public class BreedingplanController {
}
@GetMapping("/delete")
public R delete(Integer id){
boolean b = iBreedingplanService.removeById(id);
QueryWrapper<Breedingplan> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",id);
boolean b = iBreedingplanService.remove(queryWrapper);
if (b){
return R.success("删除成功");
}

View File

@ -0,0 +1,73 @@
package com.zoo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zoo.common.R;
import com.zoo.entity.Health;
import com.zoo.service.IHealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author DJ
* @since 2024-06-07
*/
@RestController
@RequestMapping("/com/zoo/health")
public class HealthController {
@Autowired
IHealthService iHealthService;
@GetMapping("info")
public R info(Integer id, Integer animallId){
QueryWrapper<Health> queryWrapper = new QueryWrapper<>();
if (id!=null){
queryWrapper.eq("id",id);
Health one = iHealthService.getOne(queryWrapper);
return R.success(one);
}
if (animallId!=null){
queryWrapper.eq("animallId",animallId);
List<Health> list = iHealthService.list(queryWrapper);
return R.success(list);
}
return R.success(iHealthService.list());
}
@PostMapping("/add")
public R add(Health health){
boolean save = iHealthService.save(health);
if (save){
return R.success("添加成功");
}
return R.error("添加失败");
}
@PostMapping("/update")
public R update(Health health){
boolean update = iHealthService.save(health);
if (update){
return R.success("修改成功");
}
return R.error("修改失败");
}
@GetMapping("/delete")
public R delete(Integer id){
QueryWrapper<Health> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",id);
boolean remove = iHealthService.remove(queryWrapper);
if (remove){
return R.success("删除成功");
}
return R.error("删除失败");
}
}

View File

@ -1,7 +1,9 @@
package com.zoo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zoo.common.R;
import com.zoo.entity.Animal;
import com.zoo.entity.Breedingplan;
import com.zoo.entity.Keeper;
import com.zoo.entity.Veterinary;
import com.zoo.service.IKeeperService;
@ -31,7 +33,9 @@ public class KeeperController {
@GetMapping("info")
public R info(Integer roleid){
if (roleid!=null){
Keeper keeper = iKeeperService.selectById(roleid);
QueryWrapper<Keeper> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleid",roleid);
Keeper keeper = iKeeperService.getOne(queryWrapper);
return R.success(keeper);
}
List<Keeper> list = iKeeperService.list();
@ -48,7 +52,9 @@ public class KeeperController {
@PostMapping("/update")
public R update(Keeper keeper){
boolean b = iKeeperService.updateById(keeper);
QueryWrapper<Keeper> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleid",keeper.getRoleid());
boolean b = iKeeperService.update(keeper,queryWrapper);
if (b){
return R.success("修改成功");
}
@ -56,7 +62,9 @@ public class KeeperController {
}
@GetMapping("/delete")
public R delete(Integer roleid){
boolean b = iKeeperService.removeById(roleid);
QueryWrapper<Keeper> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleid",roleid);
boolean b = iKeeperService.remove(queryWrapper);
if (b){
return R.success("删除成功");
}

View File

@ -1,5 +1,6 @@
package com.zoo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zoo.common.R;
import com.zoo.entity.Keeper;
import com.zoo.entity.Veterinary;
@ -29,7 +30,9 @@ public class VeterinaryController {
@GetMapping("info")
public R info(Integer roleid){
if (roleid!=null){
Veterinary veterinary = iVeterinaryService.selectById(roleid);
QueryWrapper<Veterinary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleid",roleid);
Veterinary veterinary = iVeterinaryService.getOne(queryWrapper);
return R.success(veterinary);
}
List<Veterinary> list = iVeterinaryService.list();
@ -46,7 +49,9 @@ public class VeterinaryController {
@PostMapping("/update")
public R update(Veterinary veterinary){
boolean b = iVeterinaryService.updateById(veterinary);
QueryWrapper<Veterinary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleid",veterinary.getRoleid());
boolean b = iVeterinaryService.update(veterinary,queryWrapper);
if (b){
return R.success("修改成功");
}
@ -54,7 +59,9 @@ public class VeterinaryController {
}
@GetMapping("/delete")
public R delete(Integer roleid){
boolean b = iVeterinaryService.removeById(roleid);
QueryWrapper<Veterinary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleid",roleid);
boolean b = iVeterinaryService.remove(queryWrapper);
if (b){
return R.success("删除成功");
}

View File

@ -0,0 +1,154 @@
package com.zoo.entity;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author DJ
* @since 2024-06-07
*/
public class Archive implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 档案号
*/
private Integer id;
/**
* 动物id
*/
private Integer animallId;
/**
* 动物名称
*/
private String animalName;
/**
* 生命阶段
*/
private String phase;
/**
* 状态 0 正常 1不正常
*/
private Integer state;
/**
* 档案类型
*/
private String type;
/**
* 记录日期
*/
private String date;
/**
* 记录时间
*/
private String time;
/**
* 录入人id
*/
private Integer roleId;
/**
* 描述
*/
private String description;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getAnimallId() {
return animallId;
}
public void setAnimallId(Integer animallId) {
this.animallId = animallId;
}
public String getAnimalName() {
return animalName;
}
public void setAnimalName(String animalName) {
this.animalName = animalName;
}
public String getPhase() {
return phase;
}
public void setPhase(String phase) {
this.phase = phase;
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public Integer getRoleId() {
return roleId;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
return "Archive{" +
"id=" + id +
", animallId=" + animallId +
", animalName=" + animalName +
", phase=" + phase +
", state=" + state +
", type=" + type +
", date=" + date +
", time=" + time +
", roleId=" + roleId +
", description=" + description +
"}";
}
}

View File

@ -0,0 +1,167 @@
package com.zoo.entity;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author DJ
* @since 2024-06-07
*/
public class Health implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 健康数据编号
*/
private Integer id;
/**
* 动物id
*/
private Integer animalId;
/**
* 动物名称
*/
private String animalName;
/**
* 状态 0正常 1不正常
*/
private Integer state;
/**
* 体温
*/
private Double temperature;
/**
* 呼吸频率
*/
private Integer breathRete;
/**
* 心跳频率
*/
private Integer heartRete;
/**
* 血压
*/
private Integer bloodPressure;
/**
* 记录日期
*/
private String date;
/**
* 记录时间
*/
private String time;
/**
* 描述
*/
private String description;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getAnimalId() {
return animalId;
}
public void setAnimalId(Integer animalId) {
this.animalId = animalId;
}
public String getAnimalName() {
return animalName;
}
public void setAnimalName(String animalName) {
this.animalName = animalName;
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
public Double getTemperature() {
return temperature;
}
public void setTemperature(Double temperature) {
this.temperature = temperature;
}
public Integer getBreathRete() {
return breathRete;
}
public void setBreathRete(Integer breathRete) {
this.breathRete = breathRete;
}
public Integer getHeartRete() {
return heartRete;
}
public void setHeartRete(Integer heartRete) {
this.heartRete = heartRete;
}
public Integer getBloodPressure() {
return bloodPressure;
}
public void setBloodPressure(Integer bloodPressure) {
this.bloodPressure = bloodPressure;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
return "Health{" +
"id=" + id +
", animalId=" + animalId +
", animalName=" + animalName +
", state=" + state +
", temperature=" + temperature +
", breathRete=" + breathRete +
", heartRete=" + heartRete +
", bloodPressure=" + bloodPressure +
", date=" + date +
", time=" + time +
", description=" + description +
"}";
}
}

View File

@ -0,0 +1,17 @@
package com.zoo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zoo.entity.Archive;
/**
* <p>
* Mapper 接口
* </p>
*
* @author DJ
* @since 2024-06-07
*/
public interface ArchiveMapper extends BaseMapper<Archive> {
}

View File

@ -0,0 +1,17 @@
package com.zoo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zoo.entity.Health;
/**
* <p>
* Mapper 接口
* </p>
*
* @author DJ
* @since 2024-06-07
*/
public interface HealthMapper extends BaseMapper<Health> {
}

View File

@ -0,0 +1,17 @@
package com.zoo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zoo.entity.Archive;
/**
* <p>
* 服务类
* </p>
*
* @author DJ
* @since 2024-06-07
*/
public interface IArchiveService extends IService<Archive> {
}

View File

@ -0,0 +1,17 @@
package com.zoo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zoo.entity.Health;
/**
* <p>
* 服务类
* </p>
*
* @author DJ
* @since 2024-06-07
*/
public interface IHealthService extends IService<Health> {
}

View File

@ -0,0 +1,23 @@
package com.zoo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zoo.entity.Archive;
import com.zoo.mapper.ArchiveMapper;
import com.zoo.service.IArchiveService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author DJ
* @since 2024-06-07
*/
@Service
public class ArchiveServiceImpl extends ServiceImpl<ArchiveMapper, Archive> implements IArchiveService {
}

View File

@ -0,0 +1,22 @@
package com.zoo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zoo.entity.Health;
import com.zoo.mapper.HealthMapper;
import com.zoo.service.IHealthService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author DJ
* @since 2024-06-07
*/
@Service
public class HealthServiceImpl extends ServiceImpl<HealthMapper, Health> implements IHealthService {
}

View File

@ -1,3 +1,4 @@
# 应用服务 WEB 访问端口
spring:
datasource:
@ -5,4 +6,5 @@ spring:
url: jdbc:mysql://localhost:3306/zoo
username: root
password: 83363083a
server:
port: 8888

View 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.com/zoo.mapper.ArchiveMapper">
</mapper>

View 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.com/zoo.mapper.HealthMapper">
</mapper>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View 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.com/zoo.mapper.ArchiveMapper">
</mapper>

View 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.com/zoo.mapper.HealthMapper">
</mapper>