UserServiceImpl.java 1021 字节
Newer Older
Q
qinyingjie 已提交
1 2 3 4 5 6 7 8 9 10
package com.kwan.springbootkwan.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kwan.springbootkwan.entity.User;
import com.kwan.springbootkwan.mapper.UserMapper;
import com.kwan.springbootkwan.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
11
import java.util.Objects;
Q
qinyingjie 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getUsers() {
        return userMapper.selectList(null);
    }

    @Override
    public User getUserById(Integer id) {
        return userMapper.selectById(id);
    }
28 29 30 31 32 33 34 35 36

    @Override
    public User getUserByName(String sex) {
         User userByName = userMapper.getUserByName(sex);
        if (Objects.isNull(userByName)) {
            userByName = new User();
        }
        return userByName;
    }
Q
qinyingjie 已提交
37
}