using Api.Framework;
using Api.Framework.Enums;
using Api.Framework.Model;
using Api.Framework.Tools;
using JDRebate.Entitys;
using JDRebate.Properties;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JDRebate
{
public static class SessionExt
{
const string jdinfo_temp_list_jdrebate = "jdinfo_temp_list_jdrebates";
///
/// 获取fl_adzone_info表的数据集合缓存
///
///
/// 刷新
///
public static List FindJdInfoTempGroups(this SqlSugarClient session, bool refresh = false)
{
var jdinfo_temp_groups = ApiClient.Cache.Get>(jdinfo_temp_list_jdrebate);//根据KEY、获得缓存
if (refresh || jdinfo_temp_groups == null)
{
jdinfo_temp_groups = session.Find($"select ri.id as ID,ri.type as chattype,ri.name as name,ri.nick as nick,flag.* from fl_robot_info ri left join (select ai1_temp.robot_id as id,ai1_temp.onoff as onoff,ai1_temp.adzone_pid_cps_name as pid_chief_cps_name,ai1_temp.adzone_pid as pid_chief,ai1_temp.adzone_name as pid_chief_name,ai2_temp.adzone_pid_cps_name as pid_deputy_cps_name,ai2_temp.adzone_pid as pid_deputy,ai2_temp.adzone_name as pid_deputy_name from (select * from fl_adzone_info ai1 where ai1.alliance_id = @allianceId and ai1.custom_type = @customType and ai1.extend = 'chief') ai1_temp INNER JOIN (select * from fl_adzone_info ai2 where ai2.alliance_id = @allianceId and ai2.custom_type = @customType and ai2.extend='deputy') ai2_temp on ai1_temp.robot_id = ai2_temp.robot_id) flag on ri.id = flag.id", new { allianceId = (int)CpsType.京东联盟, customType = Resources.SoftwareType });
ApiClient.Cache.Set(jdinfo_temp_list_jdrebate, jdinfo_temp_groups, 60);
}
return jdinfo_temp_groups;
}
public static void Clear()
{
ApiClient.Cache.Remove(jdinfo_temp_list_jdrebate);
}
}
}