Skip to content

Commit

Permalink
Merge branch 'main' of github.com:icepie/oh-my-lit into main
Browse files Browse the repository at this point in the history
  • Loading branch information
icepie committed Mar 8, 2022
2 parents a727e05 + 3880000 commit 7a5ab61
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 12 deletions.
2 changes: 2 additions & 0 deletions client/jw/jw.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var (
SysListXSPath = "/XSCJ/Private/list_XS.aspx"
// SysXSGRCJPath 管理员查询学生成绩结果
SysXSGRCJPath = "/XSCJ/f_xsgrcj_rpt.aspx"
// SysZNPKDayfreeSelPath 管理员查询空教室结果
SysZNPKDayfreeSelPath = "/ZNPK/DayfreeSel_Rpt.aspx"
// SysClassSelPath 管理员查询班级课表
SysClassSelPath = "/ZNPK/ClassSel_rpt.aspx"
// ClassSelPath 公用课表接口
Expand Down
6 changes: 3 additions & 3 deletions client/jw/stu_jxjh.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
// GetStuXKJGRpt 获取学生理论课程原始数据
func (u *JwUser) GetStuBYFAKCRpt() (body string, err error) {

StuBYFAKCUrl := u.Url.String() + StuBYFAKCPath
theUrl := u.Url.String() + StuBYFAKCPath

resp, _ := u.Client.R().
SetHeader("referer", StuBYFAKCUrl).
Get(StuBYFAKCUrl)
SetHeader("referer", theUrl).
Get(theUrl)

body = util.GB18030ToUTF8(resp.String())

Expand Down
6 changes: 3 additions & 3 deletions client/jw/stu_xsxj.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
// GetStuMyInfoRpt 获取学生学籍信息原数据
func (u *JwUser) GetStuMyInfoRpt() (body string, err error) {

StuMyInfoUrl := u.Url.String() + StuMyInfoPath
theUrl := u.Url.String() + StuMyInfoPath

resp, _ := u.Client.R().
SetHeader("referer", StuMyInfoUrl).
Get(StuMyInfoUrl)
SetHeader("referer", theUrl).
Get(theUrl)

body = util.GB18030ToUTF8(resp.String())

Expand Down
6 changes: 3 additions & 3 deletions client/jw/sys_xscj.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (u *JwUser) GetListXSRpt(stuID string) (body string, err error) {
// flag {0: 主修, 1: 辅修}
func (u *JwUser) GetCXGRCJRpt(timeMode uint, mode uint, flag uint, year uint, term uint, stuID string) (body string, err error) {

StuMyInfoUrl := u.Url.String() + SysXSGRCJPath
theUrl := u.Url.String() + SysXSGRCJPath

resp, _ := u.Client.R().
SetFormData(map[string]string{
Expand All @@ -45,8 +45,8 @@ func (u *JwUser) GetCXGRCJRpt(timeMode uint, mode uint, flag uint, year uint, te
"zfx_flag": fmt.Sprint(flag),
"sel_xs": stuID,
}).
SetHeader("referer", StuMyInfoUrl).
Post(StuMyInfoUrl)
SetHeader("referer", theUrl).
Post(theUrl)

body = util.GB18030ToUTF8(resp.String())

Expand Down
70 changes: 67 additions & 3 deletions client/jw/sys_znpk.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,38 @@ import (
"github.com/icepie/oh-my-lit/client/util"
)

var (
// 王城
WangchengCampus uint = 1
// 开元
KaiyuanCampus uint = 2
// 九都
JiuduCampus uint = 3
)

type DayfreeSelParam struct {
Year uint
Term uint
Week uint
Day uint
Section uint
Campus uint
Building uint // 教学楼
RoomType uint // 教室类型
}

// GetClassSelRpt 获取班级课表
func (u *JwUser) GetClassSelRpt(year int, term int, calssID string) (body string, err error) {

StuMyInfoUrl := u.Url.String() + SysClassSelPath
theUrl := u.Url.String() + SysClassSelPath

resp, _ := u.Client.R().
SetFormData(map[string]string{
"Sel_XNXQ": fmt.Sprintf("%d%d", year, term),
"Sel_BJ": calssID,
}).
SetHeader("referer", StuMyInfoUrl).
Post(StuMyInfoUrl)
SetHeader("referer", theUrl).
Post(theUrl)

body = util.GB18030ToUTF8(resp.String())

Expand All @@ -29,3 +49,47 @@ func (u *JwUser) GetClassSelRpt(year int, term int, calssID string) (body string

return
}

// 获取空教室
func (u *JwUser) GetDayfreeSelRpt(data DayfreeSelParam) (body string, err error) {

theUrl := u.Url.String() + SysZNPKDayfreeSelPath

formData := map[string]string{
"SelXN": fmt.Sprintf("%d%d", data.Year, data.Term),
"Sel_ZC": buildNumParam(data.Week), // 周次
"selxqs": fmt.Sprintf("%d", data.Day), // 星期
"Sel_JC": buildNumParam(data.Section), // 节次
"Sel_JXL": buildNumParam(data.Building),
"sel_jslx": buildNumParam(data.RoomType),
"Submit01": "%BC%EC%CB%F7",
"sel_roomname": "",
}

if data.Campus != 0 {
formData["sel_xq"] = buildNumParam(data.Campus)
}

resp, _ := u.Client.R().
SetFormData(formData).
SetHeader("referer", theUrl).
Post(theUrl)

body = util.GB18030ToUTF8(resp.String())

if strings.Contains(body, "您无权访问此页") {
err = errors.New("your account does not have permission")
}

return
}

func buildNumParam(num uint) string {
if num == 0 {
return ""
}
if num < 10 {
return fmt.Sprintf("0%d", num)
}
return fmt.Sprintf("%d", num)
}

0 comments on commit 7a5ab61

Please sign in to comment.