@@ -15,7 +15,7 @@ V1.0 | |||||
调用方式: | 调用方式: | ||||
标准http get请求 | |||||
标准http get请求,数据接口需要在header中传参 token,否则无数据返回。 | |||||
返回数据类型: | 返回数据类型: | ||||
标准json | 标准json | ||||
返回数据结构 | 返回数据结构 | ||||
@@ -34,8 +34,24 @@ data | |||||
业务数据(object) | 业务数据(object) | ||||
业务数据 | 业务数据 | ||||
获取TOKEN | |||||
地址:http://部署地址/arrangelessonlogin/gettoken?sysid=1 sysid向管理员获取 | |||||
属性 | |||||
返回值 | |||||
备注 | |||||
code | |||||
200(int) | |||||
200成功 其余失败 | |||||
info | |||||
响应成功(string) | |||||
状态描述 | |||||
data | |||||
业务数据(object) | |||||
业务数据 | |||||
部门接口 | 部门接口 | ||||
地址:http://部署地址/arrangelesson/department | |||||
地址:http://部署地址/arrangelessonlogin/department | |||||
主要业务数据 其余字段可忽略 | 主要业务数据 其余字段可忽略 | ||||
属性 | 属性 | ||||
返回值 | 返回值 | ||||
@@ -71,7 +87,7 @@ F_OuterPhone | |||||
教师信息接口 | 教师信息接口 | ||||
地址:http://部署地址/arrangelesson/allteacher | |||||
地址:http://部署地址/arrangelessonlogin/allteacher | |||||
主要业务数据 其余字段可忽略 | 主要业务数据 其余字段可忽略 | ||||
属性 | 属性 | ||||
返回值 | 返回值 | ||||
@@ -108,7 +124,7 @@ mobile | |||||
学生信息接口 | 学生信息接口 | ||||
地址:http://部署地址/arrangelesson/allstudent | |||||
地址:http://部署地址/arrangelessonlogin/allstudent | |||||
主要业务数据 其余字段可忽略 | 主要业务数据 其余字段可忽略 | ||||
属性 | 属性 | ||||
返回值 | 返回值 | ||||
@@ -164,7 +180,7 @@ ClassNo | |||||
系部接口 | 系部接口 | ||||
地址:http://部署地址/arrangelesson/alldept | |||||
地址:http://部署地址/arrangelessonlogin/alldept | |||||
主要业务数据 其余字段可忽略 | 主要业务数据 其余字段可忽略 | ||||
属性 | 属性 | ||||
返回值 | 返回值 | ||||
@@ -184,7 +200,7 @@ DeptName | |||||
否 | 否 | ||||
专业接口 | 专业接口 | ||||
地址:http://部署地址/arrangelesson/allmajor | |||||
地址:http://部署地址/arrangelessonlogin/allmajor | |||||
主要业务数据 其余字段可忽略 | 主要业务数据 其余字段可忽略 | ||||
属性 | 属性 | ||||
返回值 | 返回值 | ||||
@@ -207,7 +223,7 @@ DeptNo | |||||
校区接口 | 校区接口 | ||||
地址:http://部署地址/arrangelesson/allschool | |||||
地址:http://部署地址/arrangelessonlogin/allschool | |||||
主要业务数据 其余字段可忽略 | 主要业务数据 其余字段可忽略 | ||||
属性 | 属性 | ||||
返回值 | 返回值 | ||||
@@ -223,7 +239,7 @@ F_FullName | |||||
否 | 否 | ||||
班级接口 | 班级接口 | ||||
地址:http://部署地址/arrangelesson/allclass | |||||
地址:http://部署地址/arrangelessonlogin/allclass | |||||
主要业务数据 其余字段可忽略 | 主要业务数据 其余字段可忽略 | ||||
属性 | 属性 | ||||
返回值 | 返回值 | ||||
@@ -255,7 +271,7 @@ Grade | |||||
用户接口 | 用户接口 | ||||
地址:http://部署地址/arrangelesson/alluser | |||||
地址:http://部署地址/arrangelessonlogin/alluser | |||||
主要业务数据 其余字段可忽略 | 主要业务数据 其余字段可忽略 | ||||
属性 | 属性 | ||||
返回值 | 返回值 | ||||
@@ -292,7 +308,7 @@ Year | |||||
课程接口 | 课程接口 | ||||
地址:http://部署地址/arrangelesson/alllesson | |||||
地址:http://部署地址/arrangelessonlogin/alllesson | |||||
主要业务数据 其余字段可忽略 | 主要业务数据 其余字段可忽略 | ||||
属性 | 属性 | ||||
返回值 | 返回值 | ||||
@@ -323,7 +339,7 @@ F_SchoolId | |||||
必修开课计划接口 | 必修开课计划接口 | ||||
地址:http://部署地址/arrangelesson/allclasslesson | |||||
地址:http://部署地址/arrangelessonlogin/allclasslesson | |||||
所需参数:AcademicYearNo=19-20&Semester=1 | 所需参数:AcademicYearNo=19-20&Semester=1 | ||||
参数名称 | 参数名称 | ||||
值 | 值 | ||||
@@ -381,7 +397,7 @@ LessonTime | |||||
学生选修选课接口 | 学生选修选课接口 | ||||
地址:http://部署地址/arrangelesson/allelelectivelesson | |||||
地址:http://部署地址/arrangelessonlogin/allelelectivelesson | |||||
所需参数:AcademicYearNo=19-20&Semester=1 | 所需参数:AcademicYearNo=19-20&Semester=1 | ||||
参数名称 | 参数名称 | ||||
值 | 值 |
@@ -311,6 +311,7 @@ | |||||
<Compile Include="Program.cs" /> | <Compile Include="Program.cs" /> | ||||
<Compile Include="Properties\AssemblyInfo.cs" /> | <Compile Include="Properties\AssemblyInfo.cs" /> | ||||
<Compile Include="Modules\UserApi.cs" /> | <Compile Include="Modules\UserApi.cs" /> | ||||
<Compile Include="Until\MyEnum.cs" /> | |||||
<Compile Include="Until\ReqEntity.cs" /> | <Compile Include="Until\ReqEntity.cs" /> | ||||
<Compile Include="Until\ReqPageParam.cs" /> | <Compile Include="Until\ReqPageParam.cs" /> | ||||
<Compile Include="Modules\PersonnelManagement\ActivityScheduleApi.cs" /> | <Compile Include="Modules\PersonnelManagement\ActivityScheduleApi.cs" /> | ||||
@@ -8,7 +8,7 @@ using Nancy; | |||||
namespace Learun.Application.WebApi.Modules | namespace Learun.Application.WebApi.Modules | ||||
{ | { | ||||
public class Arrangelesson : BaseNoAuthentication | |||||
public class Arrangelesson : BaseApi | |||||
{ | { | ||||
public Arrangelesson() | public Arrangelesson() | ||||
: base("/arrangelesson/") | : base("/arrangelesson/") | ||||
@@ -4,7 +4,9 @@ using System.Linq; | |||||
using System.Web; | using System.Web; | ||||
using Learun.Application.Organization; | using Learun.Application.Organization; | ||||
using Learun.Application.TwoDevelopment.EducationalAdministration; | using Learun.Application.TwoDevelopment.EducationalAdministration; | ||||
using Learun.Util; | |||||
using Nancy; | using Nancy; | ||||
using static Learun.Application.WebApi.Until.MyEnum; | |||||
namespace Learun.Application.WebApi.Modules | namespace Learun.Application.WebApi.Modules | ||||
{ | { | ||||
@@ -13,6 +15,7 @@ namespace Learun.Application.WebApi.Modules | |||||
public ArrangelessonLogin() | public ArrangelessonLogin() | ||||
: base("/arrangelessonlogin/") | : base("/arrangelessonlogin/") | ||||
{ | { | ||||
Get["/gettoken"] = GetToken; | |||||
Get["/lessontype"] = GetLessonTypes; | Get["/lessontype"] = GetLessonTypes; | ||||
Get["/classtype"] = GetClassType; | Get["/classtype"] = GetClassType; | ||||
Get["/student"] = GetStudents; | Get["/student"] = GetStudents; | ||||
@@ -71,6 +74,14 @@ namespace Learun.Application.WebApi.Modules | |||||
private StuSelectLessonListOfElectiveIBLL stuSelectLessonListOfElectiveIbll = | private StuSelectLessonListOfElectiveIBLL stuSelectLessonListOfElectiveIbll = | ||||
new StuSelectLessonListOfElectiveBLL(); | new StuSelectLessonListOfElectiveBLL(); | ||||
private Response GetToken(dynamic _) | |||||
{ | |||||
string sid = Request.Query["sysid"]; | |||||
var sys = EnumAttribute.GetVal(typeof(ThrSys), sid.ToInt()); | |||||
if (sys.IsEmpty()) return Fail("参数错误!"); | |||||
var token=DESEncrypt.Encrypt(sys); | |||||
return Success(token); | |||||
} | |||||
private Response TranTest(dynamic _) | private Response TranTest(dynamic _) | ||||
{ | { | ||||
return Success("ok"); | return Success("ok"); | ||||
@@ -5,7 +5,8 @@ using Learun.Util.Operat; | |||||
using Nancy; | using Nancy; | ||||
using Nancy.ModelBinding; | using Nancy.ModelBinding; | ||||
using System;//D:\Item\repos\DigitalScholl\Learun.Framework.Ultimate V7\Learun.Application.WebApi\Modules\TransferApi.cs | using System;//D:\Item\repos\DigitalScholl\Learun.Framework.Ultimate V7\Learun.Application.WebApi\Modules\TransferApi.cs | ||||
using static Learun.Application.WebApi.TransferApi; | |||||
using System.Linq; | |||||
using static Learun.Application.WebApi.Until.MyEnum; | |||||
namespace Learun.Application.WebApi | namespace Learun.Application.WebApi | ||||
{ | { | ||||
@@ -96,7 +97,7 @@ namespace Learun.Application.WebApi | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public Response Success(string info) | public Response Success(string info) | ||||
{ | { | ||||
ResParameter res = new ResParameter { code = ResponseCode.success, info = info, data = new object { } }; | |||||
ResParameter res = new ResParameter { code = ResponseCode.success, info = "响应成功", data = info }; | |||||
return Response.AsText(res.ToJson()).WithContentType("application/json"); | return Response.AsText(res.ToJson()).WithContentType("application/json"); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -226,10 +227,6 @@ namespace Learun.Application.WebApi | |||||
#endregion | #endregion | ||||
#region 权限验证 | #region 权限验证 | ||||
public UserInfo userInfo; | |||||
public string loginMark; | |||||
public string token; | |||||
/// <summary> | /// <summary> | ||||
/// 前置拦截器 | /// 前置拦截器 | ||||
@@ -238,50 +235,20 @@ namespace Learun.Application.WebApi | |||||
/// <returns></returns> | /// <returns></returns> | ||||
private Response BeforeRequest(NancyContext ctx) | private Response BeforeRequest(NancyContext ctx) | ||||
{ | { | ||||
//var Requesttoken = DESEncrypt.Decrypt(Request.Headers["token"].ToString()); | |||||
var Requesttoken = DESEncrypt.Decrypt(Request.Query["token"].ToString()); | |||||
var a = EnumAttribute.GetVsS(typeof(loginins)); | |||||
//if (Requesttoken == loginins.school) | |||||
//{ | |||||
//} | |||||
ctx.Request.Url.Query = Learun.Util.WebHelper.Formatstr(ctx.Request.Url.Query); | |||||
foreach (var p in ctx.Parameters) | |||||
{ | |||||
if (p.ParameterType == typeof(string)) | |||||
{ | |||||
if (ctx.Parameters[p.ParameterName] != null) | |||||
{ | |||||
ctx.Parameters[p.ParameterName] = Learun.Util.WebHelper.Formatstr(ctx.Parameters[p.ParameterName].ToString()); | |||||
} | |||||
} | |||||
} | |||||
string path = ctx.ResolvedRoute.Description.Path; | string path = ctx.ResolvedRoute.Description.Path; | ||||
//验证登录状态 | |||||
ReqParameter req = this.Bind<ReqParameter>(); | |||||
loginMark = req.loginMark; | |||||
token = req.token; | |||||
if (path == "/learun/adms/user/login" || path == "/learun/adms/user/loginbyIdCard" || path == "/" || path == "/bgimg" || path == "/learun/adms/user/img" || path == "/learun/adms/desktop/img" || path == "/learun/adms/user/imgfordc" || path == "/learun/adms/timetable/timeTableData" || path == "/quanjiang/sso/authorize" || path == "/learun/nologin/adms/annexes/upload" || path == "/learun/adms/annexes/wxlist" || path == "/learun/visitmanage/save" || path == "/learun/visitmanage/getweixinaccess_token") | |||||
{// 登录接口,默认页面接口不做权限验证处理 | |||||
if (path == "/arrangelessonlogin/gettoken") | |||||
{// token接口,默认页面接口不做权限验证处理 | |||||
return null; | return null; | ||||
} | } | ||||
var rToken = ctx.Request.Headers["token"].FirstOrDefault(); | |||||
if(rToken.IsEmpty()) return this.FailNoLogin("权限校验失败!"); | |||||
OperatorResult res = OperatorHelper.Instance.IsOnLine(req.token, req.loginMark); | |||||
if (res.stateCode == -1) | |||||
{ | |||||
return this.FailNoLogin("未找到登录信息"); | |||||
} | |||||
if (res.stateCode == 0) | |||||
{ | |||||
return this.FailNoLogin("登录信息已过期"); | |||||
} | |||||
else | |||||
{ | |||||
// 获取登录者信息 | |||||
userInfo = res.userInfo; | |||||
} | |||||
var tss = EnumAttribute.GetVsS(typeof(ThrSys)); | |||||
var Requesttoken = DESEncrypt.Decrypt(rToken); | |||||
if(!tss.Contains(Requesttoken)) return this.FailNoLogin("权限校验失败!!"); | |||||
return null; | return null; | ||||
} | } | ||||
#endregion | #endregion | ||||
@@ -462,11 +462,7 @@ namespace Learun.Application.WebApi | |||||
public string PersonPicturePath { get; set; } | public string PersonPicturePath { get; set; } | ||||
} | } | ||||
public enum loginins | |||||
{ | |||||
school, | |||||
CODE, | |||||
} | |||||
#endregion | #endregion | ||||
} | } |
@@ -0,0 +1,21 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.ComponentModel; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Learun.Application.WebApi.Until | |||||
{ | |||||
public class MyEnum | |||||
{ | |||||
public enum ThrSys | |||||
{ | |||||
[Description("超星")] | |||||
ChaoXin=31233 | |||||
} | |||||
} | |||||
} |
@@ -42,6 +42,19 @@ namespace Learun.Util | |||||
return null; | return null; | ||||
} | } | ||||
public static string GetVal(Type enumType,int value) | |||||
{ | |||||
try | |||||
{ | |||||
var name = enumType.GetEnumName(value); | |||||
return name; | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
return ""; | |||||
} | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 返回枚举项的描述信息。 | /// 返回枚举项的描述信息。 | ||||
/// </summary> | /// </summary> | ||||