Compare commits

...

10 Commits

Author SHA1 Message Date
dongjie
3bbeea672d 添加饲养计划与档案关联 2024-06-23 07:34:10 +08:00
dongjie
8d3c862719 修改bug 2024-06-10 00:52:25 +08:00
dongjie
86a287cf8b 修改bug 2024-06-09 23:36:07 +08:00
dongjie
5399d16135 使id自增 2024-06-09 22:37:07 +08:00
dongjie
c1a879f9d4 修改没加return的接口 2024-06-09 17:44:36 +08:00
dongjie
4a6ea0fd86 修改查询用户接口,使其可以根据username查询账户 2024-06-09 17:25:35 +08:00
dongjie
4809c57412 集中角色表,重新写登录接口 2024-06-09 00:26:54 +08:00
dongjie
4e93cfb624 修改了各个角色的信息查询接口返回值,主要增加用户名密码和权限信息 2024-06-08 23:19:24 +08:00
dongjie
6af74df222 修改了其中接口的一些错误 2024-06-08 00:30:28 +08:00
dongjie
99b24e35ec 完成所有信息的增删改查操作,基础的业务逻辑已经完成 2024-06-07 18:26:04 +08:00
81 changed files with 877 additions and 656 deletions

141
README.md
View File

@ -1,8 +1,143 @@
# ZooSystem # ZooSystem
登录接口 #### **登录接口**
请求post请求 请求post请求
```
url: http://localhost:8080/zoo/login/login url: http://localhost:8080/zoo/login/login
```
输入参数 usernameadmin password123 输入参数 usernameadmin password123
返回类型为R 返回类型为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 username = "root";
String password = "83363083a"; String password = "83363083a";
String moduleName = "com/zoo"; 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\\"; String mapperLocation = "C:\\Users\\16058\\IdeaProjects\\zooSystem\\src\\main\\resources\\mapper\\";
FastAutoGenerator.create(url, username, password) FastAutoGenerator.create(url, username, password)
.globalConfig(builder -> { .globalConfig(builder -> {

View File

@ -13,7 +13,7 @@ public class MyCorsConfig {
public CorsFilter corsFilter(){ public CorsFilter corsFilter(){
CorsConfiguration corsConfiguration = new CorsConfiguration(); CorsConfiguration corsConfiguration = new CorsConfiguration();
//允许跨域的地址 //允许跨域的地址
corsConfiguration.addAllowedOrigin("http://localhost:8888"); corsConfiguration.addAllowedOrigin("http://localhost:5000");
//http://localhost:8080 //http://localhost:8080
//是否发送cookie信息 //是否发送cookie信息
corsConfiguration.setAllowCredentials(true); corsConfiguration.setAllowCredentials(true);

View File

@ -1,6 +1,11 @@
package com.zoo.controller; package com.zoo.controller;
import org.springframework.web.bind.annotation.RequestMapping; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zoo.common.R;
import com.zoo.entity.Account;
import com.zoo.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
/** /**
@ -11,8 +16,53 @@ import org.springframework.stereotype.Controller;
* @author DJ * @author DJ
* @since 2024-05-17 * @since 2024-05-17
*/ */
@Controller @RestController
@RequestMapping("/zoo/account") @RequestMapping("/zoo/account")
public class AccountController { public class AccountController {
@Autowired
IAccountService iAccountService;
@GetMapping("/info")
public R info(String username) {
if (username!=null){
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("username",username);
return R.success(iAccountService.getOne(queryWrapper));
}
return R.success(iAccountService.list());
}
@PostMapping("/save")
public R save(@RequestBody Account account){
boolean save = iAccountService.save(account);
if (save){
return R.success("添加成功");
}
return R.error("添加失败");
}
@PostMapping("/update")
public R update(@RequestBody Account account){
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",account.getId());
boolean b = iAccountService.update(account,queryWrapper);
if (b){
return R.success("修改成功");
}
return R.error("修改失败");
}
@GetMapping("/delete")
public R delete(Integer id){
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",id);
boolean b = iAccountService.remove(queryWrapper);
if (b){
return R.success("删除成功");
}
return R.error("删除失败");
}
} }

View File

@ -1,64 +0,0 @@
package com.zoo.controller;
import com.zoo.common.R;
import com.zoo.entity.Admin;
import com.zoo.entity.Keeper;
import com.zoo.entity.Veterinary;
import com.zoo.service.IAdminService;
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-05-17
*/
@RestController
@RequestMapping("/zoo/admin")
public class AdminController {
@Autowired
IAdminService iAdminService;
@GetMapping("/info")
public R info(Integer id){
if (id!=null){
Admin admin = iAdminService.selectById(id);
return R.success(admin);
}
List<Admin> list = iAdminService.list();
return R.success(list);
}
@PostMapping("/add")
public R add(Admin admin){
boolean save = iAdminService.save(admin);
if (save){
return R.success("添加成功");
}
return R.error("添加失败");
}
@PostMapping("/update")
public R update(Admin admin){
boolean b = iAdminService.updateById(admin);
if (b){
return R.success("修改成功");
}
return R.error("修改失败");
}
@GetMapping("/delete")
public R delete(Integer id){
boolean b = iAdminService.removeById(id);
if (b){
return R.success("删除成功");
}
return R.error("删除失败");
}
}

View File

@ -2,15 +2,12 @@ package com.zoo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zoo.common.R; import com.zoo.common.R;
import com.zoo.entity.Admin;
import com.zoo.entity.Animal; import com.zoo.entity.Animal;
import com.zoo.service.IAnimalService; import com.zoo.service.IAnimalService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* <p> * <p>
@ -29,15 +26,15 @@ public class AnimalController {
public R info(Integer aid){ public R info(Integer aid){
if (aid != null){ if (aid != null){
QueryWrapper<Animal> queryWrapper = new QueryWrapper<>(); QueryWrapper<Animal> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("aid",aid); queryWrapper.eq("a_id",aid);
Animal one = iAnimalService.getOne(queryWrapper); Animal one = iAnimalService.getOne(queryWrapper);
R.success(one); return R.success(one);
} }
List<Animal> list = iAnimalService.list(); List<Animal> list = iAnimalService.list();
return R.success(list); return R.success(list);
} }
@PostMapping("/add") @PostMapping("/add")
public R add(Animal animal){ public R add(@RequestBody Animal animal){
boolean save = iAnimalService.save(animal); boolean save = iAnimalService.save(animal);
if (save){ if (save){
return R.success("添加成功"); return R.success("添加成功");
@ -46,8 +43,10 @@ public class AnimalController {
} }
@PostMapping("/update") @PostMapping("/update")
public R update(Animal animal){ public R update(@RequestBody 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){ if (b){
return R.success("修改成功"); return R.success("修改成功");
} }
@ -55,7 +54,9 @@ public class AnimalController {
} }
@GetMapping("/delete") @GetMapping("/delete")
public R delete(Integer aid){ 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){ if (b){
return R.success("删除成功"); return R.success("删除成功");
} }

View File

@ -0,0 +1,84 @@
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.service.IArchiveService;
import com.zoo.service.IBreedingplanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author DJ
* @since 2024-06-07
*/
@RestController
@RequestMapping("/zoo/archive")
public class ArchiveController {
@Autowired
IArchiveService iArchiveService;
@Autowired
IBreedingplanService iBreedingplanService;
@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("animall_id",animallId);
List<Archive> list = iArchiveService.list(queryWrapper);
return R.success(list);
}
return R.success(iArchiveService.list());
}
@PostMapping("/add")
public R add(@RequestBody Archive archive){
boolean save = iArchiveService.save(archive);
if (save){
return R.success("添加成功");
}
return R.error("添加失败");
}
@PostMapping("/update")
public R update(@RequestBody 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("删除失败");
}
@GetMapping("/selectByBreedingId")
public R selectByBreedingId(Integer breedingId){
QueryWrapper<Archive> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("breeding_id",breedingId);
return R.success(iArchiveService.list(queryWrapper));
}
}

View File

@ -2,17 +2,11 @@ package com.zoo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zoo.common.R; import com.zoo.common.R;
import com.zoo.entity.Animal;
import com.zoo.entity.Breedingplan; import com.zoo.entity.Breedingplan;
import com.zoo.entity.Keeper; import com.zoo.service.IArchiveService;
import com.zoo.service.IAnimalService;
import com.zoo.service.IBreedingplanService; import com.zoo.service.IBreedingplanService;
import com.zoo.service.IKeeperService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -21,19 +15,21 @@ import java.util.List;
public class BreedingplanController { public class BreedingplanController {
@Autowired @Autowired
IBreedingplanService iBreedingplanService; IBreedingplanService iBreedingplanService;
@GetMapping("/info") @GetMapping("/info")
public R info(Integer id){ public R info(Integer id){
if (id != null){ if (id != null){
QueryWrapper<Breedingplan> queryWrapper = new QueryWrapper<>(); QueryWrapper<Breedingplan> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",id); queryWrapper.eq("id",id);
Breedingplan one = iBreedingplanService.getOne(queryWrapper); Breedingplan one = iBreedingplanService.getOne(queryWrapper);
R.success(one); return R.success(one);
} }
List<Breedingplan> list = iBreedingplanService.list(); List<Breedingplan> list = iBreedingplanService.list();
return R.success(list); return R.success(list);
} }
@PostMapping("/add") @PostMapping("/add")
public R add(Breedingplan breedingplan){ public R add(@RequestBody Breedingplan breedingplan){
boolean save = iBreedingplanService.save(breedingplan); boolean save = iBreedingplanService.save(breedingplan);
if (save){ if (save){
return R.success("添加成功"); return R.success("添加成功");
@ -42,8 +38,10 @@ public class BreedingplanController {
} }
@PostMapping("/update") @PostMapping("/update")
public R update(Breedingplan breedingplan){ public R update(@RequestBody 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){ if (b){
return R.success("修改成功"); return R.success("修改成功");
} }
@ -51,10 +49,14 @@ public class BreedingplanController {
} }
@GetMapping("/delete") @GetMapping("/delete")
public R delete(Integer id){ 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){ if (b){
return R.success("删除成功"); return R.success("删除成功");
} }
return R.error("删除失败"); return R.error("删除失败");
} }
} }

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.Breedingplan;
import com.zoo.entity.Health;
import com.zoo.service.IHealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author DJ
* @since 2024-06-07
*/
@RestController
@RequestMapping("/zoo/health")
public class HealthController {
@Autowired
IHealthService iHealthService;
@GetMapping("info")
public R info(Integer id, Integer animalId){
QueryWrapper<Health> queryWrapper = new QueryWrapper<>();
if (id!=null){
queryWrapper.eq("id",id);
Health one = iHealthService.getOne(queryWrapper);
return R.success(one);
}
if (animalId!=null){
queryWrapper.eq("animal_id",animalId);
List<Health> list = iHealthService.list(queryWrapper);
return R.success(list);
}
return R.success(iHealthService.list());
}
@PostMapping("/add")
public R add(@RequestBody Health health){
boolean save = iHealthService.save(health);
if (save){
return R.success("添加成功");
}
return R.error("添加失败");
}
@PostMapping("/update")
public R update(@RequestBody Health health){
QueryWrapper<Health> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",health.getId());
boolean b = iHealthService.update(health,queryWrapper);
if (b){
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,65 +0,0 @@
package com.zoo.controller;
import com.zoo.common.R;
import com.zoo.entity.Animal;
import com.zoo.entity.Keeper;
import com.zoo.entity.Veterinary;
import com.zoo.service.IKeeperService;
import com.zoo.service.IVeterinaryService;
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-05-17
*/
@RestController
@RequestMapping("/zoo/keeper")
public class KeeperController {
@Autowired
IKeeperService iKeeperService;
@GetMapping("info")
public R info(Integer roleid){
if (roleid!=null){
Keeper keeper = iKeeperService.selectById(roleid);
return R.success(keeper);
}
List<Keeper> list = iKeeperService.list();
return R.success(list);
}
@PostMapping("/add")
public R add(Keeper keeper){
boolean save = iKeeperService.save(keeper);
if (save){
return R.success("添加成功");
}
return R.error("添加失败");
}
@PostMapping("/update")
public R update(Keeper keeper){
boolean b = iKeeperService.updateById(keeper);
if (b){
return R.success("修改成功");
}
return R.error("修改失败");
}
@GetMapping("/delete")
public R delete(Integer roleid){
boolean b = iKeeperService.removeById(roleid);
if (b){
return R.success("删除成功");
}
return R.error("删除失败");
}
}

View File

@ -1,19 +1,10 @@
package com.zoo.controller; package com.zoo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zoo.common.R; import com.zoo.common.R;
import com.zoo.dto.AdminDto;
import com.zoo.dto.KeeperDto;
import com.zoo.dto.VeterinaryDto;
import com.zoo.entity.Account; import com.zoo.entity.Account;
import com.zoo.entity.Admin;
import com.zoo.entity.Keeper;
import com.zoo.entity.Veterinary;
import com.zoo.service.IAccountService; import com.zoo.service.IAccountService;
import com.zoo.service.IAdminService;
import com.zoo.service.IKeeperService;
import com.zoo.service.IVeterinaryService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -24,15 +15,8 @@ import org.springframework.web.bind.annotation.RestController;
public class LoginController { public class LoginController {
@Autowired @Autowired
IAccountService iAccountService; IAccountService iAccountService;
@Autowired
IAdminService iAdminService;
@Autowired
IKeeperService iKeeperService;
@Autowired
IVeterinaryService iVeterinaryService;
@PostMapping("/login") @PostMapping("/login")
public R login(String username,String password){ public R login(String username, String password) {
QueryWrapper<Account> queryWrapper = new QueryWrapper<>(); QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("username",username); queryWrapper.eq("username",username);
queryWrapper.eq("password",password); queryWrapper.eq("password",password);
@ -40,24 +24,35 @@ public class LoginController {
if (one == null){ if (one == null){
return R.error("账号密码错误"); return R.error("账号密码错误");
} }
if (one.getPermissions()==0){ return R.success(one);
Admin admin = iAdminService.selectById(one.getRoleid());
AdminDto adminDto = new AdminDto();
BeanUtils.copyProperties(admin,adminDto);
adminDto.setPermissions(0);
return R.success(adminDto);
}else if (one.getPermissions()==1){
Keeper keeper = iKeeperService.selectById(one.getRoleid());
KeeperDto keeperDto = new KeeperDto();
BeanUtils.copyProperties(keeper,keeperDto);
keeperDto.setPermissions(1);
return R.success(keeperDto);
}else {
Veterinary veterinary = iVeterinaryService.selectById(one.getRoleid());
VeterinaryDto veterinaryDto = new VeterinaryDto();
BeanUtils.copyProperties(veterinary,veterinaryDto);
veterinaryDto.setPermissions(2);
return R.success(veterinaryDto);
}
} }
// @PostMapping("/login")
// public R login(String username,String password){
// QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("username",username);
// queryWrapper.eq("password",password);
// Account one = iAccountService.getOne(queryWrapper);
// if (one == null){
// return R.error("账号密码错误");
// }
// if (one.getPermissions()==0){
// Admin admin = iAdminService.selectById(one.getRoleid());
// AdminDto adminDto = new AdminDto();
// BeanUtils.copyProperties(admin,adminDto);
// adminDto.setPermissions(0);
// return R.success(adminDto);
// }else if (one.getPermissions()==1){
// Keeper keeper = iKeeperService.selectById(one.getRoleid());
// KeeperDto keeperDto = new KeeperDto();
// BeanUtils.copyProperties(keeper,keeperDto);
// keeperDto.setPermissions(1);
// return R.success(keeperDto);
// }else {
// Veterinary veterinary = iVeterinaryService.selectById(one.getRoleid());
// VeterinaryDto veterinaryDto = new VeterinaryDto();
// BeanUtils.copyProperties(veterinary,veterinaryDto);
// veterinaryDto.setPermissions(2);
// return R.success(veterinaryDto);
// }
// }
} }

View File

@ -1,63 +0,0 @@
package com.zoo.controller;
import com.zoo.common.R;
import com.zoo.entity.Keeper;
import com.zoo.entity.Veterinary;
import com.zoo.service.IVeterinaryService;
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-05-17
*/
@RestController
@RequestMapping("/zoo/veterinary")
public class VeterinaryController {
@Autowired
IVeterinaryService iVeterinaryService;
@GetMapping("info")
public R info(Integer roleid){
if (roleid!=null){
Veterinary veterinary = iVeterinaryService.selectById(roleid);
return R.success(veterinary);
}
List<Veterinary> list = iVeterinaryService.list();
return R.success(list);
}
@PostMapping("/add")
public R add(Veterinary veterinary){
boolean save = iVeterinaryService.save(veterinary);
if (save){
return R.success("添加成功");
}
return R.error("添加失败");
}
@PostMapping("/update")
public R update(Veterinary veterinary){
boolean b = iVeterinaryService.updateById(veterinary);
if (b){
return R.success("修改成功");
}
return R.error("修改失败");
}
@GetMapping("/delete")
public R delete(Integer roleid){
boolean b = iVeterinaryService.removeById(roleid);
if (b){
return R.success("删除成功");
}
return R.error("删除失败");
}
}

View File

@ -1,16 +0,0 @@
package com.zoo.dto;
import com.zoo.entity.Admin;
public class AdminDto extends Admin {
private Integer permissions;
public Integer getPermissions() {
return permissions;
}
public void setPermissions(Integer permissions) {
this.permissions = permissions;
}
}

View File

@ -1,15 +0,0 @@
package com.zoo.dto;
import com.zoo.entity.Keeper;
public class KeeperDto extends Keeper {
private Integer permissions;
public Integer getPermissions() {
return permissions;
}
public void setPermissions(Integer permissions) {
this.permissions = permissions;
}
}

View File

@ -1,15 +0,0 @@
package com.zoo.dto;
import com.zoo.entity.Veterinary;
public class VeterinaryDto extends Veterinary {
private Integer permissions;
public Integer getPermissions() {
return permissions;
}
public void setPermissions(Integer permissions) {
this.permissions = permissions;
}
}

View File

@ -1,5 +1,8 @@
package com.zoo.entity; package com.zoo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -17,13 +20,9 @@ public class Account implements Serializable {
/** /**
* 编号 * 编号
*/ */
@TableId(type = IdType.AUTO)
private Integer id; private Integer id;
/**
* 角色id
*/
private Integer roleid;
/** /**
* 角色账号 * 角色账号
*/ */
@ -35,7 +34,7 @@ public class Account implements Serializable {
private String password; private String password;
/** /**
* 权限 * 权限 0管理员1饲养员2兽医
*/ */
private Integer permissions; private Integer permissions;
@ -46,13 +45,6 @@ public class Account implements Serializable {
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
public Integer getRoleid() {
return roleid;
}
public void setRoleid(Integer roleid) {
this.roleid = roleid;
}
public String getUsername() { public String getUsername() {
return username; return username;
} }
@ -79,7 +71,6 @@ public class Account implements Serializable {
public String toString() { public String toString() {
return "Account{" + return "Account{" +
"id=" + id + "id=" + id +
", roleid=" + roleid +
", username=" + username + ", username=" + username +
", password=" + password + ", password=" + password +
", permissions=" + permissions + ", permissions=" + permissions +

View File

@ -1,49 +0,0 @@
package com.zoo.entity;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author DJ
* @since 2024-05-17
*/
public class Admin implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 角色id
*/
private Integer roleid;
/**
* 管理员名称
*/
private String name;
public Integer getRoleid() {
return roleid;
}
public void setRoleid(Integer roleid) {
this.roleid = roleid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Admin{" +
"roleid=" + roleid +
", name=" + name +
"}";
}
}

View File

@ -1,5 +1,8 @@
package com.zoo.entity; package com.zoo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -17,6 +20,7 @@ public class Animal implements Serializable {
/** /**
* 动物ID * 动物ID
*/ */
@TableId(type = IdType.AUTO)
private Integer aId; private Integer aId;
/** /**

View File

@ -0,0 +1,175 @@
package com.zoo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author DJ
* @since 2024-06-07
*/
public class Archive implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 档案号
*/
@TableId(type = IdType.AUTO)
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;
/**
* 关联的饲养计划id
* @return
*/
private Integer breedingId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getAnimallId() {
return animallId;
}
public Integer getBreedingId() {
return breedingId;
}
public void setBreedingId(Integer breedingId) {
this.breedingId = breedingId;
}
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 +
",breedingId="+breedingId+
"}";
}
}

View File

@ -1,6 +1,9 @@
package com.zoo.entity; package com.zoo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -18,6 +21,7 @@ public class Breedingplan implements Serializable {
/** /**
* 饲养计划id * 饲养计划id
*/ */
@TableId(type = IdType.AUTO)
private Integer id; private Integer id;
/** /**
@ -53,7 +57,7 @@ public class Breedingplan implements Serializable {
/** /**
* 饲养员计划描述 * 饲养员计划描述
*/ */
private String describe; private String describe1;
public Integer getId() { public Integer getId() {
return id; return id;
@ -104,12 +108,12 @@ public class Breedingplan implements Serializable {
public void setRoleid(Integer roleid) { public void setRoleid(Integer roleid) {
this.roleid = roleid; this.roleid = roleid;
} }
public String getDescribe() { public String getDescribe1() {
return describe; return describe1;
} }
public void setDescribe(String describe) { public void setDescribe1(String describe) {
this.describe = describe; this.describe1 = describe;
} }
@Override @Override
@ -122,7 +126,7 @@ public class Breedingplan implements Serializable {
", phase=" + phase + ", phase=" + phase +
", state=" + state + ", state=" + state +
", roleid=" + roleid + ", roleid=" + roleid +
", describe=" + describe + ", describe=" + describe1 +
"}"; "}";
} }
} }

View File

@ -0,0 +1,171 @@
package com.zoo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author DJ
* @since 2024-06-07
*/
public class Health implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 健康数据编号
*/
@TableId(type = IdType.AUTO)
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

@ -1,75 +0,0 @@
package com.zoo.entity;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author DJ
* @since 2024-05-17
*/
public class Keeper implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 角色id
*/
private Integer roleid;
/**
* 性别
*/
private String sex;
/**
* 饲养员名称
*/
private String name;
/**
* 手机号码
*/
private String phone;
public Integer getRoleid() {
return roleid;
}
public void setRoleid(Integer roleid) {
this.roleid = roleid;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@Override
public String toString() {
return "Keeper{" +
"roleid=" + roleid +
", sex=" + sex +
", name=" + name +
", phone=" + phone +
"}";
}
}

View File

@ -1,62 +0,0 @@
package com.zoo.entity;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author DJ
* @since 2024-05-17
*/
public class Veterinary implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 兽医角色id
*/
private Integer roleid;
/**
* 名称
*/
private String name;
/**
* 治疗记录
*/
private String record;
public Integer getRoleid() {
return roleid;
}
public void setRoleid(Integer roleid) {
this.roleid = roleid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRecord() {
return record;
}
public void setRecord(String record) {
this.record = record;
}
@Override
public String toString() {
return "Veterinary{" +
"roleid=" + roleid +
", name=" + name +
", record=" + record +
"}";
}
}

View File

@ -1,7 +1,8 @@
package com.zoo.mapper; package com.zoo.mapper;
import com.zoo.entity.Admin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zoo.entity.Archive;
/** /**
* <p> * <p>
@ -9,8 +10,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author DJ * @author DJ
* @since 2024-05-17 * @since 2024-06-07
*/ */
public interface AdminMapper extends BaseMapper<Admin> { public interface ArchiveMapper extends BaseMapper<Archive> {
} }

View File

@ -1,7 +1,8 @@
package com.zoo.mapper; package com.zoo.mapper;
import com.zoo.entity.Keeper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zoo.entity.Health;
/** /**
* <p> * <p>
@ -9,8 +10,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author DJ * @author DJ
* @since 2024-05-17 * @since 2024-06-07
*/ */
public interface KeeperMapper extends BaseMapper<Keeper> { public interface HealthMapper extends BaseMapper<Health> {
} }

View File

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

View File

@ -1,7 +1,8 @@
package com.zoo.service; package com.zoo.service;
import com.zoo.entity.Admin;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.zoo.entity.Archive;
/** /**
* <p> * <p>
@ -9,8 +10,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
* </p> * </p>
* *
* @author DJ * @author DJ
* @since 2024-05-17 * @since 2024-06-07
*/ */
public interface IAdminService extends IService<Admin> { public interface IArchiveService extends IService<Archive> {
Admin selectById(int roleId);
} }

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

@ -1,16 +0,0 @@
package com.zoo.service;
import com.zoo.entity.Keeper;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author DJ
* @since 2024-05-17
*/
public interface IKeeperService extends IService<Keeper> {
Keeper selectById(int roleId);
}

View File

@ -1,16 +0,0 @@
package com.zoo.service;
import com.zoo.entity.Veterinary;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author DJ
* @since 2024-05-17
*/
public interface IVeterinaryService extends IService<Veterinary> {
Veterinary selectById(int roleId);
}

View File

@ -1,27 +0,0 @@
package com.zoo.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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-05-17
*/
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements IAdminService {
@Override
public Admin selectById(int roleId) {
QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleId",roleId);
return this.getOne(queryWrapper);
}
}

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,27 +0,0 @@
package com.zoo.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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-05-17
*/
@Service
public class KeeperServiceImpl extends ServiceImpl<KeeperMapper, Keeper> implements IKeeperService {
@Override
public Keeper selectById(int roleId) {
QueryWrapper<Keeper> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleId",roleId);
return this.getOne(queryWrapper);
}
}

View File

@ -1,27 +0,0 @@
package com.zoo.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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-05-17
*/
@Service
public class VeterinaryServiceImpl extends ServiceImpl<VeterinaryMapper, Veterinary> implements IVeterinaryService {
@Override
public Veterinary selectById(int roleId) {
QueryWrapper<Veterinary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("roleId",roleId);
return this.getOne(queryWrapper);
}
}

View File

@ -1,3 +1,4 @@
# 应用服务 WEB 访问端口 # 应用服务 WEB 访问端口
spring: spring:
datasource: datasource:
@ -5,4 +6,5 @@ spring:
url: jdbc:mysql://localhost:3306/zoo url: jdbc:mysql://localhost:3306/zoo
username: root username: root
password: 83363083a 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>

View File

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

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>