64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
using Cowain.Bake.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Unity;
|
|
|
|
namespace Cowain.Bake.BLL
|
|
{
|
|
public class MenuInfoService : ServiceBase
|
|
{
|
|
public MenuInfoService(IUnityContainer unityContainer) : base(unityContainer)
|
|
{
|
|
|
|
}
|
|
|
|
public List<TMenuInfo> GetBaseMenuInfo()
|
|
{
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
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 BakingEntities())
|
|
{
|
|
return Context.Set<TMenuInfo>().Where(x=>x.State == true).OrderBy(x => x.Id).ThenBy(x => x.ParentId).ToList();
|
|
}
|
|
}
|
|
|
|
public DataTable GetImage()
|
|
{
|
|
string sql = $@"SELECT ti.Header,CAST(MenuImage AS char) MenuImage FROM TMenuInfo ti
|
|
WHERE ParentId>0";
|
|
return GetDataTable(sql);
|
|
}
|
|
|
|
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 BakingEntities())
|
|
{
|
|
return Context.Database.SqlQuery<int>(sql).FirstOrDefault();
|
|
}
|
|
}
|
|
}
|
|
}
|