using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using JuSNS.Model;
using System.Data;

namespace JuSNS.Factory
{
    public interface IMood
    {
        /// <summary>
        /// 保存心情日记
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="Content">内容</param>
        /// <param name="MType">类型</param>
        /// <returns></returns>
        int SaveMini(int userId, string content, string MType);
        /// <summary>
        /// 删除心情日记
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        int DeleteMini(int userId, int miniId, bool isAdmin);
        /// <summary>
        /// 获取MiniBlog实例
        /// </summary>
        /// <param name="MiniID">MiniBlogID</param>
        /// <returns></returns>
        MiniBlogInfo GetMiniInfo(int MiniID);
        /// <summary>
        /// 检查是否有查看迷你日志的权限
        /// </summary>
        /// <param name="hostId"></param>
        /// <param name="guestId"></param>
        /// <returns></returns>
        bool CheckAuthority(int hostId, int guestId);
        /// <summary>
        /// 获取用户的最后发布的心情日记
        /// </summary>
        /// <param name="vistor"></param>
        /// <param name="owner"></param>
        /// <returns></returns>
        MiniBlogInfo GetLastInfo(int vistor, int owner);

        /// <summary>
        /// 得到心情日记的评论
        /// </summary>
        /// <param name="Mid">心情日记的ID</param>
        /// <returns></returns>
        IDataReader GetMiniComment(int Mid);

        /// <summary>
        /// 得到迷你博客的评论数量
        /// </summary>
        /// <param name="mid">迷你博客ID</param>
        /// <returns></returns>
        int GetMiniCount(int mid);

        /// <summary>
        /// 保存心情日记评论
        /// </summary>
        /// <param name="mid">被评论的ID</param>
        /// <param name="Content">内容</param>
        /// <param name="UserID">用户</param>
        /// <param name="CommentID">父ID</param>
        void SaveMiniComment(int mid, string Content, int UserID, int CommentID);
        /// <summary>
        /// 删除心情日记评论
        /// </summary>
        /// <param name="bid"></param>
        void DelMiniComent(int bid);
        #region 管理员后台
        /// <summary>
        /// 迷你博客搜索
        /// </summary>
        /// <param name="searchCondition">搜索条件:1.按作者姓名;2.按日志标题</param>
        /// <param name="keyword">搜索关键字</param>
        /// <param name="orderType">排序方式:1.按发表日期;2.按作者姓名;3.按评论数</param>
        /// <returns></returns>
        DataTable Search(int searchCondition, string keyword, int orderType, int pageIndex, int pageSize, out int recordCount, out int pageCount);

        void updateMiniRec(int ID, int NUM);
        /// <summary>
        /// 锁定或解锁心情日记
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="blogId"></param>
        /// <param name="lockSate"></param>
        int ChangeLock(int userId, int miniBlogId, bool lockSate);
        #endregion
    }
    public sealed partial class DataAccess
    {
        public static IMood CreateMood()
        {
            string className = path + ".Mood";
            return (IMood)Assembly.Load(path).CreateInstance(className);
        }
    }
}
