using Edu.Common.Enum;
using Edu.Model.Entity.OKR;
using Edu.Model.ViewModel.OKR;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;

namespace Edu.Repository.OKR
{
    /// <summary>
    /// OKR规则关联仓储层
    /// </summary>
    public class RB_OKR_RuleRelationRepository : BaseRepository<RB_OKR_RuleRelation>
    {

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="demodel"></param>
        /// <returns></returns>
        public List<RB_OKR_RuleRelation_ViewModel> GetList(RB_OKR_RuleRelation_ViewModel demodel)
        {
            string where = $@" 1=1 ";
            if (demodel.KeyResultId > 0)
            {
                where += $@" and {nameof(RB_OKR_RuleRelation_ViewModel.KeyResultId)} ={demodel.KeyResultId}";
            }
            if (!string.IsNullOrEmpty(demodel.KeyResultIds))
            {
                where += $@" and {nameof(RB_OKR_RuleRelation_ViewModel.KeyResultId)} in({demodel.KeyResultIds})";
            }

            string sql = $@" select * from RB_OKR_RuleRelation where {where} order by Id desc";
            return Get<RB_OKR_RuleRelation_ViewModel>(sql).ToList();
        }
    }
}