113 lines
3.7 KiB
C#
113 lines
3.7 KiB
C#
|
|
|
||
|
|
//模板信息:{"Template":{"Language":"C#"}}
|
||
|
|
//输出信息:{"Extension":".cs","FileName":"DAL\\MenuDAL"}
|
||
|
|
using System;
|
||
|
|
using System.Text;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
|
||
|
|
using LeadDataBaseUtility;
|
||
|
|
|
||
|
|
namespace CleanMachine.DAL
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
///
|
||
|
|
/// </summary>
|
||
|
|
public class MenuDAL
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
public MenuDAL()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
#region 一般方法
|
||
|
|
/// <summary>
|
||
|
|
/// 存在
|
||
|
|
/// </summary>
|
||
|
|
public bool Exists(string MenuId)
|
||
|
|
{
|
||
|
|
string strSql = @"SELECT count(1) from SYS_MENU WHERE MENU_ID=@MenuId ";
|
||
|
|
return LeadDbHelperSQLite.ExecuteScalar<int>(strSql, new { MenuId }) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 添加一个数据
|
||
|
|
/// </summary>
|
||
|
|
public bool Add(CleanMachine.Model.Menu model)
|
||
|
|
{
|
||
|
|
string strSql = $@"INSERT INTO SYS_MENU
|
||
|
|
(MENU_ID,MENU_CODE,MENU_NAME,MENU_URL,MENU_PID,MENU_ORDER,USED_FLAG,DEL_FLAG,CREATE_BY,CREATE_TIME,UPDATE_BY,UPDATE_TIME,DATA_VERSION,REMARKS1,REMARKS2,REMARKS3,REMARKS4,REMARKS5)
|
||
|
|
values
|
||
|
|
(@MenuId,@MenuCode,@MenuName,@MenuUrl,@MenuPid,@MenuOrder,@UsedFlag,@DelFlag,@CreateBy,@CreateTime,@UpdateBy,@UpdateTime,@DataVersion,@Remarks1,@Remarks2,@Remarks3,@Remarks4,@Remarks5) ";
|
||
|
|
return LeadDbHelperSQLite.Execute(strSql, model) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 更新一个数据
|
||
|
|
/// </summary>
|
||
|
|
public bool Update(CleanMachine.Model.Menu model)
|
||
|
|
{
|
||
|
|
string strSql = $@"UPDATE SYS_MENU SET
|
||
|
|
MENU_CODE=@MenuCode,MENU_NAME=@MenuName,MENU_URL=@MenuUrl,MENU_PID=@MenuPid,MENU_ORDER=@MenuOrder,USED_FLAG=@UsedFlag,DEL_FLAG=@DelFlag,CREATE_BY=@CreateBy,CREATE_TIME=@CreateTime,UPDATE_BY=@UpdateBy,UPDATE_TIME=@UpdateTime,DATA_VERSION=@DataVersion,REMARKS1=@Remarks1,REMARKS2=@Remarks2,REMARKS3=@Remarks3,REMARKS4=@Remarks4,REMARKS5=@Remarks5
|
||
|
|
WHERE MENU_ID=@MenuId ";
|
||
|
|
return LeadDbHelperSQLite.Execute(strSql, model) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 删除一个数据
|
||
|
|
/// </summary>
|
||
|
|
public bool Delete(string strWhere, object Params = null)
|
||
|
|
{
|
||
|
|
string strSql = $@"DELETE FROM SYS_MENU ";
|
||
|
|
if (strWhere.Trim() != "")
|
||
|
|
{
|
||
|
|
strSql += $" WHERE {strWhere}";
|
||
|
|
}
|
||
|
|
return LeadDbHelperSQLite.Execute(strSql, Params) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 删除一个数据
|
||
|
|
/// </summary>
|
||
|
|
public bool Delete(string MenuId)
|
||
|
|
{
|
||
|
|
return this.Delete("MENU_ID=@MenuId ", new { MenuId }) ;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 获得数据列表
|
||
|
|
/// </summary>
|
||
|
|
public IEnumerable<CleanMachine.Model.Menu> GetList(string strWhere, object Params = null)
|
||
|
|
{
|
||
|
|
string strSql = $@"SELECT * FROM SYS_MENU ";
|
||
|
|
if (strWhere.Trim() != "")
|
||
|
|
{
|
||
|
|
strSql += $" WHERE {strWhere}";
|
||
|
|
}
|
||
|
|
return LeadDbHelperSQLite.Query<CleanMachine.Model.Menu>(strSql, Params);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 获取一个对象
|
||
|
|
/// </summary>
|
||
|
|
public CleanMachine.Model.Menu GetModel(string MenuId)
|
||
|
|
{
|
||
|
|
return this.GetList("MENU_ID=@MenuId", new { MenuId }).FirstOrDefault();
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 查询数据
|
||
|
|
/// </summary>
|
||
|
|
// public IEnumerable<CleanMachine.Model.Menu> GetModelList(RuleGroup rule)
|
||
|
|
// {
|
||
|
|
// var tuper = _dbhelper.BuildRuleGroupStr(rule);
|
||
|
|
// return this.GetList(tuper.where, tuper.Param);
|
||
|
|
// }
|
||
|
|
}
|
||
|
|
}
|