|
- using System;
- using Learun.Application.Base.SystemModule;
- using Learun.Application.Organization;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using Learun.Util;
- using Learun.Util.Operat;
- using Nancy;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Web;
- using Learun.Application.Mapping;
- using Learun.Application.OA;
- using Learun.Application.TwoDevelopment.AdmissionsPlatform;
- using Learun.Application.TwoDevelopment.LogisticsManagement;
- using Newtonsoft.Json;
-
- namespace Learun.Application.WebApi
- {
- /// <summary>
- /// 版 本 Learun-ADMS V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创建人:数字化智慧校园-框架开发组
- /// 日 期:2017.05.12
- /// 描 述:用户信息
- /// </summary>
- public class TUserApi : BaseNoLoginApi
- {
- /// <summary>
- /// 注册接口
- /// </summary>
- public TUserApi()
- : base("/user")
- {
- Post["/login"] = Login;//登录
- Post["/studentLogin"] = StudentLogin;//学生登录
- Post["/studentRegister"] = StudentRegister;//学生注册
- Post["/getstunum"] = GetStuNum;//获得各种状态的学生数量
- Post["/getdataitem"] = GetDataItem;//根据code获取字典值
- Get["/getcompany"] = GetCompany;//获取校区
- Post["/getmajor"] = GetMajorByCompany;//根据校区获取专业
- Post["/majorDetail"] = GetMajorDetail;//专业详细
- Post["/register"] = StuRegister;//学生注册
- Post["/getCultureInfo"] = GetCultureInfo;//获取学生文化程度列表
- Post["/delstu"] = DelStu;//删除学生信息
- Post["/updatestu"] = UpdateStuInfoById;//修改学生信息
- Post["/updateStuByStuTerminal"] = UpdateStuByStuTerminal;//学生端修改个人信息
- Post["/getstuinfo"] = GetStuInfo;//获取学生列表
- Post["/getstubyid"] = GetStuById;//根据id获取学生信息
- Post["/getStuByUserId"] = GetStuInfoByUserId;//根据id获取学生信息
- Post["/upload"] = Upload;//修改头像
- Post["/uploadStudent"] = UploadStudent;//修改头像
- Post["/updatetea"] = UpdataTeacherInfo;
- Post["/updatepwd"] = UpdatePassword;//教师修改密码
- Post["/updatePwdStu"] = UpdatePasswordStu;//学生修改密码
- Post["/bankinfo"] = BankInfo;
- Post["/integradetail"] = IntegralDetails;
- Post["/detailInfo"] = DetailInfo;
- Post["/aboutSchool"] = AboutSchool;
- Post["/getnews"] = GetNews;
- Post["/getnewsdetail"] = GetNewsDetail;
- Post["/getCompanyNews"] = GetCompanyNews;//获取校区新闻和招生信息
- Post["/getCompanyNewsDetail"] = GetCompanyNewsDetail;//获取校区新闻
- Post["/getCompanyInfo"] = GetCompanyInfo;//获取校区信息
- Post["/forgetPwd"] = ForgetPwd; //忘记密码
- Post["/getEditionInfo"] = GetEditonInfo;//获取版本信息
-
-
-
-
-
- }
- private UserIBLL userIBLL = new UserBLL();
- private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
- private PostIBLL postIBLL = new PostBLL();
- private RoleIBLL roleIBLL = new RoleBLL();
- private DataItemIBLL dataItemIBLL = new DataItemBLL();
- private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
- private DepartmentIBLL departmentIBLL = new DepartmentBLL();
- private AP_OnlineStudentInfoIBLL aP_OnlineStudentInfoIBLL = new AP_OnlineStudentInfoBLL();
- private AP_OnlineUserInfoIBLL aP_OnlineUserInfoIBLL = new AP_OnlineUserInfoBLL();
- private CompanyIBLL companyIBLL = new CompanyBLL();
- private AP_TeacherBankCardIBLL aP_TeacherBankCardIBLL = new AP_TeacherBankCardBLL();
- private AP_IntegralDetailsIBLL aP_IntegralDetailsIBLL = new AP_IntegralDetailsBLL();
- private CdMajorIBLL majorIbll = new CdMajorBLL();
- private NewsIBLL newsIBLL = new NewsBLL();
- private BCdCultureDegreeIBLL bCdCultureDegreeIBLL = new BCdCultureDegreeBLL();
- private CompanyNewsIBLL companyNewsIBLL = new CompanyNewsBLL();
- private EditonManagementIBLL editonManagementIbll = new EditonManagementBLL();
-
-
-
- /// <summary>
- /// 登录接口
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response Login(dynamic _)
- {
- var loginModel = this.GetReqData<TLoginModel>();
-
- #region 内部账户验证
- UserEntity userEntity = userIBLL.CheckLogin(loginModel.username, Md5Helper.Encrypt(loginModel.password, 32));
-
- if (!userEntity.LoginOk)//登录失败
- {
- return Fail(userEntity.LoginMsg);
- }
- else
- {
- var userInfo = userIBLL.GetEntityByUserId(userEntity.F_UserId);
- var companyEntity = companyIBLL.GetEntity(userInfo?.F_CompanyId);
-
- var departmentEntity = departmentIBLL.GetEntity(userInfo?.F_CompanyId, userInfo?.F_DepartmentId);
- var result = new
- {
- ID = userInfo?.F_UserId,
- username = userInfo?.F_RealName,
- sex = userInfo?.F_Gender,
- sexname = userInfo?.F_Gender == 1 ? "男" : "女",
- photo = userInfo?.F_HeadIcon,
- phone = userInfo?.F_Mobile,
- status = 1,
- birth = userInfo?.F_Birthday,
- depart = "",
- departname = "",
- school = userInfo?.F_CompanyId,
- schoolname = companyEntity?.F_FullName,
- culture = "",
- culturename = "",
- pTotalMoney = "",
- teaID = "",
- teaName = "",
- teaPhone = "",
- ids = userInfo?.F_IdentityCardNo,
- gexin = userInfo?.PerSignature
- };
-
-
- return Success(result);
- }
- #endregion
- }
- private Response StudentLogin(dynamic _)
- {
- var loginModel = this.GetReqData<TLoginModel>();
- #region 内部账户验证
-
- var stuEntity = aP_OnlineUserInfoIBLL.GetEntityByPhone(loginModel.username);
- var stuInfoEntity = aP_OnlineStudentInfoIBLL.GetEntityByUserId(stuEntity.Id);
- var company = companyIBLL.GetEntity(stuInfoEntity.SchoolId);
- var major = majorIbll.GetCdMajorEntityByMajorNo(stuInfoEntity.MajorId);
- var teacher = userIBLL.GetEntityByUserId(stuInfoEntity.UserTeacherId);
- var cultrue = bCdCultureDegreeIBLL.GetEntity(stuInfoEntity.CultureId);
- if (stuEntity != null)
- {
- if (stuEntity.Password.Trim() == loginModel.password.Trim())
- {
- var photourl = annexesFileIBLL.GetEntityByFolderId(stuEntity.PhotoUrl)?.F_FilePath;
- if (photourl != null && photourl.IndexOf("Resource") > 0)
- {
- photourl = "/" + photourl.Substring(photourl.IndexOf("Resource"));
- }
- var entity = new
- {
- ID = stuEntity.Id,
- username = stuEntity.RealName,
- sex = stuEntity.SexId,
- sexname = stuEntity.SexId == "1" ? "男" : "女",
- photo = photourl,
- phone = stuEntity.Mobile,
- status = 1,
- birth = stuEntity.BirthDate,
- depart = stuInfoEntity.MajorId,
- departname = major?.MajorName,
- school = stuInfoEntity.SchoolId,
- schoolname = company?.F_FullName,
- culture = stuInfoEntity.CultureId,
- culturename = cultrue?.CultureDegree,
- pTotalMoney = "",
- teaID = stuInfoEntity.UserTeacherId,
- teaName = teacher?.F_RealName,
- teaPhone = teacher?.F_Mobile,
- ids = stuEntity.CertNum,
- gexin = ""
-
- };
- return Success(entity);
- }
- else
- {
- return Fail("账号密码不正确");
- }
- }
- else
- {
- return Fail("账号密码不正确");
- }
-
-
- #endregion
- }
-
- private Response StudentRegister(dynamic _)
- {
- var regModel = this.GetReqData<RegisterModel>();
- var entity = aP_OnlineUserInfoIBLL.GetEntityByMobile(regModel.mobile);
- if (entity != null)
- {
- return Fail("此手机号已经被注册");
- }
- else
- {
- var newEntity = new AP_OnlineUserInfoEntity();
- var newStuEntity = new AP_OnlineStudentInfoEntity();
- newEntity.RealName = regModel.name;
- newEntity.Mobile = regModel.mobile;
- newEntity.CertNum = regModel.ids;
- newEntity.Password = regModel.logpwd;
- aP_OnlineUserInfoIBLL.SaveEntity("", newEntity);
- newStuEntity.UserId = newEntity.Id;
- aP_OnlineStudentInfoIBLL.SaveEntity("", newStuEntity);
- return Success("注册成功");
- }
- }
-
- /// <summary>
- /// 获取用户信息
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response GetStuNum(dynamic _)
- {
- var teacherId = this.GetReqData();
- var users = aP_OnlineStudentInfoIBLL.GetAllList().Where(a => a.UserTeacherId == teacherId).ToList();
- var count = users.Count();
- var isPayNum = users.Count(a => a.IsPaymentId == "1");
- var isDropoutNum = users.Count(a => a.IsDropOut == "1");
- var result = new
- {
- count,
- isPayNum,
- isDropoutNum
- };
- return Success(result);
- }
-
- /// <summary>
- /// 获取字典
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response GetDataItem(dynamic _)
- {
- var code = this.GetReqData();
- var itemList = dataItemIBLL.GetDetailList(code);
- var result = new List<object>();
- foreach (var item in itemList)
- {
- result.Add(new
- {
- dicentryid = item.F_ItemValue,
- name = item.F_ItemName
- });
-
- }
-
- return Success(result);
- }
-
-
- /// <summary>
- /// 获取校区
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response GetCompany(dynamic _)
- {
- var compList = companyIBLL.GetList().ToList();
- var result = new List<object>();
- foreach (var company in compList)
- {
- var photo = "";
- if (company.F_Photo != null)
- {
- photo = annexesFileIBLL.GetEntityByFolderId(company.F_Photo)?.F_FilePath;
- if (!string.IsNullOrEmpty(photo))
- {
- photo = "/" + photo.Substring(photo.IndexOf("Resource"));
- }
- }
- result.Add(new
- {
- schoolID = company.F_CompanyId,
- school = company.F_FullName,
- address = company.F_Address,
- schoolPic = photo
-
-
- });
- }
- return Success(result);
- }
-
- private Response GetMajorByCompany(dynamic _)
- {
- var companyId = this.GetReqData();
- var result = new List<object>();
- if (!string.IsNullOrEmpty(companyId))
- {
- var majorList = majorIbll.GetAllList().Where(a => a.F_SchoolId == companyId);
-
- if (majorList.Count() > 0)
- {
-
- foreach (var major in majorList)
- {
- result.Add(new
- {
- departID = major.MajorNo,
- depart = major.MajorName,
- type = major.RecruitObject
-
- });
- }
- return Success(result);
- }
- else
- {
- return Fail("无专业");
- }
-
-
- }
- else
- {
- return Fail("未知错误");
- }
-
- }
-
- private Response GetMajorDetail(dynamic _)
- {
- var majorNo = this.GetReqData();
- var entity = majorIbll.GetCdMajorEntityByMajorNo(majorNo);
- var itemList = dataItemIBLL.GetDetailList("RecruitObject").ToList();
- var school = companyIBLL.GetEntity(entity.F_SchoolId);
- var photo = "";
- if (!string.IsNullOrEmpty(entity.Photo))
- {
- photo = annexesFileIBLL.GetEntityByFolderId(entity.Photo)?.F_FilePath;
- if (!string.IsNullOrEmpty(photo))
- {
- photo = "/" + photo.Substring(photo.IndexOf("Resource"));
- }
- }
- var result = new
- {
- pimage = photo,
- name = entity.MajorName,
- schoolName = school?.F_FullName,
- pObjectName = itemList.FirstOrDefault(a => a.F_ItemValue == entity.RecruitObject)?.F_ItemName, //招生对象
- developLevel = entity.DevelopLevel, //培养对象
- pCertificate = entity.Certificate,
- developTarget = entity.DevelopTarget,
- introduce = entity.Introduce,
-
- };
- return Success(result);
- }
-
- private Response StuRegister(dynamic _)
- {
- var stuModel = this.GetReqData<StuModel>();
- AP_OnlineStudentInfoEntity infoEntity = new AP_OnlineStudentInfoEntity();
- AP_OnlineUserInfoEntity userEntity = new AP_OnlineUserInfoEntity();
-
- userEntity.RealName = stuModel.username;
- userEntity.SexId = stuModel.sex;
- userEntity.Mobile = stuModel.phone;
- userEntity.Password = "123456";
- userEntity.DetailedAddress = stuModel.address;
- userEntity.CertNum = stuModel.ids;
- userEntity.Province = stuModel.province;
- userEntity.City = stuModel.city;
- userEntity.Country = stuModel.county;
-
- aP_OnlineUserInfoIBLL.SaveEntity("", userEntity);
-
-
-
- infoEntity.UserId = userEntity.Id;
- infoEntity.CultureId = stuModel.culture;
- infoEntity.SchoolId = stuModel.school;
- infoEntity.MajorId = stuModel.depart;
- infoEntity.PaymentQuota = Convert.ToDecimal(stuModel.paymentQuota);
- infoEntity.UserTeacherId = stuModel.rTeacher;
- infoEntity.Remarks = stuModel.renarks;
-
- aP_OnlineStudentInfoIBLL.SaveEntity("", infoEntity);
-
- return Success("修改成功");
-
-
- }
-
- private Response GetCultureInfo(dynamic _)
- {
- var list = bCdCultureDegreeIBLL.GetAllList().ToList();
-
- List<object> result = new List<object>();
- foreach (var item in list)
- {
- result.Add(new
- {
- dicentryid = item.CultureDegreeNo,
- name = item.CultureDegree
- });
- }
-
- return Success(result);
-
- }
- private Response DelStu(dynamic _)
- {
- var id = this.GetReqData();
- var stuEntity = aP_OnlineStudentInfoIBLL.GetEntity(id);
- if (stuEntity != null)
- {
- aP_OnlineStudentInfoIBLL.DeleteEntity(id);
- aP_OnlineUserInfoIBLL.DeleteEntity(stuEntity.UserId);
-
- return Success("删除成功");
- }
- else
- {
- return Fail("删除失败");
- }
-
-
-
- }
- private Response UpdateStuByStuTerminal(dynamic _)
- {
- var stuModel = this.GetReqData<StuModel>();
-
-
-
- AP_OnlineUserInfoEntity userEntity = aP_OnlineUserInfoIBLL.GetEntity(stuModel.id);
- if (userEntity == null)
- {
- return Fail("未找到学生信息");
- }
-
- if (!string.IsNullOrEmpty(stuModel.username))
- {
- userEntity.RealName = stuModel.username;
- }
- if (!string.IsNullOrEmpty(stuModel.birthday))
- {
- userEntity.BirthDate = Convert.ToDateTime(stuModel.birthday);
- }
- if (!string.IsNullOrEmpty(stuModel.sex))
- {
- userEntity.SexId = stuModel.sex;
- }
- if (!string.IsNullOrEmpty(stuModel.phone))
- {
- userEntity.Mobile = stuModel.phone;
- }
- if (!string.IsNullOrEmpty(stuModel.address))
- {
- userEntity.DetailedAddress = stuModel.address;
- }
- if (!string.IsNullOrEmpty(stuModel.ids))
- {
- userEntity.CertNum = stuModel.ids;
- }
- if (!string.IsNullOrEmpty(stuModel.province))
- {
- userEntity.Province = stuModel.province;
- }
- if (!string.IsNullOrEmpty(stuModel.city))
- {
- userEntity.City = stuModel.city;
- }
- if (!string.IsNullOrEmpty(stuModel.county))
- {
- userEntity.Country = stuModel.county;
- }
-
- aP_OnlineUserInfoIBLL.SaveEntity(stuModel.id, userEntity);
-
-
-
- AP_OnlineStudentInfoEntity infoEntity = aP_OnlineStudentInfoIBLL.GetEntityByUserId(userEntity.Id);
- if (infoEntity == null)
- {
- return Fail("找不到用户数据");
- }
-
- if (!string.IsNullOrEmpty(stuModel.culture))
- {
- infoEntity.CultureId = stuModel.culture;
- }
-
- if (!string.IsNullOrEmpty(stuModel.school))
- {
- infoEntity.SchoolId = stuModel.school;
- }
- if (!string.IsNullOrEmpty(stuModel.depart))
- {
- infoEntity.MajorId = stuModel.depart;
- }
-
- if (!string.IsNullOrEmpty(stuModel.paymentQuota))
- {
- infoEntity.PaymentQuota = Convert.ToDecimal(stuModel.paymentQuota);
- }
- if (!string.IsNullOrEmpty(stuModel.rTeacher))
- {
- infoEntity.UserTeacherId = stuModel.rTeacher;
- }
- if (!string.IsNullOrEmpty(stuModel.renarks))
- {
- infoEntity.Remarks = stuModel.renarks;
- }
-
- aP_OnlineStudentInfoIBLL.SaveEntity(infoEntity.Id, infoEntity);
-
-
-
- return Success("修改成功");
- }
- private Response UpdateStuInfoById(dynamic _)
- {
- var stuModel = this.GetReqData<StuModel>();
- AP_OnlineStudentInfoEntity infoEntity = aP_OnlineStudentInfoIBLL.GetEntity(stuModel.id);
- if (infoEntity == null)
- {
- return Fail("找不到用户数据");
- }
-
- if (!string.IsNullOrEmpty(stuModel.culture))
- {
- infoEntity.CultureId = stuModel.culture;
- }
-
- if (!string.IsNullOrEmpty(stuModel.school))
- {
- infoEntity.SchoolId = stuModel.school;
- }
- if (!string.IsNullOrEmpty(stuModel.depart))
- {
- infoEntity.MajorId = stuModel.depart;
- }
-
- if (!string.IsNullOrEmpty(stuModel.paymentQuota))
- {
- infoEntity.PaymentQuota = Convert.ToDecimal(stuModel.paymentQuota);
- }
- if (!string.IsNullOrEmpty(stuModel.rTeacher))
- {
- infoEntity.UserTeacherId = stuModel.rTeacher;
- }
- if (!string.IsNullOrEmpty(stuModel.renarks))
- {
- infoEntity.Remarks = stuModel.renarks;
- }
-
- aP_OnlineStudentInfoIBLL.SaveEntity(stuModel.id, infoEntity);
-
-
- AP_OnlineUserInfoEntity userEntity = aP_OnlineUserInfoIBLL.GetEntity(infoEntity.UserId);
-
- if (!string.IsNullOrEmpty(stuModel.username))
- {
- userEntity.RealName = stuModel.username;
- }
- if (!string.IsNullOrEmpty(stuModel.sex))
- {
- userEntity.SexId = stuModel.sex;
- }
- if (!string.IsNullOrEmpty(stuModel.phone))
- {
- userEntity.Mobile = stuModel.phone;
- }
- if (!string.IsNullOrEmpty(stuModel.address))
- {
- userEntity.DetailedAddress = stuModel.address;
- }
- if (!string.IsNullOrEmpty(stuModel.ids))
- {
- userEntity.CertNum = stuModel.ids;
- }
- if (!string.IsNullOrEmpty(stuModel.province))
- {
- userEntity.Province = stuModel.province;
- }
- if (!string.IsNullOrEmpty(stuModel.city))
- {
- userEntity.City = stuModel.city;
- }
- if (!string.IsNullOrEmpty(stuModel.county))
- {
- userEntity.Country = stuModel.county;
- }
-
- aP_OnlineUserInfoIBLL.SaveEntity(infoEntity.UserId, userEntity);
-
-
- return Success("修改成功");
-
-
- }
-
- private Response GetStuInfo(dynamic _)
- {
- var queryParam = this.GetReqData<stuQueryParam>();
- var stuInfolist = aP_OnlineStudentInfoIBLL.GetList("").Where(a => a.UserTeacherId == queryParam.empid).ToList();
- var userInfo = aP_OnlineUserInfoIBLL.GetList("");
- List<AP_OnlineStudentInfoEntity> reList = new List<AP_OnlineStudentInfoEntity>();
- switch (queryParam.num)
- {
- case "1":
- reList = stuInfolist;
- break;
- case "2":
- reList = stuInfolist.Where(a => a.IsPaymentId == "1")
- .Where(a => a.IsDropOut == null || a.IsDropOut == "0").ToList();
- break;
- case "3":
- reList = stuInfolist.Where(a => a.IsDropOut == "1").ToList();
- break;
- case "4":
- reList = stuInfolist.Where(a => a.PaymentQuota == 0 || a.PaymentQuota == null).ToList();
- break;
- default:
- reList = stuInfolist;
- break;
- }
-
- List<object> result = new List<object>();
- foreach (var item in reList)
- {
-
- var companyEntity = companyIBLL.GetEntity(item.SchoolId);
- var majorEntity = majorIbll.GetCdMajorEntityByMajorNo(item.MajorId);
- var entity = userInfo.FirstOrDefault(a => a.Id == item.UserId);
- var photo = entity.PhotoUrl;
- result.Add(new
- {
- userPhoto = photo,
- strdentName = entity.RealName,
- strMobile = entity.Mobile,
- moneyQuota = item.PaymentQuota == null ? 0 : item.PaymentQuota,
- schoolName = companyEntity?.F_FullName,
- professionName = majorEntity?.MajorName,
- professionMoney = "",
- ID = item.Id,
- UserID = item.UserId
- });
- }
-
- return Success(result);
- }
-
- private Response GetStuById(dynamic _)
- {
- var userId = this.GetReqData();
- var stuentity = aP_OnlineStudentInfoIBLL.GetEntity(userId);
- var userentity = aP_OnlineUserInfoIBLL.GetEntity(stuentity.UserId);
- var result = new
- {
- username = userentity.RealName,
- sexid = userentity.SexId,
- sex = userentity.SexId == "1" ? "男" : "女",
- phone = userentity.Mobile,
- address = userentity.DetailedAddress,
- ids = userentity.CertNum,
- cultureid = stuentity.CultureId,
- culture = bCdCultureDegreeIBLL.GetEntity(stuentity.CultureId)?.CultureDegree,
- schoolid = stuentity.SchoolId,
- school = companyIBLL.GetEntity(stuentity.SchoolId)?.F_FullName,
- departid = stuentity.MajorId,
- depart = majorIbll.GetCdMajorEntityByMajorNo(stuentity.MajorId)?.MajorName,
- paymentQuota = stuentity.PaymentQuota,
- renarks = stuentity.Remarks,
- province = userentity.Province,
- city = userentity.City,
- county = userentity.Country
- };
- return Success(result);
-
-
- }
- private Response GetStuInfoByUserId(dynamic _)
- {
- var userId = this.GetReqData();
- var userentity = aP_OnlineUserInfoIBLL.GetEntity(userId);
- var stuentity = aP_OnlineStudentInfoIBLL.GetEntityByUserId(userentity.Id);
- var company = companyIBLL.GetEntity(stuentity.SchoolId);
- var major = majorIbll.GetCdMajorEntityByMajorNo(stuentity.MajorId);
- var teacher = userIBLL.GetEntityByUserId(stuentity.UserTeacherId);
- var cultrue = bCdCultureDegreeIBLL.GetEntity(stuentity.CultureId);
- var photourl = annexesFileIBLL.GetEntityByFolderId(userentity.PhotoUrl)?.F_FilePath;
- if (photourl != null && photourl.IndexOf("Resource") > 0)
- {
- photourl = "/" + photourl.Substring(photourl.IndexOf("Resource"));
- }
- var result = new
- {
- ID = userentity.Id,
- username = userentity.RealName,
- sex = userentity.SexId,
- sexname = userentity.SexId == "1" ? "男" : "女",
- photo = photourl,
- phone = userentity.Mobile,
- status = 1,
- birth = userentity.BirthDate,
- depart = stuentity.MajorId,
- departname = major?.MajorName,
- school = stuentity.SchoolId,
- schoolname = company?.F_FullName,
- culture = stuentity.CultureId,
- culturename = cultrue?.CultureDegree,
- pTotalMoney = "",
- teaID = stuentity.UserTeacherId,
- teaName = teacher?.F_RealName,
- teaPhone = teacher?.F_Mobile,
- ids = userentity.CertNum,
- gexin = ""
- };
- return Success(result);
-
-
- }
-
- private Response Upload(dynamic _)
- {
- var userid = this.GetReqData();
- HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
- //没有文件上传,直接返回
- if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
- {
- return Fail("");
- }
-
- string FileEextension = Path.GetExtension(files[0].FileName);
- string filePath = Config.GetValue("AnnexesFile");
- string uploadDate = DateTime.Now.ToString("yyyyMMdd");
- string fileGuid = Guid.NewGuid().ToString();
- string fileHeadImg = Config.GetValue("AnnexesFile");
- //string fullFileName = string.Format("{0}/{1}{2}", fileHeadImg, userInfo.userId, FileEextension);
- string fullFileName = $"{fileHeadImg}/{userid}/{uploadDate}/{fileGuid}{FileEextension}";
- var saveFileName = "/Resource/" + fullFileName.Substring(fullFileName.IndexOf(userid), fullFileName.Length - fullFileName.IndexOf(userid));
- //创建文件夹,保存文件
- string path = Path.GetDirectoryName(fullFileName);
- Directory.CreateDirectory(path);
- files[0].SaveAs(fullFileName);
-
- UserEntity userEntity = new UserEntity();
- userEntity.F_UserId = userid;
- userEntity.F_HeadIcon = saveFileName;
- userIBLL.SaveEntity(userEntity.F_UserId, userEntity);
- return Success(saveFileName);
- }
- private Response UploadStudent(dynamic _)
- {
- var userid = this.GetReqData();
- HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
- //没有文件上传,直接返回
- if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
- {
- return Fail("");
- }
-
- string FileEextension = Path.GetExtension(files[0].FileName);
- string filePath = Config.GetValue("AnnexesFile");
- string uploadDate = DateTime.Now.ToString("yyyyMMdd");
- string fileGuid = Guid.NewGuid().ToString();
- string fileHeadImg = Config.GetValue("AnnexesFile");
- //string fullFileName = string.Format("{0}/{1}{2}", fileHeadImg, userInfo.userId, FileEextension);
- string fullFileName = $"{fileHeadImg}/{userid}/{uploadDate}/{fileGuid}{FileEextension}";
- var saveFileName = "/Resource/" + fullFileName.Substring(fullFileName.IndexOf(userid), fullFileName.Length - fullFileName.IndexOf(userid));
- //创建文件夹,保存文件
- string path = Path.GetDirectoryName(fullFileName);
- Directory.CreateDirectory(path);
- files[0].SaveAs(fullFileName);
-
-
- var stuInfoEntity = aP_OnlineUserInfoIBLL.GetEntity(userid);
- if (stuInfoEntity != null)
- {
- if (!string.IsNullOrEmpty(stuInfoEntity.PhotoUrl))
- {
- var annexEntity = annexesFileIBLL.GetEntityByFolderId(stuInfoEntity.PhotoUrl);
- annexEntity.F_FilePath = fullFileName;
- annexEntity.F_Id = Guid.NewGuid().ToString();
- annexesFileIBLL.SaveEntity(stuInfoEntity.PhotoUrl, annexEntity);
- }
- else
- {
- stuInfoEntity.PhotoUrl = Guid.NewGuid().ToString();
- aP_OnlineUserInfoIBLL.SaveEntity(stuInfoEntity.Id, stuInfoEntity);
-
- var annexEntity = new AnnexesFileEntity();
- annexEntity.F_FilePath = fullFileName;
- annexEntity.F_FolderId = stuInfoEntity.PhotoUrl;
- annexEntity.F_Id = Guid.NewGuid().ToString();
- annexesFileIBLL.SaveEntity(stuInfoEntity.PhotoUrl, annexEntity);
-
- }
- }
-
-
- return Success(saveFileName);
- }
- private Response UpdataTeacherInfo(dynamic _)
- {
- var strEntity = this.GetReqData<teaInfo>();
- var teaEntity = userIBLL.GetEntityByUserId(strEntity.id);
- if (teaEntity != null)
- {
- teaEntity.F_RealName = strEntity.realName;
- teaEntity.F_Gender = Convert.ToInt32(strEntity.sexID);
- teaEntity.F_Birthday = strEntity.birthDate.ToDate();
- teaEntity.PerSignature = strEntity.remark;
- teaEntity.F_Mobile = strEntity.photo;
- userIBLL.SaveEntity(teaEntity.F_UserId, teaEntity);
- }
- return Success("修改成功");
- }
- private Response UpdatePassword(dynamic _)
- {
- var strEntity = this.GetReqData<pwdModel>();
- strEntity.oldpwd = Md5Helper.Encrypt(strEntity.oldpwd, 32);
- strEntity.newpwd = Md5Helper.Encrypt(strEntity.newpwd, 32);
- var entity = userIBLL.GetEntityByUserId(strEntity.userid);
- if (entity != null)
- {
- string oldPasswordByEncrypt = Md5Helper.Encrypt(DESEncrypt.Encrypt(strEntity.oldpwd, entity.F_Secretkey).ToLower(), 32).ToLower();
- if (oldPasswordByEncrypt == entity.F_Password)
- {
- userIBLL.setPassword(entity.F_UserId, strEntity.newpwd);
- }
- else
- {
- return Fail("旧密码不正确");
- }
-
- return Success("修改成功");
- }
- else
- {
- return Fail("修改失败");
- }
-
- }
- private Response UpdatePasswordStu(dynamic _)
- {
- var strEntity = this.GetReqData<pwdModel>();
- var entity = aP_OnlineUserInfoIBLL.GetEntity(strEntity.userid);
- if (entity != null)
- {
- if (strEntity.oldpwd == entity.Password)
- {
- entity.Password = strEntity.newpwd;
- aP_OnlineUserInfoIBLL.SaveEntity(entity.Id, entity);
- }
- else
- {
- return Fail("旧密码不正确");
- }
-
- return Success("修改成功");
- }
- else
- {
- return Fail("修改失败");
- }
-
- }
- private Response BankInfo(dynamic _)
- {
- var userId = this.GetReqData();
- var list = aP_TeacherBankCardIBLL.GetListByID(userId).ToList();
- List<object> result = new List<object>();
- foreach (var item in list)
- {
- result.Add(new
- {
- bankName = item.Bank,
- bankNumber = item.BankCardNo
- });
- }
-
- return Success(result);
-
-
-
- }
- private Response IntegralDetails(dynamic _)
- {
- var userId = this.GetReqData();
- var list = aP_IntegralDetailsIBLL.GetListByID(userId).ToList();
- List<object> result = new List<object>();
- foreach (var item in list)
- {
- result.Add(new
- {
- year = item.CreateTime.ToDate().Year,
- bankNumber = item.BankCardNo,
- scoresNum = item.IntegralNum,
- createDate = item.CreateTime,
- scorename = item.IntegralName
-
- });
- }
-
- return Success(result);
-
-
-
- }
- private Response DetailInfo(dynamic _)
- {
- var userId = this.GetReqData();
- var list = aP_IntegralDetailsIBLL.GetListByID(userId).ToList();
- var result = new
- {
- getcount = list.Count(a => a.IsReceived == "1"),
- allcount = list.Count()
- };
-
- return Success(result);
-
- }
- private Response AboutSchool(dynamic _)
- {
-
- var list = newsIBLL.GetAboutSchool().FirstOrDefault();
- return Success(new { content = list.F_NewsContent });
-
- }
- private Response GetNews(dynamic _)
- {
-
- var list = newsIBLL.GetNews();
- List<object> result = new List<object>();
- foreach (var item in list)
- {
- result.Add(new
- {
- articleID = item.F_NewsId,
- title = item.F_FullHead,
- common = item.F_NewsContent,
- date = item.F_CreateDate
- });
- }
- return Success(result);
-
- }
- private Response GetNewsDetail(dynamic _)
- {
- var id = this.GetReqData();
- var list = newsIBLL.GetEntity(id);
- var result = new
- {
- title = list.F_FullHead,
- date = list.F_CreateDate,
- content = list.F_NewsContent
- };
- return Success(result);
-
- }
- private Response GetCompanyNews(dynamic _)
- {
- var param = this.GetReqData<newsParamModel>();
- var list = companyNewsIBLL.GetListByCompanyID(param.companyid).ToList();
- if (param.type == "1")
- {
- list = list.Where(a => a.NewType == "1").ToList();
- }
- else
- {
- list = list.Where(a => a.NewType == "0").ToList();
- }
- List<object> res = new List<object>();
- foreach (var item in list)
- {
- res.Add(new
- {
- articleID = item.ID,
- title = item.Title,
- date = item.F_CreateDate,
- content = item.Content
- }); ;
- }
- return Success(res);
-
- }
- private Response GetCompanyNewsDetail(dynamic _)
- {
- var id = this.GetReqData();
- var entity = companyNewsIBLL.GetCompanyNewsEntity(id);
- var res = new
- {
- title = entity.Title,
- date = entity.F_CreateDate,
- content = entity.Content
- };
- return Success(res);
-
- }
- private Response GetCompanyInfo(dynamic _)
- {
- var companyID = this.GetReqData();
- var res = companyIBLL.GetEntity(companyID);
- return Success(res);
-
- }
- /// <summary>
- /// 修改密码
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response ModifyPassword(dynamic _)
- {
- ModifyModel modifyModel = this.GetReqData<ModifyModel>();
- if (userInfo.isSystem)
- {
- return Fail("当前账户不能修改密码");
- }
- else
- {
- bool res = userIBLL.RevisePassword(modifyModel.newpassword, modifyModel.oldpassword);
- if (!res)
- {
- return Fail("原密码错误,请重新输入");
- }
- else
- {
- return Success("密码修改成功");
- }
- }
- }
-
-
- private Response ForgetPwd(dynamic _)
- {
- forgetPwdParamModel param = this.GetReqData<forgetPwdParamModel>();
- var entity = aP_OnlineUserInfoIBLL.GetEntityByMobile(param.mobile);
- if (entity != null)
- {
- if (entity.CertNum == param.ids)
- {
- return Success(entity.Password);
- }
- else
- {
- return Fail("输入的手机号或者身份证不正确");
- }
- }
- else
- {
- return Fail("输入的手机号或者身份证不正确");
- }
- }
-
- private Response GetEditonInfo(dynamic _)
- {
- var type = this.GetReqData();
- var entity = editonManagementIbll.GetEditonManagementEntityByEType(type);
- var apkurl = "";
- if (entity.Url != null)
- {
- apkurl = annexesFileIBLL.GetEntityByFolderId(entity.Url).F_FilePath;
- apkurl = "/" + apkurl.Substring(apkurl.IndexOf("Resource"));
- }
-
- entity.Url = apkurl;
- return Success(entity);
- }
-
- /// <summary>
- /// 解绑微信
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response DoUnbundWeiXin(dynamic _)
- {
- userIBLL.DoUnbundWeiXin(userInfo.userId);
- return Success("解绑成功");
-
- }
- /// <summary>
- /// 获取所有员工账号列表
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response GetList(dynamic _)
- {
- var data = userInfo;
- data.password = null;
- data.secretkey = null;
- var jsonData = new
- {
- baseinfo = data,
- post = postIBLL.GetListByPostIds(data.postIds),
- role = roleIBLL.GetListByRoleIds(data.roleIds)
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取用户映射表
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetMap(dynamic _)
- {
- string ver = this.GetReqData();// 获取模板请求数据
- var data = userIBLL.GetModelMap();
- string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
- if (md5 == ver)
- {
- return Success("no update");
- }
- else
- {
- var jsondata = new
- {
- data = data,
- ver = md5
- };
- return Success(jsondata);
- }
- }
-
-
- public Response GetSaveClassMap(dynamic _)
- {
- string account = this.GetReqData<UserAccount>().account;
- var data = userIBLL.GetSaveClassMap();
- var students = stuInfoBasicIBLL.GetSaveClassStudents(account);
- data = data.Where(a => students.Contains(a.F_Account) && a.F_Account != account).ToList();
- var dic = new Dictionary<string, UserModel>();
- foreach (var item in data)
- {
- UserModel model = new UserModel()
- {
- companyId = item.F_CompanyId,
- departmentId = item.F_DepartmentId,
- name = item.F_RealName,
- id = item.F_UserId,
- };
- string img = "";
- if (!string.IsNullOrEmpty(item.F_HeadIcon))
- {
- string fileHeadImg = Config.GetValue("fileHeadImg");
- string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, item.F_UserId, item.F_HeadIcon);
- if (DirFileHelper.IsExistFile(fileImg))
- {
- img = item.F_HeadIcon;
- }
- }
- if (string.IsNullOrEmpty(img))
- {
- if (item.F_Gender == 0)
- {
- img = "0";
- }
- else
- {
- img = "1";
- }
- }
- model.img = img;
- dic.Add(item.F_UserId, model);
- }
-
-
-
- string md5 = Md5Helper.Encrypt(dic.ToJson(), 32);
- var jsondata = new
- {
- data = dic,
- var = md5
- };
- return Success(jsondata);
- }
- /// <summary>
- /// 获取人员头像图标
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetImg(dynamic _)
- {
- string userId = this.GetReqData();// 获取模板请求数据
- userIBLL.GetImg(userId);
- return Success("获取成功");
- }
- /// <summary>
- /// 获取IP
- /// </summary>
- /// <returns></returns>
- private string GetIP()
- {
- //string ip = string.Empty;
- //if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
- // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
- //if (string.IsNullOrEmpty(ip))
- // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
- //return ip;
- string userIP = "未获取用户IP";
-
- try
- {
- if (System.Web.HttpContext.Current == null
- || System.Web.HttpContext.Current.Request == null
- || System.Web.HttpContext.Current.Request.ServerVariables == null)
- {
- return "";
- }
-
- string CustomerIP = "";
-
- //CDN加速后取到的IP simone 090805
- CustomerIP = System.Web.HttpContext.Current.Request.Headers["Cdn-Src-Ip"];
- if (!string.IsNullOrEmpty(CustomerIP))
- {
- return CustomerIP;
- }
-
- CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
-
- if (!string.IsNullOrEmpty(CustomerIP))
- {
- return CustomerIP;
- }
-
- if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
- {
- CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
-
- if (CustomerIP == null)
- {
- CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
- }
- }
- else
- {
- CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
- }
-
- if (string.Compare(CustomerIP, "unknown", true) == 0 || string.IsNullOrEmpty(CustomerIP))
- {
- return System.Web.HttpContext.Current.Request.UserHostAddress;
- }
- return CustomerIP;
- }
- catch { }
-
- return userIP;
- }
- }
-
- /// <summary>
- /// 登录信息
- /// </summary>
- public class TLoginModel
- {
- /// <summary>
- /// 账号
- /// </summary>
- public string username { get; set; }
- /// <summary>
- /// 密码
- /// </summary>
- public string password { get; set; }
- /// <summary>
- /// 设备号
- /// </summary>
- public string deviceid { get; set; }
- public string openid { get; set; }
- }
-
- public class StuModel
- {
- public string id { get; set; }
- public string username { get; set; }
- public string sex { get; set; }
- public string phone { get; set; }
- public string address { get; set; }
- public string culture { get; set; }
- public string school { get; set; }
- public string depart { get; set; }
- public string paymentQuota { get; set; }
- public string rTeacher { get; set; }
- public string ids { get; set; }
- public string renarks { get; set; }
- public string province { get; set; }
- public string city { get; set; }
- public string county { get; set; }
- public string birthday { get; set; }
- }
-
- public class stuQueryParam
- {
- public string empid { get; set; }
- public string num { get; set; }
- }
-
- public class teaInfo
- {
- public string id { get; set; }
- public string photo { get; set; }
- public string realName { get; set; }
- public string sexID { get; set; }
- public string remark { get; set; }
- public string birthDate { get; set; }
- }
-
- public class pwdModel
- {
- public string userid { get; set; }
- public string oldpwd { get; set; }
- public string newpwd { get; set; }
- }
-
- public class stuInfo
- {
- public string id { get; set; }
- public string sex { get; set; }
- public string birthday { get; set; }
- public string idcard { get; set; }
- }
-
-
- public class newsParamModel
- {
- public string companyid { get; set; }
- public string type { get; set; }
- }
-
- public class forgetPwdParamModel
- {
- public string mobile { get; set; }
- public string ids { get; set; }
- }
-
- public class RegisterModel
- {
- public string name { get; set; }
- public string logpwd { get; set; }
- public string ids { get; set; }
- public string mobile { get; set; }
- }
- }
|