init
This commit is contained in:
151
bbs-go-active/server/internal/models/constants/constants.go
Normal file
151
bbs-go-active/server/internal/models/constants/constants.go
Normal file
@@ -0,0 +1,151 @@
|
||||
package constants
|
||||
|
||||
const (
|
||||
DefaultTokenExpireDays = 7 // 用户登录token默认有效期
|
||||
SummaryLen = 256 // 摘要长度
|
||||
UploadMaxM = 10
|
||||
UploadMaxBytes int64 = 1024 * 1024 * 1024 * UploadMaxM
|
||||
CookieTokenKey = "bbsgo_token"
|
||||
)
|
||||
|
||||
// 系统配置
|
||||
const (
|
||||
SysConfigSiteTitle = "siteTitle" // 站点标题
|
||||
SysConfigSiteDescription = "siteDescription" // 站点描述
|
||||
SysConfigSiteKeywords = "siteKeywords" // 站点关键字
|
||||
SysConfigSiteLogo = "siteLogo" // 站点Logo
|
||||
SysConfigSiteNavs = "siteNavs" // 站点导航
|
||||
SysConfigSiteNotification = "siteNotification" // 站点公告
|
||||
SysConfigRecommendTags = "recommendTags" // 推荐标签
|
||||
SysConfigUrlRedirect = "urlRedirect" // 是否开启链接跳转
|
||||
SysConfigScoreConfig = "scoreConfig" // 分数配置
|
||||
SysConfigDefaultNodeId = "defaultNodeId" // 发帖默认节点
|
||||
SysConfigArticlePending = "articlePending" // 是否开启文章审核
|
||||
SysConfigTopicCaptcha = "topicCaptcha" // 是否开启发帖验证码
|
||||
SysConfigUserObserveSeconds = "userObserveSeconds" // 新用户观察期
|
||||
SysConfigTokenExpireDays = "tokenExpireDays" // 登录Token有效天数
|
||||
SysConfigLoginMethod = "loginMethod" // 登录方式
|
||||
SysConfigEnableHideContent = "enableHideContent" // 启用回复可见功能
|
||||
SysConfigCreateTopicEmailVerified = "createTopicEmailVerified" // 发话题需要邮箱认证
|
||||
SysConfigCreateArticleEmailVerified = "createArticleEmailVerified" // 发话题需要邮箱认证
|
||||
SysConfigCreateCommentEmailVerified = "createCommentEmailVerified" // 发话题需要邮箱认证
|
||||
SysConfigModules = "modules" // 功能模块
|
||||
SysConfigEmailWhitelist = "emailWhitelist" // 邮箱白名单
|
||||
)
|
||||
|
||||
// EntityType
|
||||
const (
|
||||
EntityArticle = "article"
|
||||
EntityTopic = "topic"
|
||||
EntityComment = "comment"
|
||||
EntityUser = "user"
|
||||
EntityCheckIn = "checkIn"
|
||||
)
|
||||
|
||||
// 用户角色
|
||||
const (
|
||||
RoleOwner = "owner" // 站长
|
||||
RoleAdmin = "admin" // 管理员
|
||||
RoleUser = "user" // 用户
|
||||
)
|
||||
|
||||
// 操作类型
|
||||
const (
|
||||
OpTypeCreate = "create"
|
||||
OpTypeDelete = "delete"
|
||||
OpTypeUpdate = "update"
|
||||
OpTypeForbidden = "forbidden"
|
||||
OpTypeRemoveForbidden = "removeForbidden"
|
||||
)
|
||||
|
||||
// 状态
|
||||
const (
|
||||
StatusOk = 0 // 正常
|
||||
StatusDeleted = 1 // 删除
|
||||
StatusReview = 2 // 待审核
|
||||
)
|
||||
|
||||
// 用户类型
|
||||
const (
|
||||
UserTypeNormal = 0 // 普通用户
|
||||
UserTypeEmployee = 1 // 员工用户
|
||||
)
|
||||
|
||||
// 角色类型
|
||||
const (
|
||||
RoleTypeSystem = 0 // 系统角色
|
||||
RoleTypeCustom = 1 // 自定义角色
|
||||
)
|
||||
|
||||
// 内容类型
|
||||
const (
|
||||
ContentTypeHtml = "html"
|
||||
ContentTypeMarkdown = "markdown"
|
||||
ContentTypeText = "text"
|
||||
)
|
||||
|
||||
// 第三方账号类型
|
||||
const (
|
||||
ThirdAccountTypeGithub = "github"
|
||||
ThirdAccountTypeOSC = "osc"
|
||||
ThirdAccountTypeQQ = "qq"
|
||||
)
|
||||
|
||||
// 积分操作类型
|
||||
const (
|
||||
ScoreTypeIncr = 0 // 积分+
|
||||
ScoreTypeDecr = 1 // 积分-
|
||||
)
|
||||
|
||||
type TopicType int
|
||||
|
||||
const (
|
||||
TopicTypeTopic TopicType = 0
|
||||
TopicTypeTweet TopicType = 1
|
||||
)
|
||||
|
||||
type LoginMethod string
|
||||
|
||||
const (
|
||||
LoginMethodQQ LoginMethod = "qq"
|
||||
LoginMethodGithub LoginMethod = "github"
|
||||
LoginMethodPassword LoginMethod = "password"
|
||||
)
|
||||
|
||||
const (
|
||||
FollowStatusNONE = 0
|
||||
FollowStatusFollow = 1
|
||||
FollowStatusBoth = 2
|
||||
)
|
||||
|
||||
const (
|
||||
NodeIdNewest int64 = 0
|
||||
NodeIdRecommend int64 = -1
|
||||
NodeIdFollow int64 = -2
|
||||
)
|
||||
|
||||
type Gender string
|
||||
|
||||
const (
|
||||
GenderMale Gender = "Male"
|
||||
GenderFemale Gender = "Female"
|
||||
)
|
||||
|
||||
type MenuType string
|
||||
|
||||
const (
|
||||
MenuTypeMenu = "menu" // 菜单
|
||||
MenuTypeFunc = "func" // 功能
|
||||
)
|
||||
|
||||
// 模块
|
||||
const (
|
||||
ModuleTweet = "tweet"
|
||||
ModuleTopic = "topic"
|
||||
ModuleArticle = "article"
|
||||
)
|
||||
|
||||
const (
|
||||
ForbiddenWordTypeWord = "word"
|
||||
ForbiddenWordTypeRegex = "regex"
|
||||
)
|
||||
57
bbs-go-active/server/internal/models/data.go
Normal file
57
bbs-go-active/server/internal/models/data.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package models
|
||||
|
||||
// 站点导航
|
||||
type ActionLink struct {
|
||||
Title string `json:"title"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
// 积分配置
|
||||
type ScoreConfig struct {
|
||||
PostTopicScore int `json:"postTopicScore"` // 发帖获得积分
|
||||
PostCommentScore int `json:"postCommentScore"` // 跟帖获得积分
|
||||
CheckInScore int `json:"checkInScore"` // 签到积分
|
||||
}
|
||||
|
||||
type LoginMethod struct {
|
||||
Password bool `json:"password"`
|
||||
QQ bool `json:"qq"`
|
||||
Github bool `json:"github"`
|
||||
Osc bool `json:"osc"`
|
||||
}
|
||||
|
||||
// SysConfigResponse
|
||||
//
|
||||
// 配置返回结构体
|
||||
type SysConfigResponse struct {
|
||||
SiteTitle string `json:"siteTitle"`
|
||||
SiteDescription string `json:"siteDescription"`
|
||||
SiteKeywords []string `json:"siteKeywords"`
|
||||
SiteLogo string `json:"siteLogo"`
|
||||
SiteNavs []ActionLink `json:"siteNavs"`
|
||||
SiteNotification string `json:"siteNotification"`
|
||||
RecommendTags []string `json:"recommendTags"`
|
||||
UrlRedirect bool `json:"urlRedirect"`
|
||||
ScoreConfig ScoreConfig `json:"scoreConfig"`
|
||||
DefaultNodeId int64 `json:"defaultNodeId"`
|
||||
ArticlePending bool `json:"articlePending"`
|
||||
TopicCaptcha bool `json:"topicCaptcha"`
|
||||
UserObserveSeconds int `json:"userObserveSeconds"`
|
||||
TokenExpireDays int `json:"tokenExpireDays"`
|
||||
LoginMethod LoginMethod `json:"loginMethod"`
|
||||
CreateTopicEmailVerified bool `json:"createTopicEmailVerified"`
|
||||
CreateArticleEmailVerified bool `json:"createArticleEmailVerified"`
|
||||
CreateCommentEmailVerified bool `json:"createCommentEmailVerified"`
|
||||
EnableHideContent bool `json:"enableHideContent"`
|
||||
Modules ModulesConfig `json:"modules"`
|
||||
EmailWhitelist []string `json:"emailWhitelist"` // 邮箱白名单
|
||||
}
|
||||
|
||||
// ModulesConfig
|
||||
//
|
||||
// 模块配置
|
||||
type ModulesConfig struct {
|
||||
Tweet bool `json:"tweet"`
|
||||
Topic bool `json:"topic"`
|
||||
Article bool `json:"article"`
|
||||
}
|
||||
7
bbs-go-active/server/internal/models/dto/dto.go
Normal file
7
bbs-go-active/server/internal/models/dto/dto.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package dto
|
||||
|
||||
type ApiRoute struct {
|
||||
Method string
|
||||
Path string
|
||||
Name string
|
||||
}
|
||||
138
bbs-go-active/server/internal/models/form.go
Normal file
138
bbs-go-active/server/internal/models/form.go
Normal file
@@ -0,0 +1,138 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"bbs-go/internal/models/constants"
|
||||
"bbs-go/internal/pkg/common"
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"github.com/kataras/iris/v12"
|
||||
"github.com/mlogclub/simple/common/jsons"
|
||||
"github.com/mlogclub/simple/common/strs"
|
||||
"github.com/mlogclub/simple/web/params"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
type CreateTopicForm struct {
|
||||
Type constants.TopicType `json:"type"`
|
||||
CaptchaId string `json:"captchaId"`
|
||||
CaptchaCode string `json:"captchaCode"`
|
||||
NodeId int64 `json:"nodeId"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
HideContent string `json:"hideContent"`
|
||||
Tags []string `json:"tags"`
|
||||
ImageList []ImageDTO `json:"imageList"`
|
||||
UserAgent string `json:"userAgent"`
|
||||
Ip string `json:"ip"`
|
||||
}
|
||||
|
||||
type CreateArticleForm struct {
|
||||
Title string
|
||||
Summary string
|
||||
Content string
|
||||
ContentType string
|
||||
Cover *ImageDTO
|
||||
Tags []string
|
||||
SourceUrl string
|
||||
}
|
||||
|
||||
// CreateCommentForm 发表评论
|
||||
type CreateCommentForm struct {
|
||||
EntityType string `form:"entityType"`
|
||||
EntityId int64 `form:"entityId"`
|
||||
Content string `form:"content"`
|
||||
ImageList []ImageDTO `form:"imageList"`
|
||||
QuoteId int64 `form:"quoteId"`
|
||||
UserAgent string `form:"userAgent"`
|
||||
Ip string `form:"ip"`
|
||||
}
|
||||
|
||||
type ImageDTO struct {
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
func GetCreateTopicForm(ctx iris.Context) CreateTopicForm {
|
||||
contentType := ctx.GetHeader("Content-Type")
|
||||
|
||||
var form *CreateTopicForm
|
||||
if contentType == "application/json" {
|
||||
if err := ctx.ReadJSON(&form); err != nil {
|
||||
slog.Error(err.Error(), slog.Any("err", err))
|
||||
}
|
||||
} else {
|
||||
form = &CreateTopicForm{
|
||||
Type: constants.TopicType(params.FormValueIntDefault(ctx, "type", int(constants.TopicTypeTopic))),
|
||||
CaptchaId: params.FormValue(ctx, "captchaId"),
|
||||
CaptchaCode: params.FormValue(ctx, "captchaCode"),
|
||||
NodeId: params.FormValueInt64Default(ctx, "nodeId", 0),
|
||||
Title: strings.TrimSpace(params.FormValue(ctx, "title")),
|
||||
Content: strings.TrimSpace(params.FormValue(ctx, "content")),
|
||||
HideContent: strings.TrimSpace(params.FormValue(ctx, "hideContent")),
|
||||
Tags: params.FormValueStringArray(ctx, "tags"),
|
||||
ImageList: GetImageList(ctx, "imageList"),
|
||||
UserAgent: common.GetUserAgent(ctx.Request()),
|
||||
Ip: common.GetRequestIP(ctx.Request()),
|
||||
}
|
||||
}
|
||||
return *form
|
||||
}
|
||||
|
||||
func GetCreateCommentForm(ctx iris.Context) CreateCommentForm {
|
||||
form := CreateCommentForm{
|
||||
EntityType: params.FormValue(ctx, "entityType"),
|
||||
EntityId: params.FormValueInt64Default(ctx, "entityId", 0),
|
||||
Content: strings.TrimSpace(params.FormValue(ctx, "content")),
|
||||
ImageList: GetImageList(ctx, "imageList"),
|
||||
QuoteId: params.FormValueInt64Default(ctx, "quoteId", 0),
|
||||
UserAgent: common.GetUserAgent(ctx.Request()),
|
||||
Ip: common.GetRequestIP(ctx.Request()),
|
||||
}
|
||||
return form
|
||||
}
|
||||
|
||||
func GetCreateArticleForm(ctx iris.Context) CreateArticleForm {
|
||||
var (
|
||||
title = ctx.PostValue("title")
|
||||
summary = ctx.PostValue("summary")
|
||||
content = ctx.PostValue("content")
|
||||
tags = params.FormValueStringArray(ctx, "tags")
|
||||
cover = GetImageDTO(ctx, "cover")
|
||||
)
|
||||
return CreateArticleForm{
|
||||
Title: title,
|
||||
Summary: summary,
|
||||
Content: content,
|
||||
ContentType: constants.ContentTypeMarkdown,
|
||||
Cover: cover,
|
||||
Tags: tags,
|
||||
}
|
||||
}
|
||||
|
||||
func GetImageList(ctx iris.Context, paramName string) []ImageDTO {
|
||||
imageListStr := params.FormValue(ctx, paramName)
|
||||
var imageList []ImageDTO
|
||||
if strs.IsNotBlank(imageListStr) {
|
||||
ret := gjson.Parse(imageListStr)
|
||||
if ret.IsArray() {
|
||||
for _, item := range ret.Array() {
|
||||
url := item.Get("url").String()
|
||||
imageList = append(imageList, ImageDTO{
|
||||
Url: url,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return imageList
|
||||
}
|
||||
|
||||
func GetImageDTO(ctx iris.Context, paramName string) (img *ImageDTO) {
|
||||
str := params.FormValue(ctx, paramName)
|
||||
if strs.IsBlank(str) {
|
||||
return
|
||||
}
|
||||
if err := jsons.Parse(str, &img); err != nil {
|
||||
slog.Error(err.Error(), slog.Any("err", err))
|
||||
}
|
||||
return
|
||||
}
|
||||
92
bbs-go-active/server/internal/models/model_methods.go
Normal file
92
bbs-go-active/server/internal/models/model_methods.go
Normal file
@@ -0,0 +1,92 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"bbs-go/internal/models/constants"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mlogclub/simple/common/arrays"
|
||||
"github.com/mlogclub/simple/common/dates"
|
||||
"github.com/mlogclub/simple/common/strs"
|
||||
)
|
||||
|
||||
// IsForbidden 是否禁言
|
||||
func (u *User) IsForbidden() bool {
|
||||
if u.ForbiddenEndTime == 0 {
|
||||
return false
|
||||
}
|
||||
// 永久禁言
|
||||
if u.ForbiddenEndTime == -1 {
|
||||
return true
|
||||
}
|
||||
// 判断禁言时间
|
||||
return u.ForbiddenEndTime > dates.NowTimestamp()
|
||||
}
|
||||
|
||||
// HasRole 是否有指定角色
|
||||
func (u *User) HasRole(role string) bool {
|
||||
roles := strings.Split(u.Roles, ",")
|
||||
if len(roles) == 0 {
|
||||
return false
|
||||
}
|
||||
return arrays.Contains(role, roles)
|
||||
}
|
||||
|
||||
// HasAnyRole 是否有指定的任意角色
|
||||
func (u *User) HasAnyRole(roles ...string) bool {
|
||||
if len(roles) == 0 {
|
||||
return false
|
||||
}
|
||||
for _, role := range roles {
|
||||
if u.HasRole(role) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsOwnerOrAdmin 是否是管理员
|
||||
func (u *User) IsOwnerOrAdmin() bool {
|
||||
return u.HasAnyRole(constants.RoleOwner, constants.RoleAdmin)
|
||||
}
|
||||
|
||||
// GetRoles 获取角色
|
||||
func (u *User) GetRoles() []string {
|
||||
if strs.IsBlank(u.Roles) {
|
||||
return nil
|
||||
}
|
||||
ss := strings.Split(u.Roles, ",")
|
||||
if len(ss) == 0 {
|
||||
return nil
|
||||
}
|
||||
var roles []string
|
||||
for _, s := range ss {
|
||||
s = strings.TrimSpace(s)
|
||||
if strs.IsNotBlank(s) {
|
||||
roles = append(roles, s)
|
||||
}
|
||||
}
|
||||
return roles
|
||||
}
|
||||
|
||||
// InObservationPeriod 是否在观察期
|
||||
// observeSeconds 观察时长
|
||||
func (u *User) InObservationPeriod(observeSeconds int) bool {
|
||||
if observeSeconds <= 0 {
|
||||
return false
|
||||
}
|
||||
return dates.FromTimestamp(u.CreateTime).Add(time.Second * time.Duration(observeSeconds)).After(time.Now())
|
||||
}
|
||||
|
||||
// GetTitle 获取帖子的标题
|
||||
func (t *Topic) GetTitle() string {
|
||||
if t.Type == constants.TopicTypeTweet {
|
||||
if strs.IsNotBlank(t.Content) {
|
||||
return t.Content
|
||||
} else {
|
||||
return "分享图片"
|
||||
}
|
||||
} else {
|
||||
return t.Title
|
||||
}
|
||||
}
|
||||
305
bbs-go-active/server/internal/models/models.go
Normal file
305
bbs-go-active/server/internal/models/models.go
Normal file
@@ -0,0 +1,305 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"bbs-go/internal/models/constants"
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
var Models = []interface{}{
|
||||
&UserRole{}, &Role{}, &Menu{}, &RoleMenu{}, &Api{}, &MenuApi{}, &DictType{}, &Dict{},
|
||||
|
||||
&User{}, &UserToken{}, &Tag{}, &Article{}, &ArticleTag{}, &Comment{}, &Favorite{}, &Topic{}, &TopicNode{},
|
||||
&TopicTag{}, &UserLike{}, &Message{}, &SysConfig{}, &Link{},
|
||||
&UserScoreLog{}, &OperateLog{}, &EmailCode{}, &CheckIn{}, &UserFollow{}, &UserFeed{}, &UserReport{},
|
||||
&ForbiddenWord{},
|
||||
}
|
||||
|
||||
type Model struct {
|
||||
Id int64 `gorm:"primaryKey;autoIncrement" json:"id" form:"id"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Model
|
||||
Type int `gorm:"not null;default:0" json:"type" form:"type"` // 用户类型(0:用户、1:员工)
|
||||
Username sql.NullString `gorm:"size:32;unique;" json:"username" form:"username"` // 用户名
|
||||
Email sql.NullString `gorm:"size:128;unique;" json:"email" form:"email"` // 邮箱
|
||||
EmailVerified bool `gorm:"not null;default:false" json:"emailVerified" form:"emailVerified"` // 邮箱是否验证
|
||||
Nickname string `gorm:"size:16;" json:"nickname" form:"nickname"` // 昵称
|
||||
Avatar string `gorm:"type:text" json:"avatar" form:"avatar"` // 头像
|
||||
Gender constants.Gender `gorm:"size:16;default:''" json:"gender" form:"gender"` // 性别
|
||||
Birthday *time.Time `json:"birthday" form:"birthday"` // 生日
|
||||
BackgroundImage string `gorm:"type:text" json:"backgroundImage" form:"backgroundImage"` // 个人中心背景图片
|
||||
Password string `gorm:"size:512" json:"password" form:"password"` // 密码
|
||||
HomePage string `gorm:"size:1024" json:"homePage" form:"homePage"` // 个人主页
|
||||
Description string `gorm:"type:text" json:"description" form:"description"` // 个人描述
|
||||
Score int `gorm:"type:int(11);not null;index:idx_user_score" json:"score" form:"score"` // 积分
|
||||
Status int `gorm:"type:int(11);index:idx_user_status;not null" json:"status" form:"status"` // 状态
|
||||
TopicCount int `gorm:"type:int(11);not null" json:"topicCount" form:"topicCount"` // 帖子数量
|
||||
CommentCount int `gorm:"type:int(11);not null" json:"commentCount" form:"commentCount"` // 跟帖数量
|
||||
FollowCount int `gorm:"type:int(11);not null" json:"followCount" form:"followCount"` // 关注数量
|
||||
FansCount int `gorm:"type:int(11);not null" json:"fansCount" form:"fansCount"` // 粉丝数量
|
||||
Roles string `gorm:"type:text" json:"roles" form:"roles"` // 角色
|
||||
ForbiddenEndTime int64 `gorm:"not null;default:0" json:"forbiddenEndTime" form:"forbiddenEndTime"` // 禁言结束时间
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
UpdateTime int64 `json:"updateTime" form:"updateTime"` // 更新时间
|
||||
}
|
||||
|
||||
type UserToken struct {
|
||||
Model
|
||||
Token string `gorm:"size:32;unique;not null" json:"token" form:"token"`
|
||||
UserId int64 `gorm:"not null;index:idx_user_token_user_id;" json:"userId" form:"userId"`
|
||||
ExpiredAt int64 `gorm:"not null" json:"expiredAt" form:"expiredAt"`
|
||||
Status int `gorm:"type:int(11);not null;index:idx_user_token_status" json:"status" form:"status"`
|
||||
CreateTime int64 `gorm:"not null" json:"createTime" form:"createTime"`
|
||||
}
|
||||
|
||||
// 标签
|
||||
type Tag struct {
|
||||
Model
|
||||
Name string `gorm:"size:32;unique;not null" json:"name" form:"name"`
|
||||
Description string `gorm:"size:1024" json:"description" form:"description"`
|
||||
Status int `gorm:"type:int(11);index:idx_tag_status;not null" json:"status" form:"status"`
|
||||
CreateTime int64 `json:"createTime" form:"createTime"`
|
||||
UpdateTime int64 `json:"updateTime" form:"updateTime"`
|
||||
}
|
||||
|
||||
// 文章
|
||||
type Article struct {
|
||||
Model
|
||||
CategoryId int64 `gorm:"default:0;index:idx_category_id" json:"categoryId" form:"categoryId"` // 分类ID
|
||||
UserId int64 `gorm:"index:idx_article_user_id" json:"userId" form:"userId"` // 所属用户编号
|
||||
Title string `gorm:"size:128;not null;" json:"title" form:"title"` // 标题
|
||||
Summary string `gorm:"type:text" json:"summary" form:"summary"` // 摘要
|
||||
Content string `gorm:"type:longtext;not null;" json:"content" form:"content"` // 内容
|
||||
ContentType string `gorm:"type:varchar(32);not null" json:"contentType" form:"contentType"` // 内容类型:markdown、html
|
||||
Cover string `gorm:"type:text;" json:"cover" form:"cover"` // 封面图
|
||||
Status int `gorm:"type:int(11);index:idx_article_status" json:"status" form:"status"` // 状态
|
||||
SourceUrl string `gorm:"type:text" json:"sourceUrl" form:"sourceUrl"` // 原文链接
|
||||
ViewCount int64 `gorm:"not null;" json:"viewCount" form:"viewCount"` // 查看数量
|
||||
CommentCount int64 `gorm:"default:0" json:"commentCount" form:"commentCount"` // 评论数量
|
||||
LikeCount int64 `gorm:"default:0" json:"likeCount" form:"likeCount"` // 点赞数量
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
UpdateTime int64 `json:"updateTime" form:"updateTime"` // 更新时间
|
||||
}
|
||||
|
||||
// 文章标签
|
||||
type ArticleTag struct {
|
||||
Model
|
||||
ArticleId int64 `gorm:"not null;index:idx_article_id;" json:"articleId" form:"articleId"` // 文章编号
|
||||
TagId int64 `gorm:"not null;index:idx_article_tag_tag_id;" json:"tagId" form:"tagId"` // 标签编号
|
||||
Status int64 `gorm:"not null;index:idx_article_tag_status" json:"status" form:"status"` // 状态:正常、删除
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// 评论
|
||||
type Comment struct {
|
||||
Model
|
||||
UserId int64 `gorm:"index:idx_comment_user_id;not null" json:"userId" form:"userId"` // 用户编号
|
||||
EntityType string `gorm:"index:idx_comment_entity_type;not null" json:"entityType" form:"entityType"` // 被评论实体类型
|
||||
EntityId int64 `gorm:"index:idx_comment_entity_id;not null" json:"entityId" form:"entityId"` // 被评论实体编号
|
||||
Content string `gorm:"type:text;not null" json:"content" form:"content"` // 内容
|
||||
ImageList string `gorm:"type:longtext" json:"imageList" form:"imageList"` // 图片
|
||||
ContentType string `gorm:"type:varchar(32);not null" json:"contentType" form:"contentType"` // 内容类型:markdown、html
|
||||
QuoteId int64 `gorm:"not null" json:"quoteId" form:"quoteId"` // 引用的评论编号
|
||||
LikeCount int64 `gorm:"not null;default:0" json:"likeCount" form:"likeCount"` // 点赞数量
|
||||
CommentCount int64 `gorm:"not null;default:0" json:"commentCount" form:"commentCount"` // 评论数量
|
||||
UserAgent string `gorm:"size:1024" json:"userAgent" form:"userAgent"` // UserAgent
|
||||
Ip string `gorm:"size:128" json:"ip" form:"ip"` // IP
|
||||
IpLocation string `gorm:"size:64" json:"ipLocation" form:"ipLocation"` // IP属地
|
||||
Status int `gorm:"type:int(11);index:idx_comment_status" json:"status" form:"status"` // 状态:0:待审核、1:审核通过、2:审核失败、3:已发布
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// 收藏
|
||||
type Favorite struct {
|
||||
Model
|
||||
UserId int64 `gorm:"index:idx_favorite_user_id;not null" json:"userId" form:"userId"` // 用户编号
|
||||
EntityType string `gorm:"index:idx_favorite_entity_type;size:32;not null" json:"entityType" form:"entityType"` // 收藏实体类型
|
||||
EntityId int64 `gorm:"index:idx_favorite_entity_id;not null" json:"entityId" form:"entityId"` // 收藏实体编号
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// TopicNode 话题节点
|
||||
type TopicNode struct {
|
||||
Model
|
||||
Name string `gorm:"size:32;unique" json:"name" form:"name"` // 名称
|
||||
Description string `gorm:"size:1024" json:"description" form:"description"` // 描述
|
||||
Logo string `gorm:"size:1024" json:"logo" form:"logo"` // 图标
|
||||
SortNo int `gorm:"type:int(11);index:idx_sort_no" json:"sortNo" form:"sortNo"` // 排序编号
|
||||
Status int `gorm:"type:int(11);not null" json:"status" form:"status"` // 状态
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// 话题节点
|
||||
type Topic struct {
|
||||
Model
|
||||
Type constants.TopicType `gorm:"type:int(11);not null:default:0" json:"type" form:"type"` // 类型
|
||||
NodeId int64 `gorm:"not null;index:idx_node_id;" json:"nodeId" form:"nodeId"` // 节点编号
|
||||
UserId int64 `gorm:"not null;index:idx_topic_user_id;" json:"userId" form:"userId"` // 用户
|
||||
Title string `gorm:"size:128" json:"title" form:"title"` // 标题
|
||||
Content string `gorm:"type:longtext" json:"content" form:"content"` // 内容
|
||||
ImageList string `gorm:"type:longtext" json:"imageList" form:"imageList"` // 图片
|
||||
HideContent string `gorm:"type:longtext" json:"hideContent" form:"hideContent"` // 回复可见内容
|
||||
Recommend bool `gorm:"not null;index:idx_recommend" json:"recommend" form:"recommend"` // 是否推荐
|
||||
RecommendTime int64 `gorm:"not null" json:"recommendTime" form:"recommendTime"` // 推荐时间
|
||||
Sticky bool `gorm:"not null;index:idx_sticky_sticky_time" json:"sticky" form:"sticky"` // 置顶
|
||||
StickyTime int64 `gorm:"not null;index:idx_sticky_sticky_time" json:"stickyTime" form:"stickyTime"` // 置顶时间
|
||||
ViewCount int64 `gorm:"not null" json:"viewCount" form:"viewCount"` // 查看数量
|
||||
CommentCount int64 `gorm:"not null" json:"commentCount" form:"commentCount"` // 跟帖数量
|
||||
LikeCount int64 `gorm:"not null" json:"likeCount" form:"likeCount"` // 点赞数量
|
||||
Status int `gorm:"type:int(11);index:idx_topic_status;" json:"status" form:"status"` // 状态:0:正常、1:删除
|
||||
LastCommentTime int64 `gorm:"index:idx_topic_last_comment_time" json:"lastCommentTime" form:"lastCommentTime"` // 最后回复时间
|
||||
LastCommentUserId int64 `json:"lastCommentUserId" form:"lastCommentUserId"` // 最后回复用户
|
||||
UserAgent string `gorm:"size:1024" json:"userAgent" form:"userAgent"` // UserAgent
|
||||
Ip string `gorm:"size:128" json:"ip" form:"ip"` // IP
|
||||
IpLocation string `gorm:"size:64" json:"ipLocation" form:"ipLocation"` // IP属地
|
||||
CreateTime int64 `gorm:"index:idx_topic_create_time" json:"createTime" form:"createTime"` // 创建时间
|
||||
ExtraData string `gorm:"type:text" json:"extraData" form:"extraData"` // 扩展数据
|
||||
}
|
||||
|
||||
// 主题标签
|
||||
type TopicTag struct {
|
||||
Model
|
||||
TopicId int64 `gorm:"not null;index:idx_topic_tag_topic_id;" json:"topicId" form:"topicId"` // 主题编号
|
||||
TagId int64 `gorm:"not null;index:idx_topic_tag_tag_id;" json:"tagId" form:"tagId"` // 标签编号
|
||||
Status int64 `gorm:"not null;index:idx_topic_tag_status" json:"status" form:"status"` // 状态:正常、删除
|
||||
LastCommentTime int64 `gorm:"index:idx_topic_tag_last_comment_time" json:"lastCommentTime" form:"lastCommentTime"` // 最后回复时间
|
||||
LastCommentUserId int64 `json:"lastCommentUserId" form:"lastCommentUserId"` // 最后回复用户
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// 用户点赞
|
||||
type UserLike struct {
|
||||
Model
|
||||
UserId int64 `gorm:"not null;uniqueIndex:idx_user_like_unique;" json:"userId" form:"userId"` // 用户
|
||||
EntityId int64 `gorm:"not null;uniqueIndex:idx_user_like_unique;index:idx_user_like_entity;" json:"topicId" form:"topicId"` // 实体编号
|
||||
EntityType string `gorm:"not null;size:32;uniqueIndex:idx_user_like_unique;index:idx_user_like_entity;" json:"entityType" form:"entityType"` // 实体类型
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// 消息
|
||||
type Message struct {
|
||||
Model
|
||||
FromId int64 `gorm:"not null" json:"fromId" form:"fromId"` // 消息发送人
|
||||
UserId int64 `gorm:"not null;index:idx_message_user_id;" json:"userId" form:"userId"` // 用户编号(消息接收人)
|
||||
Title string `gorm:"size:1024" json:"title" form:"title"` // 消息标题
|
||||
Content string `gorm:"type:text;not null" json:"content" form:"content"` // 消息内容
|
||||
QuoteContent string `gorm:"type:text" json:"quoteContent" form:"quoteContent"` // 引用内容
|
||||
Type int `gorm:"type:int(11);not null" json:"type" form:"type"` // 消息类型
|
||||
ExtraData string `gorm:"type:text" json:"extraData" form:"extraData"` // 扩展数据
|
||||
Status int `gorm:"type:int(11);not null" json:"status" form:"status"` // 状态:0:未读、1:已读
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// 系统配置
|
||||
type SysConfig struct {
|
||||
Model
|
||||
Key string `gorm:"not null;size:128;unique" json:"key" form:"key"` // 配置key
|
||||
Value string `gorm:"type:text" json:"value" form:"value"` // 配置值
|
||||
Name string `gorm:"not null;size:32" json:"name" form:"name"` // 配置名称
|
||||
Description string `gorm:"size:128" json:"description" form:"description"` // 配置描述
|
||||
CreateTime int64 `gorm:"not null" json:"createTime" form:"createTime"` // 创建时间
|
||||
UpdateTime int64 `gorm:"not null" json:"updateTime" form:"updateTime"` // 更新时间
|
||||
}
|
||||
|
||||
// 友链
|
||||
type Link struct {
|
||||
Model
|
||||
Url string `gorm:"not null;type:text" json:"url" form:"url"` // 链接
|
||||
Title string `gorm:"not null;size:128" json:"title" form:"title"` // 标题
|
||||
Summary string `gorm:"size:1024" json:"summary" form:"summary"` // 站点描述
|
||||
Logo string `gorm:"type:text" json:"logo" form:"logo"` // LOGO
|
||||
Status int `gorm:"type:int(11);not null" json:"status" form:"status"` // 状态
|
||||
CreateTime int64 `gorm:"not null" json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// 用户积分流水
|
||||
type UserScoreLog struct {
|
||||
Model
|
||||
UserId int64 `gorm:"not null;index:idx_user_score_log_user_id" json:"userId" form:"userId"` // 用户编号
|
||||
SourceType string `gorm:"not null;index:idx_user_score_score" json:"sourceType" form:"sourceType"` // 积分来源类型
|
||||
SourceId string `gorm:"not null;index:idx_user_score_score" json:"sourceId" form:"sourceId"` // 积分来源编号
|
||||
Description string `json:"description" form:"description"` // 描述
|
||||
Type int `gorm:"type:int(11)" json:"type" form:"type"` // 类型(增加、减少)
|
||||
Score int `gorm:"type:int(11)" json:"score" form:"score"` // 积分
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// 操作日志
|
||||
type OperateLog struct {
|
||||
Model
|
||||
UserId int64 `gorm:"not null;index:idx_operate_log_user_id" json:"userId" form:"userId"` // 用户编号
|
||||
OpType string `gorm:"not null;index:idx_op_type;size:32" json:"opType" form:"opType"` // 操作类型
|
||||
DataType string `gorm:"not null;index:idx_operate_log_data" json:"dataType" form:"dataType"` // 数据类型
|
||||
DataId int64 `gorm:"not null;index:idx_operate_log_data" json:"dataId" form:"dataId" ` // 数据编号
|
||||
Description string `gorm:"not null;size:1024" json:"description" form:"description"` // 描述
|
||||
Ip string `gorm:"size:128" json:"ip" form:"ip"` // ip地址
|
||||
UserAgent string `gorm:"type:text" json:"userAgent" form:"userAgent"` // UserAgent
|
||||
Referer string `gorm:"type:text" json:"referer" form:"referer"` // Referer
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// 邮箱验证码
|
||||
type EmailCode struct {
|
||||
Model
|
||||
UserId int64 `gorm:"not null;index:idx_user_score_log_user_id" json:"userId" form:"userId"` // 用户编号
|
||||
Email string `gorm:"not null;size:128" json:"email" form:"email"` // 邮箱
|
||||
Code string `gorm:"not null;size:8" json:"code" form:"code"` // 验证码
|
||||
Token string `gorm:"not null;size:32;unique" json:"token" form:"token"` // 验证码token
|
||||
Title string `gorm:"size:1024" json:"title" form:"title"` // 标题
|
||||
Content string `gorm:"type:text" json:"content" form:"content"` // 内容
|
||||
Used bool `gorm:"not null" json:"used" form:"used"` // 是否使用
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// 签到
|
||||
type CheckIn struct {
|
||||
Model
|
||||
UserId int64 `gorm:"not null;uniqueIndex:idx_user_id" json:"userId" form:"userId"` // 用户编号
|
||||
LatestDayName int `gorm:"type:int(11);not null;index:idx_latest" json:"dayName" form:"dayName"` // 最后一次签到
|
||||
ConsecutiveDays int `gorm:"type:int(11);not null;" json:"consecutiveDays" form:"consecutiveDays"` // 连续签到天数
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 创建时间
|
||||
UpdateTime int64 `gorm:"index:idx_latest" json:"updateTime" form:"updateTime"` // 更新时间
|
||||
}
|
||||
|
||||
// UserFollow 粉丝关注
|
||||
type UserFollow struct {
|
||||
Model
|
||||
UserId int64 `gorm:"not null;uniqueIndex:idx_user_id" json:"userId"` // 用户编号
|
||||
OtherId int64 `gorm:"not null;uniqueIndex:idx_user_id" json:"otherId"` // 对方的ID(被关注用户编号)
|
||||
Status int `gorm:"type:int(11);not null" json:"status"` // 关注状态
|
||||
CreateTime int64 `gorm:"type:bigint;not null" json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
// UserFeed 用户信息流
|
||||
type UserFeed struct {
|
||||
Model
|
||||
UserId int64 `gorm:"not null;uniqueIndex:idx_data;index:idx_user_id;index:idx_search" json:"userId"` // 用户编号
|
||||
DataId int64 `gorm:"not null;uniqueIndex:idx_data;index:idx_data_id" json:"dataId" form:"dataId"` // 数据ID
|
||||
DataType string `gorm:"not null;uniqueIndex:idx_data;index:idx_data_id;index:idx_search" json:"dataType" form:"dataType"` // 数据类型
|
||||
AuthorId int64 `gorm:"not null;index:idx_user_id" json:"authorId" form:"authorId"` // 作者编号
|
||||
CreateTime int64 `gorm:"type:bigint;not null;index:idx_search" json:"createTime" form:"createTime"` // 数据的创建时间
|
||||
}
|
||||
|
||||
// UserReport 用户举报
|
||||
type UserReport struct {
|
||||
Model
|
||||
DataId int64 `json:"dataId" form:"dataId"` // 举报数据ID
|
||||
DataType string `json:"dataType" form:"dataType"` // 举报数据类型
|
||||
UserId int64 `json:"userId" form:"userId"` // 举报人ID
|
||||
Reason string `json:"reason" form:"reason"` // 举报原因
|
||||
AuditStatus int64 `json:"auditStatus" form:"auditStatus"` // 审核状态
|
||||
AuditTime int64 `json:"auditTime" form:"auditTime"` // 审核时间
|
||||
AuditUserId int64 `json:"auditUserId" form:"auditUserId"` // 审核人ID
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 举报时间
|
||||
}
|
||||
|
||||
// ForbiddenWord 违禁词
|
||||
type ForbiddenWord struct {
|
||||
Model
|
||||
Type string `gorm:"size:16" json:"type" form:"type"` // 类型:word/regex
|
||||
Word string `gorm:"size:128" json:"word" form:"word"` // 违禁词
|
||||
Remark string `gorm:"size:1024" json:"remark" form:"remark"` // 备注
|
||||
CreateTime int64 `json:"createTime" form:"createTime"` // 举报时间
|
||||
}
|
||||
82
bbs-go-active/server/internal/models/models_system.go
Normal file
82
bbs-go-active/server/internal/models/models_system.go
Normal file
@@ -0,0 +1,82 @@
|
||||
package models
|
||||
|
||||
type Role struct {
|
||||
Model
|
||||
Type int `gorm:"not null;default:1" json:"type" form:"type"` // 角色类型(0:系统角色、1:自定义角色)
|
||||
Name string `gorm:"size:64" json:"name" form:"name"` // 角色名称
|
||||
Code string `gorm:"unique;size:64" json:"code" form:"code"` // 角色编码
|
||||
SortNo int `json:"sortNo" form:"sortNo"` // 排序
|
||||
Remark string `gorm:"size:256" json:"remark" form:"remark"` // 备注
|
||||
Status int `json:"status" form:"status"` // 状态
|
||||
CreateTime int64 `gorm:"not null;default:0" json:"createTime" form:"createTime"` // 创建时间
|
||||
UpdateTime int64 `gorm:"not null;default:0" json:"updateTime" form:"updateTime"` // 更新时间
|
||||
}
|
||||
|
||||
type Menu struct {
|
||||
Model
|
||||
ParentId int64 `json:"parentId" form:"parentId"` // 上级菜单
|
||||
Type string `gorm:"size:32" json:"type" form:"type"` // 类型(menu/func)
|
||||
Name string `gorm:"size:64" json:"name" form:"name"` // 名称
|
||||
Title string `gorm:"size:64" json:"title" form:"title"` // 标题
|
||||
Icon string `gorm:"size:1024" json:"icon" form:"icon"` // ICON
|
||||
Path string `gorm:"size:1024" json:"path" form:"path"` // 路径
|
||||
Component string `gorm:"size:256" json:"component" form:"component"` // 组件
|
||||
SortNo int `gorm:"not null;default:0" json:"sortNo" form:"sortNo"` // 排序
|
||||
Status int `json:"status" form:"status"` // 状态
|
||||
CreateTime int64 `gorm:"not null;default:0" json:"createTime" form:"createTime"` // 创建时间
|
||||
UpdateTime int64 `gorm:"not null;default:0" json:"updateTime" form:"updateTime"` // 更新时间
|
||||
}
|
||||
|
||||
// MenuApi 菜单和接口的权限关联
|
||||
type MenuApi struct {
|
||||
Model
|
||||
MenuId int64 `gorm:"not null;default:0;uniqueIndex:idx_menu_api" json:"menuId" form:"menuId"` // 菜单ID
|
||||
ApiId int64 `gorm:"not null;default:0;uniqueIndex:idx_menu_api" json:"apiId" form:"apiId"` // 接口ID
|
||||
CreateTime int64 `gorm:"not null;default:0" json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
type UserRole struct {
|
||||
Model
|
||||
UserId int64 `gorm:"uniqueIndex:idx_user_role" json:"userId" form:"userId"`
|
||||
RoleId int64 `gorm:"uniqueIndex:idx_user_role" json:"roleId" form:"roleId"`
|
||||
CreateTime int64 `gorm:"not null;default:0" json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
type RoleMenu struct {
|
||||
Model
|
||||
RoleId int64 `gorm:"uniqueIndex:idx_role_menu" json:"roleId" form:"roleId"`
|
||||
MenuId int64 `gorm:"uniqueIndex:idx_role_menu" json:"menuId" form:"menuId"`
|
||||
CreateTime int64 `gorm:"not null;default:0" json:"createTime" form:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
type Api struct {
|
||||
Model
|
||||
Name string `gorm:"size:512;unique" json:"name" form:"name"` // 名称
|
||||
Method string `gorm:"size:16" json:"method" form:"method"` // 方法
|
||||
Path string `gorm:"size:512;unique" json:"path" form:"path"` // 路径
|
||||
CreateTime int64 `gorm:"not null;default:0" json:"createTime" form:"createTime"` // 创建时间
|
||||
UpdateTime int64 `gorm:"not null;default:0" json:"updateTime" form:"updateTime"` // 更新时间
|
||||
}
|
||||
|
||||
type DictType struct {
|
||||
Model
|
||||
Name string `gorm:"size:32" json:"name" form:"name"`
|
||||
Code string `gorm:"size:64;unique" json:"code" form:"code"`
|
||||
Status int `gorm:"not null;default:0" json:"status" form:"status"`
|
||||
Remark string `gorm:"size:512" json:"remark" form:"remark"`
|
||||
CreateTime int64 `gorm:"not null;default:0" json:"createTime" form:"createTime"` // 创建时间
|
||||
UpdateTime int64 `gorm:"not null;default:0" json:"updateTime" form:"updateTime"` // 更新时间
|
||||
}
|
||||
|
||||
type Dict struct {
|
||||
Model
|
||||
TypeId int64 `gorm:"uniqueIndex:idx_dict_name" json:"typeId" form:"typeId"` // 分类
|
||||
ParentId int64 `gorm:"default:0" json:"parentId" form:"parentId"` // 上级
|
||||
Name string `gorm:"size:64;uniqueIndex:idx_dict_name" json:"name" form:"name"` // 名称
|
||||
Label string `gorm:"size:64" json:"label" form:"label"` // Label
|
||||
Value string `gorm:"type:text" json:"value" form:"value"` // Value
|
||||
SortNo int `gorm:"not null;default:0" json:"sortNo" form:"sortNo"` // 排序
|
||||
Status int `gorm:"not null;default:0" json:"status" form:"status"` // 状态
|
||||
CreateTime int64 `gorm:"not null;default:0" json:"createTime" form:"createTime"` // 创建时间
|
||||
UpdateTime int64 `gorm:"not null;default:0" json:"updateTime" form:"updateTime"` // 更新时间
|
||||
}
|
||||
217
bbs-go-active/server/internal/models/response.go
Normal file
217
bbs-go-active/server/internal/models/response.go
Normal file
@@ -0,0 +1,217 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"bbs-go/internal/models/constants"
|
||||
"time"
|
||||
|
||||
"github.com/mlogclub/simple/web"
|
||||
)
|
||||
|
||||
// UserInfo 用户简单信息
|
||||
type UserInfo struct {
|
||||
Id int64 `json:"id"`
|
||||
Type int `json:"type"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
SmallAvatar string `json:"smallAvatar"`
|
||||
Gender constants.Gender `json:"gender"`
|
||||
Birthday *time.Time `json:"birthday"`
|
||||
TopicCount int `json:"topicCount"` // 话题数量
|
||||
CommentCount int `json:"commentCount"` // 跟帖数量
|
||||
FansCount int `json:"fansCount"` // 粉丝数量
|
||||
FollowCount int `json:"followCount"` // 关注数量
|
||||
Score int `json:"score"` // 积分
|
||||
Description string `json:"description"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
|
||||
Forbidden bool `json:"forbidden"` // 是否禁言
|
||||
Followed bool `json:"followed"` // 是否关注
|
||||
}
|
||||
|
||||
// UserDetail 用户详细信息
|
||||
type UserDetail struct {
|
||||
UserInfo
|
||||
Username string `json:"username"`
|
||||
BackgroundImage string `json:"backgroundImage"`
|
||||
SmallBackgroundImage string `json:"smallBackgroundImage"`
|
||||
HomePage string `json:"homePage"`
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
// UserProfile 用户个人信息
|
||||
type UserProfile struct {
|
||||
UserDetail
|
||||
Roles []string `json:"roles"`
|
||||
PasswordSet bool `json:"passwordSet"` // 密码已设置
|
||||
Email string `json:"email"`
|
||||
EmailVerified bool `json:"emailVerified"`
|
||||
}
|
||||
|
||||
type TagResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ArticleSimpleResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
User *UserInfo `json:"user"`
|
||||
Tags *[]TagResponse `json:"tags"`
|
||||
Title string `json:"title"`
|
||||
Summary string `json:"summary"`
|
||||
Cover *ImageInfo `json:"cover"`
|
||||
SourceUrl string `json:"sourceUrl"`
|
||||
ViewCount int64 `json:"viewCount"`
|
||||
CommentCount int64 `json:"commentCount"`
|
||||
LikeCount int64 `json:"likeCount"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
Status int `json:"status"`
|
||||
Favorited bool `json:"favorited"`
|
||||
}
|
||||
|
||||
type ArticleResponse struct {
|
||||
ArticleSimpleResponse
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type NodeResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Logo string `json:"logo"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type SearchTopicResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
User *UserInfo `json:"user"`
|
||||
Node *NodeResponse `json:"node"`
|
||||
Tags *[]TagResponse `json:"tags"`
|
||||
Title string `json:"title"`
|
||||
Summary string `json:"summary"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
}
|
||||
|
||||
// 帖子列表返回实体
|
||||
type TopicResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
Type constants.TopicType `json:"type"`
|
||||
User *UserInfo `json:"user"`
|
||||
Node *NodeResponse `json:"node"`
|
||||
Tags *[]TagResponse `json:"tags"`
|
||||
Title string `json:"title"`
|
||||
Summary string `json:"summary"`
|
||||
Content string `json:"content"`
|
||||
ImageList []ImageInfo `json:"imageList"`
|
||||
LastCommentTime int64 `json:"lastCommentTime"`
|
||||
ViewCount int64 `json:"viewCount"`
|
||||
CommentCount int64 `json:"commentCount"`
|
||||
LikeCount int64 `json:"likeCount"`
|
||||
Liked bool `json:"liked"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
Recommend bool `json:"recommend"`
|
||||
RecommendTime int64 `json:"recommendTime"`
|
||||
Sticky bool `json:"sticky"`
|
||||
StickyTime int64 `json:"stickyTime"`
|
||||
Status int `json:"status"`
|
||||
Favorited bool `json:"favorited"`
|
||||
IpLocation string `json:"ipLocation"`
|
||||
}
|
||||
|
||||
// CommentResponse 评论返回数据
|
||||
type CommentResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
User *UserInfo `json:"user"`
|
||||
EntityType string `json:"entityType"`
|
||||
EntityId int64 `json:"entityId"`
|
||||
ContentType string `json:"contentType"`
|
||||
Content string `json:"content"`
|
||||
ImageList []ImageInfo `json:"imageList"`
|
||||
LikeCount int64 `json:"likeCount"`
|
||||
CommentCount int64 `json:"commentCount"`
|
||||
Liked bool `json:"liked"`
|
||||
QuoteId int64 `json:"quoteId"`
|
||||
Quote *CommentResponse `json:"quote"`
|
||||
Replies *web.CursorResult `json:"replies"`
|
||||
IpLocation string `json:"ipLocation"`
|
||||
Status int `json:"status"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
}
|
||||
|
||||
// 收藏返回数据
|
||||
type FavoriteResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
EntityType string `json:"entityType"`
|
||||
EntityId int64 `json:"entityId"`
|
||||
Deleted bool `json:"deleted"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
User *UserInfo `json:"user"`
|
||||
Url string `json:"url"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
}
|
||||
|
||||
// 消息
|
||||
type MessageResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
From *UserInfo `json:"from"` // 消息发送人
|
||||
UserId int64 `json:"userId"` // 消息接收人编号
|
||||
Title string `json:"title"` // 标题
|
||||
Content string `json:"content"` // 消息内容
|
||||
QuoteContent string `json:"quoteContent"`
|
||||
Type int `json:"type"`
|
||||
DetailUrl string `json:"detailUrl"` // 消息详情url
|
||||
ExtraData string `json:"extraData"`
|
||||
Status int `json:"status"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
}
|
||||
|
||||
// 图片
|
||||
type ImageInfo struct {
|
||||
Url string `json:"url"`
|
||||
Preview string `json:"preview"`
|
||||
}
|
||||
|
||||
type TreeNode struct {
|
||||
Id int64 `json:"id"`
|
||||
Key int64 `json:"key"`
|
||||
Title string `json:"title"`
|
||||
Children []TreeNode `json:"children"`
|
||||
}
|
||||
|
||||
type MenuResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
ParentId *int64 `json:"parentId"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Title string `json:"title"`
|
||||
Icon string `json:"icon"`
|
||||
Path string `json:"path"`
|
||||
Component string `json:"component"`
|
||||
SortNo int `json:"sortNo"`
|
||||
Status int `json:"status"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
UpdateTime int64 `json:"updateTime"`
|
||||
}
|
||||
|
||||
type MenuTreeResponse struct {
|
||||
MenuResponse
|
||||
Level int `json:"level"`
|
||||
Children []MenuTreeResponse `json:"children"`
|
||||
}
|
||||
|
||||
type DictResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
TypeId int64 `json:"typeId"`
|
||||
ParentId *int64 `json:"parentId"` // 上级分类
|
||||
Name string `json:"name"` // 名称
|
||||
Label string `json:"label"` // 标题
|
||||
Value string `json:"value"` // 值
|
||||
SortNo int `json:"sortNo"` // 排序
|
||||
Status int `json:"status"` // 状态
|
||||
CreateTime int64 `json:"createTime"` // 创建时间
|
||||
UpdateTime int64 `json:"updateTime"` // 更新时间
|
||||
}
|
||||
|
||||
type DictListResponse struct {
|
||||
DictResponse
|
||||
Children []DictListResponse `json:"children"`
|
||||
}
|
||||
Reference in New Issue
Block a user