package com.reyun.saas.mob.user.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author: hanzepeng
 * @Date: 2021/10/27/17:43
 * @Description: 同步sdk策略使用
 */
public interface SdkPolicyMapper {

    /**
     * 查询在c_policy_config 表中开启的 sdk与策略对应关系
     */
    @Select("select t2.policy_name as 'policy_name',t2.sdk_version as 'sdk_version' " +
            "from mob_dna_android_policy.c_policy_config t1 " +
            "inner join mob_dna_android_policy.c_policy_sdk_version t2 " +
            "on t1.policy = t2.policy_name " +
            "where t1.`on` = '1'")
    List<Map<String,Object>> findAndroidSdkVersionLinkConfig();


    @Select("SELECT * FROM mob_dna_android_policy.c_policy_sdk_version WHERE sdk_version = #{sdkVersion}")
    List<Map<String,Object>> findPolicyBySdkVersion(@Param("sdkVersion")String sdkVersion);


    /**
     * 查询 启用 的c_policy_config数据
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_config WHERE `on` = '1'")
    List<Map<String,Object>> findAndroidSdkPolicyConfigByOn();


    @Select("SELECT * FROM mob_dna_android_policy.c_policy_battary WHERE `on` = '1' LIMIT #{page},#{size}")
    List<Map<String,Object>> findBattaryPolicyLimit(@Param("page")Integer page, @Param("size")Integer size);

    /**
     * 查询启用的c_policy_screen策略
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_screen WHERE `on` = '1'")
    List<Map<String, Object>> findAndroidScreenPolicyByOn();

    /**
     * 查询启用的c_policy_battary策略
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_battary WHERE `on` = '1'")
    List<Map<String, Object>> findAndroidBattaryPolicyByOn();

    /**
     * 查询启用的c_policy_apps策略
     * @return
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_apps WHERE `on` = '1'")
    List<Map<String, Object>> findAndroidAppsPolicyByOn();

    /**
     * 查询启用的c_policy_env策略
     * @return
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_env WHERE `on` = '1'")
    List<Map<String, Object>> findAndroidEnvPolicyByOn();

    /**
     * 查询启用的c_policy_mem策略
     * @return
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_mem WHERE `on` = '1'")
    List<Map<String, Object>> findAndroidMemPolicyByOn();

    /**
     * 查询启用的c_policy_camera策略
     * @return
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_camera WHERE `on` = '1'")
    List<Map<String, Object>> findAndroidCameraPolicyByOn();

    /**
     * 查询启用的c_policy_bad_apps 策略
     * @return
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_bad_apps WHERE `on` = '1'")
    List<Map<String, Object>> findAndroidBadAppsPolicyByOn();

    /**
     * 查询启用的c_policy_bad_acc 策略
     * @return
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_bad_acc WHERE `on` = '1'")
    List<Map<String, Object>> findAndroidBadAccPolicyByOn();

    /**
     * 查询启用的安卓标签表
     * @return
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_tag_config WHERE `on` = '1'")
    List<Map<String, Object>> findAndroidTagConfigByOn();

    /**
     * 查询启用的c_policy_bad_wifi 策略
     * @return
     */
    @Select("SELECT * FROM mob_dna_android_policy.c_policy_bad_wifi WHERE `on` = '1'")
    List<Map<String, Object>> findAndroidBadWifiByOn();


    /**
     * 查询在i_policy_config 表中开启的 sdk与策略对应关系
     */
    @Select("select t2.policy_name as 'policy_name',t2.sdk_version as 'sdk_version' " +
            "from mob_dna_ios_policy.i_policy_config t1 " +
            "inner join mob_dna_ios_policy.i_policy_sdk_version t2 " +
            "on t1.policy = t2.policy_name " +
            "where t1.`on` = '1'")
    List<Map<String,Object>> findIosSdkVersionLinkConfig();

    /**
     * 查询 启用 的i_policy_config数据
     */
    @Select("SELECT * FROM mob_dna_ios_policy.i_policy_config WHERE `on` = '1'")
    List<Map<String, Object>> findIosSdkPolicyConfigByOn();

    /**
     * 查询启用的IOS标签表
     * @return
     */
    @Select("SELECT * FROM mob_dna_ios_policy.i_policy_tag_config WHERE `on` = '1'")
    List<Map<String, Object>> findIosTagConfigByOn();

    /**
     * 查询启用的205策略
     */
    @Select("SELECT model,build_ver,lib_vers FROM mob_dna_ios_policy.i_policy_205 WHERE `on` = 1")
    List<Map<String, Object>> findIos205PolicyByOn();

}
