Files
HJGL_DS/HJGL_DS/BLL/API/APILoginServices.cs
T
2026-08-07 17:29:30 +08:00

76 lines
2.0 KiB
C#

using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
using System.Web.UI;
namespace BLL.API
{
public class APILoginServices
{
public static Model.ResponeData login(string account, string password)
{
Model.ResponeData respone = new ResponeData();
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var user = db.Sys_User.FirstOrDefault(x => x.Account == account && x.IsPost == true);
if (user != null)
{
if (user.Password == Sys_UserService.EncryptionPassword(password))
{
UserItem userItem= new UserItem();
userItem.ID = user.UserId;
userItem.Name = user.UserName;
userItem.Code = user.UserCode;
userItem.UnitId = user.UnitId;
userItem.UnitName = BLL.Base_UnitService.GetUnitNameByUnitId(user.UnitId);
userItem.Type ="user";
respone.data = userItem;
}
else
{
respone.code = 0;
respone.message = "密码错误";
}
}
else
{
var welder = db.HJGL_BS_Welder.FirstOrDefault(x => x.WED_Code == account && (!x.LimitDate.HasValue || x.LimitDate.Value < DateTime.Now));
if (welder != null)
{
if (welder.IdentityCard.EndsWith(password) && password.Length == 6)
{
UserItem userItem = new UserItem();
userItem.ID = welder.WED_ID;
userItem.Name = welder.WED_Name;
userItem.Code = welder.WED_Code;
userItem.UnitId = welder.WED_Unit;
userItem.UnitName = BLL.Base_UnitService.GetUnitNameByUnitId(welder.WED_Unit);
userItem.IdentityCard = welder.IdentityCard;
userItem.Type = "welder";
respone.data = userItem;
}
else
{
respone.code = 0;
respone.message = "身份证后6位错误";
}
}
else
{
respone.code = 0;
respone.message = "账号或焊工号不存在";
}
}
}
return respone;
}
}
}