2022-05-05 18:01:29 +08:00
//模板信息:{"Template":{"Language":"C#"}}
2022-05-05 20:18:34 +08:00
//输出信息:{"Extension":".cs","FileName":"DAL\\SYS\\RoleDAL"}
2022-05-05 18:01:29 +08:00
using System ;
using System.Text ;
using System.Linq ;
using System.Collections.Generic ;
using LeadDataBaseUtility ;
2022-05-05 20:18:34 +08:00
namespace CleanMachine.DAL.SYS
2022-05-05 18:01:29 +08:00
{
/// <summary>
///
/// </summary>
public class RoleDAL
{
public RoleDAL ( )
{
}
#region 一 般 方 法
/// <summary>
/// 存在
/// </summary>
2022-05-05 20:18:34 +08:00
public bool Exists ( int RoleId )
2022-05-05 18:01:29 +08:00
{
string strSql = @"SELECT count(1) from SYS_ROLE WHERE ROLE_ID=@RoleId " ;
return LeadDbHelperSQLite . ExecuteScalar < int > ( strSql , new { RoleId } ) > 0 ;
}
/// <summary>
/// 添加一个数据
/// </summary>
2022-05-05 20:18:34 +08:00
public bool Add ( CleanMachine . Model . SYS . Role model )
2022-05-05 18:01:29 +08:00
{
string strSql = $ @ "INSERT INTO SYS_ROLE
( ROLE_ID , ROLE_CODE , ROLE_NAME , ROLE_GRADE , USED_FLAG , DEL_FLAG , CREATE_BY , CREATE_TIME , UPDATE_BY , UPDATE_TIME , DATA_VERSION , REMARKS1 , REMARKS2 , REMARKS3 , REMARKS4 , REMARKS5 )
values
( @RoleId , @RoleCode , @RoleName , @RoleGrade , @UsedFlag , @DelFlag , @CreateBy , @CreateTime , @UpdateBy , @UpdateTime , @DataVersion , @Remarks1 , @Remarks2 , @Remarks3 , @Remarks4 , @Remarks5 ) ";
return LeadDbHelperSQLite . Execute ( strSql , model ) > 0 ;
}
/// <summary>
/// 更新一个数据
/// </summary>
2022-05-05 20:18:34 +08:00
public bool Update ( CleanMachine . Model . SYS . Role model )
2022-05-05 18:01:29 +08:00
{
string strSql = $ @ "UPDATE SYS_ROLE SET
ROLE_CODE = @RoleCode , ROLE_NAME = @RoleName , ROLE_GRADE = @RoleGrade , 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 ROLE_ID = @RoleId ";
return LeadDbHelperSQLite . Execute ( strSql , model ) > 0 ;
}
/// <summary>
/// 删除一个数据
/// </summary>
public bool Delete ( string strWhere , object Params = null )
{
string strSql = $@"DELETE FROM SYS_ROLE " ;
if ( strWhere . Trim ( ) ! = "" )
{
strSql + = $" WHERE {strWhere}" ;
}
return LeadDbHelperSQLite . Execute ( strSql , Params ) > 0 ;
}
/// <summary>
/// 删除一个数据
/// </summary>
2022-05-05 20:18:34 +08:00
public bool Delete ( int RoleId )
2022-05-05 18:01:29 +08:00
{
return this . Delete ( "ROLE_ID=@RoleId " , new { RoleId } ) ;
}
/// <summary>
/// 获得数据列表
/// </summary>
2022-05-05 20:18:34 +08:00
public IEnumerable < CleanMachine . Model . SYS . Role > GetList ( string strWhere , object Params = null )
2022-05-05 18:01:29 +08:00
{
2022-05-06 10:36:42 +08:00
string strSql = $@"SELECT A.ROLE_ID,A.ROLE_CODE,A.ROLE_NAME,B.MENU_ID,C.MENU_CODE,C.MENU_NAME,C.MENU_URL,C.MENU_PID FROM SYS_ROLE A LEFT JOIN SYS_ROLE_MENU_PERMISSION B on A.ROLE_ID = B.ROLE_ID LEFT JOIN SYS_MENU C on B.MENU_ID = C.MENU_ID " ;
2022-05-05 18:01:29 +08:00
if ( strWhere . Trim ( ) ! = "" )
{
strSql + = $" WHERE {strWhere}" ;
}
2022-05-05 20:18:34 +08:00
return LeadDbHelperSQLite . Query < CleanMachine . Model . SYS . Role > ( strSql , Params ) ;
2022-05-05 18:01:29 +08:00
}
/// <summary>
/// 获取一个对象
/// </summary>
2022-05-05 20:18:34 +08:00
public CleanMachine . Model . SYS . Role GetModel ( int RoleId )
2022-05-05 18:01:29 +08:00
{
return this . GetList ( "ROLE_ID=@RoleId" , new { RoleId } ) . FirstOrDefault ( ) ;
}
#endregion
/// <summary>
/// 查询数据
/// </summary>
2022-05-05 20:18:34 +08:00
// public IEnumerable<CleanMachine.Model.SYS.Role> GetModelList(RuleGroup rule)
2022-05-05 18:01:29 +08:00
// {
// var tuper = _dbhelper.BuildRuleGroupStr(rule);
// return this.GetList(tuper.where, tuper.Param);
// }
}
}