-
Notifications
You must be signed in to change notification settings - Fork 0
/
subject.go
72 lines (61 loc) · 1.84 KB
/
subject.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2017 The StudyGolang Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// https://studygolang.com
// Author: polaris polaris@studygolang.com
package model
import (
"time"
)
// Subject 专栏
type Subject struct {
Id int `xorm:"pk autoincr" json:"id"`
Name string `json:"name"`
Cover string `json:"cover"`
Description string `json:"description"`
Uid int `json:"uid"`
Contribute bool `json:"contribute"`
Audit bool `json:"audit"`
ArticleNum int `json:"article_num"`
CreatedAt OftenTime `json:"created_at" xorm:"created"`
UpdatedAt OftenTime `json:"updated_at" xorm:"<-"`
User *User `json:"user" xorm:"-"`
}
// SubjectAdmin 专栏管理员
type SubjectAdmin struct {
Id int `xorm:"pk autoincr" json:"id"`
Sid int `json:"sid"`
Uid int `json:"uid"`
CreatedAt time.Time `json:"created_at" xorm:"<-"`
}
const (
ContributeStateNew = iota
ContributeStateOnline
ContributeStateOffline
)
// SubjectArticle 专栏文章
type SubjectArticle struct {
Id int `xorm:"pk autoincr" json:"id"`
Sid int `json:"sid"`
ArticleId int `json:"article_id"`
State int `json:"state"`
CreatedAt time.Time `json:"created_at" xorm:"<-"`
}
// SubjectArticles xorm join 需要
type SubjectArticles struct {
Article `xorm:"extends"`
Sid int
CreatedAt time.Time
}
func (*SubjectArticles) TableName() string {
return "articles"
}
// SubjectFollower 专栏关注者
type SubjectFollower struct {
Id int `xorm:"pk autoincr" json:"id"`
Sid int `json:"sid"`
Uid int `json:"uid"`
CreatedAt time.Time `json:"created_at" xorm:"<-"`
User *User `xorm:"-"`
TimeAgo string `xorm:"-"`
}