84 lines
3.0 KiB
C#
84 lines
3.0 KiB
C#
using HL_FristAidPlatform_Help;
|
|
using HL_FristAidPlatform_IDataBase;
|
|
using HL_FristAidPlatform_Models;
|
|
using SqlSugar;
|
|
using System.Collections.Generic;
|
|
|
|
namespace HL_FristAidPlatform_DataBase
|
|
{
|
|
public class T_SYS_UserRoleDB : BaseDB, IT_SYS_UserRole
|
|
{
|
|
public SqlSugarClient db = GetClient();
|
|
|
|
public bool Add(T_SYS_UserRole userRole)
|
|
{
|
|
return db.Insertable(userRole).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand() == 1 ? true : false;
|
|
}
|
|
|
|
public bool Dels(dynamic[] guids)
|
|
{
|
|
return db.Deleteable<T_SYS_UserRole>().In(new dynamic[] { guids }).ExecuteCommand() == 1 ? true : false;
|
|
}
|
|
|
|
public T_SYS_UserRole Get(string guid)
|
|
{
|
|
return db.Queryable<T_SYS_UserRole>().First(it => it.GUID == guid);
|
|
}
|
|
|
|
public TableModel<T_SYS_UserRole> GetList()
|
|
{
|
|
List<T_SYS_UserRole> data = db.Queryable<T_SYS_UserRole>().Where(it => it.DeleteFlag == 0).ToList();
|
|
TableModel<T_SYS_UserRole> t = new TableModel<T_SYS_UserRole>();
|
|
t.Code = 0;
|
|
t.TotalNumber = data.Count;
|
|
t.Data = data;
|
|
t.Msg = "成功";
|
|
return t;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据用户ID获取所拥有的角色列表
|
|
/// </summary>
|
|
/// <param name="userID">用户ID</param>
|
|
/// <returns></returns>
|
|
public TableModel<T_SYS_UserRoleModel> GetListByUserID(long userID)
|
|
{
|
|
TableModel<T_SYS_UserRoleModel> t = new TableModel<T_SYS_UserRoleModel>();
|
|
|
|
var listMode = db.Queryable<T_SYS_UserRole, T_SYS_Role>((UserRole, Role) => new object[] {
|
|
JoinType.Left,UserRole.RoleID==Role.ID,
|
|
}).Where((UserRole, Role) => UserRole.UserID == userID && UserRole.DeleteFlag == 0 && Role.DeleteFlag == 0)
|
|
.Select((UserRole, Role) => new T_SYS_UserRoleModel
|
|
{
|
|
GUID = UserRole.GUID.ToString(),
|
|
UserID = UserRole.UserID,
|
|
RoleID = UserRole.RoleID,
|
|
CreatorID = UserRole.CreatorID,
|
|
Creator = UserRole.Creator,
|
|
CreationDate = UserRole.CreationDate,
|
|
EditorID = UserRole.EditorID,
|
|
Editor = UserRole.Editor,
|
|
EditTime = UserRole.EditTime,
|
|
DeleteFlag = UserRole.DeleteFlag,
|
|
RoleName = Role.RoleName.ToString(),
|
|
}).OrderBy((UserRole) => UserRole.RoleID).ToList();
|
|
|
|
t.Code = 0;
|
|
t.TotalNumber = listMode.Count;
|
|
t.Data = listMode;
|
|
t.Msg = "成功";
|
|
return t;
|
|
}
|
|
|
|
public int LogicalDelete(string guid, int deleteFlag)
|
|
{
|
|
return db.Updateable<T_SYS_UserRole>().SetColumns(it => new T_SYS_UserRole() { DeleteFlag = deleteFlag }).Where(it => it.GUID == guid).ExecuteCommand();
|
|
}
|
|
|
|
public bool Update(T_SYS_UserRole userRole)
|
|
{
|
|
return db.Updateable(userRole).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand() == 1 ? true : false;
|
|
}
|
|
}
|
|
}
|