123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- package model
- import (
- "leafstalk/otherutils/deepcopy"
- "strconv"
- "time"
- "xorm.io/xorm"
- )
- // 0:未赠送 1:已赠送 2:已领取
- const (
- SendFlag_Unsent = 0
- SendFlag_Sent = 1
- SendFlag_Received = 2
- )
- // // 好友状态
- // type FriendStatus struct {
- // SendFlag int64 `json:"SendFlag"` // 赠送的体力的标志位 0:未赠送 1:已赠送
- // RcvFlag int64 `json:"RcvFlag"` // 赠送的体力的标志位 0:未赠送 1:已赠送 2:已领取
- // // LastTs int64 `json:"lastTs"` //最后收发的时间
- // }
- // 申请列表
- // type FriendRequestItem struct {
- // Requester int64 `json:"requester"` // 申请人
- // CreateTs int64 `json:"createTs"` // 申请时间
- // }
- // 玩家好友数据
- type FriendPlayer struct {
- Id int64 // id
- PlayerId int64 `xorm:"BIGINT index 'playerid'"` // 玩家ID
- Friends map[int64]struct{} `xorm:"-"` // 好友
- Requests map[int64]int64 `xorm:"-"` // 好友申请
- Approvals map[int64]int64 `xorm:"-"` // 好友审核
- Gives map[int64]struct{} `xorm:"Text json 'gives'"` // 已赠送给谁
- Receives map[int64]int `xorm:"Text json 'receives'"` // 领取状态
- LastGiveTs int64 `xorm:"BIGINT 'lastGiveTs'"` // 最后赠送的时间
- CreatedAt int64 `xorm:"BIGINT 'createdat'"`
- }
- func (m FriendPlayer) TableName() string {
- return "friend_player"
- }
- // 需要保存的数据需确保在这里能复制到new1 中
- //
- // func (m *FriendPlayer) DeepCopy() interface{} {
- // new1 := new(FriendPlayer)
- // *new1 = *m
- //
- // return new1
- // }
- func (m *FriendPlayer) QueryExist(eng *xorm.Engine) (bool, error) {
- player := new(FriendPlayer)
- player.PlayerId = m.PlayerId
- return eng.Exist(player)
- }
- func (m *FriendPlayer) UpdateDB(eng *xorm.Engine) (int64, error) {
- return eng.Where("playerid=?", m.PlayerId).AllCols().Update(m)
- }
- func (m *FriendPlayer) GetUniqueKey() string {
- return strconv.FormatInt(m.PlayerId, 10)
- }
- func CopyFriend(old *FriendPlayer) *FriendPlayer {
- nu := deepcopy.MustCopy(old).(*FriendPlayer)
- return nu
- }
- type FriendRelation struct {
- Id int64
- UserId int64 `xorm:"index notnull 'userId'"`
- FriendId int64 `xorm:"index notnull 'friendId'"`
- CreatedAt int64 `xorm:"created"`
- // Status int `xorm:"tinyint(1) notnull comment('0-待确认 1-已好友 2-已拉黑')"`
- // Group string `xorm:"varchar(20) comment('好友分组')"`
- // UpdatedAt int64 `xorm:"updated"`
- }
- func (m *FriendRelation) TableName() string {
- return "friend_relation"
- }
- // 好友申请表
- type FriendRequest struct {
- Id int64
- Requester int64 `xorm:"index notnull 'requester'"`
- Recipient int64 `xorm:"index notnull 'recipient'"`
- CreatedAt time.Time `xorm:"created"`
- // Status int `xorm:"tinyint(1) notnull comment('0-待处理 1-已接受 2-已拒绝')"`
- // Message string `xorm:"varchar(255) comment('申请留言')"`
- // ProcessedAt time.Time `xorm:"comment('处理时间')"`
- }
- func (m *FriendRequest) TableName() string {
- return "friend_request"
- }
- // TableName 表名
- // func (m Friend) TableName() string {
- // return "friend"
- // }
- // 好友基础表|Vertical-FriendBase exported from 好友相关配置.xlsx
- type FriendBase struct {
- FriendMax int64 `json:"FriendMax"` // 好友上限
- GiveStamina int64 `json:"GiveStamina"` // 体力单次赠送值/体力单次获得值
- GiveStaminaNumMax int64 `json:"GiveStaminaNumMax"` // 每天赠送体力次数上限
- GetStaminaNumMax int64 `json:"GetStaminaNumMax"` // 每日接收体力次数上限
- FriendApplyTs int64 `json:"FriendApplyTs"` // 好友申请有效时间 /天
- FriendRefNum int64 `json:"FriendRefNum"` // 好友添加刷新人数 /个
- }
|