//
//  GroupNetApi.m
//  TUIContact
//
//  Created by gan on 2025/3/24.
//

#import <Foundation/Foundation.h>
#import "GroupNetApi.h"



@implementation GroupNetApi


//新建群组
+(void)addNewGroup:(NSDictionary *_Nullable)parameters succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    [GBaseNetApi.shareInstance httpPostToken:parameters url:@"/api/sys/groups?" succ:succ fail:fail];
}

//更新群组信息
+(void)updateGroup:(NSDictionary *_Nullable)parameters groupId:(NSString *)groupId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groups/%@",groupId];
    [GBaseNetApi.shareInstance httpPatchToken:parameters url:urlstr succ:succ fail:fail];
}

//获取群组信息
+(void)getGroupInfo:(NSString *)groupId  succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groups/%@",groupId];
    [GBaseNetApi.shareInstance httpGetToken:nil url:urlstr succ:succ fail:fail];
}

//获取用户加入的群组列表
+(void)getGroupList:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groups"];
    [GBaseNetApi.shareInstance httpGetToken:nil url:urlstr succ:succ fail:fail];
}

//获取群组内用户列表
+(void)getGroupUserList:(NSString *_Nullable)groupId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groups/%@/users",groupId];
    [GBaseNetApi.shareInstance httpGetToken:nil url:urlstr succ:succ fail:fail];
}


//删除自己的群
+(void)deleteGroup:(NSString *_Nullable)groupId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groups/%@",groupId];
    [GBaseNetApi.shareInstance httpDelToken:nil url:urlstr succ:succ fail:fail];
}

//退出群
+(void)exitGroup:(NSString *_Nullable)groupId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groups/%@/exit",groupId];
    [GBaseNetApi.shareInstance httpDelToken:nil url:urlstr succ:succ fail:fail];
}


//将用户添加入群
+(void)addUsertoGroup:(NSDictionary *_Nullable)parameters groupId:(NSString *_Nullable)groupId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groups/addGroup"];
    [GBaseNetApi.shareInstance httpPostToken:parameters url:urlstr succ:succ fail:fail];
}


//将用户踢出群
+(void)getoutUserGroup:(NSString *_Nullable)groupId userId:(NSString *_Nullable)userId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groups/%@/users/%@",groupId,userId];
    [GBaseNetApi.shareInstance httpDelToken:nil url:urlstr succ:succ fail:fail];
}


//批量将用户踢出群
+(void)getoutUsersGroup:(NSDictionary *_Nullable)parameters succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    
}


//转让群主
+(void)transferGroup:(NSString *_Nullable)groupId userId:(NSString *_Nullable)userId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groups/%@/transference/%@",groupId,userId];
    [GBaseNetApi.shareInstance httpPostToken:nil url:urlstr succ:succ fail:fail];
}

//上传头像
+(void)upLoaddataWToken:(NSData *_Nonnull)data fileName:(NSString *_Nullable)fileName succ:(GSucc _Nullable )succ fail:(GFail _Nullable )fail{
    [GBaseNetApi.shareInstance upLoaddataWToken:data fileName:fileName succ:succ fail:fail];
}


/**
 * 查询当前待审核的群邀请
 */
+(void)getshenheList:(NSString *_Nullable)groupId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groupInvites?groupId=%@",groupId];
    [GBaseNetApi.shareInstance httpGetToken:nil url:urlstr succ:succ fail:fail];
}
/**
 * 查询当前待审核的群邀请数量
 */
+(void)waitCheckList:(NSString *_Nullable)groupId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groupInvites/waitCheckList"];
    [GBaseNetApi.shareInstance httpGetToken:nil url:urlstr succ:succ fail:fail];
}

//同意加入
+(void)Checkagree:(NSString *_Nullable)groupId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groupInvites/agree/%@",groupId];
    [GBaseNetApi.shareInstance httpPostToken:nil url:urlstr succ:succ fail:fail];
}
//拒绝加入
+(void)Checkrefuse:(NSString *_Nullable)groupId succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/groupInvites/refuse/%@",groupId];
    [GBaseNetApi.shareInstance httpPostToken:nil url:urlstr succ:succ fail:fail];
}

+(void)getGroupMsgListWithChatId:(NSString * _Nonnull)chatId time:(NSInteger)timestamp pageSize:(NSInteger)size succ:(nullable GSucc)succ fail:(nullable GFail)fail{
    //http://br1.qihg091ew.com:8080/api/sys/messages/queryGroupMessage?type=1&chatId=1936003432742780929&timestamp=-1&size=20
    NSString *urlstr=[NSString stringWithFormat:@"/api/sys/messages/queryGroupMessage?type=1&chatId=%@&timestamp=%ld&size=%ld",chatId,timestamp,size];
    [GBaseNetApi.shareInstance httpGetToken:nil url:urlstr succ:succ fail:fail];
}

@end
