package com.springboot.cloud.sysadmin.organization.service.company.impl;

/*
 **********************************************
 *      DATE           PERSON       REASON
 *    2020-12-29          FXY        Created
 **********************************************
 */


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.springboot.cloud.sysadmin.organization.dao.company.CompanyUserMapper;
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyUser;
import com.springboot.cloud.sysadmin.organization.exception.UserNotFoundException;
import com.springboot.cloud.sysadmin.organization.service.company.CompanyRoleUserService;
import com.springboot.cloud.sysadmin.organization.service.company.CompanyUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
@Slf4j
public class CompanyUserServiceImpl extends ServiceImpl<CompanyUserMapper, CompanyUser> implements CompanyUserService {

    @Override
    public CompanyUser getUserByCompanyIdAndUserId(String companyId, String userId) {
        QueryWrapper<CompanyUser> userQueryWrapper=new QueryWrapper<>();
        userQueryWrapper.eq("company_id",companyId).eq("user_id",userId);
        return this.getOne(userQueryWrapper);
    }

    @Override
    public List<CompanyUser> getCompanyByUserId(String userId) {
        QueryWrapper<CompanyUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        return this.list(queryWrapper);
    }
}
