mysql

package
v0.0.0-...-a93d61e Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PasswordSalt = "20210407160200"
)
View Source
const (
	TableNameCommunity = "community"
)
View Source
const (
	TableNamePost = "post"
)

Variables

This section is empty.

Functions

func CheckUserExist

func CheckUserExist(username string) (bool, error)

CheckUserExist 根据用户名检查用户是否存在

func Close

func Close()

func CreatePost

func CreatePost(param *models.CreatePostReq) error

CreatePost 创建帖子

func CreateUser

func CreateUser(user *models.User) error

CreateUser 创建用户

func Init

func Init(dbConf *settings.DbConf)

Types

type Community

type Community struct {
	Id            uint32 `json:"id" db:"id"`
	CommunityId   uint32 `json:"community_id" db:"community_id"`
	CommunityName string `json:"community_name" db:"community_name"`
	Introduction  string `json:"introduction" db:"introduction"`
	CreateTime    string `json:"create_time" db:"create_time"`
	UpdateTime    string `json:"update_time" db:"update_time"`
}

func GetCommunityDetailById

func GetCommunityDetailById(id int64) (*Community, error)

GetCommunityDetailById 根据社区id获取详情

func GetCommunityList

func GetCommunityList() ([]Community, error)

GetCommunityList 获取社区列表

type Post

type Post struct {
	Id          int64  `json:"id" db:"id"`
	PostId      int64  `json:"post_id" db:"post_id"`
	AuthorId    int64  `json:"author_id" db:"author_id"`
	CommunityId int64  `json:"community_id" db:"community_id"`
	Title       string `json:"title" db:"title"`
	CreateTime  string `json:"create_time" db:"create_time"`
	UpdateTime  string `json:"update_time" db:"update_time"`
	Content     string `json:"content" db:"content"`
	Status      int    `json:"status" db:"status"`
}

func GetPostById

func GetPostById(postId int64) (*Post, error)

GetPostById 根据文章id获取文章

func GetPosts

func GetPosts(page, pageSize uint) ([]Post, error)

GetPosts 获取帖子列表

func GetPostsByIds

func GetPostsByIds(postIds []string) ([]Post, error)

GetPostsByIds 根据文章ids获取文章列表

type User

type User struct {
	Id         uint64 `db:"id"`
	UserId     int64  `db:"user_id"`
	Username   string `db:"username"`
	Password   string `db:"password"`
	Email      string `db:"email"`
	CreateTime string `db:"create_time"`
	UpdateTime string `db:"update_time"`
	Gender     int    `db:"gender"`
}

func GetUserByUserId

func GetUserByUserId(userId int64) (*User, error)

GetUserByUserId 根据userId获取用户信息

func QueryUserByUsername

func QueryUserByUsername(username string) (*User, error)

Jump to

Keyboard shortcuts

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