jwch

package module
v0.4.23 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 19 Imported by: 11

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 Config added in v0.2.24

type Config struct {
	Proxy ProxyConfig `json:"proxy"` // 代理配置
}

Config 应用配置

func LoadConfigFromEnv added in v0.2.24

func LoadConfigFromEnv() *Config

LoadConfigFromEnv 从环境变量加载配置

func (*Config) GetProxyURL added in v0.2.24

func (c *Config) GetProxyURL() (*url.URL, error)

GetProxyURL 根据青果网络文档生成代理URL

func (*Config) GetTunnelAddress added in v0.2.24

func (c *Config) GetTunnelAddress() (string, error)

GetTunnelAddress 获取青果网络隧道地址

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"`         // 上课时间地点规则
	FullWeekScheduleRules []CourseFullWeekScheduleRule `json:"fullWeekScheduleRules"` // 整周课程上课时间地点规则
	AdjustRules           []CourseAdjustRule           `json:"adjustRules"`           // 调课规则
	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"`   // 原-结束节数

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

调课规则

type CourseFullWeekScheduleRule added in v0.2.18

type CourseFullWeekScheduleRule struct {
	StartWeek    int `json:"startWeek"`    // 开始周
	StartWeekDay int `json:"startWeekDay"` // 开始周在星期几
	EndWeek      int `json:"endWeek"`      // 结束周
	EndWeekDay   int `json:"endWeekDay"`   // 结束周在星期几
}

整周课程的上课时间地点规则

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"` // 是否来自整周课程
}

周内课程的上课时间地点规则

func ApplyAdjustRules added in v0.2.40

func ApplyAdjustRules(scheduleRules []CourseScheduleRule, adjustRules []CourseAdjustRule) []CourseScheduleRule

ApplyAdjustRules 将调课规则应用到原始课程安排上,返回调整后的 ScheduleRules。 该函数会将匹配到的调课周次从原有规则中移除,并添加调课后的新规则。

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 Lecture added in v0.2.38

type Lecture struct {
	Category         string `json:"category"`          // 讲座类别
	IssueNumber      int    `json:"issue_number"`      // 期号
	Title            string `json:"title"`             // 讲座题目
	Speaker          string `json:"speaker"`           // 主讲人
	Timestamp        int64  `json:"timestamp"`         // 时间戳
	Location         string `json:"location"`          // 地点
	AttendanceStatus string `json:"attendance_status"` // 听取讲座情况
}

Lecture 讲座信息

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 NoticeDetail added in v0.2.42

type NoticeDetail struct {
	NoticeInfo

	Content string // 通知内容
}

type NoticeDetailReq added in v0.2.42

type NoticeDetailReq struct {
	WbTreeId string // 部门ID (1035: 综合科; 1036: 教学类型; 1037: 教研教改; 1038: 计划科; 1139: 实践科; 1140: 质量办; 1141: 电教中心; 1142: 教材中心; 1143: 铜盘校区管理科)
	WbNewsId string // 新闻ID
}

type NoticeInfo added in v0.2.3

type NoticeInfo struct {
	Title    string // 通知标题
	URL      string // 通知链接
	Date     string // 通知日期
	WbTreeId string // 部门ID (1035: 综合科; 1036: 教学类型; 1037: 教研教改; 1038: 计划科; 1139: 实践科; 1140: 质量办; 1141: 电教中心; 1142: 教材中心; 1143: 铜盘校区管理科)
	WbNewsId string // 新闻ID
}

type NoticeInfoReq added in v0.2.3

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

type ProxyConfig added in v0.2.24

type ProxyConfig struct {
	AuthKey     string `json:"auth_key"`     // 青果网络认证密钥
	AuthPwd     string `json:"auth_pwd"`     // 青果网络认证密码
	ProxyServer string `json:"proxy_server"` // 代理服务器地址 (从隧道接口获取)
	Enabled     bool   `json:"enabled"`      // 是否启用代理
}

ProxyConfig 青果网络代理配置

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) GetCreditV2 added in v0.2.34

func (s *Student) GetCreditV2() (majorCredits, minorCredits []*CreditStatistics, err error)

GetCreditV2 用于获取原始的学分统计

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) GetLectures added in v0.2.38

func (s *Student) GetLectures() ([]*Lecture, error)

GetLectures 获取报名的讲座

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) GetNoticeDetail added in v0.2.42

func (s *Student) GetNoticeDetail(req *NoticeDetailReq) (*NoticeDetail, error)

GetNoticeDetail 获取通知正文内容

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 TunnelData added in v0.2.24

type TunnelData struct {
	Server   string `json:"server"`   // 代理服务器地址,格式: host:port
	Area     string `json:"area"`     // 区域代码
	Distinct bool   `json:"distinct"` // 是否独享
}

TunnelData 隧道数据

type TunnelResponse added in v0.2.24

type TunnelResponse struct {
	Code      string       `json:"code"`       // 响应码,"SUCCESS"表示成功
	Data      []TunnelData `json:"data"`       // 隧道数据数组
	RequestId string       `json:"request_id"` // 请求ID
}

TunnelResponse 隧道地址响应

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