2022-05-05 18:01:29 +08:00
|
|
|
|
|
|
|
|
//模板信息:{"Template":{"Language":"C#"}}
|
2022-05-05 20:18:34 +08:00
|
|
|
//输出信息:{"Extension":".cs","FileName":"DAL\\SYS\\UserDAL"}
|
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 UserDAL
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UserDAL()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#region 一般方法
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 存在
|
|
|
|
|
/// </summary>
|
2022-05-05 20:18:34 +08:00
|
|
|
public bool Exists(int UserId)
|
2022-05-05 18:01:29 +08:00
|
|
|
{
|
|
|
|
|
string strSql = @"SELECT count(1) from SYS_USER WHERE USER_ID=@UserId ";
|
|
|
|
|
return LeadDbHelperSQLite.ExecuteScalar<int>(strSql, new { UserId }) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加一个数据
|
|
|
|
|
/// </summary>
|
2022-05-05 20:18:34 +08:00
|
|
|
public bool Add(CleanMachine.Model.SYS.User model)
|
2022-05-05 18:01:29 +08:00
|
|
|
{
|
|
|
|
|
string strSql = $@"INSERT INTO SYS_USER
|
|
|
|
|
(USER_ID,USER_CODE,USER_NAME,PASSWORD,GENDER,ROLE_ID,SCHEDULE_CODE,USED_FLAG,DEL_FLAG,CREATE_BY,CREATE_TIME,UPDATE_BY,UPDATE_TIME,DATA_VERSION,REMARKS1,REMARKS2,REMARKS3,REMARKS4,REMARKS5)
|
|
|
|
|
values
|
|
|
|
|
(@UserId,@UserCode,@UserName,@Password,@Gender,@RoleId,@ScheduleCode,@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.User model)
|
2022-05-05 18:01:29 +08:00
|
|
|
{
|
|
|
|
|
string strSql = $@"UPDATE SYS_USER SET
|
|
|
|
|
USER_CODE=@UserCode,USER_NAME=@UserName,PASSWORD=@Password,GENDER=@Gender,ROLE_ID=@RoleId,SCHEDULE_CODE=@ScheduleCode,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 USER_ID=@UserId ";
|
|
|
|
|
return LeadDbHelperSQLite.Execute(strSql, model) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除一个数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Delete(string strWhere, object Params = null)
|
|
|
|
|
{
|
|
|
|
|
string strSql = $@"DELETE FROM SYS_USER ";
|
|
|
|
|
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 UserId)
|
2022-05-05 18:01:29 +08:00
|
|
|
{
|
|
|
|
|
return this.Delete("USER_ID=@UserId ", new { UserId }) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获得数据列表
|
|
|
|
|
/// </summary>
|
2022-05-05 20:18:34 +08:00
|
|
|
public IEnumerable<CleanMachine.Model.SYS.User> GetList(string strWhere, object Params = null)
|
2022-05-05 18:01:29 +08:00
|
|
|
{
|
|
|
|
|
string strSql = $@"SELECT * FROM SYS_USER ";
|
|
|
|
|
if (strWhere.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
strSql += $" WHERE {strWhere}";
|
|
|
|
|
}
|
2022-05-05 20:18:34 +08:00
|
|
|
return LeadDbHelperSQLite.Query<CleanMachine.Model.SYS.User>(strSql, Params);
|
2022-05-05 18:01:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取一个对象
|
|
|
|
|
/// </summary>
|
2022-05-05 20:18:34 +08:00
|
|
|
public CleanMachine.Model.SYS.User GetModel(int UserId)
|
2022-05-05 18:01:29 +08:00
|
|
|
{
|
|
|
|
|
return this.GetList("USER_ID=@UserId", new { UserId }).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2022-05-05 20:18:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除一个数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Delete(string UserCode)
|
|
|
|
|
{
|
|
|
|
|
return this.Delete("USER_CODE=@UserCode ", new { UserCode }) ;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取一个对象
|
|
|
|
|
/// </summary>
|
|
|
|
|
public CleanMachine.Model.SYS.User GetModel(string UserCode)
|
|
|
|
|
{
|
|
|
|
|
return this.GetList("USER_CODE=@UserCode", new { UserCode }).QueryFirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Exists(string UserCode)
|
|
|
|
|
{
|
|
|
|
|
string strSql = @"SELECT count(1) from SYS_USER WHERE USER_CODE=@UserCode ";
|
|
|
|
|
return LeadDbHelperSQLite.ExecuteScalar<int>(strSql, new { UserCode }) > 0;
|
|
|
|
|
}
|
2022-05-05 18:01:29 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询数据
|
|
|
|
|
/// </summary>
|
2022-05-05 20:18:34 +08:00
|
|
|
// public IEnumerable<CleanMachine.Model.SYS.User> GetModelList(RuleGroup rule)
|
2022-05-05 18:01:29 +08:00
|
|
|
// {
|
|
|
|
|
// var tuper = _dbhelper.BuildRuleGroupStr(rule);
|
|
|
|
|
// return this.GetList(tuper.where, tuper.Param);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|