CeramicProjectTool/Util/DBHelper.Service.cs

80 lines
2.4 KiB
C#
Raw Normal View History

using CeramicProjectTool.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CeramicProjectTool.Util
{
public static partial class DBHelper
{
public static bool Login(string userName, string pwd)
{
var sql = $"select top 1 1 from nr_z_yhzh where zhanghao=@userName and mima=@pwd";
var result = _db.Ado.GetInt(sql, new { userName, pwd });
if (result >= 1)
{
return true;
}
else
{
return false;
}
}
public static async Task<List<ModuleModel>> GetModuleList()
{
var result = await _db.Queryable<ModuleModel>().ToListAsync();
return result;
}
public static async Task<ModuleModel> Getodule(int id)
{
var result = await _db.Queryable<ModuleModel>().Where(i => i.Id == id).FirstAsync();
return result;
}
public static async Task UpdateModule(ModuleModel module)
{
await _db.Updateable<ModuleModel>(module).ExecuteCommandAsync();
}
public static async Task<List<PermissonModel>> GetPermissons()
{
var result = await _db.Queryable<PermissonModel>().ToListAsync();
return result;
}
public static async Task<List<PermissonModel>> GetPermissonsByModule(string moduleName)
{
var result = await _db.Queryable<PermissonModel>().Where(x => x.ModuleName == moduleName).ToListAsync();
return result;
}
public static async Task UpdatePermissons(List<PermissonModel> permissons)
{
var ids = permissons.Select(x => x.Id).ToList();
try
{
_db.BeginTran();
//await _db.Deleteable<PermissonModel>().Where(x => !ids.Contains(x.Id)).ExecuteCommandAsync();
await _db.Updateable(permissons).ExecuteCommandAsync();
_db.CommitTran();
}
catch (Exception)
{
_db.RollbackTran();
throw;
}
}
public static async Task<List<RuleModel>> GetRules()
{
var result = await _db.Queryable<RuleModel>().ToListAsync();
return result;
}
}
}