add: 添加事务
This commit is contained in:
@@ -4,7 +4,6 @@ import jakarta.annotation.Resource;
|
|||||||
import org.dromara.common.Result;
|
import org.dromara.common.Result;
|
||||||
import org.dromara.domain.Cls;
|
import org.dromara.domain.Cls;
|
||||||
import org.dromara.service.IClsService;
|
import org.dromara.service.IClsService;
|
||||||
import org.dromara.service.impl.ClsService;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@@ -6,6 +6,7 @@ import org.dromara.domain.Student;
|
|||||||
import org.dromara.mapper.StudentMapper;
|
import org.dromara.mapper.StudentMapper;
|
||||||
import org.dromara.service.IStudentService;
|
import org.dromara.service.IStudentService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
@@ -13,22 +14,27 @@ public class StudentService implements IStudentService {
|
|||||||
@Resource
|
@Resource
|
||||||
private StudentMapper studentMapper;
|
private StudentMapper studentMapper;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public void add(Student student) {
|
public void add(Student student) {
|
||||||
studentMapper.insert(student);
|
studentMapper.insert(student);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public void update(Student student) {
|
public void update(Student student) {
|
||||||
studentMapper.updateById(student);
|
studentMapper.updateById(student);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public void deleteById(Integer id) {
|
public void deleteById(Integer id) {
|
||||||
studentMapper.deleteById(id);
|
studentMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
public List<Student> selectAll(Student student) {
|
public List<Student> selectAll(Student student) {
|
||||||
return studentMapper.selectAll(student);
|
return studentMapper.selectAll(student);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
public Student selectById( Integer id) {
|
public Student selectById( Integer id) {
|
||||||
return studentMapper.selectById(id);
|
return studentMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user