From d60eb1a5adfb73e12a58464f20bb2e0c898d012a Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 31 Dec 2024 17:57:36 +0800 Subject: [PATCH] =?UTF-8?q?im=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd_db_im.bat | 25 +++++++++++++++++ src/im/model/group.go | 19 +++++++++++++ src/im/model/group_notice.go | 17 ++++++++++++ .../model/group_notice_with_like_records.go | 7 +++++ src/im/model/group_user.go | 17 ++++++++++++ src/im/model/im_send_red_package_ord.go | 27 +++++++++++++++++++ src/im/model/user.go | 18 +++++++++++++ 7 files changed, 130 insertions(+) create mode 100644 cmd_db_im.bat create mode 100644 src/im/model/group.go create mode 100644 src/im/model/group_notice.go create mode 100644 src/im/model/group_notice_with_like_records.go create mode 100644 src/im/model/group_user.go create mode 100644 src/im/model/im_send_red_package_ord.go create mode 100644 src/im/model/user.go diff --git a/cmd_db_im.bat b/cmd_db_im.bat new file mode 100644 index 0000000..2661ea0 --- /dev/null +++ b/cmd_db_im.bat @@ -0,0 +1,25 @@ +@echo off + +set Table=* +set TName="" +set one=%1 + +if "%one%" NEQ "" ( + set Table=%one% + set TName="^%one%$" +) + +set BasePath="./" +set DBUSER="root" +set DBPSW="Fnuo123com@" +set DBNAME="egg-im" +set DBHOST="119.23.182.117" +set DBPORT="3306" + +del "src\model\%Table%.go" + +echo start reverse table %Table% + +xorm reverse mysql "%DBUSER%:%DBPSW%@tcp(%DBHOST%:%DBPORT%)/%DBNAME%?charset=utf8" %BasePath%/etc/db_tpl %BasePath%/src/im/model/ %TName% + +echo end \ No newline at end of file diff --git a/src/im/model/group.go b/src/im/model/group.go new file mode 100644 index 0000000..148c0df --- /dev/null +++ b/src/im/model/group.go @@ -0,0 +1,19 @@ +package model + +import ( + "time" +) + +type Group struct { + Id int64 `json:"id" xorm:"pk autoincr comment('自增主键') BIGINT(20)"` + Name string `json:"name" xorm:"not null comment('群组名称') VARCHAR(50)"` + AvatarUrl string `json:"avatar_url" xorm:"not null comment('群组头像') VARCHAR(255)"` + Introduction string `json:"introduction" xorm:"not null comment('群组简介') VARCHAR(255)"` + UserNum int `json:"user_num" xorm:"not null default 0 comment('群组人数') INT(11)"` + IsAllMemberBanned int `json:"is_all_member_banned" xorm:"not null default 2 comment('是否全员禁言(1:是 2:否)') TINYINT(1)"` + IsAllAddFriend int `json:"is_all_add_friend" xorm:"not null default 2 comment('是否允许加好友(1:是 2:否)') TINYINT(1)"` + Extra string `json:"extra" xorm:"not null comment('附加属性') VARCHAR(1024)"` + Kind int `json:"kind" xorm:"not null default 1 comment('群类型(1:用户创建 2:系统创建)') TINYINT(1)"` + CreateTime time.Time `json:"create_time" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"` + UpdateTime time.Time `json:"update_time" xorm:"not null default CURRENT_TIMESTAMP comment('更新时间') DATETIME"` +} diff --git a/src/im/model/group_notice.go b/src/im/model/group_notice.go new file mode 100644 index 0000000..559c4bb --- /dev/null +++ b/src/im/model/group_notice.go @@ -0,0 +1,17 @@ +package model + +import ( + "time" +) + +type GroupNotice struct { + Id int64 `json:"id" xorm:"pk autoincr comment('自增主键') BIGINT(20)"` + GroupId int64 `json:"group_id" xorm:"not null comment('组id') BIGINT(20)"` + UserId int64 `json:"user_id" xorm:"not null comment('发布用户id') BIGINT(20)"` + Content string `json:"content" xorm:"not null default '' comment('公告内容') VARCHAR(1500)"` + LikeNums int `json:"like_nums" xorm:"not null default 0 comment('点赞数量') INT(11)"` + ReadNums int `json:"read_nums" xorm:"not null default 0 comment('阅读数量') INT(11)"` + PublishType int `json:"publish_type" xorm:"not null default 1 comment('发布方式(1:仅发布 2:发布并通知 3:通知并置顶)') TINYINT(1)"` + CreateTime time.Time `json:"create_time" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"` + UpdateTime time.Time `json:"update_time" xorm:"not null default CURRENT_TIMESTAMP comment('更新时间') DATETIME"` +} diff --git a/src/im/model/group_notice_with_like_records.go b/src/im/model/group_notice_with_like_records.go new file mode 100644 index 0000000..73f11a5 --- /dev/null +++ b/src/im/model/group_notice_with_like_records.go @@ -0,0 +1,7 @@ +package model + +type GroupNoticeWithLikeRecords struct { + Id int64 `json:"id" xorm:"pk autoincr comment('自增主键') BIGINT(20)"` + GroupId int64 `json:"group_id" xorm:"not null comment('组id') BIGINT(20)"` + UserId int64 `json:"user_id" xorm:"not null comment('点赞用户id') BIGINT(20)"` +} diff --git a/src/im/model/group_user.go b/src/im/model/group_user.go new file mode 100644 index 0000000..c9d7d03 --- /dev/null +++ b/src/im/model/group_user.go @@ -0,0 +1,17 @@ +package model + +import ( + "time" +) + +type GroupUser struct { + Id int64 `json:"id" xorm:"pk autoincr comment('自增主键') BIGINT(20)"` + GroupId int64 `json:"group_id" xorm:"not null comment('组id') unique(uk_group_id_user_id) BIGINT(20)"` + UserId int64 `json:"user_id" xorm:"not null comment('用户id') index unique(uk_group_id_user_id) BIGINT(20)"` + MemberType int `json:"member_type" xorm:"not null comment('成员类型,1:群主 2:普通成员 3:管理员') TINYINT(4)"` + Remarks string `json:"remarks" xorm:"not null comment('备注') VARCHAR(20)"` + Extra string `json:"extra" xorm:"not null comment('附加属性') VARCHAR(1024)"` + Status int `json:"status" xorm:"not null comment('状态') TINYINT(255)"` + CreateTime time.Time `json:"create_time" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"` + UpdateTime time.Time `json:"update_time" xorm:"not null default CURRENT_TIMESTAMP comment('更新时间') DATETIME"` +} diff --git a/src/im/model/im_send_red_package_ord.go b/src/im/model/im_send_red_package_ord.go new file mode 100644 index 0000000..4bf6c44 --- /dev/null +++ b/src/im/model/im_send_red_package_ord.go @@ -0,0 +1,27 @@ +package model + +import ( + "time" +) + +type ImSendRedPackageOrd struct { + Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` + Uid int64 `json:"uid" xorm:"not null comment('用户id') BIGINT(20)"` + ImUid int `json:"im_uid" xorm:"not null comment('im对应用户id') INT(11)"` + OrdNo string `json:"ord_no" xorm:"not null comment('订单号') VARCHAR(255)"` + State int `json:"state" xorm:"not null comment('红包状态(0:未领取 1:领取中 2:领取完 3:已过期)') TINYINT(3)"` + Amount string `json:"amount" xorm:"not null comment('金额') DECIMAL(10,2)"` + RedPacketBalanceAmount string `json:"red_packet_balance_amount" xorm:"not null comment('红包余额') DECIMAL(10,2)"` + RedPacketType int `json:"red_packet_type" xorm:"not null comment('红包类型(0:未知 1:好友红包 2:群组普通红包 3:群组手气红包 4:群组专属红包 5:系统红包)') TINYINT(3)"` + RedPacketNums int `json:"red_packet_nums" xorm:"not null comment('红包数量') INT(11)"` + RedPacketBalanceNums int `json:"red_packet_balance_nums" xorm:"not null comment('红包剩余数量') INT(11)"` + WaitDrawUserIds string `json:"wait_draw_user_ids" xorm:"not null comment('待领取用户id(逗号分割)') VARCHAR(255)"` + WaitDrawImUserIds string `json:"wait_draw_im_user_ids" xorm:"not null comment('待领取im用户id(逗号分割)') VARCHAR(255)"` + ReceivedUserIds string `json:"received_user_ids" xorm:"not null comment('已领取用户id(逗号分割)') VARCHAR(255)"` + ReceivedImUserIds string `json:"received_im_user_ids" xorm:"not null comment('已领取im用户id(逗号分割)') VARCHAR(255)"` + ReceivedTimes string `json:"received_times" xorm:"not null comment('已领取时间(逗号分割)') VARCHAR(255)"` + ReceivedUserAmount string `json:"received_user_amount" xorm:"not null comment('已领取用户金额(逗号分割)') VARCHAR(255)"` + ImData string `json:"im_data" xorm:"comment('im数据') TEXT"` + CreateTime time.Time `json:"create_time" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"` + UpdateTime time.Time `json:"update_time" xorm:"not null default CURRENT_TIMESTAMP comment('更新时间') DATETIME"` +} diff --git a/src/im/model/user.go b/src/im/model/user.go new file mode 100644 index 0000000..c7b0c86 --- /dev/null +++ b/src/im/model/user.go @@ -0,0 +1,18 @@ +package model + +import ( + "time" +) + +type User struct { + Id int64 `json:"id" xorm:"pk autoincr comment('自增主键') BIGINT(20)"` + PhoneNumber string `json:"phone_number" xorm:"not null comment('手机号') unique VARCHAR(20)"` + Nickname string `json:"nickname" xorm:"not null comment('昵称') VARCHAR(20)"` + Sex int `json:"sex" xorm:"not null comment('性别,0:未知;1:男;2:女') TINYINT(4)"` + AvatarUrl string `json:"avatar_url" xorm:"not null comment('用户头像链接') VARCHAR(256)"` + Extra string `json:"extra" xorm:"not null comment('附加属性') VARCHAR(1024)"` + CreateTime time.Time `json:"create_time" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"` + UpdateTime time.Time `json:"update_time" xorm:"not null default CURRENT_TIMESTAMP comment('更新时间') DATETIME"` + IsAutoAddedFriends int `json:"is_auto_added_friends" xorm:"not null default 0 comment('是否自动被添加好友') TINYINT(1)"` + CustomerId int `json:"customer_id" xorm:"not null default 0 comment('客服id') INT(11)"` +}