yg-tools
Version:
some convenient APIs and Methods for Youngon
492 lines (491 loc) • 16.5 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var url_1 = __importDefault(require("./url"));
var req_1 = __importDefault(require("./req"));
var YGAPIs = /** @class */ (function () {
function YGAPIs(config) {
var _this = this;
/**
* @function 绑定微信账号
* */
this.bindWXAccount = function (_a) {
var stuid = _a.stuid, password = _a.password, wxid = _a.wxid;
var opt = {
url: url_1.default.patch_wxid,
data: { stuid: stuid, password: password, wxid: wxid },
method: 'POST'
};
return _this.YGR.Req(opt);
};
/**
* @function 绑定QQ账号
* */
this.bindQQAccount = function (_a) {
var stuid = _a.stuid, password = _a.password, qqid = _a.qqid;
var opt = {
url: url_1.default.patch_qqid,
data: { stuid: stuid, password: password, qqid: qqid },
method: 'POST'
};
return _this.YGR.Req(opt);
};
/**
* @function 注册账号
* */
this.regAccount = function (_a) {
var stuid = _a.stuid, password = _a.password, name = _a.name, email = _a.email, utype = _a.utype, wxid = _a.wxid, qqid = _a.qqid;
var opt = {
url: url_1.default.post_users,
data: { stuid: stuid, password: password, name: name, email: email, utype: utype, wxid: wxid, qqid: qqid },
method: 'POST'
};
return _this.YGR.Req(opt);
};
/**
* @function 获取注册码
* */
this.getRegisterCode = function () {
var opt = {
url: url_1.default.get_reg_code,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 设置站员注册码
* */
this.setRegisterCode = function (Rcode) {
var opt = {
url: url_1.default.set_reg_code,
method: 'PUT',
data: { Rcode: Rcode }
};
return _this.YGR.Req(opt);
};
/**
* @function 通过`wxid`获取用户信息
* */
this.getUserInfoByWX = function () {
return _this.YGR.getCode().then(function (rs) {
var opt = {
url: url_1.default.get_users_by_wxid,
data: { code: rs.code },
method: 'GET'
};
return _this.YGR.Req(opt);
});
};
/**
* @function 通过`qqid`获取用户信息
* */
this.getUserInfoByQQ = function () {
return _this.YGR.getCode().then(function (rs) {
var opt = {
url: url_1.default.get_users_by_qqid,
data: { code: rs.code },
method: 'GET'
};
return _this.YGR.Req(opt);
});
};
/**
* @function 获取最新公告
* */
this.getLastNotice = function () {
var opt = {
url: url_1.default.get_last_notices,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 获取当前在站成员信息
* */
this.getCurrentOnline = function () {
var opt = {
url: url_1.default.get_current_online,
method: 'GET'
};
return _this.YGR.Req(opt);
};
/**
* @function 获取携带钥匙站员信息
* */
this.getHaskey = function () {
var opt = {
url: url_1.default.get_has_key,
method: 'GET'
};
return _this.YGR.Req(opt);
};
/**
* @function 获取本周签到记录
* */
this.getThisWeekSR = function () {
var opt = {
url: url_1.default.get_sign_record_this_week,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 获取上周签到记录
* */
this.getLastWeekSR = function () {
var opt = {
url: url_1.default.get_sign_record_last_week,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 经纬度转地址
* */
this.getLocation = function (_a) {
var latitude = _a.latitude, longitude = _a.longitude;
var opt = {
url: url_1.default.get_location + "/?latitude=" + latitude + "&longitude=" + longitude + "&wxmp=1",
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 通过学号和管理员token获取用户信息
* */
this.getUserByToken = function (stuid, token) {
var opt = {
url: url_1.default.get_user_by_stuid_and_admin_token + "/?stuid=" + stuid + "&adminToken=" + token,
method: 'GET'
};
return _this.YGR.Req(opt);
};
/**
* @function 通过管理员token获取所有管理员信息
* */
this.getAllAdminByToken = function (token) {
var opt = {
url: url_1.default.get_all_admin_by_token + "/?adminToken=" + token,
method: 'GET'
};
return _this.YGR.Req(opt);
};
/**
* @function 通过管理员token获取所有用户信息
* */
this.getAllUsersByToken = function (token) {
var opt = {
url: url_1.default.get_all_user_by_token + "/?adminToken=" + token,
method: 'GET'
};
return _this.YGR.Req(opt);
};
/**
* @function 获取允许签到的wifi信息
* */
this.getAllowWifi = function () {
var opt = {
url: url_1.default.get_allow_wifi,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 设置允许签到的wifi信息
* */
this.setAllowWifi = function (wifi) {
var opt = {
url: url_1.default.set_allow_wifi,
method: 'PUT',
data: { wifi: JSON.stringify(wifi) }
};
return _this.YGR.Req(opt);
};
/**
* @function 获取允许签到的经纬度信息
* */
this.getAllowLocation = function () {
var opt = {
url: url_1.default.get_allow_longlat,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 设置允许签到的经纬度信息
* */
this.setAlloLocation = function (latlong) {
var opt = {
url: url_1.default.set_allow_longlat,
method: 'PUT',
data: { latlong: JSON.stringify(latlong) }
};
return _this.YGR.Req(opt);
};
/**
* @function 获取某一时间的签到记录
* */
this.getSignRecordByTime = function (_a) {
var time = _a.time, page = _a.page, count = _a.count;
var opt = {
url: url_1.default.get_sign_record_by_time + "/?time=" + time + "&page=" + page + "&count=" + count,
method: 'GET'
};
return _this.YGR.Req(opt);
};
/**
* @function 签到
* */
this.signInRequest = function (stuid, reason) {
var opt = {
url: url_1.default.post_sign_in,
method: 'POST',
data: { stuid: stuid, reason: reason }
};
return _this.YGR.Req(opt);
};
/**
* @function 签退
* */
this.signOutRequest = function (stuid, ifkey) {
var opt = {
url: url_1.default.post_sign_out,
method: 'POST',
data: { stuid: stuid, ifkey: ifkey }
};
return _this.YGR.Req(opt);
};
/**
* @function 添加值班记录
* */
this.addDuty = function (stuid, dutydate) {
var opt = {
url: url_1.default.post_update_duty,
method: 'POST',
data: { stuid: stuid, dutydate: dutydate }
};
return _this.YGR.Req(opt);
};
/**
* @function 修改用户类型
* */
this.modifyUtype = function (stuid, utype) {
var opt = {
url: url_1.default.patch_user_utype,
method: 'PUT',
data: { stuid: stuid, utype: utype }
};
return _this.YGR.Req(opt);
};
/**
* @function 修改用户信息
* */
this.modifyUserInfo = function (_a) {
var _b;
var stuid = _a.stuid, info = _a.info, value = _a.value;
var opt = {
url: url_1.default.patch_user_info + "/" + info,
method: 'PUT',
data: (_b = { stuid: stuid }, _b[info] = value, _b)
};
return _this.YGR.Req(opt);
};
/**
* @function 自动查值班
* */
this.getDutyInfo = function () {
var opt = {
url: url_1.default.get_duty_info,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 获取待处理/已拒绝的申请
* */
this.getApplyByType = function (type) {
var opt = {
url: url_1.default.get_apply_by_type + "/" + type,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 获取某人申请
* */
this.getApplyByStuid = function (stuid) {
var opt = {
url: url_1.default.get_apply_by_stuid + "/?stuid=" + stuid,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 分页获取已同意的申请
* */
this.getApprovalApply = function (page) {
var opt = {
url: url_1.default.get_apply_by_type + "/approvalByPage?page=" + page,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 分页获取公告列表
* */
this.getNoticeByPage = function (page) {
var opt = {
url: url_1.default.get_notices_by_page + "/?page=" + page,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 查询某人值班情况
* */
this.getDutyByStuid = function (stuid) {
var opt = {
url: url_1.default.get_duty_info_by_stuid + "/?stuid=" + stuid,
method: 'GET'
};
return _this.YGR.ReqAnyData(opt);
};
/**
* @function 发布公告
* */
this.postNotice = function (stuid, content) {
var opt = {
url: url_1.default.post_notice,
method: 'POST',
data: { stuid: stuid, content: content }
};
return _this.YGR.Req(opt);
};
/**
* @function 处理申请
* */
this.handleApply = function (_a) {
var stuid = _a.stuid, aid = _a.aid, state = _a.state;
var opt = {
url: url_1.default.patch_handle_apply,
method: 'PUT',
data: { stuid: stuid, aid: aid, state: state }
};
return _this.YGR.Req(opt);
};
/**
* @function 发送邮件
* */
this.sendEmail = function (_a) {
var tomail = _a.tomail, type = _a.type, title = _a.title, content = _a.content;
var opt = {
url: url_1.default.post_email,
method: 'POST',
data: { tomail: tomail, type: type, title: title, content: content }
};
return _this.YGR.Req(opt);
};
/**
* @function 向当前在站正式站员发送邮件
* */
this.sendEmailToCurYoungoner = function (_a) {
var type = _a.type, title = _a.title, content = _a.content;
var opt = {
url: url_1.default.post_email + "/post/curyoungon",
method: 'POST',
data: { type: type, title: title, content: content }
};
return _this.YGR.Req(opt);
};
/**
* @function 向当管理员发送邮件
* */
this.sendEmailToAdmins = function (_a) {
var type = _a.type, title = _a.title, content = _a.content;
var opt = {
url: url_1.default.post_email + "/post/admins",
method: 'POST',
data: { type: type, title: title, content: content }
};
return _this.YGR.Req(opt);
};
/**
* @function 提出申请
* */
this.postApply = function (_a) {
var stuid = _a.stuid, reason = _a.reason, apptime = _a.apptime, appclass = _a.appclass, appfixtime = _a.appfixtime, appfixclass = _a.appfixclass;
var opt = {
url: url_1.default.post_apply,
method: 'POST',
data: { stuid: stuid, reason: reason, apptime: apptime, appclass: appclass, appfixtime: appfixtime, appfixclass: appfixclass }
};
return _this.YGR.Req(opt);
};
/**
* @function 上传图片
* */
this.uploadImage = function (type, value) {
var _a;
var opt = {
url: url_1.default.post_upload_img + "?type=" + type,
method: 'POST',
data: (_a = {}, _a[type] = value, _a)
};
return _this.YGR.Req(opt);
};
/**
* @function 修改用户证件照
* */
this.modifyUserPhoto = function (_a) {
var stuid = _a.stuid, photo = _a.photo;
var opt = {
url: url_1.default.patch_user_info + "/uploadPhoto",
method: 'PUT',
data: { stuid: stuid, photo: photo }
};
return _this.YGR.Req(opt);
};
/**
* @function 通过社团标志获取社团信息
* */
this.getOrgInfoByOrgId = function (orgId) {
var opt = {
url: url_1.default.get_org_info_by_orgid,
data: { orgId: orgId },
method: 'GET'
};
return _this.YGR.Req(opt);
};
/**
* @function 通过年级获取社团成员信息
* */
this.getGradeMembersByGrade = function (grade) {
var opt = {
url: url_1.default.get_members_by_grade,
data: { grade: grade },
method: 'GET'
};
return _this.YGR.Req(opt);
};
/**
* @function 通过部门获取社团成员信息
* */
this.getDepartmentMembersByDepartment = function (department) {
var opt = {
url: url_1.default.get_members_by_department,
data: { department: department },
method: 'GET'
};
return _this.YGR.Req(opt);
};
this.config = config;
this.YGR = req_1.default.createYGREQ(config);
}
YGAPIs.createYGAPIs = function (config) {
return new YGAPIs(config);
};
return YGAPIs;
}());
exports.default = YGAPIs;