Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

98 lignes
3.3 KiB

  1. using Learun.Application.Base.SystemModule;
  2. using Learun.Application.TwoDevelopment.EducationalAdministration;
  3. using Microsoft.Ajax.Utilities;
  4. using Nancy;
  5. using Nancy.Session;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Configuration;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace Learun.Application.WebApi.Modules.Device
  13. {
  14. public class LessonShow : BaseNoAuthentication
  15. {
  16. public LessonShow() : base("/app/lesson")
  17. {
  18. Get["/class/list"] = GetClassList;
  19. Get["/arrangelesson"] = GetLesson;
  20. Post["/class/bind"] = BindClass;
  21. Post["/checkpwd"] = CheckPwd;
  22. }
  23. private DataSourceIBLL dataSourceIBLL = new DataSourceBLL();
  24. private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
  25. private ArrangeLessonTermIBLL arrangeLessonTermIBLL = new ArrangeLessonTermBLL();
  26. /// <summary>
  27. /// 班级列表
  28. /// </summary>
  29. /// <param name="_"></param>
  30. /// <returns></returns>
  31. public Response GetClassList(dynamic _)
  32. {
  33. //var keyValue = this.GetReqData(); 1=1 AND CheckMark=1 order by classno desc
  34. var data = dataSourceIBLL.GetDataTable("bjsj", "");
  35. return Success(data);
  36. }
  37. /// <summary>
  38. /// 邦定班级
  39. /// </summary>
  40. /// <param name="_"></param>
  41. /// <returns></returns>
  42. public Response BindClass(dynamic _)
  43. {
  44. var k = this.GetReq<BindDevClass>();
  45. classInfoIBLL.BindDevice(k.ClassNo, k.DeviceNo);
  46. return Success("操作成功");
  47. }
  48. public class BindDevClass
  49. {
  50. /// <summary>
  51. /// 班级编号
  52. /// </summary>
  53. public string ClassNo { get; set; }
  54. /// <summary>
  55. /// 设备编号
  56. /// </summary>
  57. public string DeviceNo { get; set; }
  58. /// <summary>
  59. /// 设备密码
  60. /// </summary>
  61. public string DevPwd { get; set; }
  62. }
  63. /// <summary>
  64. /// 获取课程
  65. /// </summary>
  66. /// <param name="_"></param>
  67. /// <returns></returns>
  68. public Response GetLesson(dynamic _)
  69. {
  70. var bj = this.GetReq<BindDevClass>();
  71. if (bj.DeviceNo.IsNullOrWhiteSpace()) return Fail($"设备码不正确({bj.DeviceNo});");
  72. var classInfo = classInfoIBLL.GetClassNoByDevice(bj.DeviceNo);
  73. if (classInfo == null) return Success(new { Lesson = new List<TimeTable>(), ClassName="" }); //return Fail("未找到班级");
  74. var lesson = arrangeLessonTermIBLL.GetLessonDay(DateTime.Today, classInfo.ClassNo, "");
  75. return Success(new { Lesson=lesson,classInfo.ClassName});
  76. }
  77. /// <summary>
  78. /// 验证密码
  79. /// </summary>
  80. /// <param name="_"></param>
  81. /// <returns></returns>
  82. public Response CheckPwd(dynamic _)
  83. {
  84. var pwd = this.GetReq<BindDevClass>();
  85. var setp = ConfigurationManager.AppSettings["DevPwd"].ToString();
  86. if (pwd.DevPwd != setp)
  87. {
  88. return Fail("密码错误!");
  89. }
  90. return Success("验证通过");
  91. }
  92. }
  93. }