package cn.com.ctop.kuaishou.modules.batch.service.impl;

import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppListMapper;
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 快手-应用列表
 * @Author: jeecg-boot
 * @Date: 2019-07-26
 * @Version: V1.0
 */
@Service
public class KuaiShouAppListServiceImpl extends ServiceImpl<KuaiShouAppListMapper, KuaiShouAppList> implements IKuaiShouAppListService {

    @Autowired
    private KuaiShouAppListMapper shouAppListMapper;
    @Override
    public KuaiShouAppList getAppInfo(Long accountId, Long appId) {
        QueryWrapper<KuaiShouAppList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("account_id", accountId);
        queryWrapper.eq("app_id", appId);
        queryWrapper.orderByDesc("create_time");
        queryWrapper.last("limit 1");
        return this.getOne(queryWrapper);
    }

    @Override
    public List<KuaiShouAppList> getAppListByAccountId(Long accountId) {
        QueryWrapper<KuaiShouAppList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("account_id", accountId);
        queryWrapper.eq("platform", 1);
        return this.list(queryWrapper);
    }

    @Override
    public List<KuaiShouAppList> getAppNames(JSONArray appIds) {
        return shouAppListMapper.getAppNames(appIds);
    }

    @Override
    public KuaiShouAppList getAppListByAppId(Long appId) {
        return shouAppListMapper.getAppListByAppId(appId);
    }
}
