using Edu.Model.Entity.OKR;
using Edu.Model.ViewModel.OKR;
using System.Collections.Generic;
using System.Linq;

namespace Edu.Repository.OKR
{
    /// <summary>
    /// OKR关注仓储层
    /// </summary>
    public class RB_OKR_AttentionRepository : BaseRepository<RB_OKR_Attention>
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="demodel"></param>
        /// <returns></returns>
        public List<RB_OKR_Attention_ViewModel> GetList(RB_OKR_Attention_ViewModel demodel)
        {
            string where = $@" 1=1 and Status =0";
            if (demodel.Group_Id > 0)
            {
                where += $@" and {nameof(RB_OKR_Attention_ViewModel.Group_Id)} ={demodel.Group_Id}";
            }
            if (demodel.AccountId > 0)
            {
                where += $@" and {nameof(RB_OKR_Attention_ViewModel.AccountId)} ={demodel.AccountId}";
            }
            if (demodel.AttentionId > 0)
            {
                where += $@" and {nameof(RB_OKR_Attention_ViewModel.AttentionId)} ={demodel.AttentionId}";
            }

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