Skip to content

ZhaiYanbo/csu-notice-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSU Notice API

License version

开发中,响应格式不稳定

解析学院及校内通知的原始HTML文本,将其封装成为API,供外部应用调用。此仓库不提供在线服务,启用API以获取校内通知需自行部署程序,并配置个人信息门户账号。

客户端参考实现:csu-notice-bot

部署

  1. 填写application.properties文件中的数据库源及账号密码。
  2. 运行服务端程序,生成settings.properties配置文件。
  3. 根据服务器的硬件配置,在settings.properties文件中填写合适的线程并发数。
  4. 运行服务端程序

API

可用接口

  • ../{tag}/page/{num}GET,获取第 num 页的所有通知。
  • ../{tag}/headGET,获取通知列表头指针。
  • ../{tag}/fetch/{head}GET,获取指针head与通知列表头指针之间的所有通知。
  • ../{tag}/notice/{id}GET,获取值为id的指针所指向的通知信息。
  • ../{tag}/latestGET,获取最新的一条通知。
  • ../{tag}/search/{title}GET,获取标题含有title字符串的所有通知。
  • ../{tag}/content/{id}GET,获取值为id的指针所指向的通知内容图片(Base64编码)。
  • ../{tag}/reload/{token}/{id}GET,强制重新加载值为id的指针所指向的通知内容图片,该操作需要校验token值,传入值与服务端预存值相同时才可进行加载。

可用标签(tag)

  • 校内通知:main
  • 计算机学院:cse
  • 校长信箱:mail
  • 学工网:xgw

响应格式

所有响应均为json格式文本,且均含有API版本号version、响应状态status和响应信息msg三个字段。

通知信息

{
  "msg": "ok",
  "data": [
    {
      "id": 1,
      "title": "关于认真做好2021年教育事业统计工作的通知",
      "from": "学校办公室",
      "uri": "http://tz.its.csu.edu.cn/Home/Release_TZTG_zd/2C6CB96118B04E98AB62C2F9F22904F8",
      "createTime": "2021-10-14T12:22:37.305+00:00",
      "updateTime": "2021-10-14T12:22:37.445+00:00"
    },
    {
      "id": 2,
      "title": "关于着手准备学校第四次党代会报告的通知",
      "from": "学校办公室",
      "uri": "http://tz.its.csu.edu.cn/Home/Release_TZTG_zd/ED71487900F540DF889B7DF89A35EF21",
      "createTime": "2021-10-14T12:22:37.305+00:00",
      "updateTime": "2021-10-14T12:22:37.455+00:00"
    }
  ],
  "version": 2,
  "status": 200
}

通知内容

{
  "msg": "ok",
  "data": {
    "id": 1,
    "uri": "http://tz.its.csu.edu.cn/Home/Release_TZTG_zd/2C6CB96118B04E98AB62C2F9F22904F8",
    "content": "Base64 code example",
    "createTime": "2021-10-14T12:23:36.042+00:00",
    "updateTime": "2021-10-14T12:23:40.987+00:00"
  },
  "version": 2,
  "status": 200
}

配置文件

首次运行后将在运行目录下生成settings.properties,该文件为配置文件。

#CSU Notice API Configuration
#Created By MagicalSheep
#Sat Oct 16 22:46:01 CST 2021
cse_notice_url=https://cse.csu.edu.cn/index/tzgg.htm
update_cse_notice=false
school_notice_url=http://tz.its.csu.edu.cn
password=example password
max_thread_nums=2
user_name=8200000000
initialization=false
update_school_notice=true
update_pages_num=5
token=example token
headmaster_mail_url=http\://oa.its.csu.edu.cn/webserver/mailbox/MailList_Pub.aspx
update_headmaster_mail=false
xgw_notice_url=https://xgw.csu.edu.cn/tzgg.htm
update_xgw_notice=false
  • cse_notice_url: 计算机学院通知公告网址
  • update_cse_notice: 更新时是否获取计算机学院通知
  • school_notice_url: 校内通知网址
  • password: 信息门户密码
  • max_thread_nums: 获取通知内容时使用的最大线程数
  • user_name: 信息门户学工号
  • initialization: 是否在启动时更新整个数据库(获取所有通知)
  • update_school_notice: 更新时是否获取校内通知
  • update_pages_num: 每次更新时,从网站上获取通知的页数
  • token: 服务端预存的token
  • headmaster_mail_url: 校长信箱网址
  • update_headmaster_mail: 更新时是否获取校长信箱信息
  • xgw_notice_url: 学工网网址
  • update_xgw_notice: 更新时是否获取学工网通知

About

将校内通知封装成为API,供外部应用调用

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%