完成各个数据的基础增删改查接口的实现

This commit is contained in:
dongjie 2024-05-20 22:04:03 +08:00
parent 2e9bd54570
commit 165b0e9ea8
65 changed files with 488 additions and 35 deletions

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";
String table = "account,admin,animal,keeper,veterinary,breedingplan";
String mapperLocation = "C:\\Users\\16058\\IdeaProjects\\zooSystem\\src\\main\\resources\\mapper\\";
FastAutoGenerator.create(url, username, password)
.globalConfig(builder -> {

View File

@ -3,9 +3,15 @@ package com.zoo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@MapperScan("com.demo.zoo.mapper")
@MapperScan("com.zoo.mapper")
//会扫描@WebFilter
@ServletComponentScan
//开启事务管理
@EnableTransactionManagement
public class ZooSystemApplication {
public static void main(String[] args) {

View File

@ -1,7 +1,18 @@
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>
@ -11,8 +22,43 @@ import org.springframework.stereotype.Controller;
* @author DJ
* @since 2024-05-17
*/
@Controller
@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

@ -1,8 +1,17 @@
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.Admin;
import com.zoo.entity.Animal;
import com.zoo.service.IAnimalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import java.util.List;
import java.util.Map;
/**
* <p>
* 前端控制器
@ -11,8 +20,45 @@ import org.springframework.stereotype.Controller;
* @author DJ
* @since 2024-05-17
*/
@Controller
@RestController
@RequestMapping("/zoo/animal")
public class AnimalController {
@Autowired
IAnimalService iAnimalService;
@GetMapping("/info")
public R info(Integer aid){
if (aid != null){
QueryWrapper<Animal> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("aid",aid);
Animal one = iAnimalService.getOne(queryWrapper);
R.success(one);
}
List<Animal> list = iAnimalService.list();
return R.success(list);
}
@PostMapping("/add")
public R add(Animal animal){
boolean save = iAnimalService.save(animal);
if (save){
return R.success("添加成功");
}
return R.error("添加失败");
}
@PostMapping("/update")
public R update(Animal animal){
boolean b = iAnimalService.updateById(animal);
if (b){
return R.success("修改成功");
}
return R.error("修改失败");
}
@GetMapping("/delete")
public R delete(Integer aid){
boolean b = iAnimalService.removeById(aid);
if (b){
return R.success("删除成功");
}
return R.error("删除失败");
}
}

View File

@ -0,0 +1,60 @@
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.service.IAnimalService;
import com.zoo.service.IBreedingplanService;
import com.zoo.service.IKeeperService;
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.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/zoo/plan")
public class BreedingplanController {
@Autowired
IBreedingplanService iBreedingplanService;
@GetMapping("/info")
public R info(Integer id){
if (id != null){
QueryWrapper<Breedingplan> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",id);
Breedingplan one = iBreedingplanService.getOne(queryWrapper);
R.success(one);
}
List<Breedingplan> list = iBreedingplanService.list();
return R.success(list);
}
@PostMapping("/add")
public R add(Breedingplan breedingplan){
boolean save = iBreedingplanService.save(breedingplan);
if (save){
return R.success("添加成功");
}
return R.error("添加失败");
}
@PostMapping("/update")
public R update(Breedingplan breedingplan){
boolean b = iBreedingplanService.updateById(breedingplan);
if (b){
return R.success("修改成功");
}
return R.error("修改失败");
}
@GetMapping("/delete")
public R delete(Integer id){
boolean b = iBreedingplanService.removeById(id);
if (b){
return R.success("删除成功");
}
return R.error("删除失败");
}
}

View File

@ -1,7 +1,19 @@
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>
@ -11,8 +23,43 @@ import org.springframework.stereotype.Controller;
* @author DJ
* @since 2024-05-17
*/
@Controller
@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,7 +1,17 @@
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>
@ -11,8 +21,43 @@ import org.springframework.stereotype.Controller;
* @author DJ
* @since 2024-05-17
*/
@Controller
@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

@ -8,7 +8,7 @@ import java.io.Serializable;
* </p>
*
* @author DJ
* @since 2024-05-17
* @since 2024-05-18
*/
public class Animal implements Serializable {
@ -52,7 +52,7 @@ public class Animal implements Serializable {
/**
* 饲养员ID
*/
private Integer roleId;
private Integer roleid;
/**
* 颜色
@ -65,9 +65,9 @@ public class Animal implements Serializable {
private String features;
/**
* 生活习性
* 成长阶段
*/
private String habit;
private String phase;
public Integer getaId() {
return aId;
@ -118,12 +118,12 @@ public class Animal implements Serializable {
public void setState(Integer state) {
this.state = state;
}
public Integer getRoleId() {
return roleId;
public Integer getRoleid() {
return roleid;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
public void setRoleid(Integer roleid) {
this.roleid = roleid;
}
public String getColor() {
return color;
@ -139,28 +139,28 @@ public class Animal implements Serializable {
public void setFeatures(String features) {
this.features = features;
}
public String getHabit() {
return habit;
public String getPhase() {
return phase;
}
public void setHabit(String habit) {
this.habit = habit;
public void setPhase(String phase) {
this.phase = phase;
}
@Override
public String toString() {
return "Animal{" +
"aId=" + aId +
", name=" + name +
", sex=" + sex +
", species=" + species +
", weight=" + weight +
", height=" + height +
", state=" + state +
", roleId=" + roleId +
", color=" + color +
", features=" + features +
", habit=" + habit +
"}";
"aId=" + aId +
", name=" + name +
", sex=" + sex +
", species=" + species +
", weight=" + weight +
", height=" + height +
", state=" + state +
", roleid=" + roleid +
", color=" + color +
", features=" + features +
", phase=" + phase +
"}";
}
}

View File

@ -0,0 +1,128 @@
package com.zoo.entity;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author DJ
* @since 2024-05-20
*/
public class Breedingplan implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 饲养计划id
*/
private Integer id;
/**
* 饲养计划名称
*/
private String name;
/**
* 种类
*/
private String species;
/**
* 饲养动物性别
*/
private String sex;
/**
* 动物生长阶段
*/
private String phase;
/**
* 状态 0 正常 1 异常
*/
private Integer state;
/**
* 执行计划饲养员id
*/
private Integer roleid;
/**
* 饲养员计划描述
*/
private String describe;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSpecies() {
return species;
}
public void setSpecies(String species) {
this.species = species;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
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 Integer getRoleid() {
return roleid;
}
public void setRoleid(Integer roleid) {
this.roleid = roleid;
}
public String getDescribe() {
return describe;
}
public void setDescribe(String describe) {
this.describe = describe;
}
@Override
public String toString() {
return "Breedingplan{" +
"id=" + id +
", name=" + name +
", species=" + species +
", sex=" + sex +
", phase=" + phase +
", state=" + state +
", roleid=" + roleid +
", describe=" + describe +
"}";
}
}

View File

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

View File

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

View File

@ -0,0 +1,21 @@
package com.zoo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zoo.entity.Breedingplan;
import com.zoo.mapper.BreedingplanMapper;
import com.zoo.service.IBreedingplanService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author DJ
* @since 2024-05-20
*/
@Service
public class BreedingplanServiceImpl extends ServiceImpl<BreedingplanMapper, Breedingplan> implements IBreedingplanService {
}

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.AccountMapper">
</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.BreedingplanMapper">
</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.

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.

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.AccountMapper">
</mapper>

View File

@ -1,5 +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 namespace="com.com.zoo.mapper.AdminMapper">
</mapper>

View File

@ -1,5 +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 namespace="com.com.zoo.mapper.AnimalMapper">
</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.BreedingplanMapper">
</mapper>

View File

@ -1,5 +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 namespace="com.com.zoo.mapper.KeeperMapper">
</mapper>

View File

@ -1,5 +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 namespace="com.com.zoo.mapper.VeterinaryMapper">
</mapper>