package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.system.domain.OpenAccount;
import com.ruoyi.system.mapper.IUserinfoMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.AccountService;
import com.ruoyi.system.service.SysLoginService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    @Autowired
    IUserinfoMapper iUserinfoMapper;


    private final SysLoginService sysLoginService;

    @Override
    public String login(String uId) {
        QueryWrapper<OpenAccount> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("u_id",uId);
        OpenAccount openAccount = iUserinfoMapper.selectOne(queryWrapper);

        if (openAccount != null){
            //登录
            String token = sysLoginService.UIdLogin(openAccount.getUserName());
            return token;
        }
        return null;
    }
}
