using Dapper;
using NetCore.Model.enums;
using NetCore.Model.qw;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace NetCore.BLL
{
public class bas_config_bll
{
private string comcode;
public bas_config_bll(string _comcode)
{
comcode = _comcode;
}
///
/// 获取配置
///
///
public bas_config GetConfig(BasConfigEnum config)
{
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode, false))
{
return con.QueryFirstOrDefault("select code,value from bas_config where code=@code", new { code = config.ToString() });
}
}
///
/// 获取需要补充的关键字数据
///
///
public int GetIntConfig(BasConfigEnum config)
{
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode, false))
{
bas_config co = con.QueryFirstOrDefault("select code,value from bas_config where code=@code", new { code = config.ToString() });
return co == null ? 0 : Convert.ToInt32(co.value);
}
}
///
/// 获取当前消息库的消息表列表
///
///
///
public List GetCorpTable(string corpid)
{
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode, false))
{
string sql = @"select TABLE_NAME table_name from information_schema.`TABLES`
where table_schema=@dbname
and table_name REGEXP'^ww_message_[0-9]{6}'
and table_name<=@nowtablename
order by TABLE_NAME ASC";
return con.Query(sql, new
{
dbname = string.Format("wework_{0}", corpid),
nowtablename = string.Format("ww_message_{0}", DateTime.Now.ToString("yyyyMM"))
}, buffered: false).ToList();
}
}
}
}