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
{
///
/// 版 本 Learun-ADMS V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创建人:数字化智慧校园-框架开发组
/// 日 期:2017.05.12
/// 描 述:用户信息
///
public class TUserApi : BaseNoLoginApi
{
///
/// 注册接口
///
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();
///
/// 登录接口
///
///
///
private Response Login(dynamic _)
{
var loginModel = this.GetReqData();
#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();
#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();
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("注册成功");
}
}
///
/// 获取用户信息
///
///
///
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);
}
///
/// 获取字典
///
///
///
private Response GetDataItem(dynamic _)
{
var code = this.GetReqData();
var itemList = dataItemIBLL.GetDetailList(code);
var result = new List