package cn.com.ctop.kuaishou.modules.ai.mapper;

import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 人群包模板和账户绑定关系表
 *
 * @author jeecg-boot
 * 2021-05-07
 * @version V1.0
 */
public interface KuaishouPopulationPackageRelMapper extends BaseMapper<KuaishouPopulationPackageRel> {

    /**
     * 查询账户同一主题下可推送的该人群包ID
     */
    KuaishouPopulationPackageRel queryPushableCrowdPackage(@Param("accountId") Long accountId, @Param("id") Long id);

    KuaishouPopulationPackageRel queryByAccountId(@Param("accountId") Long accountId, @Param("orientationId") Long orientationId);

    void replaceBatch(@Param("packageRels") List<KuaishouPopulationPackageRel> packageRels);

    List<JSONObject> queryPushResults(@Param("id") Long id, @Param("accountIds") JSONArray accountIds);

    List<JSONObject> getRelatedAccounts(@Param("id") Long id);

    KuaishouPopulationPackageRel queryEntity(@Param("accountId") Long accountId, @Param("id") Long id);

    List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId, @Param("id") String id);

    void updateStatus(@Param("rel") KuaishouPopulationPackageRel rel);

    List<Long> queryByOrientationId(@Param("orientationId") Long orientationId, @Param("accountId") Long accountId);
}
