qzgo

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

README

qzgo

强智教务系统 API 的 Go SDK 实现。

本项目基于 TLingC/QZAPI

Getting Started

First, use go get to install the latest version of the library.

go get -u github.com/cdfmlr/qzgo

Next, include qzapi in your application:

import "github.com/cdfmlr/qzgo"

Then enjoy your "强(ruò)智教务系统":

// 登录
client, err := qzgo.NewClientLogin("你的学校", '你本人的学号', '你本人的密码')
// 你的学校填 jwxt.xxxx.edu.cn 的那个 xxxx
if err != nil {
    panic(err)
}

// 查成绩
r, err := client.GetCjcx("目标学号", "")
if err != nil {
    panic(err)
}
for _, c := range r.Result {
    fmt.Println(c.Kcmc, c.Zcj)
}

完整使用文档正在施工。

已完成的API

  • authUser:登录
  • getCurrentTime:时间信息
  • getCjcx:成绩信息
  • getKbcxAzc:课程信息

贡献

  1. Issues Welcome!
  2. Forks & PRs Welcome!
  3. 鄙人穷苦,感谢支持🙏
  • BTC: 1DgTSywmxeYvwpSxtNaU1zJE3VwK345v9A

开放源代码

Copyright 2020 CDFMLR

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthUserRespBody

type AuthUserRespBody struct {
	Flag         string `json:"flag"`
	UserRealName string `json:"userrealname"`
	Token        string `json:"token"`
	UserDwmc     string `json:"userdwmc"`
	UserType     string `json:"usertype"`
	Msg          string `json:"msg"`
}

type Client

type Client struct {
	School string // 学校
	Xh     string // 学号
	Pwd    string // 密码
	// contains filtered or unexported fields
}

func NewClientLogin

func NewClientLogin(school string, xh string, pwd string) (*Client, error)

func (*Client) AuthUser

func (c *Client) AuthUser() (*AuthUserRespBody, error)

AuthUser 登录帐号。

在调用其它接口前,需要使用本接口获取token。并在调用其它接口的请求的header中添加本接口获得的token参数。

GET http://jwxt.xxxx.edu.cn/app.do?method=authUser&xh={$学号}&pwd={$密码}

Req:

{
	"method":'AuthUser',  //必填
	"xh":'登陆教务系统使用的学号',  //必填
	"pwd":'登陆教务系统需要的密码'  //必填
}

Resp:

{
	"flag":"1", //是否成功 #成功1 失败0
	"userrealname":"张三", //用户真实姓名 #失败 null
	"token":"", //令牌 #失败 -1
	"userdwmc":"XXXX学院", //用户所在学院名称 #失败 null
	"usertype":"2", //用户类别 #已知学生身份为2 失败 null
	"msg":"登录成功" //返回消息
}

func (*Client) GetCjcx

func (c *Client) GetCjcx(xh, xnxqid string) (GetCjcxRespBody, error)
 GetCjcx 获取成绩信息

 GET http://jwxt.xxxx.edu.cn/app.do?method=getCjcx&xh={$学号}&xnxqid={$学年学期ID}

 Req:
	request.header{token:'运行身份验证authUser时获取到的token,有过期机制'},
	request.data{
		'method':'getCjcx',  //必填
		'xh':'2017168xxxxx',  //必填,可以添加非本token学号查询他人成绩
		'xqxnid':'2017-2018-2' //非必填,不填输出全部成绩
	}

 Resp:
	{
		"success": ture,
		"result": 	[
			{
				"bz": null,  //未知
				"cjbsmc": null,  //特殊情况通报,例如“作弊”“缺考”
				"kclbmc": "必修", //课程类别名称
				"zcj": "88",  //总成绩
				"xm": "某某某",  //学生姓名
				"xqmc": "2017-2018-2",  //学期名称
				"kcxzmc": "公共基础课",  //课程性质名称,根据此项不同值可判断该科成绩是否计入GPA
				"kcywmc": "College students career development and guidance",  //课程英文名称
				"ksxzmc": "正常考试",  //考试性质名称,目前遇见的情况有正常考试,补考(x),重修(x),分别意为补考第x次和重修第x次,若补考未通过,正常考试条目和补考条目将同时存在,若补考通过,则只存在补考条目
				"kcmc": "大学生职业发展与就业指导",  //课程名称
				"xf": 1  //学分
			}
		]
	}

func (*Client) GetCurrentTime

func (c *Client) GetCurrentTime(currDate string) (*GetCurrentTimeRespBody, error)

GetCurrentTime 获取所提交的日期的时间、周次、学年等信息。

GET http://jwxt.xxxx.edu.cn/app.do?method=getCurrentTime&currDate={$查询日期}

Req:

request.header{token:'运行身份验证authUser时获取到的token,有过期机制'},
request.data{
	'method':'FetchCurrentTime',  //必填
	'currDate':  //格式为"YYYY-MM-DD",必填,留空调用成功,但返回值均为null
}

Resp:

{
	"zc":20, //当前周次
	"e_time":"2019-01-20", //本周结束时间
	"s_time":"2019-01-14", //本周开始时间
	"xnxqh":"2018-2019-1" //学年学期名称
}

func (*Client) GetKbcxAzc

func (c *Client) GetKbcxAzc(xh, xnxqid, zc string) ([]GetKbcxAzcRespBodyItem, error)

GetKbcxAzc 获取一周的课程信息

GET http://jwxt.xxxx.edu.cn/app.do?method=getKbcxAzc&xh={$学号}&xnxqid={$学年学期ID}&zc={$周次}

Req:

request.header{token:'运行身份验证authUser时获取到的token,有过期机制'},
request.data{
	'method':'GetKbcxAzc',  //必填
	'xh':'2017168xxxxx',  //必填,使用与获取token时不同的学号,则可以获取到新输入的学号的课表
	'xnxqid':'2018-2019-1',  //格式为"YYYY-YYYY-X",非必填,不包含时返回当前日期所在学期课表
	'zc':'1'  //必填
}

Resp:

[
	{
		"jsxm":"张三", //教师姓名
		"jsmc":"教学楼101", //教室名称
		"jssj":"10:00", //结束时间
		"kssj":"08:00", //开始时间
		"kkzc":"1", //开课周次,有三种已知格式1)a-b、2)a,b,c、3)a-b,c-d
		"kcsj":"10506", //课程时间,格式x0a0b,意为星期x的第a,b节上课
		"kcmc":"大学英语", //课程名称
		"sjbz":"0" //具体意义未知,据观察值为1时本课单周上,2时双周上
	}
]

type GetCjcxRespBody

type GetCjcxRespBody struct {
	Success bool                  `json:"success"`
	Result  []GetCjcxRespBodyItem `json:"result"`
}

type GetCjcxRespBodyItem

type GetCjcxRespBodyItem struct {
	Cjbsmc string  `json:"cjbsmc"`
	Kclbmc string  `json:"kclbmc"`
	Zcj    string  `json:"zcj"`
	Xm     string  `json:"xm"`
	Xqmc   string  `json:"xqmc"`
	Kcxzmc string  `json:"kcxzmc"`
	Kcywmc string  `json:"kcywmc"`
	Ksxzmc string  `json:"ksxzmc"`
	Kcmc   string  `json:"kcmc"`
	Xf     float32 `json:"xf"`
}

type GetCurrentTimeRespBody

type GetCurrentTimeRespBody struct {
	Zc    int    `json:"zc"`
	STime string `json:"s_time"`
	ETime string `json:"e_time"`
	Xnxqh string `json:"xnxqh"`
}

type GetKbcxAzcRespBodyItem

type GetKbcxAzcRespBodyItem struct {
	Jsxm string `json:"jsxm"`
	Jsmc string `json:"jsmc"`
	Kssj string `json:"kssj"`
	Jssj string `json:"jssj"`
	Kkzc string `json:"kkzc"`
	Kcsj string `json:"kcsj"`
	Kcmc string `json:"kcmc"`
	Sjbz string `json:"sjbz"`
}

type QzWeekday

type QzWeekday int
const (
	Monday QzWeekday
	Tuesday
	Wednesday
	Thursday
	Friday
	Saturday
	Sunday
)

func TimeWeekToQzWeekday

func TimeWeekToQzWeekday(weekday time.Weekday) QzWeekday

TimeWeekToQzWeekday 将 time.Weekday 转化为 qzWeekday

Jump to

Keyboard shortcuts

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