54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
|
|
using Cowain.Preheat.Model;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Data;
|
||
|
|
using System.Linq;
|
||
|
|
using Unity;
|
||
|
|
|
||
|
|
namespace Cowain.Preheat.BLL
|
||
|
|
{
|
||
|
|
public class MenuInfoService : ServiceBase
|
||
|
|
{
|
||
|
|
public MenuInfoService(IUnityContainer unityContainer) : base(unityContainer)
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<TMenuInfo> GetBaseMenuInfo()
|
||
|
|
{
|
||
|
|
using (var Context = new PreheatEntities())
|
||
|
|
{
|
||
|
|
return Context.Set<TMenuInfo>().Where(x => x.ParentId == 0).OrderBy(x => x.MenuIndex).ToList();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public DataTable GetLabelName(string MethodName)
|
||
|
|
{
|
||
|
|
string sql = $@"SELECT ti.Header,ti.JSON->>'$.Value0' Value0,ti.JSON->>'$.Value1' Value1
|
||
|
|
FROM TMenuInfo ti
|
||
|
|
WHERE ti.MenuType=2 and ti.JSON->>'$.CMD'='{MethodName}';";
|
||
|
|
return GetDataTable(sql);
|
||
|
|
}
|
||
|
|
public List<TMenuInfo> GetMenuInfoList()
|
||
|
|
{
|
||
|
|
using (var Context = new PreheatEntities())
|
||
|
|
{
|
||
|
|
return Context.Set<TMenuInfo>().OrderBy(x => x.Id).ThenBy(x => x.ParentId).ToList();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public int GetMenuParam(string menuName)
|
||
|
|
{
|
||
|
|
string sql = $@"SELECT ifnull(ts.ParamValue,-1) ParaValue FROM TSysSetup ts
|
||
|
|
WHERE ts.ParamCode=(
|
||
|
|
SELECT IF(LENGTH(JSON)>4,JSON->>'$.CMD','') ParaID
|
||
|
|
FROM TMenuInfo
|
||
|
|
WHERE MenuType=2 AND Header='{menuName}');";
|
||
|
|
|
||
|
|
using (var Context = new PreheatEntities())
|
||
|
|
{
|
||
|
|
return Context.Database.SqlQuery<int>(sql).FirstOrDefault();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|