using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;

namespace Mall.Repository.Education
{
    public class Rb_Education_DynamicLikeRepository : BaseRepository<Rb_Education_DynamicLike>
    {
        /// <summary>
        /// 获取动态点赞
        /// </summary>
        /// <param name="articleId">动态文章id</param>
        /// <returns></returns>
        public List<Rb_Education_DynamicLike_Extend> GetDynamicLikeList(Rb_Education_DynamicLike_Extend model)
        {
            string where = " where 1=1 ";
            if (model != null)
            {
                if (model.TenantId > 0)
                {
                    where += $@" and l.TenantId = {model.TenantId} ";
                }
                if (model.MallBaseId > 0)
                {
                    where += $@" and l.MallBaseId = {model.MallBaseId} ";
                }
                if (model.UserId > 0)
                {
                    where += $@" and l.UserId = {model.UserId} ";
                }
                if (model.ArticleId > 0)
                {
                    where += $@" and l.ArticleId = {model.ArticleId} ";
                }
                if (!string.IsNullOrWhiteSpace(model.ArticleIds))
                {
                    where += $@" and l.ArticleId in({model.ArticleIds} ) ";
                }
            }
            string sql = $@"SELECT l.*,e.`Name` as EmName from rb_education_dynamiclike l 
                            INNER JOIN  rb_member_user e  on e.Id = l.UserId
                            {where} order by l.CreateTime desc";
            return Get<Rb_Education_DynamicLike_Extend>(sql).ToList();
        }


        
    }
}
