add: 添加事务

This commit is contained in:
2025-08-08 10:48:02 +08:00
parent 4a77a59c9b
commit c5c67281c5
2 changed files with 6 additions and 1 deletions

View File

@@ -4,7 +4,6 @@ import jakarta.annotation.Resource;
import org.dromara.common.Result;
import org.dromara.domain.Cls;
import org.dromara.service.IClsService;
import org.dromara.service.impl.ClsService;
import org.springframework.web.bind.annotation.*;
import java.util.List;

View File

@@ -6,6 +6,7 @@ import org.dromara.domain.Student;
import org.dromara.mapper.StudentMapper;
import org.dromara.service.IStudentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@@ -13,22 +14,27 @@ public class StudentService implements IStudentService {
@Resource
private StudentMapper studentMapper;
@Transactional
public void add(Student student) {
studentMapper.insert(student);
}
@Transactional
public void update(Student student) {
studentMapper.updateById(student);
}
@Transactional
public void deleteById(Integer id) {
studentMapper.deleteById(id);
}
@Transactional(readOnly = true)
public List<Student> selectAll(Student student) {
return studentMapper.selectAll(student);
}
@Transactional(readOnly = true)
public Student selectById( Integer id) {
return studentMapper.selectById(id);
}