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

namespace JuSNS.Factory
{
    public interface IGroupMember
    {
        /// <summary>
        /// 加入群组
        /// </summary>
        /// <param name="Info">群组成员实体类</param>
        /// <returns>加入成功返回1</returns>
        int Join(GroupMemberInfo Info);

        /// <summary>
        /// 退出一个群
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <param name="GroupID">群编号</param>
        /// <returns></returns>
        int Out(int UserID, int GroupID);

        /// <summary>
        /// 设置群成员为管理员
        /// </summary>
        /// <param name="GroupUserID">群成员编号</param>
        /// <param name="GroupID">组编号</param>
        /// <param name="UserID">群主编号</param>
        /// <returns>设置成功返回1</returns>
        int SetAdmin(int GroupUserID, int GroupID, int UserID);

        /// <summary>
        /// 删除群管理员
        /// </summary>
        /// <param name="GroupUserID">群成员编号</param>
        /// <param name="GroupID">组编号</param>
        /// <param name="UserID">群主编号</param>
        /// <returns>设置成功返回1</returns>
        int DelAdmin(int GroupUserID, int GroupID, int UserID);


        /// <summary>
        /// 管理员辞职
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <param name="GroupID">群组编号</param>
        /// <returns>辞职成功返回1</returns>
        int QuitGroup(int UserID, int GroupID);

        /// <summary>
        /// 取得群组各等级类型的群员列表
        /// </summary>
        /// <param name="Grade">等级</param>
        /// <param name="GroupID">组编号</param>
        /// <returns></returns>
        DataTable GroupMemberGradeList(int Grade, int GroupID);

        /// <summary>
        /// 取得最新六位成员
        /// </summary>
        /// <param name="GroupID">群组编号</param>
        /// <returns>返回数据表</returns>
        DataTable Top6GroupMemberList(int GroupID);

        /// <summary>
        /// 检查会员是不是此组的成员
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <param name="GroupID">群组编号</param>
        /// <returns>如果是返回true，否则返回false</returns>
        bool IsGroupMember(int UserID, int GroupID);

        /// <summary>
        /// 检查会员是不是此组的管理员
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <param name="GroupID">群组编号</param>
        /// <returns>如果是返回true，否则返回false</returns>
        bool IsGroupAdmin(int UserID, int GroupID);

        /// <summary>
        /// 取得群组是否有邀请
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <returns>返回数据表</returns>
        DataTable getGroupRequest(int UserID);

        /// <summary>
        /// 取得群组成员信息
        /// </summary>
        /// <param name="ID">记录编号</param>
        /// <returns></returns>
        GroupMemberInfo Info(int ID);
    }

    public sealed partial class DataAccess
    {
        public static IGroupMember CreateGroupMember()
        {
            string className = path + ".GroupMember";
            return (IGroupMember)Assembly.Load(path).CreateInstance(className);
        }
    }
}
