using Bowin.Common.Utility; using YLShipBuildLandMap.Entity; using YLShipBuildLandMap.Entity.ViewModel.SystemSetting; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace YLShipBuildLandMap.Services.SystemSetting { public class FunctionCodeService : IFunctionCodeService { private YLShipBuildLandMapContext DbContext { get; set; } public FunctionCodeService(YLShipBuildLandMapContext dbContext) { DbContext = dbContext; } public List GetUserFunctionCodes(Guid userID) { var sql = (from u in DbContext.SysUser.Where(x => x.UserId == userID) from r in u.SysUserSysRole from rf in r.Role.SysRoleSysFunctionCode select rf.FunctionCode).Distinct(); return sql.ToList(); } public List GetFunctionCodeList() { var sql = (from f in DbContext.SysFunctionCode select new FunctionCodeView { FunctionCode = f.FunctionCode, FunctionName = f.FunctionName, ParentFunctionCode = f.ParentFunctionCode ?? "", OrderNo = f.OrderNo }); return sql.OrderBy(x => x.OrderNo).ToList(); } public List GetRoleFunctionCode(Guid roleID) { var sql = (from rf in DbContext.SysRoleSysFunctionCode.Where(x => x.RoleId == roleID) select rf.FunctionCode); return sql.ToList(); } } }