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_ScoreDetailRepository : BaseRepository<RB_OKR_ScoreDetail>
    {

        /// <summary>
        /// 获取分页列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="rowsCount"></param>
        /// <param name="demodel"></param>
        /// <returns></returns>
        public List<RB_OKR_ScoreDetail_ViewModel> GetPageList(int pageIndex, int pageSize, out long rowsCount, RB_OKR_ScoreDetail_ViewModel demodel)
        {
            string where = $@" 1=1";
            if (demodel.ScoreId > 0)
            {
                where += $@" and {nameof(RB_OKR_ScoreDetail_ViewModel.ScoreId)} ={demodel.ScoreId}";
            }

            string sql = $@" select * from RB_OKR_ScoreDetail where {where} order by Id desc";
            return GetPage<RB_OKR_ScoreDetail_ViewModel>(pageIndex, pageSize, out rowsCount, sql).ToList();
        }

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

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