using Edu.Model.Entity.WeChat;
using Edu.Model.ViewModel.WeChat;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Edu.Repository.WeChat
{
    /// <summary>
    /// 企业微信APP
    /// </summary>
    public class RB_WeChat_APPRepository : BaseRepository<RB_WeChat_APP>
    {
        private const string TABLE_NAME = nameof(RB_WeChat_APP);

        /// <summary>
        /// 获取指定代号的应用
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public RB_WeChat_APP_ViewModel GetAPPConfigByCodeAndParent(int parentId, string code)
        {
            var sql = $"select Id,ParentId,AppId,Secret,Code from {TABLE_NAME} where ParentId={parentId} and Code='{code}'";

            var result = Get<RB_WeChat_APP_ViewModel>(sql).ToList();
            return result.FirstOrDefault();
        }
    }
}
