package com.ruoyi.app.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.system.domain.InfoUser;
import com.ruoyi.system.service.IInfoUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.sound.sampled.Line;

@Service
public class UserService {
    @Autowired
    private IInfoUserService userService;

    /**
     * 检查用户状态
     * @param userId
     */
    public InfoUser checkUserStatus(Long userId){
        InfoUser user=userService.getOne(new LambdaQueryWrapper<InfoUser>().eq(InfoUser::getUserId,userId));
        if(user==null){
            throw new ServiceException(MessageUtils.message("no.wallet.noexist.userinfo"));
        }
        if(!"1".equals(user.getAuditStatus())){
            throw new ServiceException(MessageUtils.message("no.user.state.no.audit"));
        }
        return user;
    }

}
