using Edu.Common.Enum;
using Edu.Model.Entity.OKR;
using Edu.Model.ViewModel.OKR;
using System;
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_MatterRepository : BaseRepository<RB_OKR_Matter>
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="demodel"></param>
        /// <returns></returns>
        public List<RB_OKR_Matter> GetList(RB_OKR_Matter demodel)
        {
            string where = $@" 1=1 and Status =0";
            if (demodel.Group_Id > 0)
            {
                where += $@" and {nameof(RB_OKR_Matter.Group_Id)} ={demodel.Group_Id}";
            }
            if (demodel.PeriodId > 0)
            {
                where += $@" and {nameof(RB_OKR_Matter.PeriodId)} ={demodel.PeriodId}";
            }
            if (demodel.UserId > 0)
            {
                where += $@" and {nameof(RB_OKR_Matter.UserId)} ={demodel.UserId}";
            }
            if (demodel.Type > 0)
            {
                where += $@" and {nameof(RB_OKR_Matter.Type)} ={(int)demodel.Type}";
            }
            string sql = $@" select * from RB_OKR_Matter where {where} order by Id desc";
            return Get<RB_OKR_Matter>(sql).ToList();
        }
    }
}