diff --git a/internal/logic/domain/group/model/group_notice.go b/internal/logic/domain/group/model/group_notice.go new file mode 100644 index 0000000..83022ea --- /dev/null +++ b/internal/logic/domain/group/model/group_notice.go @@ -0,0 +1,17 @@ +package model + +import ( + "time" +) + +type GroupComplain struct { + Id int64 // 自增主键 + GroupId int64 // 群组id + UserId int64 // 用户id + ComplainType int // 投诉类型(1:存在赌博行为 2:存在骗钱行为 3:不当信息骚扰 4:传播谣言 5:发布假冒商品信息 6:侵犯未成年人权益 7:其他) + Text string // 投诉内容 + ImageList string // 图片 + Status int // 状态 + CreateTime time.Time // 创建时间 + UpdateTime time.Time // 更新时间 +} diff --git a/internal/logic/domain/group/model/group_notice_with_like_records.go b/internal/logic/domain/group/model/group_notice_with_like_records.go new file mode 100644 index 0000000..4000023 --- /dev/null +++ b/internal/logic/domain/group/model/group_notice_with_like_records.go @@ -0,0 +1,17 @@ +package model + +import ( + "time" +) + +type GroupNotice struct { + Id int64 // 自增主键 + GroupId int64 // 群组id + UserId int64 // 用户id + Content string // 公告内容 + LikeNums int // 点赞数量 + ReadNums int // 阅读数量 + PublishType int32 // 发布方式(1:仅发布 2:发布并通知 3:通知并置顶) + CreateTime time.Time // 创建时间 + UpdateTime time.Time // 更新时间 +} diff --git a/internal/logic/domain/group/repo/group_notice_dao.go b/internal/logic/domain/group/repo/group_notice_dao.go new file mode 100644 index 0000000..75ca20a --- /dev/null +++ b/internal/logic/domain/group/repo/group_notice_dao.go @@ -0,0 +1,35 @@ +package repo + +import ( + "egg-im/internal/logic/domain/group/model" + "egg-im/pkg/db" + "egg-im/pkg/gerrors" + + "github.com/jinzhu/gorm" +) + +type groupComplainDao struct{} + +var GroupComplainDao = new(groupComplainDao) + +// Get 获取群组信息 +func (*groupComplainDao) Get(id int64) (*model.GroupComplain, error) { + var group = model.GroupComplain{Id: id} + err := db.DB.First(&group).Error + if err != nil && err != gorm.ErrRecordNotFound { + return nil, gerrors.WrapError(err) + } + if err == gorm.ErrRecordNotFound { + return nil, nil + } + return &group, nil +} + +// Save 插入一条群组 +func (*groupComplainDao) Save(group *model.GroupComplain) error { + err := db.DB.Save(&group).Error + if err != nil { + return gerrors.WrapError(err) + } + return nil +} diff --git a/internal/logic/domain/group/repo/group_notice_with_like_records_dao.go b/internal/logic/domain/group/repo/group_notice_with_like_records_dao.go new file mode 100644 index 0000000..c01a83e --- /dev/null +++ b/internal/logic/domain/group/repo/group_notice_with_like_records_dao.go @@ -0,0 +1,35 @@ +package repo + +import ( + "egg-im/internal/logic/domain/group/model" + "egg-im/pkg/db" + "egg-im/pkg/gerrors" + + "github.com/jinzhu/gorm" +) + +type groupNoticeDao struct{} + +var GroupNoticeDao = new(groupNoticeDao) + +// Get 获取群组公告信息 +func (*groupNoticeDao) Get(groupId int64) (*model.GroupNotice, error) { + var group = model.GroupNotice{GroupId: groupId} + err := db.DB.First(&group).Error + if err != nil && err != gorm.ErrRecordNotFound { + return nil, gerrors.WrapError(err) + } + if err == gorm.ErrRecordNotFound { + return nil, nil + } + return &group, nil +} + +// Save 插入一条群组 +func (*groupNoticeDao) Save(groupNotice *model.GroupNotice) error { + err := db.DB.Save(&groupNotice).Error + if err != nil { + return gerrors.WrapError(err) + } + return nil +} diff --git a/pkg/proto/business.ext.proto b/pkg/proto/business.ext.proto index 84ce20a..e384971 100644 --- a/pkg/proto/business.ext.proto +++ b/pkg/proto/business.ext.proto @@ -21,8 +21,45 @@ service BusinessExt { rpc IsFriends (IsFriendsReq) returns (IsFriendsResp); // 投诉群 rpc ComplainGroup (ComplainGroupReq) returns (Empty); + // 发布群公告 + rpc PublishGroupNotice (PublishGroupNoticeReq) returns (Empty); + // 查看群公告 + rpc ViewGroupNotice (ViewGroupNoticeReq) returns (ViewGroupNoticeResp); + // 点赞群公告 + rpc LikeGroupNotice (LikeGroupNoticeReq) returns (Empty); + // 取消点赞群公告 + rpc CancelLikeGroupNotice (CancelLikeGroupNoticeReq) returns (Empty); } +message LikeGroupNoticeReq { + int64 group_id = 1; +} + +message CancelLikeGroupNoticeReq { + int64 group_id = 1; +} + +message ViewGroupNoticeReq { + int64 group_id = 1; +} + +message ViewGroupNoticeResp { + int64 group_id = 1; + int64 user_id = 2; //发布用户id + string content = 3; //公告内容 + int64 like_nums = 4; //点赞数量 + int64 read_nums = 5; //阅读数量 + GroupNoticePublishType publish_type = 6; // 发布方式 + string publish_time = 7; // 发布时间 + bool is_like = 8; // 是否点赞 +} + +message PublishGroupNoticeReq { + int64 group_id = 1; + int64 user_id = 2; //发布用户id + GroupNoticePublishType publish_type = 3; // 发布方式 + string content = 4; // 发布内容 +} message ComplainGroupReq { int64 group_id = 1; @@ -31,7 +68,7 @@ message ComplainGroupReq { repeated string image_list = 4; // 图片 } -// 消息类型 +// 投诉类型 enum ComplainType { CT_UNKNOWN = 0; // 未知 CT_GAMBLE = 1; // 存在赌博行为 @@ -43,6 +80,14 @@ enum ComplainType { MT_OTHER = 7; // 其他 } +// 群公告发布方式 +enum GroupNoticePublishType { + UNKNOWN_PUBLISH = 0; // 未知 + ONLY_PUBLISH = 1; // 仅发布 + PUBLISH_AND_NOTICE = 2; // 发布并通知 + NOTICE_AND_TOP_UP = 3; // 存在骗钱行为 +} + message IsFriendsReq { string user_phone = 1;