You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.4 KiB
94 lines
3.4 KiB
using NFine.Code;
|
|
using NFine.Domain.Entity.SystemManage;
|
|
using NFine.Domain.IRepository.SystemManage;
|
|
using NFine.Repository.SystemManage;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace NFine.Application.SystemManage
|
|
{
|
|
public class RoleApp
|
|
{
|
|
private IRoleRepository service = new RoleRepository();
|
|
private ModuleApp moduleApp = new ModuleApp();
|
|
private ModuleButtonApp moduleButtonApp = new ModuleButtonApp();
|
|
|
|
public List<RoleEntity> GetList(Pagination pagination, string keyword = "")
|
|
{
|
|
var expression = ExtLinq.True<RoleEntity>();
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
expression = expression.And(t => t.F_FullName.Contains(keyword));
|
|
expression = expression.Or(t => t.F_EnCode.Contains(keyword));
|
|
}
|
|
expression = expression.And(t => t.F_Category == 1);
|
|
//return service.IQueryable(expression).OrderBy(t => t.F_SortCode).ToList();
|
|
if (pagination == null)
|
|
{
|
|
return service.IQueryable(expression).OrderBy(t => t.F_SortCode).ToList();
|
|
}
|
|
else
|
|
{
|
|
return service.FindList(expression, pagination);
|
|
}
|
|
|
|
}
|
|
|
|
public List<RoleEntity> GetList( string keyword = "")
|
|
{
|
|
var expression = ExtLinq.True<RoleEntity>();
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
expression = expression.And(t => t.F_FullName.Contains(keyword));
|
|
expression = expression.Or(t => t.F_EnCode.Contains(keyword));
|
|
}
|
|
expression = expression.And(t => t.F_Category == 1);
|
|
return service.IQueryable(expression).OrderBy(t => t.F_SortCode).ToList();
|
|
|
|
|
|
}
|
|
|
|
public RoleEntity GetForm(string keyValue)
|
|
{
|
|
return service.FindEntity(keyValue);
|
|
}
|
|
|
|
public void DeleteForm(string keyValue)
|
|
{
|
|
service.DeleteForm(keyValue);
|
|
}
|
|
|
|
public void SubmitForm(RoleEntity roleEntity, string[] permissionIds, string keyValue)
|
|
{
|
|
if (!string.IsNullOrEmpty(keyValue))
|
|
{
|
|
roleEntity.F_Id = keyValue;
|
|
}
|
|
else
|
|
{
|
|
roleEntity.F_Id = Common.GuId();
|
|
}
|
|
var moduledata = moduleApp.GetList();
|
|
var buttondata = moduleButtonApp.GetList();
|
|
List<RoleAuthorizeEntity> roleAuthorizeEntitys = new List<RoleAuthorizeEntity>();
|
|
foreach (var itemId in permissionIds)
|
|
{
|
|
RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity();
|
|
roleAuthorizeEntity.F_Id = Common.GuId();
|
|
roleAuthorizeEntity.F_ObjectType = 1;
|
|
roleAuthorizeEntity.F_ObjectId = roleEntity.F_Id;
|
|
roleAuthorizeEntity.F_ItemId = itemId;
|
|
if (moduledata.Find(t => t.F_Id == itemId) != null)
|
|
{
|
|
roleAuthorizeEntity.F_ItemType = 1;
|
|
}
|
|
if (buttondata.Find(t => t.F_Id == itemId) != null)
|
|
{
|
|
roleAuthorizeEntity.F_ItemType = 2;
|
|
}
|
|
roleAuthorizeEntitys.Add(roleAuthorizeEntity);
|
|
}
|
|
service.SubmitForm(roleEntity, roleAuthorizeEntitys, keyValue);
|
|
}
|
|
}
|
|
}
|