117 lines
3.4 KiB
C#
117 lines
3.4 KiB
C#
using CeramicProjectTool.Model;
|
|
using CeramicProjectTool.Model.ResultModel;
|
|
using CeramicProjectTool.Util;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CeramicProjectTool.ViewModel
|
|
{
|
|
public class PermissonConfigViewModel : INotifyPropertyChanged
|
|
{
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
public void OnPropertyChanged(string propertyName)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
|
|
public ModuleModel selectMudole;
|
|
public RuleModel selectRule;
|
|
|
|
public bool isSelectAll = false;
|
|
|
|
public List<RulePermissonResult>? rulePermissons;
|
|
public Task<List<PermissonModel>> GetPermissons()
|
|
{
|
|
var result = DBHelper.GetPermissons();
|
|
return result;
|
|
}
|
|
public Task<List<PermissonModel>> GetPermissons(string searchText)
|
|
{
|
|
var result = DBHelper.GetPermissonsByModule(searchText);
|
|
return result;
|
|
}
|
|
|
|
public Task<List<RuleModel>> GetRules()
|
|
{
|
|
var result = DBHelper.GetRules();
|
|
return result;
|
|
}
|
|
|
|
public async Task<List<RulePermissonResult>> GetPermissonsByRule(string ruleName, string moduleName)
|
|
{
|
|
var result = await DBHelper.GetPermissonsByRule(ruleName, moduleName);
|
|
return result;
|
|
}
|
|
|
|
public Task<List<ModuleModel>> GetMkList()
|
|
{
|
|
Task<List<ModuleModel>> modelList = DBHelper.GetModuleList();
|
|
|
|
return modelList;
|
|
//modelList.ContinueWith((task) =>
|
|
//{
|
|
// ModelListView.Dispatcher.Invoke(() =>
|
|
// {
|
|
// ModelListView.ItemsSource = task.Result;
|
|
// });
|
|
//});
|
|
}
|
|
|
|
internal void UpdateRulePermisson(List<RulePermissonModel> rulePermisson)
|
|
{
|
|
var _db = DBHelper.Db;
|
|
|
|
try
|
|
{
|
|
_db.Ado.BeginTran();
|
|
//_db.Deleteable<RulePermissonModel>().Where(x => x.RuleId == rulePermisson[0].RuleId).ExecuteCommand();
|
|
_db.Insertable(rulePermisson).ExecuteCommand();
|
|
_db.Ado.CommitTran();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_db.Ado.RollbackTran();
|
|
throw ex;
|
|
}
|
|
}
|
|
internal void DeleteRulePermisson(List<int> rulePermissonId)
|
|
{
|
|
var _db = DBHelper.Db;
|
|
|
|
try
|
|
{
|
|
_db.Ado.BeginTran();
|
|
_db.Deleteable<RulePermissonModel>().Where(x => rulePermissonId.Contains(x.Id)).ExecuteCommand();
|
|
//_db.Insertable(rulePermisson).ExecuteCommand();
|
|
_db.Ado.CommitTran();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_db.Ado.RollbackTran();
|
|
throw ex;
|
|
}
|
|
}
|
|
internal bool CheckPermissonExist(string featureName)
|
|
{
|
|
bool isExist = false;
|
|
//rulePermissons.ForEach(item =>
|
|
foreach (var item in rulePermissons)
|
|
{
|
|
if (item.FeatureName == featureName)
|
|
{
|
|
isExist = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return isExist;
|
|
}
|
|
}
|
|
}
|