|
|
@@ -1,6 +1,8 @@ |
|
|
|
using BPA.SAAS.Manage.Application.Auth.Dtos; |
|
|
|
using BPA.SAAS.Manage.Comm.Const; |
|
|
|
using BPA.SAAS.Manage.Comm.Enum; |
|
|
|
using BPA.SAAS.Manage.Core.Base; |
|
|
|
using BPA.SAAS.Manage.Core.DataBase; |
|
|
|
using BPA.SAAS.Manage.Core.Org; |
|
|
|
using Mapster; |
|
|
|
using Newtonsoft.Json; |
|
|
@@ -34,7 +36,7 @@ namespace BPA.SAAS.Manage.Application.Auth |
|
|
|
{ |
|
|
|
|
|
|
|
// 获取加密后的密码 |
|
|
|
var encryptPasswod = MD5Encryption.Encrypt(input.Password).ToLower(); |
|
|
|
var encryptPasswod = MD5Encryption.Encrypt(input.Password).ToLower(); |
|
|
|
// 判断用户名和密码是否正确 忽略全局过滤器 |
|
|
|
var user = await _db.Queryable<BPA_Users>().Where(u => u.Account.Equals(input.Account) |
|
|
|
&& u.Password.Equals(encryptPasswod) |
|
|
@@ -46,7 +48,10 @@ namespace BPA.SAAS.Manage.Application.Auth |
|
|
|
conModels.Add(new ConditionalModel() { FieldName = "Id", ConditionalType = ConditionalType.Equal, FieldValue = user.GroupId }); |
|
|
|
conModels.Add(new ConditionalModel() { FieldName = "Status", ConditionalType = ConditionalType.Equal, FieldValue = CommonStatus.ENABLE.ToString() }); |
|
|
|
conModels.Add(new ConditionalModel() { FieldName = "IsDeleted", ConditionalType = ConditionalType.Equal, FieldValue ="0" }); |
|
|
|
|
|
|
|
//if (user.AdminType != 1) |
|
|
|
//{ |
|
|
|
// conModels.Add(new ConditionalModel() { FieldName = "Type", ConditionalType = ConditionalType.Equal, FieldValue = input.Type.ToString() }); |
|
|
|
//} |
|
|
|
var company = _db.Queryable<BPA_Company>().Where(conModels).First(); |
|
|
|
|
|
|
|
string CLAINM_SUPERADMIN = "Customer"; |
|
|
@@ -116,5 +121,75 @@ namespace BPA.SAAS.Manage.Application.Auth |
|
|
|
// _httpContextAccessor.SignoutToSwagger(); |
|
|
|
await Task.CompletedTask; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 添加平台授权 |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 分页 |
|
|
|
/// </summary> |
|
|
|
/// <param name="input"></param> |
|
|
|
/// <returns></returns> |
|
|
|
[HttpPost("/api/authorization/pageauthorization")] |
|
|
|
public async Task<PageUtil> PageAuthorization(PageInputBase input) |
|
|
|
{ |
|
|
|
RefAsync<int> total = 0; |
|
|
|
var res = await _db.Queryable<BPA_PlatformAuthorization>() |
|
|
|
.OrderBy(x => x.CreateAt, OrderByType.Desc) |
|
|
|
.Select(x => new PlatformAuthorizationDto() |
|
|
|
{ |
|
|
|
Id = x.Id.SelectAll(), |
|
|
|
}) |
|
|
|
.ToPageListAsync(input.Current, input.PageSize, total); |
|
|
|
PageUtil util = new PageUtil() |
|
|
|
{ |
|
|
|
Total = total, |
|
|
|
Data = res |
|
|
|
}; |
|
|
|
return util; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 添加授权码 |
|
|
|
/// </summary> |
|
|
|
/// <returns></returns> |
|
|
|
[HttpPost("/api/authorization/addauthorization")] |
|
|
|
public async Task<bool> AddAuthorization() |
|
|
|
{ |
|
|
|
var data = _db.Queryable<BPA_PlatformAuthorization>().ToList(); |
|
|
|
if (data.Count > 0) |
|
|
|
{ |
|
|
|
throw Oops.Oh("授权码已存在"); |
|
|
|
} |
|
|
|
|
|
|
|
var res = await _db.Insertable(new BPA_PlatformAuthorization() |
|
|
|
{ |
|
|
|
Key = Guid.NewGuid().ToString(), |
|
|
|
|
|
|
|
}).CallEntityMethod(t => t.Create()).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
return res > 0; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 修改授权码 |
|
|
|
/// </summary> |
|
|
|
/// <param name="id"></param> |
|
|
|
/// <returns></returns> |
|
|
|
[HttpPost("/api/authorization/updateauthorization")] |
|
|
|
public async Task<bool> UpdateAuthorization(string id) |
|
|
|
{ |
|
|
|
var data = await _db.Queryable<BPA_PlatformAuthorization>().FirstAsync(x => x.Id == id); |
|
|
|
if (data == null) |
|
|
|
{ |
|
|
|
throw Oops.Oh("授权信息不存在"); |
|
|
|
} |
|
|
|
data.Key = Guid.NewGuid().ToString(); |
|
|
|
|
|
|
|
return await _db.Updateable(data).ExecuteCommandHasChangeAsync(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
} |
|
|
|
} |