package cn.com.ctop.common.module.service.impl;

import cn.com.ctop.common.module.entity.OauthAgentToken;
import cn.com.ctop.common.module.mapper.OauthAgentTokenMapper;
import cn.com.ctop.common.module.service.IOauthAgentTokenService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 代理商token
 *
 * @author jeecg-boot
 * @version V1.0
 * @date 2020-08-18
 */
@Service
public class OauthAgentTokenServiceImpl extends ServiceImpl<OauthAgentTokenMapper, OauthAgentToken> implements IOauthAgentTokenService {

    @Resource
    private OauthAgentTokenMapper mapper;


    @Override
    public OauthAgentToken getTokenByAppId(Long appId) {
        QueryWrapper<OauthAgentToken> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("app_id", appId);
        queryWrapper.last("limit 1");
        OauthAgentToken one = this.getOne(queryWrapper);
        return one;
    }

    @Override
    public List<OauthAgentToken> getLiveKuaiShouAgentList(Integer mediaId) {
        return mapper.getLiveKuaiShouAgentList(mediaId);
    }
}
