package com.absentm.spbt.service.impl;

import com.absentm.spbt.dao.UserMapper;
import com.absentm.spbt.entity.User;
import com.absentm.spbt.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public User getUserById(Integer id) {
        return userMapper.getUserByIdDao(id);
    }

    @Override
    public ArrayList<User> getAllUserList() {
        return userMapper.getAllUserListDao();
    }

    @Override
    public User getUserByName(String name) {
        return userMapper.getUserByName(name);
    }

    @Override
    public User getUserByIdAndName(Integer id, String name) {
        return userMapper.getUserByIdAndNameDao(id, name);
    }

    @Override
    public int addUser(User user) {
        return userMapper.addNewUser(user);
    }

    @Override
    public int updateUserById(User user) {
        return userMapper.updateUserById(user);
    }

    @Override
    public int deleteUserById(Integer id) {
        return userMapper.deleteUserById(id);
    }
}

@@ -201,16 +201,81 @@
 Service;
+%0Aimport org.springframework.transaction.annotation.Transactional;
 %0A%0Aimport
@@ -928,32 +928,82 @@
 %0A%0A    @Override%0A
+    @Transactional(rollbackFor = Exception.class)%0A
     public int a
@@ -1014,32 +1014,32 @@
 er(User user) %7B%0A
-
         return u
@@ -1079,32 +1079,82 @@
 %0A%0A    @Override%0A
+    @Transactional(rollbackFor = Exception.class)%0A
     public int u
@@ -1227,32 +1227,32 @@
 d(user);%0A    %7D%0A%0A
-
     @Override%0A  
@@ -1241,32 +1241,82 @@
 %0A%0A    @Override%0A
+    @Transactional(rollbackFor = Exception.class)%0A
     public int d

Add Transactional support