parent
1396a52945
commit
693e23f779
@ -0,0 +1,4 @@ |
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
<mapper namespace="wusthelper.data.dao.mapper.StudentMapper"> |
||||
</mapper> |
@ -0,0 +1,4 @@ |
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
<mapper namespace="wusthelper.data.dao.mapper.UserBasicMapper"> |
||||
</mapper> |
@ -0,0 +1,12 @@ |
||||
package wusthelper.web.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Target({ElementType.METHOD, ElementType.TYPE}) |
||||
public @interface RequireToken { |
||||
boolean require() default true; |
||||
} |
@ -0,0 +1,486 @@ |
||||
package wusthelper.web.api.v2.code; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* <h>响应码枚举</h> |
||||
* <ul> |
||||
* <li>BASE_ 基本状态码: 10000-19999</li> |
||||
* <li>AUTH_ 用户身份验证C: 20000-29999</li> |
||||
* <li>JWC_ 教务处: 30000-39999</li> |
||||
* <li>LIB_ 图书馆: 40000-49999</li> |
||||
* <li>VOL_ 工时: 50000-59999</li> |
||||
* <li>YJS_ 研究生: 80000-89999</li> |
||||
* </ul> |
||||
* <p>状态码表示含义: <br> |
||||
* 12345: 1号模块23号接口45型状态 |
||||
* </p> |
||||
* |
||||
* <p> |
||||
* <br> |
||||
* 关于状态码统一: <br> |
||||
* 由于安卓端表示成功状态码过于繁杂,这里对成功的状态码进行了统一: <br> |
||||
* 所有成功状态: 10000 <br> |
||||
* 所有因官方崩溃产生的失败,但读取本地数据成功的状态: 11000 <br> |
||||
* 修改: 2021/3/12 田 |
||||
* </p> |
||||
* <br><br> |
||||
* <p>LingHang业务接口</p> |
||||
* |
||||
* @Author WSharkCoder |
||||
* @Date 2021/1/15 21:40 |
||||
* @ClassName ResponseCode |
||||
*/ |
||||
@AllArgsConstructor |
||||
@Getter |
||||
public enum V2ResponseCode { |
||||
//基本状态码 START (1)
|
||||
/** |
||||
* 成功 |
||||
*/ |
||||
SUC(10000, "成功"), |
||||
/** |
||||
* 本地成功 |
||||
*/ |
||||
LOCAL_SUC(11000, "本地成功"), |
||||
|
||||
/** |
||||
* 操作频繁 |
||||
*/ |
||||
LIMIT_REQUEST(99999, "操作频繁,请稍后再试"), |
||||
/** |
||||
* 失败 |
||||
*/ |
||||
ERR(11111, "失败"), |
||||
/** |
||||
* 参数缺失或参数类型错误 |
||||
*/ |
||||
BASE_PARAM_ERR(10001, "参数缺失或参数类型错误"), |
||||
/** |
||||
* 拒绝请求 |
||||
*/ |
||||
REQUEST_DENIED(10002, "请求错误"), |
||||
/** |
||||
* 接口调用错误:请求方式出错或者参数缺失 |
||||
*/ |
||||
REQUEST_CALLED_ERR(10003, "接口调用错误:请求出错,data中为错误信息,请检查并详细参照api文档使用该接口"), |
||||
/** |
||||
* 客户端连接中断 |
||||
*/ |
||||
CLIENT_ABORT_ERR(10004, "连接中断"), |
||||
//基本状态码 END
|
||||
|
||||
//身份验证状态码 START (2)
|
||||
/** |
||||
* 用户身份验证模块异常 |
||||
*/ |
||||
AUTH_ERR(20001, "用户身份验证模块异常"), |
||||
/** |
||||
* 用户身份校验失败:请求缺失令牌TOKEN |
||||
*/ |
||||
AUTH_ERR_TOKEN_MISS(21001, "用户身份校验失败:请求缺失令牌TOKEN"), |
||||
/** |
||||
* 用户身份校验失败:TOKEN无效或过期 |
||||
*/ |
||||
AUTH_ERR_TOKEN_INVALID(21002, "用户身份校验失败:TOKEN无效或过期"), |
||||
/** |
||||
* TOKEN解密成功 |
||||
*/ |
||||
AUTH_DECODE_FOR_STUNUM_SUC(10000, "TOKEN解密成功"), |
||||
/** |
||||
* TOKEN解密失败 |
||||
*/ |
||||
AUTH_DECODE_FOR_STUNUM_ERR(21101, "TOKEN解密失败"), |
||||
//身份验证状态码 END
|
||||
|
||||
|
||||
//JWC模块状态码 START (3)
|
||||
/** |
||||
* 教务处密码已修改,请重新登录! |
||||
*/ |
||||
JWC_PWD_NED_UPD(30001, "教务处密码已修改,请重新登录"), |
||||
/** |
||||
* 教务处登录成功 |
||||
*/ |
||||
JWC_LOGIN_SUC(10000, "教务处登录成功"), |
||||
/** |
||||
* 教务登录失败:教务崩溃 |
||||
*/ |
||||
JWC_LOGIN_ERR_JWC_ERR(30104, "登录失败:教务系统异常,请重试"), |
||||
/** |
||||
* 教务处登录失败:账号或密码错误 |
||||
*/ |
||||
JWC_LOGIN_ERR_JWC_FIN_INFO_ERR(30101, "登陆失败:账号或密码错误"), |
||||
/** |
||||
* 教务处登录失败:需用户前往教务处修改默认密码 |
||||
*/ |
||||
JWC_LOGIN_ERR_JWC_MOD_DEF_PWD(30102, "登录失败:请前往教务官网修改默认密码"), |
||||
/** |
||||
* 教务登录失败:教务崩溃|本地登录失败:本地账号或密码错误 |
||||
*/ |
||||
JWC_LOGIN_ERR_JWC_ERR_INFO_ERR(30103, "登录失败:账号或密码错误,或教务异常,请重试"), |
||||
/** |
||||
* 教务处登录失败:重试次数过多 |
||||
*/ |
||||
JWC_LOGIN_ERR_JWC_RETRY_TOO_MANY_TIMES_ERR(30101, "登录失败:密码重试次数已达三次,继续重试可能会导致暂时封禁,请等待约三分钟后重试,请确保账号和密码为“统一认证平台”的账号和密码,如忘记可前往官网进行密码找回"), |
||||
/** |
||||
* 教务处登录失败:重试次数过多被封禁 |
||||
*/ |
||||
JWC_LOGIN_ERR_JWC_USER_WAS_BANNED_ERR(30101, "登录失败:密码总重试次数已达五次,已被暂时封禁,请等待约十分钟后重试,请确保账号和密码为“统一认证平台”的账号和密码,如忘记可前往官网进行密码找回"), |
||||
/** |
||||
* 教务登录失败:教务崩溃|本地登录成功 |
||||
*/ |
||||
JWC_LOGIN_SUC_JWC_ERR_LOC_SUC(11000, "教务异常:缓存登录成功"), |
||||
/** |
||||
* 教务处获取用户信息成功 |
||||
*/ |
||||
JWC_GETSTUINFO_SUC(10000, "教务处获取用户信息成功"), |
||||
/** |
||||
* 教务处获取用户信息失败:教务处崩溃|本地学生信息获取成功 |
||||
*/ |
||||
JWC_GETSTUINFO_SUC_JWC_ERR_LOC_SUC(11000, "教务异常:缓存学生信息获取成功"), |
||||
/** |
||||
* 教务处获取用户信息失败,用户不存在 |
||||
*/ |
||||
JWC_GETSTUINFO_ERR_NO_SUCH_STU(30201, "教务处获取用户信息失败:用户不存在"), |
||||
/** |
||||
* 教务处获取课表信息成功 |
||||
*/ |
||||
JWC_GETCURRICULUM_SUC(10000, "教务处获取课表信息成功"), |
||||
/** |
||||
* 教务处获取课表信息失败:教务崩溃|本地课表信息获取成功 |
||||
*/ |
||||
JWC_GETCURRICULUM_SUC_JWC_ERR_LOC_SUC(11000, "教务异常:缓存课表信息获取成功"), |
||||
/** |
||||
* 教务异常:获取课表失败 |
||||
*/ |
||||
JWC_GETCURRICULUM_ERR_JWC_ERR(30301, "教务异常:获取课表失败"), |
||||
/** |
||||
* 教务公告列表获取成功 |
||||
*/ |
||||
JWC_GETJWCANNLIST_SUC(10000, "教务公告列表获取成功"), |
||||
/** |
||||
* 教务公告内容获取成功 |
||||
*/ |
||||
JWC_GETJWCANNCNT_SUC(10000, "教务公告内容获取成功"), |
||||
/** |
||||
* 教务处成绩获取成功 |
||||
*/ |
||||
JWC_GETGRADE_SUC(10000, "教务处成绩获取成功"), |
||||
/** |
||||
* 教务处成绩获取失败:需用户前往教务处评教|本地成绩获取成功 |
||||
*/ |
||||
JWC_GETGRADE_ERR_NEED_EVALUATE_TEACHING(30601, "教务处成绩获取失败:请前往教务官网评教"), |
||||
/** |
||||
* 教务处成绩获取失败:教务处崩溃|本地成绩获取成功 |
||||
*/ |
||||
JWC_GETGRADE_ERR_JWC_ERR_LOC_SUC(11000, "教务异常:缓存成绩获取成功"), |
||||
/** |
||||
* 教务处学分明细获取成功 |
||||
*/ |
||||
JWC_GETCREDIT_SUC(10000, "教务处学分明细获取成功"), |
||||
/** |
||||
* 教务处学分明细获取失败:教务处崩溃|本地学分明细获取成功 |
||||
*/ |
||||
JWC_GETCREDIT_SUC_JWC_ERR_LOC_SUC(11000, "教务异常:缓存学分明细获取成功"), |
||||
|
||||
JWC_TRAINING_SCHEME_SUC(10000, "教务处培养方案获取成功"), |
||||
JWC_TRAINING_SCHEME_ERR(30701, "教务异常,培养方案获取失败"), |
||||
|
||||
//JWC模块验证码 END
|
||||
|
||||
|
||||
//LIB状态码 START (4)
|
||||
/** |
||||
* 图书馆密码已经修改,请重新登录! |
||||
*/ |
||||
LIB_PWD_NED_UPD(40001, "图书馆密码已经修改,请重新登录!"), |
||||
/** |
||||
* 图书馆登录已过期,请重新登录 |
||||
*/ |
||||
LIB_LOGIN_EXPIRE(40002, "图书馆登录已过期,请重新登录"), |
||||
/** |
||||
* 图书馆登录成功 |
||||
*/ |
||||
LIB_LOGIN_SUC(10000, "图书馆登录成功"), |
||||
/** |
||||
* 图书馆登录失败:账号或密码错误 |
||||
*/ |
||||
LIB_LOGIN_ERR_LIB_FIN_INFO_ERR(40101, "登录失败:账号或密码错误"), |
||||
/** |
||||
* 图书馆登录失败:验证码错误 |
||||
*/ |
||||
LIB_LOGIN_ERR_WRONG_AUTH_CODE(40103, "登录失败:验证码错误"), |
||||
/** |
||||
* 图书馆登录失败:登陆失败次数过多,请稍后重试 |
||||
*/ |
||||
LIB_LOGIN_ERR_TOO_MUCH_TIME(40104, "登录失败:登陆失败次数过多,请稍后重试"), |
||||
/** |
||||
* 图书馆登录失败:图书馆崩溃|本地登录失败:账号或密码错误 |
||||
*/ |
||||
LIB_LOGIN_ERR_LIB_ERR_INFO_ERR(40102, "登录失败:账号或密码错误"), |
||||
/** |
||||
* 图书馆登录失败:图书管崩溃|本地登录成功 |
||||
*/ |
||||
LIB_LOGIN_ERR_LIB_ERR_LOC_SUC(11000, "图书管异常:缓存登录成功"), |
||||
/** |
||||
* 图书馆历史借阅记录获取成功 |
||||
*/ |
||||
LIB_GETRENTHISTORY_SUC(10000, "图书馆历史借阅记录获取成功"), |
||||
/** |
||||
* 图书馆崩溃|本地图书馆借阅历史缓存获取成功 |
||||
*/ |
||||
LIB_GETRENTHISTORY_SUC_LIB_ERR_LOC_SUC(11000, "图书馆异常:缓存图书馆借阅历史缓存获取成功"), |
||||
/** |
||||
* 图书馆当前借阅记录获取成功 |
||||
*/ |
||||
LIB_GETCURRENTRENT_SUC(10000, "图书馆当前借阅记录获取成功"), |
||||
/** |
||||
* 图书馆崩溃|本地当前借阅获取成功 |
||||
*/ |
||||
LIB_GETCURRENTRENT_SUC_LIB_ERR_LOC_SUC(11000, "图书馆异常:缓存当前借阅获取成功"), |
||||
/** |
||||
* 图书馆异常:缓存借阅记录获取成功 |
||||
*/ |
||||
LIB_GETRENT_SUC_LIB_ERR_LOC_SUC(11000, "图书馆异常:缓存借阅记录获取成功"), |
||||
/** |
||||
* 借阅记录获取成功 |
||||
*/ |
||||
LIB_GETRENT_SUC(10000, "借阅记录获取成功"), |
||||
/** |
||||
* 图书馆公告列表获取成功 |
||||
*/ |
||||
LIB_GETLIBANNLIST_SUC(10000, "图书馆公告列表获取成功"), |
||||
/** |
||||
* 图书馆公告内容获取成功 |
||||
*/ |
||||
LIB_GETLIBANNCNT_SUC(10000, "图书馆公告内容获取成功"), |
||||
/** |
||||
* 图书馆检索图书成功 |
||||
*/ |
||||
LIB_SEARCH_SUC(10000, "图书馆检索图书成功"), |
||||
/** |
||||
* 图书馆检索图书异常 |
||||
*/ |
||||
LIB_SEARCH_ERR(40601, "图书馆检索图书异常"), |
||||
/** |
||||
* 图书馆获取图书详情成功 |
||||
*/ |
||||
LIB_GETBOOKDETAIL_SUC(10000, "图书馆获取图书详情成功"), |
||||
/** |
||||
* 图书馆获取图书详情异常 |
||||
*/ |
||||
LIB_GETBOOKDETAIL_ERR(40701, "图书馆获取图书详情异常"), |
||||
/** |
||||
* 图书馆增添收藏成功 |
||||
*/ |
||||
LIB_ADDCOLLECTION_SUC(10000, "图书馆增添收藏成功"), |
||||
/** |
||||
* 图书馆添加收藏异常 |
||||
*/ |
||||
LIB_ADDCOLLECTION_ERR(40801, "图书馆添加收藏异常"), |
||||
/** |
||||
* 图书馆收藏列表查询成功 |
||||
*/ |
||||
LIB_LISTCOLLECTION_SUC(10000, "图书馆收藏列表查询成功"), |
||||
/** |
||||
* 图书馆收藏删除成功 |
||||
*/ |
||||
LIB_DELCOLLECTION_SUC(10000, "图书馆收藏删除成功"), |
||||
/** |
||||
* 图书馆获取验证码成功 |
||||
*/ |
||||
LIB_GETYZM_SUC(11111, "图书馆获取验证码成功"), |
||||
/** |
||||
* 图书馆获取借阅历史和当前借阅成功 |
||||
*/ |
||||
LIB_GETCRH_SUC(10101, "图书馆获取借阅历史和当前借阅成功"), |
||||
|
||||
//LIB状态码 END
|
||||
|
||||
//YJS状态码 START ()
|
||||
|
||||
/** |
||||
* 研究生官网登录成功 |
||||
*/ |
||||
YJS_LOGIN_SUC(10000, "研究生官网登录成功"), |
||||
/** |
||||
* 研究生官网登录失败:账号或密码错误 |
||||
*/ |
||||
YJS_LOGIN_ERR_YJS_FIN_INFO_ERR(80002, "登录失败:账号或密码错误"), |
||||
|
||||
YJS_LOGIN_ERROR(11111, "登录失败,研究生官网异常,请稍后再试"), |
||||
|
||||
YJS_GETSTUINFO_SUC(10000, "研究生官网获取用户信息成功"), |
||||
|
||||
YJS_GETSTUINFO_ERR(11111, "研究生官网异常,获取用户信息失败,请稍后再试"), |
||||
|
||||
YJS_GETGRADE_SUC(10000, "研究生官网成绩获取成功"), |
||||
|
||||
YJS_GETGRADE_ERR(11111, "研究生官网异常,获取成绩失败,请稍后再试"), |
||||
|
||||
YJS_GETCOURSE_SUC(10000, "研究生官网课表获取成功"), |
||||
|
||||
YJS_GETCOURSE_ERR(11111, "研究生官网异常,刷新课表失败,请稍后再试"), |
||||
|
||||
YJS_GETTRAINPLAN_SUC(10000, "研究生官网培养管理获取成功"), |
||||
|
||||
YJS_GETTRAINPLAN_ERR(11111, "研究生官网异常,获取培养管理失败,请稍后再试"), |
||||
|
||||
YJS_PWD_NED_UPD(80001, "研究生官网密码已修改,请重新登录"), |
||||
|
||||
|
||||
//YJS状态码 END
|
||||
|
||||
//倒计时 START (5)
|
||||
/** |
||||
* 倒计时:操作成功 |
||||
*/ |
||||
COUNTDOWN_OPERATION_SUC(10000, "倒计时:操作成功"), |
||||
//倒计时 END
|
||||
|
||||
|
||||
//消息中心 START (6)
|
||||
/** |
||||
* 发送邮件成功 |
||||
*/ |
||||
SEND_EMAIL_SUC(10000, "发送邮件成功"), |
||||
/** |
||||
* 无效的消息来源 |
||||
*/ |
||||
MSG_ORIGIN_INVALID(60003, "无效的消息来源"), |
||||
/** |
||||
* 发送邮件失败 |
||||
*/ |
||||
SEND_EMAIL_ERR(60001, "发送邮件失败"), |
||||
/** |
||||
* 发送邮件失败,收件邮箱不存在 |
||||
*/ |
||||
SEND_EMAIL_ERR_INVALID_TAR_ERR(60002, "发送邮件失败,收件邮箱不存在或产生其他问题"), |
||||
/** |
||||
* 向飞书通知群发送消息成功 |
||||
*/ |
||||
SEND_MSG_TO_FEISHU_SUC(10000, "向飞书通知群发送消息成功"), |
||||
/** |
||||
* 向飞书通知群发送消息失败 |
||||
*/ |
||||
SEND_MSG_TO_FEISHU_ERR(60101, "向飞书通知群发送消息失败"), |
||||
/** |
||||
* 向安卓客户端发送消息成功 |
||||
*/ |
||||
SEND_MSG_TO_ANDROID_SUC(10000, "向安卓客户端发送消息成功"), |
||||
/** |
||||
* 向安卓客户端发送消息失败 |
||||
*/ |
||||
SEND_MSG_TO_ANDROID_ERR(60201, "向安卓客户端发送消息失败,用户可能不在线上,或是发生错误"), |
||||
/** |
||||
* 获取全部安卓端记录消息成功 |
||||
*/ |
||||
ANDROID_MSG_GET_SUC(10000, "获取全部安卓端记录消息成功"), |
||||
//消息中心 END
|
||||
|
||||
|
||||
//物理实验 START (7)
|
||||
/** |
||||
* 登陆失败:账号或密码错误,或不在实验课不在本学期 |
||||
*/ |
||||
WLSY_LOGIN_ERR_WLSY_FIN_INFO_ERR(70001, "登陆失败:账号或密码错误,或不在实验课不在本学期"), |
||||
/** |
||||
* 登陆失败:实验系统官网异常,请重试 |
||||
*/ |
||||
WLSY_LOGIN_ERR_WLSY_ERR(70002, "登陆失败:实验系统官网异常,请重试"), |
||||
/** |
||||
* 实验系统异常:缓存登陆成功 |
||||
*/ |
||||
WLSY_LOGIN_ERR_WLSY_ERR_LOC_SUC(11000, "实验系统异常:缓存登陆成功"), |
||||
/** |
||||
* 物理实验系统登陆成功 |
||||
*/ |
||||
WLSY_LOGIN_SUC(10000, "物理实验系统登陆成功"), |
||||
/** |
||||
* 获取已选实验课失败:实验系统官网异常 |
||||
*/ |
||||
WLSY_GETCOURSE_ERR_WLSY_ERR(70101, "获取已选实验课失败:实验系统官网异常"), |
||||
/** |
||||
* 获取已选实验课失败:登录过期 |
||||
*/ |
||||
WLSY_GETCOURSE_ERR_LOGIN_EXPIRED(70102, "获取已选实验课失败:登录过期"), |
||||
/** |
||||
* 实验系统异常:缓存获取已选实验课成功 |
||||
*/ |
||||
WLSY_GETCOURSE_ERR_WLSY_ERR_LOC_SUC(11000, "实验系统异常:缓存获取已选实验课成功"), |
||||
/** |
||||
* 获取已选实验课成功 |
||||
*/ |
||||
WLSY_GETCOURSE_SUC(10000, "获取已选实验课成功"), |
||||
//物理实验 END
|
||||
|
||||
|
||||
//教室查询 START (8)
|
||||
/** |
||||
* 查询空教室成功 |
||||
*/ |
||||
CLSR_SEARCH_EMPTY_CLASSROOM_SUC(10000, "查询空教室成功"), |
||||
/** |
||||
* 查询学院列表成功 |
||||
*/ |
||||
CLSR_GET_COLLEGE_LIST_SUC(10000, "查询学院列表成功"), |
||||
/** |
||||
* 查询课名列表成功 |
||||
*/ |
||||
CLSR_GET_COURSE_NAME_LIST_SUC(10000, "查询课名列表成功"), |
||||
/** |
||||
* 查询课程详情成功 |
||||
*/ |
||||
CLSR_GET_COURSE_DETAIL_LIST_SUC(10000, "查询课程详情成功"), |
||||
/** |
||||
* 查询结果为空 |
||||
*/ |
||||
CLSR_RESULT_EMPTY(80001, "查询结果为空"), |
||||
/** |
||||
* 已是最后一页 |
||||
*/ |
||||
CLSR_NO_MORE_PAGE(80002, "已是最后一页"), |
||||
//教室查询 END (8)
|
||||
|
||||
|
||||
//助手信息查询 BEGIN (9)
|
||||
/** |
||||
* 获取用户详情信息成功 |
||||
*/ |
||||
GET_USER_INFO_SUC(10000, "获取用户详情信息成功"), |
||||
/** |
||||
* 获取用户操作记录成功 |
||||
*/ |
||||
GET_USER_OPE_RECORD_SUC(10000, "获取用户操作记录成功"), |
||||
/** |
||||
* 获取学号列表成功 |
||||
*/ |
||||
GET_STU_NUM_LIST_SUC(10000, "获取学号列表成功"), |
||||
/** |
||||
* 获取用户信息失败,用户不存在 |
||||
*/ |
||||
GET_USER_INFO_ERR_USER_NOT_EXIST(90001, "获取用户信息失败,用户不存在"), |
||||
/** |
||||
* 获取用户操作记录失败,用户不存在 |
||||
*/ |
||||
GET_USER_OPE_RECORD_ERR_USER_NOT_EXIST(90101, "获取用户操作记录失败,用户不存在"), |
||||
/** |
||||
* 目标日志不存在或为空 |
||||
*/ |
||||
LOG_EMPTY_OR_NOT_EXIST(90201, "目标日志不存在或为空"), |
||||
/** |
||||
* 获取日志信息成功 |
||||
*/ |
||||
GET_LOG_INFO_SUC(10000, "获取日志信息成功"), |
||||
/** |
||||
* 获取时段请求信息成功 |
||||
*/ |
||||
GET_TIME_REPORT_SUC(10000, "获取时段请求信息成功"), |
||||
//助手信息查询 END (9)
|
||||
; |
||||
|
||||
private final int code; |
||||
private final String msg; |
||||
} |
@ -1,4 +1,4 @@ |
||||
package wusthelper.web.api.v2.dto.response; |
||||
package wusthelper.web.api.v2.dto.response.graduate; |
||||
|
||||
import cn.wustlinghang.mywust.data.global.StudentInfo; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
@ -0,0 +1,94 @@ |
||||
package wusthelper.web.api.v2.dto.response.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.library.origin.BookSearchResult; |
||||
import cn.wustlinghang.mywust.data.library.parsed.BookDetail; |
||||
import cn.wustlinghang.mywust.data.library.parsed.BookHolding; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Data |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class BookDetailResponse { |
||||
/** |
||||
* 题名/责任者 |
||||
*/ |
||||
private String bookNameAndAuth; |
||||
|
||||
/** |
||||
* 出版发行项 |
||||
*/ |
||||
private String publisher; |
||||
|
||||
/** |
||||
* ISBN及定价 |
||||
*/ |
||||
private String ISBN; |
||||
|
||||
/** |
||||
* 内容简介 |
||||
*/ |
||||
private String introduction; |
||||
|
||||
/** |
||||
* 图片URL |
||||
*/ |
||||
private String imgUrl; |
||||
|
||||
/** |
||||
* 是否已经收藏 |
||||
*/ |
||||
private Integer isCollection; |
||||
|
||||
/** |
||||
* 租借信息 |
||||
*/ |
||||
private List<BookHoldingInfo> list; |
||||
|
||||
public static BookDetailResponse from(BookDetail bookDetail) { |
||||
BookDetailResponse bookDetailResponse = new BookDetailResponse(); |
||||
|
||||
var extraInfo = bookDetail.getExtraInfoMap(); |
||||
bookDetailResponse.setBookNameAndAuth(extraInfo.get("题名/责任者")); |
||||
bookDetailResponse.setPublisher(extraInfo.get("出版发行项")); |
||||
|
||||
bookDetailResponse.setISBN(bookDetail.getIsbn()); |
||||
bookDetailResponse.setIntroduction(bookDetail.getIntroduction()); |
||||
bookDetailResponse.setIsCollection(0); |
||||
bookDetailResponse.setImgUrl(bookDetail.getCoverUrl()); |
||||
// bookDetailResponse.setList();
|
||||
|
||||
return bookDetailResponse; |
||||
} |
||||
|
||||
@Data |
||||
public static class BookHoldingInfo { |
||||
/** |
||||
* 索书号 |
||||
*/ |
||||
private String callNo; |
||||
/** |
||||
* 条号码 |
||||
*/ |
||||
private String barCode; |
||||
/** |
||||
* 馆藏地 |
||||
*/ |
||||
private String location; |
||||
/** |
||||
* 是否可借 |
||||
*/ |
||||
private String status; |
||||
|
||||
public static BookHoldingInfo from(BookHolding bookHolding) { |
||||
BookHoldingInfo bookHoldingInfo = new BookHoldingInfo(); |
||||
bookHoldingInfo.setCallNo(bookHolding.getCallNumber()); |
||||
bookHoldingInfo.setBarCode(bookHolding.getBarCode()); |
||||
bookHoldingInfo.setLocation(bookHolding.getLocation()); |
||||
bookHoldingInfo.setStatus(bookHolding.getStatus()); |
||||
|
||||
return bookHoldingInfo; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,78 @@ |
||||
package wusthelper.web.api.v2.dto.response.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.library.origin.BookSearchResult; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Arrays; |
||||
|
||||
@Data |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class BookSearchResponseItem { |
||||
/** |
||||
* 书名 |
||||
*/ |
||||
private String title; |
||||
|
||||
/** |
||||
* 作者 |
||||
*/ |
||||
private String author; |
||||
|
||||
/** |
||||
* 发布时间 |
||||
*/ |
||||
private String pubYear; |
||||
|
||||
/** |
||||
* 出版方 |
||||
*/ |
||||
private String publisher; |
||||
|
||||
/** |
||||
* 索书号 |
||||
*/ |
||||
private String callNo; |
||||
|
||||
/** |
||||
* 书籍详情URL |
||||
*/ |
||||
private String detailUrl; |
||||
|
||||
/** |
||||
* 图片URL |
||||
*/ |
||||
private String imgUrl; |
||||
|
||||
/** |
||||
* 馆藏总数 |
||||
*/ |
||||
private String allNum; |
||||
|
||||
/** |
||||
* 可借数目 |
||||
*/ |
||||
private String remainNum; |
||||
|
||||
private String isbn; |
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public static BookSearchResponseItem from(BookSearchResult bookSearchResult) { |
||||
BookSearchResponseItem bookSearchResponseItem = new BookSearchResponseItem(); |
||||
bookSearchResponseItem.setTitle(bookSearchResult.getTitle()); |
||||
bookSearchResponseItem.setAuthor(bookSearchResult.getAuthor()); |
||||
bookSearchResponseItem.setPubYear(bookSearchResult.getPubYear()); |
||||
bookSearchResponseItem.setPublisher(bookSearchResult.getPublisher()); |
||||
|
||||
var callNumberString = Arrays.toString(bookSearchResult.getCallNumber().toArray(new String[0])); |
||||
bookSearchResponseItem.setCallNo(callNumberString); |
||||
|
||||
bookSearchResponseItem.setIsbn(bookSearchResult.getIsbn()); |
||||
// bookSearchResponseItem.setDetailUrl();
|
||||
// bookSearchResponseItem.setImgUrl();
|
||||
// bookSearchResponseItem.setAllNum();
|
||||
// bookSearchResponseItem.setRemainNum();
|
||||
|
||||
return bookSearchResponseItem; |
||||
} |
||||
} |
@ -0,0 +1,31 @@ |
||||
package wusthelper.web.api.v2.dto.response.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.library.origin.CurrentLoanBook; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class CurrentRentResponse { |
||||
private String bookCode; |
||||
private String reRentNum = ""; |
||||
private String bookPlace; |
||||
private String bookUrl; |
||||
private String rentTime; |
||||
private String bookName; |
||||
private String returnTime; |
||||
|
||||
private static final String bookUrlFormat = "https://libsys.wust.edu.cn/meta-local/opac/bibs/%s/infos"; |
||||
|
||||
public static CurrentRentResponse from(CurrentLoanBook currentLoanBook) { |
||||
CurrentRentResponse currentRentResponse = new CurrentRentResponse(); |
||||
currentRentResponse.setBookCode(currentLoanBook.getBarCode()); |
||||
currentRentResponse.setBookPlace(currentLoanBook.getLocation()); |
||||
currentRentResponse.setBookUrl(bookUrlFormat.formatted(currentLoanBook.getBibId())); |
||||
currentRentResponse.setRentTime(currentLoanBook.getLoanDate()); |
||||
currentRentResponse.setBookName(currentLoanBook.getTitle()); |
||||
currentRentResponse.setReturnTime(currentLoanBook.getDueDate()); |
||||
|
||||
return currentRentResponse; |
||||
} |
||||
} |
@ -0,0 +1,29 @@ |
||||
package wusthelper.web.api.v2.dto.response.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.library.origin.HistoryLoanBook; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class RentHistoryResponse { |
||||
private String bookCode; |
||||
private String bookPlace; |
||||
private String bookAuthor; |
||||
private String bookUrl; |
||||
private String rentTime; |
||||
private String bookName; |
||||
private String returnTime; |
||||
|
||||
private static final String bookUrlFormat = "https://libsys.wust.edu.cn/meta-local/opac/bibs/%s/infos"; |
||||
|
||||
public static RentHistoryResponse from(HistoryLoanBook historyLoanBook) { |
||||
RentHistoryResponse currentRentResponse = new RentHistoryResponse(); |
||||
currentRentResponse.setBookCode(historyLoanBook.getBarCode()); |
||||
currentRentResponse.setBookPlace(historyLoanBook.getLocation()); |
||||
currentRentResponse.setBookUrl(bookUrlFormat.formatted(historyLoanBook.getBibId())); |
||||
currentRentResponse.setRentTime(historyLoanBook.getLoanDate()); |
||||
currentRentResponse.setBookName(historyLoanBook.getTitle()); |
||||
currentRentResponse.setReturnTime(historyLoanBook.getReturnDate()); |
||||
|
||||
return currentRentResponse; |
||||
} |
||||
} |
@ -1,8 +1,7 @@ |
||||
package wusthelper.web.api.v2.dto.response; |
||||
package wusthelper.web.api.v2.dto.response.physics; |
||||
|
||||
import cn.wustlinghang.mywust.data.physics.PhysicsCourse; |
||||
import lombok.Data; |
||||
import wusthelper.WebBackendMain; |
||||
import wusthelper.web.util.GlobalLogger; |
||||
|
||||
import java.sql.Date; |
@ -1,6 +1,6 @@ |
||||
package wusthelper.web.api.v2.dto.response; |
||||
package wusthelper.web.api.v2.dto.response.undergrad; |
||||
|
||||
import cn.wustlinghang.mywust.data.global.Course; |
||||
import wusthelper.web.api.v2.dto.response.CourseResponse; |
||||
|
||||
import java.util.List; |
||||
|
@ -1,4 +1,4 @@ |
||||
package wusthelper.web.api.v2.dto.response; |
||||
package wusthelper.web.api.v2.dto.response.undergrad; |
||||
|
||||
import cn.wustlinghang.mywust.data.global.StudentInfo; |
||||
import lombok.Data; |
@ -0,0 +1,36 @@ |
||||
package wusthelper.web.api.v2.interceptor; |
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import jakarta.annotation.Nonnull; |
||||
import jakarta.servlet.http.HttpServletRequest; |
||||
import jakarta.servlet.http.HttpServletResponse; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.servlet.HandlerInterceptor; |
||||
import org.springframework.web.servlet.ModelAndView; |
||||
import wusthelper.code.ServiceCode; |
||||
import wusthelper.web.response.Response; |
||||
|
||||
@Component |
||||
public class NotFoundPathInterceptor implements HandlerInterceptor { |
||||
private final ObjectMapper objectMapper; |
||||
|
||||
public NotFoundPathInterceptor(ObjectMapper objectMapper) { |
||||
this.objectMapper = objectMapper; |
||||
} |
||||
|
||||
@Override |
||||
public void postHandle(@Nonnull HttpServletRequest request, |
||||
@Nonnull HttpServletResponse servletResponse, |
||||
@Nonnull Object handler, |
||||
ModelAndView modelAndView) throws Exception { |
||||
if (servletResponse.getStatus() == HttpStatus.NOT_FOUND.value()) { |
||||
var response = Response.error(ServiceCode.ApiNotImplement); |
||||
var json = objectMapper.writeValueAsString(response); |
||||
|
||||
servletResponse.setContentType("application/json"); |
||||
servletResponse.setCharacterEncoding("utf-8"); |
||||
servletResponse.getWriter().write(json); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,83 @@ |
||||
package wusthelper.web.api.v2.interceptor; |
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import jakarta.annotation.Nonnull; |
||||
import jakarta.servlet.http.HttpServletRequest; |
||||
import jakarta.servlet.http.HttpServletResponse; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.method.HandlerMethod; |
||||
import org.springframework.web.servlet.HandlerInterceptor; |
||||
import wusthelper.web.annotation.RequireToken; |
||||
import wusthelper.web.api.v2.TokenTool; |
||||
import wusthelper.web.api.v2.code.V2ResponseCode; |
||||
import wusthelper.web.response.Response; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
@Slf4j |
||||
@Component |
||||
public class TokenInterceptor implements HandlerInterceptor { |
||||
|
||||
private final ObjectMapper objectMapper; |
||||
|
||||
public TokenInterceptor(ObjectMapper objectMapper) { |
||||
this.objectMapper = objectMapper; |
||||
} |
||||
|
||||
@Override |
||||
public boolean preHandle(@Nonnull HttpServletRequest request, |
||||
@Nonnull HttpServletResponse response, |
||||
@Nonnull Object handler) throws Exception { |
||||
|
||||
if (!(handler instanceof HandlerMethod handlerMethod)) { |
||||
return true; |
||||
} |
||||
|
||||
// 方法上的RequireToken
|
||||
var methodAnnotation = handlerMethod.getMethodAnnotation(RequireToken.class); |
||||
if (methodAnnotation == null) { |
||||
// class上的RequireToken
|
||||
var classAnnotation = handlerMethod.getMethod().getDeclaringClass().getAnnotation(RequireToken.class); |
||||
if (classAnnotation == null) { |
||||
return true; |
||||
} else { |
||||
if (!classAnnotation.require()) { |
||||
return true; |
||||
} |
||||
} |
||||
} else { |
||||
if (!methodAnnotation.require()) { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
// 验证token
|
||||
var token = request.getHeader("token"); |
||||
if (token == null || "".equals(token)) { |
||||
this.rejectRequest(response); |
||||
return false; |
||||
} |
||||
|
||||
var tokenValid = verifyToken(token); |
||||
if (!tokenValid) { |
||||
this.rejectRequest(response); |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
private boolean verifyToken(String token) { |
||||
return TokenTool.verify(token); |
||||
} |
||||
|
||||
private void rejectRequest(HttpServletResponse servletResponse) throws IOException { |
||||
var response = Response.error(V2ResponseCode.AUTH_ERR_TOKEN_INVALID.getCode(), "token无效或已过期,请重新登录"); |
||||
var json = objectMapper.writeValueAsString(response); |
||||
|
||||
servletResponse.setContentType("application/json"); |
||||
servletResponse.setCharacterEncoding("utf-8"); |
||||
servletResponse.getWriter().write(json); |
||||
} |
||||
} |
@ -0,0 +1,28 @@ |
||||
package wusthelper.web.api.v2.module.library; |
||||
|
||||
import org.springframework.web.bind.annotation.*; |
||||
import wusthelper.web.annotation.RequireToken; |
||||
import wusthelper.web.api.v2.TokenTool; |
||||
import wusthelper.web.api.v2.code.V2ResponseCode; |
||||
import wusthelper.web.response.Response; |
||||
import wusthelper.web.service.campus.UserLoginService; |
||||
|
||||
@RequireToken |
||||
@RestController |
||||
@RequestMapping("/v2/lib") |
||||
public class LibraryLoginController { |
||||
private final UserLoginService userLoginService; |
||||
|
||||
public LibraryLoginController(UserLoginService userLoginService) { |
||||
this.userLoginService = userLoginService; |
||||
} |
||||
|
||||
@PostMapping("/login") |
||||
public Response<Object> login(@RequestParam("libPwd") String password, |
||||
@RequestHeader("Token") String token) { |
||||
String username = TokenTool.getStudentNumber(token); |
||||
userLoginService.login(username, password, UserLoginService.LoginType.Library); |
||||
|
||||
return Response.success(V2ResponseCode.LIB_LOGIN_SUC.getCode(), null); |
||||
} |
||||
} |
@ -0,0 +1,64 @@ |
||||
package wusthelper.web.api.v2.module.library; |
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestHeader; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import wusthelper.web.annotation.RequireToken; |
||||
import wusthelper.web.api.v2.TokenTool; |
||||
import wusthelper.web.api.v2.code.V2ResponseCode; |
||||
import wusthelper.web.api.v2.dto.response.library.CurrentRentResponse; |
||||
import wusthelper.web.api.v2.dto.response.library.RentHistoryResponse; |
||||
import wusthelper.web.response.Response; |
||||
import wusthelper.web.service.campus.library.LibraryPersonalService; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@RequireToken |
||||
@RestController |
||||
@RequestMapping("/v2/lib") |
||||
public class LibraryPersonalController { |
||||
|
||||
private final LibraryPersonalService service; |
||||
|
||||
public LibraryPersonalController(LibraryPersonalService service) { |
||||
this.service = service; |
||||
} |
||||
|
||||
/** |
||||
* 获取当前借阅信息 |
||||
* |
||||
* @param token |
||||
* @return |
||||
*/ |
||||
@GetMapping(path = "/get-current-rent", produces = {"application/json"}) |
||||
public Response<List<CurrentRentResponse>> getCurrentRent(@RequestHeader(value = "Token") String token) { |
||||
String stuNum = TokenTool.getStudentNumber(token); |
||||
var resultList = service.getCurrentLoan(stuNum, 0, 30).getData(); |
||||
var responseData = new ArrayList<CurrentRentResponse>(resultList.size()); |
||||
for (var result : resultList) { |
||||
responseData.add(CurrentRentResponse.from(result)); |
||||
} |
||||
|
||||
return Response.success(V2ResponseCode.LIB_GETCURRENTRENT_SUC.getCode(), responseData); |
||||
} |
||||
|
||||
/** |
||||
* 获取历史借阅信息 |
||||
* |
||||
* @param token |
||||
* @return |
||||
*/ |
||||
@GetMapping(path = "/get-rent-history", produces = {"application/json"}) |
||||
public Response<List<RentHistoryResponse>> getRentHistory(@RequestHeader(value = "Token") String token) { |
||||
String stuNum = TokenTool.getStudentNumber(token); |
||||
var resultList = service.getLoanHistory(stuNum, 0, 30).getData(); |
||||
var responseData = new ArrayList<RentHistoryResponse>(resultList.size()); |
||||
for (var result : resultList) { |
||||
responseData.add(RentHistoryResponse.from(result)); |
||||
} |
||||
|
||||
return Response.success(V2ResponseCode.LIB_GETRENTHISTORY_SUC.getCode(), responseData); |
||||
} |
||||
} |
@ -0,0 +1,74 @@ |
||||
package wusthelper.web.api.v2.module.library; |
||||
|
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import wusthelper.code.ServiceCode; |
||||
import wusthelper.web.api.v2.code.V2ResponseCode; |
||||
import wusthelper.web.api.v2.dto.response.library.BookDetailResponse; |
||||
import wusthelper.web.api.v2.dto.response.library.BookSearchResponseItem; |
||||
import wusthelper.web.response.Response; |
||||
import wusthelper.web.service.campus.library.LibraryPublicService; |
||||
|
||||
import java.util.*; |
||||
import java.util.regex.Pattern; |
||||
|
||||
@RestController |
||||
@RequestMapping("/v2/lib") |
||||
public class LibraryPublicController { |
||||
private final LibraryPublicService service; |
||||
|
||||
public LibraryPublicController(LibraryPublicService service) { |
||||
this.service = service; |
||||
} |
||||
|
||||
private static final Pattern BOOK_URL_PATTERN = Pattern.compile("https://libsys.wust.edu.cn/meta-local/opac/bibs/(.*?)/infos"); |
||||
|
||||
@RequestMapping(path = "/get-book-detail") |
||||
public Response<BookDetailResponse> getBookDetail(@RequestParam(value = "url") String url) { |
||||
var urlMatcher = BOOK_URL_PATTERN.matcher(url); |
||||
if (!urlMatcher.find()) { |
||||
return Response.error(ServiceCode.ParamWrong); |
||||
} |
||||
var id = urlMatcher.group(1); |
||||
var detail = service.getBookDetail(id); |
||||
|
||||
var responseData = BookDetailResponse.from(detail); |
||||
|
||||
var holdingInfoList = service.getBookHolding(id); |
||||
List<BookDetailResponse.BookHoldingInfo> bookHoldingInfoList = new ArrayList<>(holdingInfoList.size()); |
||||
for (var holdingInfo : holdingInfoList) { |
||||
var bookHoldingInfo = BookDetailResponse.BookHoldingInfo.from(holdingInfo); |
||||
bookHoldingInfoList.add(bookHoldingInfo); |
||||
} |
||||
responseData.setList(bookHoldingInfoList); |
||||
|
||||
return Response.success(V2ResponseCode.LIB_GETBOOKDETAIL_SUC.getCode(), responseData); |
||||
} |
||||
|
||||
@RequestMapping(path = "/search") |
||||
public Response<List<BookSearchResponseItem>> search( |
||||
@RequestParam(value = "keyWord") String keyword, |
||||
@RequestParam(value = "pageNum", required = false, defaultValue = "1") int page, |
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "20") int pageSize |
||||
) { |
||||
var upstreamResultList = service.searchBooks(keyword, page, pageSize).getData(); |
||||
var responseData = new ArrayList<BookSearchResponseItem>(upstreamResultList.size()); |
||||
var isbnList = new ArrayList<String>(upstreamResultList.size()); |
||||
for (var result : upstreamResultList) { |
||||
var item = BookSearchResponseItem.from(result); |
||||
item.setAllNum("1"); |
||||
item.setRemainNum("1"); |
||||
responseData.add(item); |
||||
isbnList.add(result.getIsbn()); |
||||
} |
||||
|
||||
var coverUrls = service.getBookCoverImageBatch(isbnList); |
||||
for (var item : responseData) { |
||||
item.setImgUrl(coverUrls.get(item.getIsbn()).get(0)); |
||||
} |
||||
|
||||
return Response.success(V2ResponseCode.LIB_SEARCH_SUC.getCode(), responseData); |
||||
} |
||||
} |
@ -0,0 +1,17 @@ |
||||
package wusthelper.web.api.v2.module.linghang; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import wusthelper.web.annotation.RequireToken; |
||||
import wusthelper.web.api.v2.code.V2ResponseCode; |
||||
import wusthelper.web.response.Response; |
||||
|
||||
@RestController |
||||
@RequestMapping("/v2/lh") |
||||
public class LinghangController { |
||||
@RequireToken |
||||
@RequestMapping("check-token") |
||||
public Response<Object> checkToken() { |
||||
return Response.success(V2ResponseCode.SUC.getCode(), null); |
||||
} |
||||
} |
@ -0,0 +1,31 @@ |
||||
package wusthelper.web.configure; |
||||
|
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
import wusthelper.web.api.v2.interceptor.NotFoundPathInterceptor; |
||||
import wusthelper.web.api.v2.interceptor.TokenInterceptor; |
||||
|
||||
@Configuration |
||||
public class WebMvcConfigure implements WebMvcConfigurer { |
||||
|
||||
private final TokenInterceptor tokenInterceptor; |
||||
private final NotFoundPathInterceptor notFoundPathInterceptor; |
||||
|
||||
public WebMvcConfigure(TokenInterceptor tokenInterceptor, |
||||
NotFoundPathInterceptor notFoundPathInterceptor) { |
||||
this.tokenInterceptor = tokenInterceptor; |
||||
this.notFoundPathInterceptor = notFoundPathInterceptor; |
||||
} |
||||
|
||||
@Override |
||||
public void addInterceptors(InterceptorRegistry registry) { |
||||
registry.addInterceptor(this.tokenInterceptor) |
||||
.addPathPatterns("/**"); |
||||
|
||||
registry.addInterceptor(this.notFoundPathInterceptor) |
||||
.addPathPatterns("/**"); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,27 @@ |
||||
package wusthelper.web.rpc.http.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.global.Course; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import wusthelper.internal.rpc.response.RpcResponseDto; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Component |
||||
@FeignClient(name = "wusthelper.library", contextId = "library-bookCoverImage", url = "http://127.0.0.1:22804") |
||||
public interface LibraryBookCoverImageRemote { |
||||
String ROOT_PATH = "/cover_image"; |
||||
|
||||
@GetMapping(ROOT_PATH) |
||||
RpcResponseDto<Object> get(@RequestParam("isbn") String isbn); |
||||
|
||||
@GetMapping(ROOT_PATH + "/agent") |
||||
RpcResponseDto<String> agent(@RequestParam("isbn") String isbn); |
||||
|
||||
@PostMapping(ROOT_PATH + "/batch") |
||||
RpcResponseDto<Map<String, List<String>>> batch(@RequestParam("isbn") String isbnList); |
||||
} |
@ -0,0 +1,24 @@ |
||||
package wusthelper.web.rpc.http.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.global.Course; |
||||
import cn.wustlinghang.mywust.data.library.parsed.BookDetail; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import wusthelper.internal.rpc.response.RpcResponseDto; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Component |
||||
@FeignClient(name = "wusthelper.library", contextId = "library-bookDetail", url = "http://127.0.0.1:22804") |
||||
public interface LibraryBookDetailRemote { |
||||
String ROOT_PATH = "/book_detail"; |
||||
|
||||
@GetMapping(ROOT_PATH) |
||||
RpcResponseDto<BookDetail> get(@RequestParam("id") String id); |
||||
|
||||
@GetMapping(ROOT_PATH + "/agent") |
||||
RpcResponseDto<BookDetail> agent(@RequestParam("id") String id); |
||||
} |
@ -0,0 +1,23 @@ |
||||
package wusthelper.web.rpc.http.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.global.Course; |
||||
import cn.wustlinghang.mywust.data.library.parsed.BookHolding; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import wusthelper.internal.rpc.response.RpcResponseDto; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Component |
||||
@FeignClient(name = "wusthelper.library", contextId = "library-bookHoldings", url = "http://127.0.0.1:22804") |
||||
public interface LibraryBookHoldingRemote { |
||||
String ROOT_PATH = "/holdings"; |
||||
|
||||
@GetMapping(ROOT_PATH) |
||||
RpcResponseDto<List<BookHolding>> get(@RequestParam("id") String id); |
||||
|
||||
@GetMapping(ROOT_PATH + "/agent") |
||||
RpcResponseDto<List<BookHolding>> agent(@RequestParam("id") String id); |
||||
} |
@ -0,0 +1,20 @@ |
||||
package wusthelper.web.rpc.http.library; |
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import wusthelper.internal.rpc.response.RpcResponseDto; |
||||
|
||||
@Component |
||||
@FeignClient(name = "wusthelper.library", contextId = "library-cookie", url = "http://127.0.0.1:22804") |
||||
public interface LibraryCookieRemote { |
||||
String COOKIE_ROOT_PATH = "/cookie"; |
||||
|
||||
@GetMapping(COOKIE_ROOT_PATH) |
||||
RpcResponseDto<String> login(@RequestParam("username") String username, |
||||
@RequestParam("password") String password); |
||||
|
||||
@GetMapping(COOKIE_ROOT_PATH + "/verify") |
||||
RpcResponseDto<Boolean> verify(@RequestParam("cookie") String cookie); |
||||
} |
@ -0,0 +1,31 @@ |
||||
package wusthelper.web.rpc.http.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.library.PagingResult; |
||||
import cn.wustlinghang.mywust.data.library.origin.CurrentLoanBook; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import wusthelper.internal.rpc.response.RpcResponseDto; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Component |
||||
@FeignClient(name = "wusthelper.library", contextId = "library-currentLoan", url = "http://127.0.0.1:22804") |
||||
public interface LibraryCurrentLoanRemote { |
||||
String ROOT_PATH = "/current_loan"; |
||||
|
||||
@GetMapping(ROOT_PATH) |
||||
RpcResponseDto<PagingResult<List<CurrentLoanBook>>> get( |
||||
@RequestParam("cookie") String cookie, |
||||
@RequestParam("page") int page, |
||||
@RequestParam("page_ize") int pageSize |
||||
); |
||||
|
||||
@GetMapping(ROOT_PATH + "/agent") |
||||
RpcResponseDto<PagingResult<List<CurrentLoanBook>>> agent( |
||||
@RequestParam("cookie") String cookie, |
||||
@RequestParam("page") int page, |
||||
@RequestParam("page_ize") int pageSize |
||||
); |
||||
} |
@ -0,0 +1,31 @@ |
||||
package wusthelper.web.rpc.http.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.library.PagingResult; |
||||
import cn.wustlinghang.mywust.data.library.origin.HistoryLoanBook; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import wusthelper.internal.rpc.response.RpcResponseDto; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Component |
||||
@FeignClient(name = "wusthelper.library", contextId = "library-loanHistory", url = "http://127.0.0.1:22804") |
||||
public interface LibraryLoanHistoryRemote { |
||||
String ROOT_PATH = "/loan_history"; |
||||
|
||||
@GetMapping(ROOT_PATH) |
||||
RpcResponseDto<PagingResult<List<HistoryLoanBook>>> get( |
||||
@RequestParam("cookie") String cookie, |
||||
@RequestParam("page") int page, |
||||
@RequestParam("page_ize") int pageSize |
||||
); |
||||
|
||||
@GetMapping(ROOT_PATH + "/agent") |
||||
RpcResponseDto<PagingResult<List<HistoryLoanBook>>> agent( |
||||
@RequestParam("cookie") String cookie, |
||||
@RequestParam("page") int page, |
||||
@RequestParam("page_ize") int pageSize |
||||
); |
||||
} |
@ -0,0 +1,31 @@ |
||||
package wusthelper.web.rpc.http.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.library.PagingResult; |
||||
import cn.wustlinghang.mywust.data.library.origin.BaseLoanBook; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import wusthelper.internal.rpc.response.RpcResponseDto; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Component |
||||
@FeignClient(name = "wusthelper.library", contextId = "library-overdueSoon", url = "http://127.0.0.1:22804") |
||||
public interface LibraryOverdueSoonRemote { |
||||
String ROOT_PATH = "/overdue_soon"; |
||||
|
||||
@GetMapping(ROOT_PATH) |
||||
RpcResponseDto<PagingResult<List<BaseLoanBook>>> get( |
||||
@RequestParam("cookie") String cookie, |
||||
@RequestParam("page") int page, |
||||
@RequestParam("page_ize") int pageSize |
||||
); |
||||
|
||||
@GetMapping(ROOT_PATH + "/agent") |
||||
RpcResponseDto<PagingResult<List<BaseLoanBook>>> agent( |
||||
@RequestParam("cookie") String cookie, |
||||
@RequestParam("page") int page, |
||||
@RequestParam("page_ize") int pageSize |
||||
); |
||||
} |
@ -0,0 +1,31 @@ |
||||
package wusthelper.web.rpc.http.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.library.PagingResult; |
||||
import cn.wustlinghang.mywust.data.library.origin.BookSearchResult; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import wusthelper.internal.rpc.response.RpcResponseDto; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Component |
||||
@FeignClient(name = "wusthelper.library", contextId = "library-search", url = "http://127.0.0.1:22804") |
||||
public interface LibrarySearchRemote { |
||||
String ROOT_PATH = "/search"; |
||||
|
||||
@GetMapping(ROOT_PATH) |
||||
RpcResponseDto<PagingResult<List<BookSearchResult>>> get( |
||||
@RequestParam("keyword") String keyword, |
||||
@RequestParam("page") int page, |
||||
@RequestParam("page_ize") int pageSize |
||||
); |
||||
|
||||
@GetMapping(ROOT_PATH + "/agent") |
||||
RpcResponseDto<PagingResult<List<BookSearchResult>>> agent( |
||||
@RequestParam("keyword") String keyword, |
||||
@RequestParam("page") int page, |
||||
@RequestParam("page_ize") int pageSize |
||||
); |
||||
} |
@ -0,0 +1,70 @@ |
||||
package wusthelper.web.service.campus.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.library.PagingResult; |
||||
import cn.wustlinghang.mywust.data.library.origin.BaseLoanBook; |
||||
import cn.wustlinghang.mywust.data.library.origin.CurrentLoanBook; |
||||
import cn.wustlinghang.mywust.data.library.origin.HistoryLoanBook; |
||||
import org.springframework.stereotype.Service; |
||||
import wusthelper.code.ServiceCode; |
||||
import wusthelper.web.data.entity.CookieType; |
||||
import wusthelper.web.exception.ServiceException; |
||||
import wusthelper.web.rpc.http.library.LibraryCurrentLoanRemote; |
||||
import wusthelper.web.rpc.http.library.LibraryLoanHistoryRemote; |
||||
import wusthelper.web.rpc.http.library.LibraryOverdueSoonRemote; |
||||
import wusthelper.web.service.cookie.CookieManager; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Service |
||||
public class LibraryPersonalService { |
||||
private final CookieManager cookieManager; |
||||
|
||||
private final LibraryCurrentLoanRemote currentLoanRemote; |
||||
private final LibraryLoanHistoryRemote loanHistoryRemote; |
||||
private final LibraryOverdueSoonRemote overdueSoonRemote; |
||||
|
||||
public LibraryPersonalService(CookieManager cookieManager, |
||||
LibraryCurrentLoanRemote currentLoanRemote, |
||||
LibraryLoanHistoryRemote loanHistoryRemote, |
||||
LibraryOverdueSoonRemote overdueSoonRemote) { |
||||
|
||||
this.cookieManager = cookieManager; |
||||
|
||||
this.currentLoanRemote = currentLoanRemote; |
||||
this.loanHistoryRemote = loanHistoryRemote; |
||||
this.overdueSoonRemote = overdueSoonRemote; |
||||
} |
||||
|
||||
public PagingResult<List<CurrentLoanBook>> getCurrentLoan(String user, int page, int pageSize) { |
||||
String cookie = cookieManager.getCookie(user, CookieType.Library); |
||||
var rpcResp = currentLoanRemote.get(cookie, page, pageSize); |
||||
if (rpcResp.code() != ServiceCode.Ok) { |
||||
ServiceException.error(rpcResp.code()); |
||||
} |
||||
|
||||
// todo 异步存用户课表,异常判断等等
|
||||
return rpcResp.data(); |
||||
} |
||||
|
||||
public PagingResult<List<HistoryLoanBook>> getLoanHistory(String user, int page, int pageSize) { |
||||
String cookie = cookieManager.getCookie(user, CookieType.Library); |
||||
var rpcResp = loanHistoryRemote.get(cookie, page, pageSize); |
||||
if (rpcResp.code() != ServiceCode.Ok) { |
||||
ServiceException.error(rpcResp.code()); |
||||
} |
||||
|
||||
// todo 异步存用户课表,异常判断等等
|
||||
return rpcResp.data(); |
||||
} |
||||
|
||||
public PagingResult<List<BaseLoanBook>> getOverdueSoon(String user, int page, int pageSize) { |
||||
String cookie = cookieManager.getCookie(user, CookieType.Library); |
||||
var rpcResp = overdueSoonRemote.get(cookie, page, pageSize); |
||||
if (rpcResp.code() != ServiceCode.Ok) { |
||||
ServiceException.error(rpcResp.code()); |
||||
} |
||||
|
||||
// todo 异步存用户课表,异常判断等等
|
||||
return rpcResp.data(); |
||||
} |
||||
} |
@ -0,0 +1,93 @@ |
||||
package wusthelper.web.service.campus.library; |
||||
|
||||
import cn.wustlinghang.mywust.data.library.PagingResult; |
||||
import cn.wustlinghang.mywust.data.library.origin.BookSearchResult; |
||||
import cn.wustlinghang.mywust.data.library.parsed.BookDetail; |
||||
import cn.wustlinghang.mywust.data.library.parsed.BookHolding; |
||||
import org.springframework.stereotype.Service; |
||||
import wusthelper.code.ServiceCode; |
||||
import wusthelper.web.exception.ServiceException; |
||||
import wusthelper.web.rpc.http.library.LibraryBookCoverImageRemote; |
||||
import wusthelper.web.rpc.http.library.LibraryBookDetailRemote; |
||||
import wusthelper.web.rpc.http.library.LibraryBookHoldingRemote; |
||||
import wusthelper.web.rpc.http.library.LibrarySearchRemote; |
||||
|
||||
import java.util.*; |
||||
|
||||
@Service |
||||
public class LibraryPublicService { |
||||
private final LibraryBookCoverImageRemote bookCoverImageRemote; |
||||
private final LibraryBookDetailRemote bookDetailRemote; |
||||
private final LibraryBookHoldingRemote bookHoldingRemote; |
||||
private final LibrarySearchRemote searchRemote; |
||||
|
||||
public LibraryPublicService(LibraryBookCoverImageRemote bookCoverImageRemote, |
||||
LibraryBookDetailRemote bookDetailRemote, |
||||
LibraryBookHoldingRemote bookHoldingRemote, |
||||
LibrarySearchRemote searchRemote) { |
||||
|
||||
this.bookCoverImageRemote = bookCoverImageRemote; |
||||
this.bookDetailRemote = bookDetailRemote; |
||||
this.bookHoldingRemote = bookHoldingRemote; |
||||
this.searchRemote = searchRemote; |
||||
} |
||||
|
||||
public String getBookCoverImage(String isbn) { |
||||
var rpcResp = bookCoverImageRemote.agent(isbn); |
||||
if (rpcResp.code() != ServiceCode.Ok) { |
||||
ServiceException.error(rpcResp.code()); |
||||
} |
||||
|
||||
// todo 异步存用户课表,异常判断等等
|
||||
return rpcResp.data(); |
||||
} |
||||
|
||||
public Map<String, List<String>> getBookCoverImageBatch(Collection<String> isbn) { |
||||
if (isbn.isEmpty()) { |
||||
return new HashMap<>(); |
||||
} |
||||
|
||||
StringJoiner stringJoiner = new StringJoiner(","); |
||||
for (var i : isbn) { |
||||
stringJoiner.add(i); |
||||
} |
||||
|
||||
var rpcResp = bookCoverImageRemote.batch(stringJoiner.toString()); |
||||
if (rpcResp.code() != ServiceCode.Ok) { |
||||
ServiceException.error(rpcResp.code()); |
||||
} |
||||
|
||||
// todo 异步存用户课表,异常判断等等
|
||||
return rpcResp.data(); |
||||
} |
||||
|
||||
public BookDetail getBookDetail(String id) { |
||||
var rpcResp = bookDetailRemote.get(id); |
||||
if (rpcResp.code() != ServiceCode.Ok) { |
||||
ServiceException.error(rpcResp.code()); |
||||
} |
||||
|
||||
// todo 异步存用户课表,异常判断等等
|
||||
return rpcResp.data(); |
||||
} |
||||
|
||||
public List<BookHolding> getBookHolding(String id) { |
||||
var rpcResp = bookHoldingRemote.get(id); |
||||
if (rpcResp.code() != ServiceCode.Ok) { |
||||
ServiceException.error(rpcResp.code()); |
||||
} |
||||
|
||||
// todo 异步存用户课表,异常判断等等
|
||||
return rpcResp.data(); |
||||
} |
||||
|
||||
public PagingResult<List<BookSearchResult>> searchBooks(String keyword, int page, int pageSize) { |
||||
var rpcResp = searchRemote.get(keyword, page, pageSize); |
||||
if (rpcResp.code() != ServiceCode.Ok) { |
||||
ServiceException.error(rpcResp.code()); |
||||
} |
||||
|
||||
// todo 异步存用户课表,异常判断等等
|
||||
return rpcResp.data(); |
||||
} |
||||
} |
@ -1 +1 @@ |
||||
Subproject commit 5da31b26d1a8b7560f068d8bf507d01e34c1cdaf |
||||
Subproject commit 9dba2a9c374c28ee7ddd2c10beb28b99bc249f35 |
@ -0,0 +1,15 @@ |
||||
package wusthelper.internal.rpc.util; |
||||
|
||||
import java.net.InetAddress; |
||||
import java.net.UnknownHostException; |
||||
|
||||
public class IPUtil { |
||||
public static String getHostName() { |
||||
try { |
||||
InetAddress addr = InetAddress.getLocalHost(); |
||||
return addr.getHostName(); |
||||
} catch (UnknownHostException e) { |
||||
return "unknown-host"; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue