jwch

package module
v0.2.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2025 License: Apache-2.0 Imports: 16 Imported by: 8

README

JWCH

This is an interface encapsulation class of Fuzhou University Academic Affairs Office implemented by Golang, which supports simulated users to conduct personal academic affairs operations.

Docs

Name Location
api ./docs/api.md
error ./docs/error.md
model ./docs/model.md

How to use

We use this repo as an

❯ go get github.com/west2-online/jwch

Then we just need to modify main.go to test any func.

For more detail, plz visit API docs.

Current progress

  • User login
  • Get course selections for each semester
  • Get marks
  • Get user info
  • Session check
  • Automatic code identification
  • Set any apis but not implement
  • Empty Rooms
  • Using Currency
  • Complete all apis
  • Benchmark test
  • Bug check & fix
  • ...

File tree

.
├── README.md			// 文档
├── cookies.txt
├── errno			// 错误处理
│   ├── code.go
│   ├── default.go
│   └── errno.go
├── docs			// 文档
│   ├── api.md			// API接口
│   ├── error.md		// 错误定义
├── go.mod
├── go.sum
├── jwch			// 教务处类
│   ├── course.go		// 课程
│   ├── jwch.go			// 类主函数
│   ├── mark.go			// 成绩
│   ├── model.go		// 自定义结构体
│   ├── user.go			// 用户
│   └── xpath.go		// xpath优化函数
├── main.go
└── utils			// 通用函数
    └── utils.go
Lark Docs

https://west2-online.feishu.cn/wiki/HAZUwmgkWiRq4zkBkAecu5eGn9n

Local Action Test

we can use act to local github action test.

  1. Create act_secret_file in root folder
  2. Insert items:
USERNAME_23="YourJwchAccount"
PASSWORD_23="YourJwchSecret"
  1. use act push --secret-file ./act_secret_file

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValidateCode

func GetValidateCode(image string) (string, error)

GetValidateCode 获取验证码

Types

type CalTerm

type CalTerm struct {
	TermId     string `json:"termId"`     // 学期ID
	SchoolYear string `json:"schoolYear"` // 学年
	Term       string `json:"term"`       // 学期
	StartDate  string `json:"startDate"`  // 开始日期 格式:2024-08-26
	EndDate    string `json:"endDate"`    // 结束日期 格式:2025-01-17
}

type CalTermEvent

type CalTermEvent struct {
	Name      string `json:"name"`      // 事件名称
	StartDate string `json:"startDate"` // 开始日期 格式:2024-08-26
	EndDate   string `json:"endDate"`   // 结束日期 格式:2025-01-17
}

type CalTermEvents

type CalTermEvents struct {
	TermId     string         `json:"termId"`     // 学期ID
	Term       string         `json:"term"`       // 学期
	SchoolYear string         `json:"schoolYear"` // 学年
	Events     []CalTermEvent `json:"events"`     // 事件
}

type Course

type Course struct {
	Type       string `json:"type"`       // 修读类别
	Name       string `json:"name"`       // 课程名称
	Syllabus   string `json:"syllabus"`   // 课程大纲
	LessonPlan string `json:"lessonplan"` // 课程计划
	// PaymentStatus string `json:"paymentstatus"` // 缴费状态
	Credits          string               `json:"credit"`           // 学分
	ElectiveType     string               `json:"electivetype"`     // 选课类型
	ExamType         string               `json:"examtype"`         // 考试类别
	Teacher          string               `json:"teacher"`          // 任课教师
	ScheduleRules    []CourseScheduleRule `json:"scheduleRules"`    // 上课时间地点规则
	RawScheduleRules string               `json:"rawScheduleRules"` // 上课时间地点(原始文本)
	RawExamTime      string               `json:"rawExamTime"`      // 考试时间地点(原始文本)
	RawAdjust        string               `json:"rawAdjust"`        // 调课信息(原始文本)
	Remark           string               `json:"remark"`           // 备注
}

课程信息

type CourseAdjustRule

type CourseAdjustRule struct {
	OldWeek       int `json:"oldWeek"`       // 原-周次
	OldWeekday    int `json:"oldWeekday"`    // 原-星期几
	OldStartClass int `json:"oldStartClass"` // 原-开始节数
	OldEndClass   int `json:"oldEndClass"`   // 原-结束节数

	NewWeek       int    `json:"newWeek"`       // 新-周次
	NewWeekday    int    `json:"newWeekday"`    // 新-星期几
	NewStartClass int    `json:"newStartClass"` // 新-开始节数
	NewEndClass   int    `json:"newEndClass"`   // 新-结束节数
	NewLocation   string `json:"newLocation"`   // 新-上课地点
}

type CourseScheduleRule

type CourseScheduleRule struct {
	Location     string `json:"location"`     // 上课地点
	StartClass   int    `json:"startClass"`   // 开始节数
	EndClass     int    `json:"endClass"`     // 结束节数
	StartWeek    int    `json:"startWeek"`    // 开始周
	EndWeek      int    `json:"endWeek"`      // 结束周
	Weekday      int    `json:"weekday"`      // 星期几
	Single       bool   `json:"single"`       // 单周 (PS: 为啥不用 odd)
	Double       bool   `json:"double"`       // 双周 (PS: 为啥不用 even)
	Adjust       bool   `json:"adjust"`       // 调课
	FromFullWeek bool   `json:"fromFullWeek"` // 是否来自整周课程
}

type CreditStatistics

type CreditStatistics struct {
	Type  string // 学分类型
	Gain  string // 已获得
	Total string // 应获学分
}

type EmptyRoomReq

type EmptyRoomReq struct {
	Campus   string `form:"campus" binding:"required"` // 校区
	Time     string `form:"time" binding:"required"`   // 日期 格式:2023-09-22
	Start    string `form:"start" binding:"required"`
	End      string `form:"end" binding:"required"`   // 查询第Start节到第End节
	Building string `form:"build" binding:"required"` // 教学楼名
}

空教室请求

type ExamRoomInfo added in v0.1.8

type ExamRoomInfo struct {
	CourseName string // 课程名称
	Credit     string // 学分
	Teacher    string // 任课教师
	Date       string // 考试日期
	Time       string // 考试时间
	Location   string // 考试地点
}

type ExamRoomReq added in v0.1.8

type ExamRoomReq struct {
	Term string
}

type GPABean

type GPABean struct {
	Time string // 绩点计算时间
	Data []GPAData
}

type GPAData

type GPAData struct {
	Type  string
	Value string
}

type LocateDate added in v0.2.12

type LocateDate struct {
	Week string
	Year string
	Term string
}

LocateDate 当前时间

type Mark

type Mark struct {
	Type          string `json:"type"`           // 修读类别
	Semester      string `json:"semester"`       // 开课学期
	Name          string `json:"name"`           // 课程名称
	Credits       string `json:"credit"`         // 计划学分
	Score         string `json:"score"`          // 得分
	GPA           string `json:"GPA"`            // 绩点
	EarnedCredits string `json:"earned_credits"` // 得到学分
	ElectiveType  string `json:"electivetype"`   // 选课类型
	ExamType      string `json:"examtype"`       // 考试类别
	Teacher       string `json:"teacher"`        // 任课教师
	Classroom     string `json:"classroom"`      // 上课时间地点
	ExamTime      string `json:"examtime"`       // 考试时间地点
}

type NoticeInfo added in v0.2.3

type NoticeInfo struct {
	Title string // 通知标题
	URL   string // 通知链接
	Date  string // 通知日期
}

type NoticeInfoReq added in v0.2.3

type NoticeInfoReq struct {
	PageNum int // 获取第几页的数据,从 1 开始
}

type SchoolCalendar

type SchoolCalendar struct {
	CurrentTerm string    `json:"currentTerm"` // 当前学期
	Terms       []CalTerm `json:"terms"`       // 学期信息
}

校历

type Student

type Student struct {
	ID       string `json:"id"`       // 学号
	Password string `json:"password"` // 密码

	// 如果我们使用client进行登陆的话,此时该字段失效,因为client会在登录时自动保存登陆凭证(session)
	// 所以该字段用于其他服务调用时传递登陆凭证
	Identifier string // 位于url上id=....的一个标识符,主要用于组成url
	// contains filtered or unexported fields
}

学生对象

func NewStudent

func NewStudent() *Student

func (*Student) CheckSession

func (s *Student) CheckSession() error

CheckSession returns not nil if SessionExpired or AccountConflict

func (*Student) ClearLoginData

func (s *Student) ClearLoginData()

func (*Student) GetCET

func (s *Student) GetCET() ([]*UnifiedExam, error)

获取CET成绩

func (*Student) GetCredit

func (s *Student) GetCredit() (creditStatistics []*CreditStatistics, err error)

func (*Student) GetCultivatePlan added in v0.2.2

func (s *Student) GetCultivatePlan() (string, error)

func (*Student) GetEmptyRoom

func (s *Student) GetEmptyRoom(req EmptyRoomReq) ([]string, error)

func (*Student) GetExamRoom added in v0.1.8

func (s *Student) GetExamRoom(req ExamRoomReq) ([]*ExamRoomInfo, error)

考场查询

func (*Student) GetGPA

func (s *Student) GetGPA() (gpa *GPABean, err error)

func (*Student) GetIdentifierAndCookies

func (s *Student) GetIdentifierAndCookies() (string, []*http.Cookie, error)

GetIdentifierAndCookies 方面服务端进行测试设置的接口

func (*Student) GetInfo

func (s *Student) GetInfo() (resp *StudentDetail, err error)

GetInfo 获取学生个人信息

func (*Student) GetJS

func (s *Student) GetJS() ([]*UnifiedExam, error)

获取省计算机成绩

func (*Student) GetLocateDate added in v0.2.12

func (s *Student) GetLocateDate() (*LocateDate, error)

func (*Student) GetMarks

func (s *Student) GetMarks() (resp []*Mark, err error)

获取成绩,由于教务处缺陷,这里会返回全部的成绩

func (*Student) GetNoticeInfo added in v0.2.3

func (s *Student) GetNoticeInfo(req *NoticeInfoReq) (list []*NoticeInfo, totalPages int, err error)

func (*Student) GetQiShanEmptyRoom

func (s *Student) GetQiShanEmptyRoom(req EmptyRoomReq) ([]string, error)

func (*Student) GetSchoolCalendar

func (s *Student) GetSchoolCalendar() (*SchoolCalendar, error)

func (*Student) GetSemesterCourses

func (s *Student) GetSemesterCourses(term, viewState, eventValidation string) ([]*Course, error)

获取我的选课

func (*Student) GetTermEvents

func (s *Student) GetTermEvents(termId string) (*CalTermEvents, error)

func (*Student) GetTerms

func (s *Student) GetTerms() (*Term, error)

获取我的学期

func (*Student) GetWithIdentifier

func (s *Student) GetWithIdentifier(url string) (*html.Node, error)

func (*Student) Login

func (s *Student) Login() error

Login 模拟教务处登录/刷新Session

func (*Student) NewRequest

func (s *Student) NewRequest() *resty.Request

func (*Student) PostWithIdentifier

func (s *Student) PostWithIdentifier(url string, formData map[string]string) (*html.Node, error)

PostWithIdentifier returns parse tree for the resp of the request.

func (*Student) SetCookies

func (s *Student) SetCookies(cookies []*http.Cookie)

func (*Student) SetIdentifier

func (s *Student) SetIdentifier(identifier string)

func (*Student) WithLoginData

func (s *Student) WithLoginData(identifier string, cookies []*http.Cookie) *Student

func (*Student) WithUser

func (s *Student) WithUser(id, password string) *Student

WithUser 携带账号密码,这部分考虑整合到Login中,因为实际上我们不需要这个东西

type StudentDetail

type StudentDetail struct {
	Name             string `json:"name"`              // 姓名
	Sex              string `json:"sex"`               // 性别
	Birthday         string `json:"birthday"`          // 出生日期
	Phone            string `json:"phont"`             // 手机号
	Email            string `json:"email"`             // 邮箱
	College          string `json:"college"`           // 学院
	Grade            string `json:"grade"`             // 年级
	StatusChanges    string `json:"status_change"`     // 学籍异动与奖励
	Major            string `json:"major"`             // 专业
	Counselor        string `json:"counselor"`         // 辅导员
	ExamineeCategory string `json:"examinee_category"` // 考生类别
	Nationality      string `json:"nationality"`       // 民族
	Country          string `json:"country"`           // 国别
	PoliticalStatus  string `json:"political_status"`  // 政治面貌
	Source           string `json:"source"`            // 生源地
}

学生信息详情

type Term

type Term struct {
	Terms           []string `json:"terms"`           // 学期数量
	ViewState       string   `json:"viewstate"`       // 课表必要信息
	EventValidation string   `json:"eventvalidation"` // 课表必要信息
}

学期信息

type UnifiedExam

type UnifiedExam struct {
	Name  string
	Score string
	Term  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL