-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.go
200 lines (176 loc) · 5.1 KB
/
models.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// Package dnevnik76 model
package dnevnik76
import (
"encoding/json"
"net/http"
"time"
)
// Client struct
type Client struct {
Username string `json:"login"`
Password string `json:"password"`
RegionID int64 `json:"region_id"`
SchoolID int64 `json:"schoolId" xorm:"'school_id'"`
Token string `json:"token"`
http *http.Client `xorm:"-"`
CurrentInfo CurrentInfo `xorm:"-"`
}
// CurrentInfo struct
type CurrentInfo struct {
//PersonID int64 `json:"personId" xorm:"'person_id'"`
RegionID int64 `json:"regionId" xorm:"'region_id'"`
SchoolID int64 `json:"schoolId" xorm:"'school_id'"`
SchoolName string `json:"schoolName"`
ClassID int64 `json:"clsId" xorm:"'class_id'"`
Class string `json:"cls"`
EduYearStart int `json:"eduYearStart"`
EduYearEnd int `json:"eduYearEnd"`
}
// Region struct
type Region struct {
ID int64 `json:"id" xorm:"pk 'id'"`
Name string `json:"name" xorm:"'name'"`
}
// School struct
type School struct {
ID int64 `json:"id" xorm:"pk 'id'"`
RegionID int64 `json:"regionId" xorm:"'region_id'"`
Name string `json:"name"`
Type string `json:"type"`
}
// Teacher struct
type Teacher struct {
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
UserID string `json:"userId" xorm:"'user_id'"`
SchoolID int64 `json:"schoolId" xorm:"'school_id'"`
FullName string `json:"fullName"`
CourseID string `json:"courseId" xorm:"'course_id'"`
CourseName string `json:"courseName"`
}
// Course struct
type Course struct {
ID int64 `json:"id" xorm:"pk 'id'"`
Name string `json:"name"`
}
// Schedule struct
type Schedule struct {
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
SchoolID int64 `json:"schoolId" xorm:"'school_id'"`
StudentID int64 `json:"studentId" xorm:"'student_id'"`
CourseID int64 `json:"courseId" xorm:"'course_id'"`
Subject string `json:"subject"`
Homework string `json:"homework"`
Marks []int8 `json:"marks"`
Date time.Time `json:"date"`
}
// Homework struct
type Homework struct {
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
SchoolID int64 `json:"schoolId" xorm:"'school_id'"`
ClassID int64 `json:"classId" xorm:"'class_id'"`
Date time.Time `json:"date"`
DayOfWeek string `json:"dow"`
CourseID int64 `json:"courseId" xorm:"'course_id'"`
CourseName string `json:"courseName"`
Homework string `json:"homework"`
Subject string `json:"subject"`
}
// Lperiod struct
type Lperiod struct {
SchoolID int64 `json:"schoolId" xorm:"'school_id'"`
SYear int `json:"start_year"`
EYear int `json:"end_year"`
Name string `json:"name"`
Period string `json:"period"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
}
func (p Lperiod) String() string {
out, err := json.Marshal(p)
if err != nil {
panic(err)
}
return string(out)
}
// Mark struct
type Mark struct {
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
UserID string `json:"userId" xorm:"'user_id'"`
SchoolID int64 `json:"school_id" xorm:"'school_id'"`
CourseID int64 `json:"course_id" xorm:"'course_id'"`
CourseName string `json:"courseName"`
Subject string `json:"subject"`
HomeWork string `json:"homework"`
Grade []int8 `json:"grades"`
DayOfWeek string `json:"dow"`
Date time.Time `json:"date"`
SYear int `json:"s_year" xorm:"SMALLINT null"`
EYear int `json:"e_year" xorm:"SMALLINT null"`
Quarter int `json:"quarter" xorm:"SMALLINT null"`
Annual bool `json:"annual" xorm:"null"`
}
func (m Mark) String() string {
out, err := json.Marshal(m)
if err != nil {
panic(err)
}
return string(out)
}
type MarksByDate []Mark
func (a MarksByDate) Len() int { return len(a) }
func (a MarksByDate) Less(i, j int) bool { return a[i].Date.Before(a[j].Date) }
func (a MarksByDate) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
// Message struct
type Message struct {
ID int64 `json:"id" xorm:"pk 'id'"`
UserID string `json:"userId" xorm:"'user_id'"`
Date time.Time `json:"date"`
From string `json:"from"`
IsUnread bool `json:"isUnread"`
Subject string `json:"subject"`
Body string `json:"body"`
}
// MarksListType type
type MarksListType int
const (
// Note type
Note MarksListType = iota
// List type
List
// Date type
Date
)
func (s MarksListType) String() string {
return [...]string{"note", "list", "date"}[s]
}
// MarkRange in month
type MarkRange int
const (
// Month9 is September
Month9 MarkRange = iota
// Month10 is October
Month10
// Month11 is November
Month11
// Month12 is December
Month12
// Month1 is January
Month1
// Month2 is Febrary
Month2
// Month3 is March
Month3
// Month4 is April
Month4
// Month5 is May
Month5
// Month6 is June
Month6
// Month7 is July
Month7
// Month8 is August
Month8
)
func (s MarkRange) String() string {
return [...]string{"month9", "month10", "month11", "month12", "month1", "month2", "month3", "month4", "month5", "month6", "month7", "month8"}[s]
}