This commit is contained in:
BLRTTX 2024-10-10 11:55:43 +08:00
parent 48b58c544e
commit 5da79544a7
9 changed files with 48 additions and 62 deletions

View File

@ -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<Orders> findOrdersByPersonId(int personId);
}

View File

@ -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<Person> getAllPersonStuCard();
public List<Person> getAllPerson();
//int 表示增加的条数
public int addPerson(Person person);
public int deletePerson(int id);
public int updatePerson(Person person);
}

View File

@ -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);
}

View File

@ -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<Product> productList;
}

View File

@ -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<Orders> ordersList;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<Person> 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) {