package com.example.springboot.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.example.springboot.entity.User; import com.example.springboot.mapper.UserMapper; @Service public class UserService { @Autowired private UserMapper userMapper; public void Save(User user) { if (user.getId() == null) { userMapper.insert(user); } else { userMapper.update(user); } } }