diff --git a/src/main/java/com/hnucm/springboot/springboot1/dao/OrdersMapper.java b/src/main/java/com/hnucm/springboot/springboot1/dao/OrdersMapper.java new file mode 100644 index 0000000..6fca7b3 --- /dev/null +++ b/src/main/java/com/hnucm/springboot/springboot1/dao/OrdersMapper.java @@ -0,0 +1,12 @@ +package com.hnucm.springboot.springboot1.dao; + +import com.hnucm.springboot.springboot1.model.Orders; +import com.hnucm.springboot.springboot1.model.StuCard; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface OrdersMapper { + public List findOrdersByPersonId(int personId); +} diff --git a/src/main/java/com/hnucm/springboot/springboot1/dao/PersonMapper.java b/src/main/java/com/hnucm/springboot/springboot1/dao/PersonMapper.java new file mode 100644 index 0000000..1095c9b --- /dev/null +++ b/src/main/java/com/hnucm/springboot/springboot1/dao/PersonMapper.java @@ -0,0 +1,16 @@ +package com.hnucm.springboot.springboot1.dao; + +import com.hnucm.springboot.springboot1.model.Person; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface PersonMapper { + public List getAllPersonStuCard(); + public List getAllPerson(); + //int 表示增加的条数 + public int addPerson(Person person); + public int deletePerson(int id); + public int updatePerson(Person person); +} diff --git a/src/main/java/com/hnucm/springboot/springboot1/dao/StuCardMapper.java b/src/main/java/com/hnucm/springboot/springboot1/dao/StuCardMapper.java new file mode 100644 index 0000000..5c9d3f2 --- /dev/null +++ b/src/main/java/com/hnucm/springboot/springboot1/dao/StuCardMapper.java @@ -0,0 +1,17 @@ +package com.hnucm.springboot.springboot1.dao; + +import com.hnucm.springboot.springboot1.model.Person; +import com.hnucm.springboot.springboot1.model.StuCard; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface StuCardMapper { + //根据学生证的主键查询对应的学生证信息 + public StuCard getStuCardById(int id); + //增加成功的条数 + public int addStuCard(StuCard stuCard); + // 删除学生卡 根据id + public int deleteStuCard(int id); +} diff --git a/src/main/java/com/hnucm/springboot/springboot1/model/Orders.java b/src/main/java/com/hnucm/springboot/springboot1/model/Orders.java deleted file mode 100644 index e34e4d1..0000000 --- a/src/main/java/com/hnucm/springboot/springboot1/model/Orders.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hnucm.springboot.springboot1.model; - -import lombok.Data; - -import java.util.List; - -@Data -public class Orders { - private int id; - private String orderinfo; - private int orderprice; - private int personid; - private List productList; - -} diff --git a/src/main/java/com/hnucm/springboot/springboot1/model/Person.java b/src/main/java/com/hnucm/springboot/springboot1/model/Person.java deleted file mode 100644 index 134d520..0000000 --- a/src/main/java/com/hnucm/springboot/springboot1/model/Person.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hnucm.springboot.springboot1.model; - -import lombok.Data; - -import java.util.List; - -@Data -public class Person { - private int id; - private String name; - private int age; - private StuCard stuCard; - private List ordersList; -} diff --git a/src/main/java/com/hnucm/springboot/springboot1/model/Product.java b/src/main/java/com/hnucm/springboot/springboot1/model/Product.java deleted file mode 100644 index f419ac6..0000000 --- a/src/main/java/com/hnucm/springboot/springboot1/model/Product.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.hnucm.springboot.springboot1.model; - -import lombok.Data; - -@Data -public class Product { - private int id; - private String productname; - private String productprice; -} diff --git a/src/main/java/com/hnucm/springboot/springboot1/model/StuCard.java b/src/main/java/com/hnucm/springboot/springboot1/model/StuCard.java deleted file mode 100644 index eaccfc8..0000000 --- a/src/main/java/com/hnucm/springboot/springboot1/model/StuCard.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.hnucm.springboot.springboot1.model; - -import lombok.Data; - -@Data -public class StuCard { - private int id; - private String stuid; - private String classname; -} diff --git a/src/main/java/com/hnucm/springboot/springboot1/model/User.java b/src/main/java/com/hnucm/springboot/springboot1/model/User.java deleted file mode 100644 index ab69313..0000000 --- a/src/main/java/com/hnucm/springboot/springboot1/model/User.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.hnucm.springboot.springboot1.model; - -import lombok.Data; -// Data set+ get -@Data -public class User { - private int id; - private String name; - private int age; -} diff --git a/src/main/java/com/hnucm/springboot/springboot1/service/impl/PersonServiceImpl.java b/src/main/java/com/hnucm/springboot/springboot1/service/impl/PersonServiceImpl.java index 7fe6063..be2e1b5 100644 --- a/src/main/java/com/hnucm/springboot/springboot1/service/impl/PersonServiceImpl.java +++ b/src/main/java/com/hnucm/springboot/springboot1/service/impl/PersonServiceImpl.java @@ -13,10 +13,10 @@ import java.util.List; @Service public class PersonServiceImpl implements PersonService { @Autowired - private PersonMapper personMapper2; + private PersonMapper personMapper3; @Autowired - StuCardMapper stuCardMapper2; + StuCardMapper stuCardMapper3; @Override public List getAllPerson() { @@ -29,7 +29,7 @@ public class PersonServiceImpl implements PersonService { stuCardMapper.addStuCard(person.getStuCard()); return personMapper.addPerson(person); } - // 事务 -》 增删改 多张表 同时操作 + @Transactional @Override public int deletePerson(int id, int stuid) {