using Common.system; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using XHWK.Model; using XHWK.WKTool.Config; namespace XHWK.WKTool.DAL { public class Interface { string APIRequestAddress = FileToolsCommon.GetConfigValue("APIRequestAddress"); string FileRequestAddress = FileToolsCommon.GetConfigValue("FileRequestAddress"); string schoolfileRequestAddress = FileToolsCommon.GetConfigValue("schoolfileRequestAddress"); /// /// 登陆 /// /// /// public int Login(string loginname, string loginpwd) { string url = ZConfig.apiUrl + "/user/login";//地址 Dictionary dic = new Dictionary { { "loginname", loginname}, { "loginpwd", loginpwd} }; string body = JsonHelper.ToJson(dic); ResultVo result = HttpHelper.PostAndRespSignle>(url, postData: body); if (result != null) { APP.UserInfo = new Model_UserInfo(); APP.ServerMsg = result.msg; APP.UserInfo = result.obj; return result.code; } else { APP.ServerMsg = "网络异常!"; APP.UserInfo =new Model_UserInfo(); return 1; } } /// /// 教师教材列表 /// /// /// public int TsubjectbookList() { APP.TsubjectbookList = new List(); try { string url = ZConfig.apiUrl + "/tsubjectbook/list";//地址 Dictionary dic = new Dictionary { { "teacherid",APP.UserInfo.Userid} }; string body = JsonHelper.ToJson(dic); ResultVo> result = HttpHelper.PostAndRespSignle>>(url, postData: body); if (result != null) { APP.ServerMsg = result.msg; APP.TsubjectbookList = result.obj; return result.code; } else { APP.ServerMsg = "网络异常!"; return 1; } } catch (Exception ex) { LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex); return 1; } } /// /// 章节--列表 /// /// /// public int DirectorList(int lsbid,int directortype,int createid) { APP.DirectorList = new List(); try { string url = ZConfig.apiUrl + "/director/list";//地址 Dictionary dic = new Dictionary { { "lsbid", lsbid }, { "directortype", directortype }, { "createid", createid } }; string body = JsonHelper.ToJson(dic); ResultVo> result = HttpHelper.PostAndRespSignle>>(url, postData: body); if (result != null) { APP.ServerMsg = result.msg; APP.DirectorList = result.obj; return result.code; } else { APP.ServerMsg = "网络异常!"; return 1; } } catch (Exception ex) { LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex); return 1; } } /// /// 资源--添加 /// /// /// public int ResourceAdd(Model_ResourceAdd model) { APP.DirectorList = new List(); try { string url = ZConfig.apiUrl + "/resource/add";//地址 Dictionary dic = new Dictionary(); // converted: 0 //createid: 80 //directorid: 1009 //duration: 39 //imgUrl: "" //level: 2 //lsbid: 40 //mp4code: "h264" //resourcebelong: 3 //resourceclass: 2 //resourcecover: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.jpg" //resourcename: "weather_pic" //resourcesize: 6105268 //resourcetype: 0 //resourceurl: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.mp4" //schoolid: 12 //suffix: "mp4" //uid: 80 dic.Add("converted", model.converted); dic.Add("createid", model.createid); if(model.directorid!=999999)//章节上传可以不选 { dic.Add("directorid", model.directorid); } dic.Add("duration", model.duration); dic.Add("imgUrl", model.imgUrl); dic.Add("level", model.level); dic.Add("lsbid", model.lsbid); dic.Add("mp4code", model.mp4code); dic.Add("resourcebelong", model.resourcebelong); dic.Add("resourceclass", model.resourceclass); dic.Add("resourcecover", model.resourcecover); dic.Add("resourcename", model.resourcename); dic.Add("resourcesize", model.resourcesize); dic.Add("resourcetype", model.resourcetype); dic.Add("resourceurl", model.resourceurl); dic.Add("schoolid", model.schoolid); dic.Add("suffix", model.suffix); //dic.Add("uid", model.uid); string body = JsonHelper.ToJson(dic); string xmlDoc = HttpHelper.HttpPost(body, url); JObject obj = JObject.Parse(xmlDoc); if (obj != null) { APP.ServerMsg = obj["msg"].ToString(); return Convert.ToInt32(obj["code"].ToString()); } else { APP.ServerMsg = "网络异常!"; return 1; } } catch (Exception ex) { LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex); return 1; } } } }