//
//  GroupDBMgr.h
//  zhuxun
//
//  Created by winsoft on 17/4/24.
//
//
//立马内存返回更改后的数据,异步再存储/update
#import <Foundation/Foundation.h>

//数据模型不变
//#import "UserGroupEntity.h"
//#import "MessageEntity.h"
//#import "RecentEntity.h"
//#import "NoticeModels.h"
//#import "AddrBook.h"

@interface GroupDBMgr : NSObject

+ (instancetype)shareInstance;
/**
 *  数据库写入消息体
 *
 *  @param uuid        消息唯一id,如果不存在,则创建
 *  @param content     消息内容
 *  @param voiceLength 消息长度
 *  @param localPath   本地路径
 *  @param conteType   消息内容类型
 *  @param msgType     消息来源类型(个人/群体)
 *  @param name        receive dispalyName/GroupName
 *  @param resultBlock 结果
 *
 *  @return 消息体
 */
//- (MessageEntity *)createMessageWithUUID:(NSString *)uuid sessionID:(NSString *)sessionID content:(NSString *)content voiceLength:(NSNumber *)voiceLength localPath:(NSString *)localPath msgContentType:(int)conteType msgType:(int)msgType fileDownUpStatus:(int)fileDownUpStatus msgState:(int)msgState  name:(NSString *)name  time:(NSDate *)date resultBlock:(void(^)())resultBlock;

//有可能为富文本.
- (NSArray *)createSingleMessageWithJSONParams:(NSDictionary *)params resultBlock:(void(^)())resultBlock;

- (NSArray *)createGroupMessageWithJSONParams:(NSDictionary *)params resultBlock:(void(^)())resultBlock;
/**
 *  pc截图富文本处理
 *
 *  @param msgDic      jsondata
 *  @param resultBlock callback
 *
 *  @return 多个msgs
 */
- (NSArray *)createMessagesWithSingleMutialTextPicMessage:(NSDictionary *)msgDic resultBlock:(void(^)())resultBlock;

- (void)deleteMessageWithTitle:(NSString *)title UUID:(NSString *)uuid sessionID:(NSString *)sessionID resultBlock:(void(^)())resultBlock;
/**
 *  获取群的最后一条消息
 *
 *  @param groupID     群id
 *  @param resultBlock result
 */
//- (void)getLatestMessageInGroupWithGroupID:(NSString *)groupID resultBlock:(void(^)(MessageEntity *msgEntity))resultBlock;
/**
 *  数据库写入通知
 *
 *  @param params      json参数
 *  @param resultBlock result call back
 *
 *  @return NoticeModels
 */
//- (NoticeModels *)createNoticeModelWithJSONParams:(NSDictionary *)params resultBlock:(void(^)())resultBlock;

/**
 *  修改recent表->注意也修改dict的recent.,如果没有则创建.
 *
 *  @param sessionID   recentID
 *  @param type        群/个人
 *  @param title       title
 *  @param uuid        对应的消息唯一id
 *  @param lastTime    最后一条消息时间
 *  @param unreadCount 未读数,一般+1
 *  @param lastMsg     最后一条消息
 *
 *  @return <#return value description#>
 */
//- (RecentEntity *)updateRecentEntityWithSessionID:(NSString *)sessionID type:(int)type title:(NSString *)title uuid:(NSString *)uuid lastTime:(NSDate *)lastTime unreadCount:(NSInteger)unreadCount lastMsg:(NSString *)lastMsg  resultBlock:(void(^)())resultBlock;

//- (RecentEntity *)updateRecentEntityWithMsgEntity:(MessageEntity *)msgEntity unreadCount:(int)unreadCount title:(NSString *)title resultBlock:(void(^)())resultBlock;

//建群
//- (UserGroupEntity *)createGroupEntityWithGroupID:(NSString *)groupID groupName:(NSString *)groupName creator:(NSString *)creator managers:(NSArray *)managers groupMembers:(NSArray *)groupMembers groupHeaderImage:(UIImage *)groupHeaderImage createTs:(NSDate *)ts ActiveAs:(NSDate *)as JoinJs:(NSDate *)js ignores:(NSArray *)ignors tags:(NSArray *)tags notice:(NSString *)notice intro:(NSString *)intro invite:(NSNumber *)invite type:(NSNumber *)type ver:(NSNumber *)ver auth:(NSNumber *)auth msgReceiveLevel:(NSNumber *)msgReceiveLevel unreadMsgCount:(NSNumber *)unradMsgCount unreadMsgIdentifierDict:(NSDictionary *)unreadMsgIdentifierDict  resultBlock:(void(^)())resultBlock;

//- (UserGroupEntity *)createGroupEntityWithGroupParams:(NSDictionary *)params resultBlock:(void(^)())resultBlock;

//- (void)getGroupEntityWithGroupID:(NSString *)groupID resultGroupEntityBlock:(void(^)(UserGroupEntity *userGroupEntity))resultGroupEntityBlock;
//群解散
- (void)deleteGroupWithGroupID:(NSString *)groupID  resultBlock:(void(^)())resultBlock;

//被踢
- (void)kickOutFromGroupWithGroupID:(NSString *)groupID  resultBlock:(void(^)())resultBlock;
#warning 2017-05-26 待新增群踢人..

- (void)getMyAllGroupsWithResultGroupsBlock:(void(^)(NSArray *))groups;
//- (UserGroupEntity *)updateGroupEntityWithParams:(NSDictionary *)params  resultBlock:(void(^)())resultBlock;
//- (UserGroupEntity *)updateGroupEntityWithGroupID:(NSString *)groupID groupName:(NSString *)groupName creator:(NSString *)creator managers:(NSArray *)managers groupMembers:(NSArray *)groupMembers groupHeaderImage:(UIImage *)groupHeaderImage createTs:(NSDate *)ts ActiveAs:(NSDate *)as JoinJs:(NSDate *)js ignores:(NSArray *)ignors tags:(NSArray *)tags notice:(NSString *)notice intro:(NSString *)intro invite:(NSNumber *)invite type:(NSNumber *)type ver:(NSNumber *)ver auth:(NSNumber *)auth  resultBlock:(void(^)())resultBlock;

//- (AddrBook *)getAddrbookWithUerID:(NSString *)userID;
//- (AddrBook *)createUserDetailsWithJSONParams:(NSDictionary *)prams resultBlock:(void(^)())resultBlock;
//- (AddrBook *)updateUserDetailsWithJSONParams:(NSDictionary *)prams resultBlock:(void(^)())resultBlock;
@end
