Skip to content

Commit

Permalink
v0.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
bvp committed Oct 5, 2023
1 parent 96441a7 commit 1f3befd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,21 @@ var (
)

// NewClient create new client
func NewClient(login string, password string, schoolID int64, httpClient *http.Client) *Client {
func NewClient(login string, password string, regionID int64, schoolID int64, httpClient *http.Client) *Client {
jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
if err != nil {
log.Fatal(err)
}

ci := CurrentInfo{}
ci.RegionID = regionID
ci.SchoolID = schoolID
schools, _ := GetSchools(regionID)
for _, s := range schools {
if s.ID == schoolID {
ci.SchoolName = s.Name
}
}

cookie := &http.Cookie{
Name: "items_perpage",
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func setup() {
cfg = config{}
_ = json.Unmarshal([]byte(file), &cfg)

client = NewClient(cfg.Login, cfg.Password, cfg.SchoolID, nil)
client = NewClient(cfg.Login, cfg.Password, cfg.RegionID, cfg.SchoolID, nil)
err := client.Login()
if err != nil {
log.Fatal(err.Error())
Expand Down
3 changes: 3 additions & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
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:"-"`
Expand All @@ -20,7 +21,9 @@ type Client struct {
// 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"`
Expand Down

0 comments on commit 1f3befd

Please sign in to comment.