models

package
v0.0.0-...-5354c0c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFriend

func AddFriend(userId, friendUserId uint) error

AddFriend 添加好友

func AddUser

func AddUser(data map[string]any) (uint, error)

func EditUser

func EditUser(data map[string]any) error

func InsertMessage

func InsertMessage(data map[string]any) error

InsertMessage 写入信息

func Setup

func Setup()

Types

type FriendModel

type FriendModel struct {
	gorm.Model
	UserId       uint      `json:"user_id" gorm:"index"`
	FriendUserId uint      `json:"friend_user_id"`
	FriendUser   UserModel `gorm:"foreignKey:ID;references:friend_user_id"`
}

func (*FriendModel) TableName

func (f *FriendModel) TableName() string

type MessageInfo

type MessageInfo struct {
	ID         uint      `json:"id"`
	CreatedAt  time.Time `json:"created_at"`
	FromUserId uint      `json:"from_user_id"`
	ToUserId   uint      `json:"to_user_id"`
	Content    string    `json:"content"`
}

func GetMessageList

func GetMessageList(fromUserId, toUserId uint) ([]*MessageInfo, error)

GetMessageList 读取信息列表

type MessageModel

type MessageModel struct {
	gorm.Model
	FromUserId uint   `json:"from_user_id" gorm:"index"`
	ToUserId   uint   `json:"to_user_id" gorm:"index"`
	Content    string `json:"content" gorm:"size:2300"`
}

func (*MessageModel) TableName

func (m *MessageModel) TableName() string

type UserInfo

type UserInfo struct {
	ID        uint   `json:"id"`
	Name      string `json:"name"`
	AvatarUrl string `json:"avatar_url"`
}

func GetFriendsList

func GetFriendsList(userId uint) []*UserInfo

GetFriendsList 获取好友列表

type UserModel

type UserModel struct {
	gorm.Model
	Name      string `json:"name" gorm:"size:31"`
	AvatarUrl string `json:"avatar_url" gorm:"size:255"`
	Password  string `json:"password" gorm:"size:63"`
}

func GetUserById

func GetUserById(id uint) (*UserModel, error)

func (*UserModel) TableName

func (u *UserModel) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL