Files
MeiSaiSiXieTongApi/MyCode.Project.WebApi/Areas/Admin/Controllers/LoginController.cs
2025-04-24 18:31:27 +08:00

159 lines
4.6 KiB
C#

using MyCode.Project.Domain.Message.Act.User;
using MyCode.Project.Domain.Message.Common;
using MyCode.Project.Domain.Message.Request.User;
using MyCode.Project.Domain.Message.Response.Common;
using MyCode.Project.Domain.Message.Response.User;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Infrastructure.Enumeration;
using MyCode.Project.Infrastructure.Exceptions;
using MyCode.Project.Services;
using MyCode.Project.Services.Implementation;
using System.Collections.Generic;
using System.Web.Http;
using System.Web.UI.WebControls;
namespace MyCode.Project.WebApi.Areas.Admin.Controllers
{
/// <summary>
/// 账号相关
/// </summary>
public class LoginController : BaseAdminController
{
private ISysLoginService _sysLoginService;
private IPurchaseOrderService _purchaseOrderService;
/// <summary>
///
/// </summary>
/// <param name="sysLoginService"></param>
public LoginController(ISysLoginService sysLoginService
, IPurchaseOrderService purchaseOrderService
)
{
_purchaseOrderService = purchaseOrderService;
_sysLoginService = sysLoginService;
}
#region Login()
/// <summary>
/// 账号登陆
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public string Login(GetTokenRequest request)
{
return _sysLoginService.Login(request);
}
#endregion
#region GetPageList()
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="search"></param>
/// <returns></returns>
[HttpPost]
public PageResult<AccountPageList> GetPageList(PagedSearch<SysLoginPageSearch> search)
{
return _sysLoginService.GetPageList(search,this.CurrentLogin);
}
#endregion
#region Save()
/// <summary>
/// 保存账号
/// </summary>
/// <param name="act"></param>
/// <returns></returns>
[HttpPost]
public void Save(SysloginAct act)
{
if (this.CurrentLogin.RoleType == 1)
_sysLoginService.Save(act, this.CurrentLogin);
else
{
throw new BaseException("只有管理员才能新建账号");
}
}
#endregion
#region Save()
/// <summary>
/// 供应商修改自己的密码
/// </summary>
/// <param name="pwd">密码</param>
/// <returns></returns>
[HttpGet]
public void UpPassword(string pwd)
{
_sysLoginService.UpPassword(pwd, this.CurrentLogin);
}
#endregion
/// <summary>
/// 获取供应商列表
/// </summary>
/// <returns></returns>
[HttpGet]
public List<ItemResult> GetBDSupplierList()
{
var result = _purchaseOrderService.GetBDSupplierList();
return result;
}
/// <summary>
/// 获取金蝶系统的采购组织
/// </summary>
/// <returns></returns>
[HttpGet]
public List<ItemResult> GetFPurchaseOrgList()
{
var result = _purchaseOrderService.GetFPurchaseOrgList();
return result;
}
#region GetAccountInfo()
/// <summary>
/// 获取已登录的账号信息
/// </summary>
/// <returns></returns>
[HttpGet]
public AccountInfo GetAccountInfo()
{
var loginInfo = this.CurrentLogin;
AccountInfo result = new AccountInfo();
result.SupplierName = loginInfo.SupplierName;
result.Name = loginInfo.Name;
result.RoleType = loginInfo.RoleType;
result.IfForeign = loginInfo.IfForeign;
return result;
}
#endregion
#region BatchUpdateStatus()
/// <summary>
/// 批量更新账号状态
/// </summary>
/// <param name="act"></param>
[HttpPost]
public void BatchUpdateStatus(StatusAct act)
{
if (this.CurrentLogin.RoleType == 1)
_sysLoginService.BatchUpdateStatus(act, act.Status);
else
{
throw new BaseException("只有管理员才能启用/禁用账号");
}
}
#endregion
}
}