星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. using Common.system;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using XHWK.Model;
  9. using XHWK.WKTool.Config;
  10. namespace XHWK.WKTool.DAL
  11. {
  12. public class Interface
  13. {
  14. string APIRequestAddress = FileToolsCommon.GetConfigValue("APIRequestAddress");
  15. string FileRequestAddress = FileToolsCommon.GetConfigValue("FileRequestAddress");
  16. string schoolfileRequestAddress = FileToolsCommon.GetConfigValue("schoolfileRequestAddress");
  17. /// <summary>
  18. /// 登陆
  19. /// </summary>
  20. /// <param name="request"></param>
  21. /// <returns></returns>
  22. public int Login(string loginname, string loginpwd)
  23. {
  24. string url = ZConfig.apiUrl + "/user/login";//地址
  25. Dictionary<string, object> dic = new Dictionary<string, object>
  26. {
  27. { "loginname", loginname},
  28. { "loginpwd", loginpwd}
  29. };
  30. string body = JsonHelper.ToJson(dic);
  31. ResultVo<Model_UserInfo> result = HttpHelper.PostAndRespSignle<ResultVo<Model_UserInfo>>(url, postData: body);
  32. if (result != null)
  33. {
  34. APP.UserInfo = new Model_UserInfo();
  35. APP.ServerMsg = result.msg;
  36. APP.UserInfo = result.obj;
  37. return result.code;
  38. }
  39. else
  40. {
  41. APP.ServerMsg = "网络异常!";
  42. APP.UserInfo =new Model_UserInfo();
  43. return 1;
  44. }
  45. }
  46. /// <summary>
  47. /// 教师教材列表
  48. /// </summary>
  49. /// <param name="request"></param>
  50. /// <returns></returns>
  51. public int TsubjectbookList()
  52. {
  53. APP.TsubjectbookList = new List<Model_TsubjectbookList>();
  54. try
  55. {
  56. string url = ZConfig.apiUrl + "/tsubjectbook/list";//地址
  57. Dictionary<string, int> dic = new Dictionary<string, int>
  58. {
  59. { "teacherid",APP.UserInfo.Userid}
  60. };
  61. string body = JsonHelper.ToJson(dic);
  62. ResultVo<List<Model_TsubjectbookList>> result = HttpHelper.PostAndRespSignle<ResultVo<List<Model_TsubjectbookList>>>(url, postData: body);
  63. if (result != null)
  64. {
  65. APP.ServerMsg = result.msg;
  66. APP.TsubjectbookList = result.obj;
  67. return result.code;
  68. }
  69. else
  70. {
  71. APP.ServerMsg = "网络异常!";
  72. return 1;
  73. }
  74. }
  75. catch (Exception ex)
  76. {
  77. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  78. return 1;
  79. }
  80. }
  81. /// <summary>
  82. /// 章节--列表
  83. /// </summary>
  84. /// <param name="request"></param>
  85. /// <returns></returns>
  86. public int DirectorList(int lsbid,int directortype,int createid)
  87. {
  88. APP.DirectorList = new List<Model_DirectorList>();
  89. try
  90. {
  91. string url = ZConfig.apiUrl + "/director/list";//地址
  92. Dictionary<string, int> dic = new Dictionary<string, int>
  93. {
  94. { "lsbid", lsbid },
  95. { "directortype", directortype },
  96. { "createid", createid }
  97. };
  98. string body = JsonHelper.ToJson(dic);
  99. ResultVo<List<Model_DirectorList>> result = HttpHelper.PostAndRespSignle<ResultVo<List<Model_DirectorList>>>(url, postData: body);
  100. if (result != null)
  101. {
  102. APP.ServerMsg = result.msg;
  103. APP.DirectorList = result.obj;
  104. return result.code;
  105. }
  106. else
  107. {
  108. APP.ServerMsg = "网络异常!";
  109. return 1;
  110. }
  111. }
  112. catch (Exception ex)
  113. {
  114. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  115. return 1;
  116. }
  117. }
  118. /// <summary>
  119. /// 资源--添加
  120. /// </summary>
  121. /// <param name="request"></param>
  122. /// <returns></returns>
  123. public int ResourceAdd(Model_ResourceAdd model)
  124. {
  125. APP.DirectorList = new List<Model_DirectorList>();
  126. try
  127. {
  128. string url = ZConfig.apiUrl + "/resource/add";//地址
  129. Dictionary<string, object> dic = new Dictionary<string, object>();
  130. // converted: 0
  131. //createid: 80
  132. //directorid: 1009
  133. //duration: 39
  134. //imgUrl: ""
  135. //level: 2
  136. //lsbid: 40
  137. //mp4code: "h264"
  138. //resourcebelong: 3
  139. //resourceclass: 2
  140. //resourcecover: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.jpg"
  141. //resourcename: "weather_pic"
  142. //resourcesize: 6105268
  143. //resourcetype: 0
  144. //resourceurl: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.mp4"
  145. //schoolid: 12
  146. //suffix: "mp4"
  147. //uid: 80
  148. dic.Add("converted", model.converted);
  149. dic.Add("createid", model.createid);
  150. if(model.directorid!=999999)//章节上传可以不选
  151. {
  152. dic.Add("directorid", model.directorid);
  153. }
  154. dic.Add("duration", model.duration);
  155. dic.Add("imgUrl", model.imgUrl);
  156. dic.Add("level", model.level);
  157. dic.Add("lsbid", model.lsbid);
  158. dic.Add("mp4code", model.mp4code);
  159. dic.Add("resourcebelong", model.resourcebelong);
  160. dic.Add("resourceclass", model.resourceclass);
  161. dic.Add("resourcecover", model.resourcecover);
  162. dic.Add("resourcename", model.resourcename);
  163. dic.Add("resourcesize", model.resourcesize);
  164. dic.Add("resourcetype", model.resourcetype);
  165. dic.Add("resourceurl", model.resourceurl);
  166. dic.Add("schoolid", model.schoolid);
  167. dic.Add("suffix", model.suffix);
  168. //dic.Add("uid", model.uid);
  169. string body = JsonHelper.ToJson(dic);
  170. string xmlDoc = HttpHelper.HttpPost(body, url);
  171. JObject obj = JObject.Parse(xmlDoc);
  172. if (obj != null)
  173. {
  174. APP.ServerMsg = obj["msg"].ToString();
  175. return Convert.ToInt32(obj["code"].ToString());
  176. }
  177. else
  178. {
  179. APP.ServerMsg = "网络异常!";
  180. return 1;
  181. }
  182. }
  183. catch (Exception ex)
  184. {
  185. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  186. return 1;
  187. }
  188. }
  189. }
  190. }