package com.yinlihupo.enlish.service.service.user;

import cn.dev33.satoken.stp.StpUtil;
import com.yinlihupo.enlish.service.domain.dataobject.UserDO;
import com.yinlihupo.enlish.service.domain.mapper.UserDOMapper;
import com.yinlihupo.enlish.service.service.UserService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class UserServiceImpl implements UserService {


    @Resource
    private UserDOMapper userDOMapper;



    @Override
    public UserDO findUser() {
        String loginIdStr =(String) StpUtil.getLoginId();
        Long loginId = Long.parseLong(loginIdStr);
        return userDOMapper.selectById(loginId);
    }

    @Override
    public List<UserDO> findUsersList(int page, int limit, String name) {

        return userDOMapper.selectUserDOList(name, (page - 1) * limit, limit);
    }

    @Override
    public Integer findUserTotal() {
        return userDOMapper.selectUserTotal();
    }

    @Override
    public void createUser(UserDO userDO) {
        userDOMapper.insert(userDO);
    }

}
