package com.ym.mec.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ym.mec.biz.dal.dao.SysUserTenantDao;
import com.ym.mec.biz.dal.entity.SysUserTenant;
import com.ym.mec.biz.dal.vo.SysUserTenantVo;
import com.ym.mec.biz.service.SysUserTenantService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 平台用户与机构关系表(SysUserTenant)表服务实现类
 *
 * @author hgw
 * @since 2022-03-02 11:09:34
 */
@Service("sysUserTenantService")
public class SysUserTenantServiceImpl extends ServiceImpl<SysUserTenantDao, SysUserTenant> implements SysUserTenantService {

    private final static Logger log = LoggerFactory.getLogger(SysUserTenantServiceImpl.class);

    @Override
    public SysUserTenantDao getDao() {
        return this.baseMapper;
    }

    @Override
    public List<SysUserTenantVo> queryUserTenant(Integer userId) {
        return baseMapper.queryUserTenant(userId);
    }

    /**
     * 根据用户id删除用户与机构关系
     *
     * @param userId 用户id
     */
    @Override
    public void deleteByUserId(Integer userId) {
        baseMapper.delete(new QueryWrapper<SysUserTenant>().eq("user_id_", userId));
    }

}

