merge master
This commit is contained in:
commit
b1eb89892a
@ -131,6 +131,7 @@ Vue版前端技术栈 :基于vue、vuex、vue-router 、vue-cli 、axios 和 e
|
||||
- 👉Ruoyi.vue:[Ruoyi](http://www.ruoyi.vip/)
|
||||
- 👉SqlSugar:[SqlSugar](https://gitee.com/dotnetchina/SqlSugar)
|
||||
- 👉vue-element-admin:[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
|
||||
- 👉Meiam.System:[Meiam.System](https://github.com/91270/Meiam.System)
|
||||
|
||||
## 🎀捐赠
|
||||
如果这个项目对您有所帮助,请扫下方二维码就当打发要饭的吧。
|
||||
@ -143,4 +144,5 @@ Vue版前端技术栈 :基于vue、vuex、vue-router 、vue-cli 、axios 和 e
|
||||
|
||||
## 源码地址
|
||||
- [Gitee](https://gitee.com/izory/ZrAdminNetCore/)
|
||||
- [Github](https://github.com/izhaorui/ZrAdmin.NET/)
|
||||
- [Github](https://github.com/izhaorui/ZrAdmin.NET/)
|
||||
- [NET6版本](https://gitee.com/izory/ZrAdminNetCore/tree/net6.0/)
|
||||
@ -20,26 +20,21 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
[Route("system/user")]
|
||||
public class SysUserController : BaseController
|
||||
{
|
||||
private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly ISysUserService UserService;
|
||||
private readonly ISysRoleService RoleService;
|
||||
private readonly ISysPostService PostService;
|
||||
private readonly ISysUserPostService UserPostService;
|
||||
private IWebHostEnvironment WebHostEnvironment;
|
||||
|
||||
public SysUserController(
|
||||
ISysUserService userService,
|
||||
ISysRoleService roleService,
|
||||
ISysPostService postService,
|
||||
ISysUserPostService userPostService,
|
||||
IWebHostEnvironment HostEnvironment)
|
||||
ISysUserPostService userPostService)
|
||||
{
|
||||
UserService = userService;
|
||||
RoleService = roleService;
|
||||
PostService = postService;
|
||||
UserPostService = userPostService;
|
||||
WebHostEnvironment = HostEnvironment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -50,11 +50,11 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
#region db0
|
||||
db.GetConnection(0).Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
var param = DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value));
|
||||
var param = db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value));
|
||||
|
||||
FilterData();
|
||||
FilterData(db.GetConnection(0));
|
||||
|
||||
logger.Info($"{sql},{param}");
|
||||
logger.Info($"【sql语句】{sql},{param}");
|
||||
};
|
||||
|
||||
db.GetConnection(0).Aop.OnError = (e) =>
|
||||
@ -74,7 +74,7 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
{
|
||||
var param = DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value));
|
||||
|
||||
logger.Info($"Sql语句:{sql}, {param}");
|
||||
logger.Info($"【sql语句】{sql}, {param}");
|
||||
};
|
||||
//Db1错误日志
|
||||
db.GetConnection(1).Aop.OnError = (e) =>
|
||||
@ -88,7 +88,7 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
/// <summary>
|
||||
/// 分页获取count 不会追加sql
|
||||
/// </summary>
|
||||
private static void FilterData()
|
||||
private static void FilterData(ISqlSugarClient sqlSugarClient)
|
||||
{
|
||||
var u = App.User;
|
||||
if (u == null) return;
|
||||
@ -119,8 +119,7 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
var exp = Expressionable.Create<SysDept>();
|
||||
exp.Or(it => it.DeptId == user.DeptId);
|
||||
var filter1 = new TableFilterItem<SysDept>(exp.ToExpression());
|
||||
DbScoped.SugarScope.GetConnection(0).QueryFilter.Add(filter1);
|
||||
Console.WriteLine("本部门数据过滤");
|
||||
sqlSugarClient.QueryFilter.Add(filter1);
|
||||
}
|
||||
else if (DATA_SCOPE_DEPT_AND_CHILD.Equals(dataScope))//本部门及以下数据
|
||||
{
|
||||
@ -128,8 +127,8 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
}
|
||||
else if (DATA_SCOPE_SELF.Equals(dataScope))//仅本人数据
|
||||
{
|
||||
var filter1 = new TableFilterItem<SysUser>(it => it.UserId == user.UserId);
|
||||
DbScoped.SugarScope.GetConnection(0).QueryFilter.Add(filter1);
|
||||
var filter1 = new TableFilterItem<SysUser>(it => it.UserId == user.UserId, true);
|
||||
sqlSugarClient.QueryFilter.Add(filter1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
<PackageReference Include="NLog" Version="5.0.0-rc2" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.14.0" />
|
||||
<PackageReference Include="Mapster" Version="7.3.0" />
|
||||
<PackageReference Include="SqlSugar.IOC" Version="1.7.0" />
|
||||
<PackageReference Include="EPPlus" Version="5.8.6" />
|
||||
<PackageReference Include="Hei.Captcha" Version="0.3.0" />
|
||||
<PackageReference Include="Snowflake.Core" Version="2.0.0" />
|
||||
|
||||
@ -21,7 +21,7 @@ namespace ${options.ServicesNamespace}.${options.SubNamespace}
|
||||
public class ${replaceDto.ModelTypeName}Service : BaseService<${replaceDto.ModelTypeName}>, I${replaceDto.ModelTypeName}Service
|
||||
{
|
||||
private readonly ${replaceDto.ModelTypeName}Repository _${replaceDto.ModelTypeName}repository;
|
||||
public ${replaceDto.ModelTypeName}Service(${replaceDto.ModelTypeName}Repository repository) : base(repository)
|
||||
public ${replaceDto.ModelTypeName}Service(${replaceDto.ModelTypeName}Repository repository)
|
||||
{
|
||||
_${replaceDto.ModelTypeName}repository = repository;
|
||||
}
|
||||
|
||||
@ -11,11 +11,9 @@
|
||||
</el-form>
|
||||
<!-- 工具区域 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
$if(replaceDto.ShowBtnExport)
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['${replaceDto.PermissionPrefix}:export']">导出</el-button>
|
||||
</el-col>
|
||||
$end
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
@ -59,9 +57,7 @@ $end
|
||||
import {
|
||||
list${genTable.BusinessName},
|
||||
get${genTable.BusinessName},
|
||||
$if(replaceDto.ShowBtnExport)
|
||||
export${genTable.BusinessName},
|
||||
$end
|
||||
} from '@/api/${tool.FirstLowerCase(genTable.ModuleName)}/${tool.FirstLowerCase(genTable.BusinessName)}.js';
|
||||
|
||||
export default {
|
||||
|
||||
@ -12,6 +12,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JinianNet.JNTemplate" Version="2.2.5" />
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.5.4" />
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.6" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EPPlus" Version="5.8.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.5.4" />
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.6" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -15,16 +15,17 @@ namespace ZR.Repository
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class BaseRepository<T> : IBaseRepository<T> where T : class, new()
|
||||
public class BaseRepository<T> : SimpleClient<T> where T : class, new()
|
||||
{
|
||||
public ISqlSugarClient Context;
|
||||
|
||||
public BaseRepository(ISqlSugarClient client = null)
|
||||
public ITenant itenant = null;//多租户事务
|
||||
public BaseRepository(ISqlSugarClient client = null) : base(client)
|
||||
{
|
||||
//通过特性拿到ConfigId
|
||||
var configId = typeof(T).GetCustomAttribute<TenantAttribute>()?.configId;
|
||||
if(configId != null)
|
||||
if (configId != null)
|
||||
{
|
||||
Context = DbScoped.SugarScope.GetConnection(configId);
|
||||
itenant = DbScoped.SugarScope;//设置租户接口
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -53,10 +54,10 @@ namespace ZR.Repository
|
||||
{
|
||||
return Context.Insertable(t).ExecuteCommand();
|
||||
}
|
||||
public long InsertReturnBigIdentity(T t)
|
||||
{
|
||||
return Context.Insertable(t).ExecuteReturnBigIdentity();
|
||||
}
|
||||
//public long InsertReturnBigIdentity(T t)
|
||||
//{
|
||||
// return Context.Insertable(t).ExecuteReturnBigIdentity();
|
||||
//}
|
||||
|
||||
//public int InsertIgnoreNullColumn(List<T> t)
|
||||
//{
|
||||
@ -194,14 +195,38 @@ namespace ZR.Repository
|
||||
|
||||
public DbResult<bool> UseTran(Action action)
|
||||
{
|
||||
var result = Context.Ado.UseTran(() => action());
|
||||
return result;
|
||||
try
|
||||
{
|
||||
var result = Context.Ado.UseTran(() => action());
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
Console.WriteLine(ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="action">增删改查方法</param>
|
||||
/// <returns></returns>
|
||||
public DbResult<bool> UseTran(SqlSugarClient client, Action action)
|
||||
{
|
||||
var result = client.Ado.UseTran(() => action());
|
||||
return result;
|
||||
try
|
||||
{
|
||||
var result = client.AsTenant().UseTran(() => action());
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
client.AsTenant().RollbackTran();
|
||||
Console.WriteLine(ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseTran2(Action action)
|
||||
@ -216,16 +241,6 @@ namespace ZR.Repository
|
||||
return Context.Deleteable<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除表达式
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
public int Delete(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
return Context.Deleteable<T>().Where(expression).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
@ -258,32 +273,6 @@ namespace ZR.Repository
|
||||
return Context.Queryable<T>();
|
||||
}
|
||||
|
||||
//public ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName)
|
||||
//{
|
||||
// return Context.Queryable(tableName, shortName);
|
||||
//}
|
||||
|
||||
public List<T> GetList(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
return Context.Queryable<T>().Where(expression).ToList();
|
||||
}
|
||||
|
||||
//public Task<List<T>> QueryableToListAsync(Expression<Func<T, bool>> expression)
|
||||
//{
|
||||
// return Context.Queryable<T>().Where(expression).ToListAsync();
|
||||
//}
|
||||
|
||||
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
||||
//{
|
||||
// var query = base.Context.Queryable<T>().Select(select).Where(expressionWhere).ToList();
|
||||
// return query.JilToJson();
|
||||
//}
|
||||
|
||||
//public List<T> QueryableToList(string tableName)
|
||||
//{
|
||||
// return Context.Queryable<T>(tableName).ToList();
|
||||
//}
|
||||
|
||||
public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10)
|
||||
{
|
||||
int totalNumber = 0;
|
||||
@ -318,15 +307,6 @@ namespace ZR.Repository
|
||||
{
|
||||
return Context.Ado.SqlQuery<T>(sql, obj);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
/// <param name="where">Expression<Func<T, bool>></param>
|
||||
/// <returns></returns>
|
||||
public T GetFirst(Expression<Func<T, bool>> where)
|
||||
{
|
||||
return Context.Queryable<T>().Where(where).First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主值查询单条数据
|
||||
@ -371,10 +351,6 @@ namespace ZR.Repository
|
||||
return Context.Queryable<T>().WithCacheIF(useCache, cacheSecond).ToList();
|
||||
}
|
||||
|
||||
public int Count(Expression<Func<T, bool>> where)
|
||||
{
|
||||
return Context.Queryable<T>().Count(where);
|
||||
}
|
||||
#endregion query
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,44 +1,20 @@
|
||||
using Infrastructure.Model;
|
||||
using SqlSugar;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model;
|
||||
|
||||
namespace ZR.Repository
|
||||
{
|
||||
public interface IBaseRepository<T> where T : class, new()
|
||||
public interface IBaseRepository<T> : ISimpleClient<T> where T : class, new()
|
||||
{
|
||||
#region add
|
||||
int Add(T t);
|
||||
|
||||
//int Insert(SqlSugarClient client, T t);
|
||||
|
||||
int Insert(List<T> t);
|
||||
int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
|
||||
|
||||
//int InsertIgnoreNullColumn(List<T> t);
|
||||
|
||||
//int InsertIgnoreNullColumn(List<T> t, params string[] columns);
|
||||
|
||||
//DbResult<bool> InsertTran(T t);
|
||||
|
||||
//DbResult<bool> InsertTran(List<T> t);
|
||||
long InsertReturnBigIdentity(T t);
|
||||
//T InsertReturnEntity(T t);
|
||||
|
||||
//T InsertReturnEntity(T t, string sqlWith = SqlWith.UpdLock);
|
||||
|
||||
//bool ExecuteCommand(string sql, object parameters);
|
||||
|
||||
//bool ExecuteCommand(string sql, params SugarParameter[] parameters);
|
||||
|
||||
//bool ExecuteCommand(string sql, List<SugarParameter> parameters);
|
||||
IInsertable<T> Insertable(T t);
|
||||
#endregion add
|
||||
|
||||
@ -70,7 +46,6 @@ namespace ZR.Repository
|
||||
|
||||
#region delete
|
||||
IDeleteable<T> Deleteable();
|
||||
int Delete(Expression<Func<T, bool>> expression);
|
||||
int Delete(object[] obj);
|
||||
int Delete(object id);
|
||||
int DeleteTable();
|
||||
@ -88,24 +63,12 @@ namespace ZR.Repository
|
||||
|
||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, OrderByType orderEnum = OrderByType.Asc);
|
||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderByType);
|
||||
|
||||
|
||||
bool Any(Expression<Func<T, bool>> expression);
|
||||
|
||||
ISugarQueryable<T> Queryable();
|
||||
List<T> GetAll(bool useCache = false, int cacheSecond = 3600);
|
||||
|
||||
//ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName);
|
||||
|
||||
//ISugarQueryable<T, T1, T2> Queryable<T1, T2>() where T1 : class where T2 : new();
|
||||
|
||||
List<T> GetList(Expression<Func<T, bool>> expression);
|
||||
|
||||
//Task<List<T>> QueryableToListAsync(Expression<Func<T, bool>> expression);
|
||||
|
||||
//string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere);
|
||||
|
||||
//List<T> QueryableToList(string tableName);
|
||||
|
||||
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10);
|
||||
@ -113,23 +76,9 @@ namespace ZR.Repository
|
||||
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
List<T> SqlQueryToList(string sql, object obj = null);
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
/// <param name="where">Expression<Func<T, bool>></param>
|
||||
/// <returns></returns>
|
||||
T GetFirst(Expression<Func<T, bool>> where);
|
||||
|
||||
T GetId(object pkValue);
|
||||
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
/// <param name="parm">string</param>
|
||||
/// <returns></returns>
|
||||
//T GetFirst(string parm);
|
||||
|
||||
int Count(Expression<Func<T, bool>> where);
|
||||
|
||||
#endregion query
|
||||
|
||||
#region Procedure
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MySql.Data" Version="8.0.25" />
|
||||
<PackageReference Include="NETCore.Encrypt" Version="2.1.0" />
|
||||
<PackageReference Include="SqlSugar.IOC" Version="1.7.0" />
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.5.4" />
|
||||
<PackageReference Include="SqlSugar.IOC" Version="1.8.0" />
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,12 +1,4 @@
|
||||
using Infrastructure.Model;
|
||||
using SqlSugar;
|
||||
using SqlSugar.IOC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq.Expressions;
|
||||
using ZR.Model;
|
||||
using ZR.Repository;
|
||||
using ZR.Repository;
|
||||
|
||||
namespace ZR.Service
|
||||
{
|
||||
@ -14,393 +6,13 @@ namespace ZR.Service
|
||||
/// 基础服务定义
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class BaseService<T> : IBaseService<T> where T : class, new()
|
||||
public class BaseService<T> : BaseRepository<T> where T : class, new()
|
||||
{
|
||||
public IBaseRepository<T> baseRepository;
|
||||
//public IBaseRepository<T> baseRepository;
|
||||
|
||||
public BaseService(IBaseRepository<T> repository)
|
||||
{
|
||||
this.baseRepository = repository ?? throw new ArgumentNullException(nameof(repository));
|
||||
}
|
||||
#region add
|
||||
/// <summary>
|
||||
/// 插入指定列使用
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <param name="iClumns"></param>
|
||||
/// <param name="ignoreNull"></param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
|
||||
{
|
||||
return baseRepository.Insert(parm, iClumns, ignoreNull);
|
||||
}
|
||||
/// <summary>
|
||||
/// 插入实体
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public int Add(T t)
|
||||
{
|
||||
return baseRepository.Add(t);
|
||||
}
|
||||
public IInsertable<T> Insertable(T t)
|
||||
{
|
||||
return baseRepository.Insertable(t);
|
||||
}
|
||||
//public int Insert(SqlSugarClient client, T t)
|
||||
//public BaseService(IBaseRepository<T> repository)
|
||||
//{
|
||||
// return client.Insertable(t).ExecuteCommand();
|
||||
//}
|
||||
|
||||
//public long InsertBigIdentity(T t)
|
||||
//{
|
||||
// return base.Context.Insertable(t).ExecuteReturnBigIdentity();
|
||||
//}
|
||||
|
||||
public int Insert(List<T> t)
|
||||
{
|
||||
return baseRepository.Insert(t);
|
||||
}
|
||||
public long InsertReturnBigIdentity(T t)
|
||||
{
|
||||
return baseRepository.InsertReturnBigIdentity(t);
|
||||
}
|
||||
|
||||
//public int InsertIgnoreNullColumn(List<T> t)
|
||||
//{
|
||||
// return base.Context.Insertable(t).IgnoreColumns(true).ExecuteCommand();
|
||||
//}
|
||||
|
||||
//public int InsertIgnoreNullColumn(List<T> t, params string[] columns)
|
||||
//{
|
||||
// return base.Context.Insertable(t).IgnoreColumns(columns).ExecuteCommand();
|
||||
//}
|
||||
//public DbResult<bool> InsertTran(T t)
|
||||
//{
|
||||
// var result = base.Context.Ado.UseTran(() =>
|
||||
// {
|
||||
// base.Context.Insertable(t).ExecuteCommand();
|
||||
// });
|
||||
// return result;
|
||||
//}
|
||||
|
||||
//public DbResult<bool> InsertTran(List<T> t)
|
||||
//{
|
||||
// var result = base.Context.Ado.UseTran(() =>
|
||||
// {
|
||||
// base.Context.Insertable(t).ExecuteCommand();
|
||||
// });
|
||||
// return result;
|
||||
//}
|
||||
|
||||
//public T InsertReturnEntity(T t)
|
||||
//{
|
||||
// return base.Context.Insertable(t).ExecuteReturnEntity();
|
||||
//}
|
||||
|
||||
//public T InsertReturnEntity(T t, string sqlWith = SqlWith.UpdLock)
|
||||
//{
|
||||
// return base.Context.Insertable(t).With(sqlWith).ExecuteReturnEntity();
|
||||
//}
|
||||
|
||||
//public bool ExecuteCommand(string sql, object parameters)
|
||||
//{
|
||||
// return base.Context.Ado.ExecuteCommand(sql, parameters) > 0;
|
||||
//}
|
||||
|
||||
//public bool ExecuteCommand(string sql, params SugarParameter[] parameters)
|
||||
//{
|
||||
// return base.Context.Ado.ExecuteCommand(sql, parameters) > 0;
|
||||
//}
|
||||
|
||||
//public bool ExecuteCommand(string sql, List<SugarParameter> parameters)
|
||||
//{
|
||||
// return base.Context.Ado.ExecuteCommand(sql, parameters) > 0;
|
||||
//}
|
||||
|
||||
#endregion add
|
||||
|
||||
#region update
|
||||
|
||||
public int Update(T entity, bool ignoreNullColumns = false)
|
||||
{
|
||||
return baseRepository.Update(entity, ignoreNullColumns);
|
||||
}
|
||||
|
||||
public int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
|
||||
{
|
||||
return baseRepository.Update(entity, expression, ignoreAllNull);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据实体类更新 eg:Update(dept, it => new { it.Status }, f => depts.Contains(f.DeptId));只更新Status列,条件是包含
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <param name="where"></param>
|
||||
/// <returns></returns>
|
||||
public int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
{
|
||||
return baseRepository.Update(entity, expression, where);
|
||||
}
|
||||
|
||||
public int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
{
|
||||
return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="entity"></param>
|
||||
///// <param name="list"></param>
|
||||
///// <param name="isNull">默认为true</param>
|
||||
///// <returns></returns>
|
||||
//public bool Update(T entity, List<string> list = null, bool isNull = true)
|
||||
//{
|
||||
// if (list == null)
|
||||
// {
|
||||
// list = new List<string>()
|
||||
// {
|
||||
// "Create_By",
|
||||
// "Create_time"
|
||||
// };
|
||||
// }
|
||||
// //base.Context.Updateable(entity).IgnoreColumns(c => list.Contains(c)).Where(isNull).ExecuteCommand()
|
||||
// return baseRepository.Update(entity, list, isNull);
|
||||
//}
|
||||
|
||||
//public bool Update(List<T> entity)
|
||||
//{
|
||||
// var result = base.Context.Ado.UseTran(() =>
|
||||
// {
|
||||
// base.Context.Updateable(entity).ExecuteCommand();
|
||||
// });
|
||||
// return result.IsSuccess;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定列 eg:Update(w => w.NoticeId == model.NoticeId, it => new SysNotice(){ Update_time = DateTime.Now, Title = "通知标题" });
|
||||
/// </summary>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="columns"></param>
|
||||
/// <returns></returns>
|
||||
public int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
|
||||
{
|
||||
return baseRepository.Update(where, columns);
|
||||
}
|
||||
#endregion update
|
||||
|
||||
public DbResult<bool> UseTran(Action action)
|
||||
{
|
||||
var result = baseRepository.UseTran(action);
|
||||
return result;
|
||||
}
|
||||
|
||||
public DbResult<bool> UseTran(SqlSugarClient client, Action action)
|
||||
{
|
||||
var result = client.Ado.UseTran(() => action());
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool UseTran2(Action action)
|
||||
{
|
||||
var result = baseRepository.UseTran2(action);
|
||||
return result;
|
||||
}
|
||||
|
||||
#region delete
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IDeleteable<T> Deleteable()
|
||||
{
|
||||
return baseRepository.Deleteable();
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除表达式
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
public int Delete(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
return baseRepository.Delete(expression);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public int Delete(object[] obj)
|
||||
{
|
||||
return baseRepository.Delete(obj);
|
||||
}
|
||||
public int Delete(object id)
|
||||
{
|
||||
return baseRepository.Delete(id);
|
||||
}
|
||||
public int DeleteTable()
|
||||
{
|
||||
return baseRepository.DeleteTable();
|
||||
}
|
||||
|
||||
#endregion delete
|
||||
|
||||
#region query
|
||||
|
||||
public bool Any(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
return baseRepository.Any(expression);
|
||||
}
|
||||
|
||||
public ISugarQueryable<T> Queryable()
|
||||
{
|
||||
return baseRepository.Queryable();
|
||||
}
|
||||
|
||||
public List<T> GetList(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
return baseRepository.GetList(expression);
|
||||
}
|
||||
|
||||
//public Task<List<T>> QueryableToListAsync(Expression<Func<T, bool>> expression)
|
||||
//{
|
||||
// return Context.Queryable<T>().Where(expression).ToListAsync();
|
||||
//}
|
||||
|
||||
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
||||
//{
|
||||
// var query = base.Context.Queryable<T>().Select(select).Where(expressionWhere).ToList();
|
||||
// return query.JilToJson();
|
||||
//}
|
||||
|
||||
//public List<T> QueryableToList(string tableName)
|
||||
//{
|
||||
// return Context.Queryable<T>(tableName).ToList();
|
||||
//}
|
||||
|
||||
//public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10)
|
||||
//{
|
||||
// int totalNumber = 0;
|
||||
// var list = Context.Queryable<T>().Where(expression).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
//}
|
||||
|
||||
//public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10)
|
||||
//{
|
||||
// int totalNumber = 0;
|
||||
// var list = Context.Queryable<T>().Where(expression).OrderBy(order).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
//}
|
||||
|
||||
//public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10)
|
||||
//{
|
||||
// int totalNumber = 0;
|
||||
|
||||
// if (orderBy.Equals("DESC", StringComparison.OrdinalIgnoreCase))
|
||||
// {
|
||||
// var list = Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var list = Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Asc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||
// return (list, totalNumber);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public List<T> SqlQueryToList(string sql, object obj = null)
|
||||
//{
|
||||
// return Context.Ado.SqlQuery<T>(sql, obj);
|
||||
//}
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
/// <param name="where">Expression<Func<T, bool>></param>
|
||||
/// <returns></returns>
|
||||
public T GetFirst(Expression<Func<T, bool>> where)
|
||||
{
|
||||
return baseRepository.GetFirst(where);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主值查询单条数据
|
||||
/// </summary>
|
||||
/// <param name="pkValue">主键值</param>
|
||||
/// <returns>泛型实体</returns>
|
||||
public T GetId(object pkValue)
|
||||
{
|
||||
return baseRepository.GetId(pkValue);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm)
|
||||
{
|
||||
var source = baseRepository.GetPages(where, parm);
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, OrderByType orderEnum = OrderByType.Asc)
|
||||
{
|
||||
return baseRepository.GetPages(where, parm, order, orderEnum);
|
||||
}
|
||||
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderByType)
|
||||
{
|
||||
return baseRepository.GetPages(where, parm, order, orderByType == "desc" ? OrderByType.Desc : OrderByType.Asc);
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询所有数据(无分页,请慎用)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<T> GetAll(bool useCache = false, int cacheSecond = 3600)
|
||||
{
|
||||
return baseRepository.GetAll(useCache, cacheSecond);
|
||||
}
|
||||
|
||||
public int Count(Expression<Func<T, bool>> where)
|
||||
{
|
||||
return baseRepository.Count(where);
|
||||
}
|
||||
#endregion query
|
||||
|
||||
/// <summary>
|
||||
/// 此方法不带output返回值
|
||||
/// var list = new List<SugarParameter>();
|
||||
/// list.Add(new SugarParameter(ParaName, ParaValue)); input
|
||||
/// </summary>
|
||||
/// <param name="procedureName"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
public DataTable UseStoredProcedureToDataTable(string procedureName, List<SugarParameter> parameters)
|
||||
{
|
||||
return baseRepository.UseStoredProcedureToDataTable(procedureName, parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 带output返回值
|
||||
/// var list = new List<SugarParameter>();
|
||||
/// list.Add(new SugarParameter(ParaName, ParaValue, true)); output
|
||||
/// list.Add(new SugarParameter(ParaName, ParaValue)); input
|
||||
/// </summary>
|
||||
/// <param name="procedureName"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
public (DataTable, List<SugarParameter>) UseStoredProcedureToTuple(string procedureName, List<SugarParameter> parameters)
|
||||
{
|
||||
return baseRepository.UseStoredProcedureToTuple(procedureName, parameters);
|
||||
}
|
||||
|
||||
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
// this.baseRepository = repository ?? throw new ArgumentNullException(nameof(repository));
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,4 @@
|
||||
using Infrastructure.Model;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq.Expressions;
|
||||
using ZR.Model;
|
||||
using ZR.Repository;
|
||||
|
||||
namespace ZR.Service
|
||||
{
|
||||
@ -12,145 +6,7 @@ namespace ZR.Service
|
||||
/// 基础服务定义
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public interface IBaseService<T> where T : class, new()
|
||||
public interface IBaseService<T> : IBaseRepository<T> where T : class, new()
|
||||
{
|
||||
#region add
|
||||
int Add(T t);
|
||||
|
||||
//int Insert(SqlSugarClient client, T t);
|
||||
|
||||
//long InsertBigIdentity(T t);
|
||||
IInsertable<T> Insertable(T t);
|
||||
int Insert(List<T> t);
|
||||
int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
|
||||
|
||||
//int InsertIgnoreNullColumn(List<T> t);
|
||||
|
||||
//int InsertIgnoreNullColumn(List<T> t, params string[] columns);
|
||||
|
||||
//DbResult<bool> InsertTran(T t);
|
||||
|
||||
//DbResult<bool> InsertTran(List<T> t);
|
||||
long InsertReturnBigIdentity(T t);
|
||||
//T InsertReturnEntity(T t);
|
||||
|
||||
//T InsertReturnEntity(T t, string sqlWith = SqlWith.UpdLock);
|
||||
|
||||
//bool ExecuteCommand(string sql, object parameters);
|
||||
|
||||
//bool ExecuteCommand(string sql, params SugarParameter[] parameters);
|
||||
|
||||
//bool ExecuteCommand(string sql, List<SugarParameter> parameters);
|
||||
|
||||
#endregion add
|
||||
|
||||
#region update
|
||||
|
||||
int Update(T entity, bool ignoreNullColumns = false);
|
||||
|
||||
/// <summary>
|
||||
/// 只更新表达式的值
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
|
||||
|
||||
int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
|
||||
int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="entity">T</param>
|
||||
/// <param name="list">忽略更新</param>
|
||||
/// <param name="isNull">Null不更新</param>
|
||||
/// <returns></returns>
|
||||
//bool Update(T entity, List<string> list = null, bool isNull = true);
|
||||
|
||||
//bool Update(List<T> entity);
|
||||
int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
|
||||
|
||||
#endregion update
|
||||
|
||||
DbResult<bool> UseTran(Action action);
|
||||
|
||||
DbResult<bool> UseTran(SqlSugarClient client, Action action);
|
||||
|
||||
bool UseTran2(Action action);
|
||||
|
||||
#region delete
|
||||
IDeleteable<T> Deleteable();
|
||||
int Delete(Expression<Func<T, bool>> expression);
|
||||
int Delete(object[] obj);
|
||||
int Delete(object id);
|
||||
int DeleteTable();
|
||||
|
||||
#endregion delete
|
||||
|
||||
#region query
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm);
|
||||
|
||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, OrderByType orderEnum = OrderByType.Asc);
|
||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderType);
|
||||
bool Any(Expression<Func<T, bool>> expression);
|
||||
|
||||
ISugarQueryable<T> Queryable();
|
||||
List<T> GetAll(bool useCache = false, int cacheSecond = 3600);
|
||||
|
||||
//ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName);
|
||||
|
||||
//ISugarQueryable<T, T1, T2> Queryable<T1, T2>() where T1 : class where T2 : new();
|
||||
|
||||
List<T> GetList(Expression<Func<T, bool>> expression);
|
||||
|
||||
//Task<List<T>> QueryableToListAsync(Expression<Func<T, bool>> expression);
|
||||
|
||||
//string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere);
|
||||
|
||||
//List<T> QueryableToList(string tableName);
|
||||
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10);
|
||||
|
||||
//(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Bootstrap.BootstrapParams bootstrap);
|
||||
|
||||
//List<T> SqlQueryToList(string sql, object obj = null);
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
/// <param name="where">Expression<Func<T, bool>></param>
|
||||
/// <returns></returns>
|
||||
T GetFirst(Expression<Func<T, bool>> where);
|
||||
T GetId(object pkValue);
|
||||
|
||||
/// <summary>
|
||||
/// 获得一条数据
|
||||
/// </summary>
|
||||
/// <param name="parm">string</param>
|
||||
/// <returns></returns>
|
||||
//T GetFirst(string parm);
|
||||
|
||||
int Count(Expression<Func<T, bool>> where);
|
||||
|
||||
#endregion query
|
||||
|
||||
#region Procedure
|
||||
|
||||
DataTable UseStoredProcedureToDataTable(string procedureName, List<SugarParameter> parameters);
|
||||
|
||||
(DataTable, List<SugarParameter>) UseStoredProcedureToTuple(string procedureName, List<SugarParameter> parameters);
|
||||
|
||||
#endregion Procedure
|
||||
}
|
||||
}
|
||||
@ -15,9 +15,6 @@ namespace ZR.Service.System
|
||||
[AppService(ServiceType = typeof(IArticleCategoryService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class ArticleCategoryService : BaseService<ArticleCategory>, IArticleCategoryService
|
||||
{
|
||||
public ArticleCategoryService(ArticleCategoryRepository repository) : base(repository)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// 构建前端所需要树结构
|
||||
/// </summary>
|
||||
|
||||
@ -12,8 +12,5 @@ namespace ZR.Service.System
|
||||
[AppService(ServiceType = typeof(IArticleService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class ArticleService : BaseService<Article>, IArticleService
|
||||
{
|
||||
public ArticleService(ArticleRepository repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ namespace ZR.Service.System
|
||||
{
|
||||
private GenTableRepository GenTableRepository;
|
||||
private IGenTableColumnService GenTableColumnService;
|
||||
public GenTableService(IGenTableColumnService genTableColumnService, GenTableRepository genTableRepository) : base(genTableRepository)
|
||||
public GenTableService(IGenTableColumnService genTableColumnService, GenTableRepository genTableRepository)
|
||||
{
|
||||
GenTableColumnService = genTableColumnService;
|
||||
GenTableRepository = genTableRepository;
|
||||
@ -45,7 +45,7 @@ namespace ZR.Service.System
|
||||
/// <returns></returns>
|
||||
public int DeleteGenTableByTbName(string tableName)
|
||||
{
|
||||
return GenTableRepository.Delete(f => f.TableName == tableName);
|
||||
return GenTableRepository.Delete(f => f.TableName == tableName) ? 1: 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -180,7 +180,7 @@ namespace ZR.Service.System
|
||||
{
|
||||
|
||||
private GenTableColumnRepository GetTableColumnRepository;
|
||||
public GenTableColumnService(GenTableColumnRepository genTableColumnRepository) : base(genTableColumnRepository)
|
||||
public GenTableColumnService(GenTableColumnRepository genTableColumnRepository)
|
||||
{
|
||||
GetTableColumnRepository = genTableColumnRepository;
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ using ZR.Model.System.Generate;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface IGenTableService: IBaseService<GenTable>
|
||||
public interface IGenTableService : IBaseService<GenTable>
|
||||
{
|
||||
List<GenTable> SelectDbTableListByNamess(string[] tableNames);
|
||||
|
||||
@ -19,8 +19,8 @@ namespace ZR.Service.System.IService
|
||||
int UpdateGenTable(GenTable genTable);
|
||||
}
|
||||
|
||||
public interface IGenTableColumnService: IBaseService<GenTableColumn>
|
||||
{
|
||||
public interface IGenTableColumnService : IBaseService<GenTableColumn>
|
||||
{
|
||||
int InsertGenTableColumn(List<GenTableColumn> tableColumn);
|
||||
|
||||
int DeleteGenTableColumn(long tableId);
|
||||
|
||||
@ -9,7 +9,7 @@ namespace ZR.Service.System
|
||||
/// @author zhaorui
|
||||
/// @date 2021-09-29
|
||||
/// </summary>
|
||||
public interface ISysConfigService: IBaseService<SysConfig>
|
||||
public interface ISysConfigService : IBaseService<SysConfig>
|
||||
{
|
||||
SysConfig GetSysConfigByKey(string key);
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ namespace ZR.Service.System.IService
|
||||
List<SysRoleDept> SelectRoleDeptByRoleId(long roleId);
|
||||
|
||||
List<long> SelectRoleDepts(long roleId);
|
||||
int DeleteRoleDeptByRoleId(long roleId);
|
||||
bool DeleteRoleDeptByRoleId(long roleId);
|
||||
int InsertRoleDepts(SysRole role);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,5 +10,6 @@ namespace ZR.Service.System.IService
|
||||
{
|
||||
string CheckPostNameUnique(SysPost sysPost);
|
||||
string CheckPostCodeUnique(SysPost sysPost);
|
||||
List<SysPost> GetAll();
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,6 @@ namespace ZR.Service.System.IService
|
||||
public List<long> GetUserPostsByUserId(long userId);
|
||||
|
||||
public string GetPostsStrByUserId(long userId);
|
||||
int Delete(long userId);
|
||||
bool Delete(long userId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ namespace ZR.Service.System
|
||||
public class SysConfigService : BaseService<SysConfig>, ISysConfigService
|
||||
{
|
||||
private readonly SysConfigRepository _SysConfigrepository;
|
||||
public SysConfigService(SysConfigRepository repository) : base(repository)
|
||||
public SysConfigService(SysConfigRepository repository)
|
||||
{
|
||||
_SysConfigrepository = repository;
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ namespace ZR.Service.System
|
||||
{
|
||||
public SysDeptRepository DeptRepository;
|
||||
public SysRoleDeptRepository RoleDeptRepository;
|
||||
public SysDeptService(SysDeptRepository deptRepository, SysRoleDeptRepository roleDeptRepository) : base(deptRepository)
|
||||
public SysDeptService(SysDeptRepository deptRepository, SysRoleDeptRepository roleDeptRepository)
|
||||
{
|
||||
DeptRepository = deptRepository;
|
||||
RoleDeptRepository = roleDeptRepository;
|
||||
@ -256,7 +256,7 @@ namespace ZR.Service.System
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteRoleDeptByRoleId(long roleId)
|
||||
public bool DeleteRoleDeptByRoleId(long roleId)
|
||||
{
|
||||
return RoleDeptRepository.Delete(f => f.RoleId == roleId);
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ namespace ZR.Service.System
|
||||
{
|
||||
|
||||
private readonly SysDictDataRepository SysDictDataRepository;
|
||||
public SysDictDataService(SysDictDataRepository sysDictDataRepository) : base(sysDictDataRepository)
|
||||
public SysDictDataService(SysDictDataRepository sysDictDataRepository)
|
||||
{
|
||||
SysDictDataRepository = sysDictDataRepository;
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ namespace ZR.Service.System
|
||||
private SysDictRepository DictRepository;
|
||||
private SysDictDataRepository DictDataRepository;
|
||||
|
||||
public SysDictService(SysDictRepository sysDictRepository, SysDictDataRepository dictDataRepository) : base(sysDictRepository)
|
||||
public SysDictService(SysDictRepository sysDictRepository, SysDictDataRepository dictDataRepository)
|
||||
{
|
||||
this.DictRepository = sysDictRepository;
|
||||
this.DictDataRepository = dictDataRepository;
|
||||
|
||||
@ -11,7 +11,6 @@ using System.Net;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository.System;
|
||||
using Infrastructure.Extensions;
|
||||
using SqlSugar.DistributedSystem.Snowflake;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
@ -24,7 +23,7 @@ namespace ZR.Service.System
|
||||
private string domainUrl = AppSettings.GetConfig("ALIYUN_OSS:domainUrl");
|
||||
private readonly SysFileRepository SysFileRepository;
|
||||
|
||||
public SysFileService(SysFileRepository repository) : base(repository)
|
||||
public SysFileService(SysFileRepository repository)
|
||||
{
|
||||
SysFileRepository = repository;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ namespace ZR.Service.System
|
||||
{
|
||||
private SysLogininfoRepository SysLogininfoRepository;
|
||||
|
||||
public SysLoginService(SysLogininfoRepository sysLogininfo): base(sysLogininfo)
|
||||
public SysLoginService(SysLogininfoRepository sysLogininfo)
|
||||
{
|
||||
SysLogininfoRepository = sysLogininfo;
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ namespace ZR.Service
|
||||
|
||||
public SysMenuService(
|
||||
SysMenuRepository menuRepository,
|
||||
ISysRoleService sysRoleService) : base(menuRepository)
|
||||
ISysRoleService sysRoleService)
|
||||
{
|
||||
MenuRepository = menuRepository;
|
||||
SysRoleService = sysRoleService;
|
||||
|
||||
@ -20,7 +20,7 @@ namespace ZR.Service.System
|
||||
public class SysNoticeService : BaseService<SysNotice>, ISysNoticeService
|
||||
{
|
||||
private readonly SysNoticeRepository _SysNoticerepository;
|
||||
public SysNoticeService(SysNoticeRepository repository) : base(repository)
|
||||
public SysNoticeService(SysNoticeRepository repository)
|
||||
{
|
||||
_SysNoticerepository = repository;
|
||||
}
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
using Infrastructure.Attribute;
|
||||
using System.Collections.Generic;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Repository.System;
|
||||
using ZR.Service.System.IService;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Model;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
@ -18,7 +16,7 @@ namespace ZR.Service.System
|
||||
{
|
||||
public SysOperLogRepository sysOperLogRepository;
|
||||
|
||||
public SysOperLogService(SysOperLogRepository sysOperLog) : base(sysOperLog)
|
||||
public SysOperLogService(SysOperLogRepository sysOperLog)
|
||||
{
|
||||
sysOperLogRepository = sysOperLog;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ namespace ZR.Service.System
|
||||
public class SysPostService : BaseService<SysPost>, ISysPostService
|
||||
{
|
||||
public SysPostRepository PostRepository;
|
||||
public SysPostService(SysPostRepository postRepository): base(postRepository)
|
||||
public SysPostService(SysPostRepository postRepository)
|
||||
{
|
||||
PostRepository = postRepository;
|
||||
}
|
||||
@ -50,5 +50,10 @@ namespace ZR.Service.System
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
public List<SysPost> GetAll()
|
||||
{
|
||||
return PostRepository.GetAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ namespace ZR.Service
|
||||
public SysRoleService(
|
||||
SysRoleRepository sysRoleRepository,
|
||||
ISysUserRoleService sysUserRoleService,
|
||||
ISysDeptService deptService) : base(sysRoleRepository)
|
||||
ISysDeptService deptService)
|
||||
{
|
||||
SysRoleRepository = sysRoleRepository;
|
||||
SysUserRoleService = sysUserRoleService;
|
||||
|
||||
@ -11,7 +11,7 @@ namespace ZR.Service.System
|
||||
[AppService(ServiceType = typeof(ISysTasksQzService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysTasksQzService : BaseService<SysTasksQz>, ISysTasksQzService
|
||||
{
|
||||
public SysTasksQzService(SysTasksQzRepository repository) : base(repository)
|
||||
public SysTasksQzService(SysTasksQzRepository repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ namespace ZR.Service.System
|
||||
return string.Join(',', list.Select(x => x.PostName));
|
||||
}
|
||||
|
||||
public int Delete(long userId)
|
||||
public bool Delete(long userId)
|
||||
{
|
||||
return UserPostRepository.Delete(x => x.UserId == userId);
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ namespace ZR.Service
|
||||
SysUserRepository userRepository,
|
||||
ISysRoleService sysRoleService,
|
||||
ISysUserRoleService userRoleService,
|
||||
ISysUserPostService userPostService) : base(userRepository)
|
||||
ISysUserPostService userPostService)
|
||||
{
|
||||
UserRepository = userRepository;
|
||||
RoleService = sysRoleService;
|
||||
|
||||
@ -65,6 +65,9 @@
|
||||
<!-- 角色菜单弹框 -->
|
||||
<el-dialog title="角色权限分配" :visible.sync="showRoleScope" width="500px">
|
||||
<el-form :model="form" label-width="80px">
|
||||
<el-form-item label="菜单搜索">
|
||||
<el-input placeholder="请输入关键字进行过滤" v-model="searchText"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="权限字符">
|
||||
{{form.roleKey}}
|
||||
</el-form-item>
|
||||
@ -73,7 +76,7 @@
|
||||
<el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox>
|
||||
<el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox>
|
||||
<el-tree class="tree-border" :data="menuOptions" show-checkbox ref="menu" node-key="id" :check-strictly="!form.menuCheckStrictly"
|
||||
empty-text="加载中,请稍后" :props="defaultProps"></el-tree>
|
||||
empty-text="加载中,请稍后" :filter-node-method="menuFilterNode" :props="defaultProps"></el-tree>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
@ -149,19 +152,19 @@ import {
|
||||
updateRole,
|
||||
exportRole,
|
||||
dataScope,
|
||||
changeRoleStatus,
|
||||
} from "@/api/system/role";
|
||||
changeRoleStatus
|
||||
} from '@/api/system/role'
|
||||
import {
|
||||
treeselect as menuTreeselect,
|
||||
roleMenuTreeselect,
|
||||
} from "@/api/system/menu";
|
||||
roleMenuTreeselect
|
||||
} from '@/api/system/menu'
|
||||
import {
|
||||
treeselect as deptTreeselect,
|
||||
roleDeptTreeselect,
|
||||
} from "@/api/system/dept";
|
||||
roleDeptTreeselect
|
||||
} from '@/api/system/dept'
|
||||
|
||||
export default {
|
||||
name: "role",
|
||||
name: 'role',
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
@ -181,7 +184,7 @@ export default {
|
||||
// 角色表格数据
|
||||
roleList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
title: '',
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
menuExpand: true,
|
||||
@ -197,25 +200,25 @@ export default {
|
||||
// 数据范围选项
|
||||
dataScopeOptions: [
|
||||
{
|
||||
dictValue: "1",
|
||||
dictLabel: "全部",
|
||||
dictValue: '1',
|
||||
dictLabel: '全部'
|
||||
},
|
||||
// {
|
||||
// dictValue: "2",
|
||||
// dictLabel: "自定义",
|
||||
// },
|
||||
{
|
||||
dictValue: "3",
|
||||
dictLabel: "本部门",
|
||||
dictValue: '3',
|
||||
dictLabel: '本部门'
|
||||
},
|
||||
// {
|
||||
// dictValue: "4",
|
||||
// dictLabel: "本部门及以下数据权限",
|
||||
// },
|
||||
{
|
||||
dictValue: "5",
|
||||
dictLabel: "仅本人",
|
||||
},
|
||||
dictValue: '5',
|
||||
dictLabel: '仅本人'
|
||||
}
|
||||
],
|
||||
// 菜单列表
|
||||
menuOptions: [],
|
||||
@ -227,351 +230,362 @@ export default {
|
||||
pageSize: 10,
|
||||
roleName: undefined,
|
||||
roleKey: undefined,
|
||||
status: undefined,
|
||||
status: undefined
|
||||
},
|
||||
searchText: '',
|
||||
// 表单参数
|
||||
form: {},
|
||||
defaultProps: {
|
||||
children: "children",
|
||||
label: "label",
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
roleName: [
|
||||
{ required: true, message: "角色名称不能为空", trigger: "blur" },
|
||||
{ required: true, message: '角色名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
roleKey: [
|
||||
{ required: true, message: "权限字符不能为空", trigger: "blur" },
|
||||
{ required: true, message: '权限字符不能为空', trigger: 'blur' }
|
||||
],
|
||||
roleSort: [
|
||||
{ required: true, message: "角色顺序不能为空", trigger: "blur" },
|
||||
],
|
||||
},
|
||||
};
|
||||
{ required: true, message: '角色顺序不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
searchText(val) {
|
||||
this.$refs.menu.filter(val)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getDicts("sys_normal_disable").then((response) => {
|
||||
this.statusOptions = response.data;
|
||||
});
|
||||
this.getList()
|
||||
this.getDicts('sys_normal_disable').then((response) => {
|
||||
this.statusOptions = response.data
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
/** 查询角色列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
this.loading = true
|
||||
|
||||
listRole(this.addDateRange(this.queryParams, this.dateRange)).then(
|
||||
(response) => {
|
||||
this.roleList = response.data.result;
|
||||
this.total = response.data.totalNum;
|
||||
this.loading = false;
|
||||
this.roleList = response.data.result
|
||||
this.total = response.data.totalNum
|
||||
this.loading = false
|
||||
}
|
||||
);
|
||||
)
|
||||
},
|
||||
/** 查询菜单树结构 */
|
||||
getMenuTreeselect() {
|
||||
menuTreeselect().then((response) => {
|
||||
this.menuOptions = response.data;
|
||||
});
|
||||
this.menuOptions = response.data
|
||||
})
|
||||
},
|
||||
/** 查询部门树结构 */
|
||||
getDeptTreeselect() {
|
||||
deptTreeselect().then((response) => {
|
||||
this.deptOptions = response.data;
|
||||
});
|
||||
this.deptOptions = response.data
|
||||
})
|
||||
},
|
||||
// 所有菜单节点数据
|
||||
getMenuAllCheckedKeys() {
|
||||
// 目前被选中的菜单节点
|
||||
let checkedKeys = this.$refs.menu.getCheckedKeys();
|
||||
const checkedKeys = this.$refs.menu.getCheckedKeys()
|
||||
// 半选中的菜单节点
|
||||
let halfCheckedKeys = this.$refs.menu.getHalfCheckedKeys();
|
||||
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
||||
return checkedKeys;
|
||||
const halfCheckedKeys = this.$refs.menu.getHalfCheckedKeys()
|
||||
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys)
|
||||
return checkedKeys
|
||||
},
|
||||
// 所有部门节点数据
|
||||
getDeptAllCheckedKeys() {
|
||||
// 目前被选中的部门节点
|
||||
let checkedKeys = this.$refs.dept.getCheckedKeys();
|
||||
const checkedKeys = this.$refs.dept.getCheckedKeys()
|
||||
// 半选中的部门节点
|
||||
let halfCheckedKeys = this.$refs.dept.getHalfCheckedKeys();
|
||||
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
||||
return checkedKeys;
|
||||
const halfCheckedKeys = this.$refs.dept.getHalfCheckedKeys()
|
||||
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys)
|
||||
return checkedKeys
|
||||
},
|
||||
/** 根据角色ID查询菜单树结构 */
|
||||
getRoleMenuTreeselect(roleId) {
|
||||
return roleMenuTreeselect(roleId).then((response) => {
|
||||
this.menuOptions = response.data.menus;
|
||||
return response;
|
||||
});
|
||||
this.menuOptions = response.data.menus
|
||||
return response
|
||||
})
|
||||
},
|
||||
/** 根据角色ID查询部门树结构 */
|
||||
getRoleDeptTreeselect(roleId) {
|
||||
return roleDeptTreeselect(roleId).then((response) => {
|
||||
console.log('角色', response);
|
||||
this.deptOptions = response.data.depts;
|
||||
return response;
|
||||
});
|
||||
console.log('角色', response)
|
||||
this.deptOptions = response.data.depts
|
||||
return response
|
||||
})
|
||||
},
|
||||
// 角色状态修改
|
||||
handleStatusChange(row) {
|
||||
let text = row.status === "0" ? "启用" : "停用";
|
||||
const text = row.status === '0' ? '启用' : '停用'
|
||||
|
||||
console.log(JSON.stringify(row), text);
|
||||
console.log(JSON.stringify(row), text)
|
||||
this.$confirm(
|
||||
'确认要"' + text + '""' + row.roleName + '"角色吗?',
|
||||
"警告",
|
||||
'警告',
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
.then(function () {
|
||||
return changeRoleStatus(row.roleId, row.status);
|
||||
.then(function() {
|
||||
return changeRoleStatus(row.roleId, row.status)
|
||||
})
|
||||
.then(() => {
|
||||
this.msgSuccess(text + "成功");
|
||||
this.msgSuccess(text + '成功')
|
||||
})
|
||||
.catch(function() {
|
||||
row.status = row.status === '0' ? '1' : '0'
|
||||
})
|
||||
.catch(function () {
|
||||
row.status = row.status === "0" ? "1" : "0";
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.showRoleScope = false;
|
||||
this.reset();
|
||||
this.open = false
|
||||
this.showRoleScope = false
|
||||
this.reset()
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
if (this.$refs.menu != undefined) {
|
||||
this.$refs.menu.setCheckedKeys([]);
|
||||
this.$refs.menu.setCheckedKeys([])
|
||||
}
|
||||
(this.menuExpand = false),
|
||||
(this.menuNodeAll = false),
|
||||
(this.deptExpand = true),
|
||||
(this.deptNodeAll = false),
|
||||
(this.form = {
|
||||
roleId: undefined,
|
||||
roleName: undefined,
|
||||
roleKey: undefined,
|
||||
roleSort: 99,
|
||||
status: "0",
|
||||
menuIds: [],
|
||||
deptIds: [],
|
||||
dataScope: "1",
|
||||
menuCheckStrictly: true,
|
||||
deptCheckStrictly: true,
|
||||
remark: undefined,
|
||||
});
|
||||
this.resetForm("form");
|
||||
(this.menuNodeAll = false),
|
||||
(this.deptExpand = true),
|
||||
(this.deptNodeAll = false),
|
||||
(this.form = {
|
||||
roleId: undefined,
|
||||
roleName: undefined,
|
||||
roleKey: undefined,
|
||||
roleSort: 99,
|
||||
status: '0',
|
||||
menuIds: [],
|
||||
deptIds: [],
|
||||
dataScope: '1',
|
||||
menuCheckStrictly: true,
|
||||
deptCheckStrictly: true,
|
||||
remark: undefined
|
||||
})
|
||||
this.resetForm('form')
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
this.dateRange = []
|
||||
this.resetForm('queryForm')
|
||||
this.handleQuery()
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.roleId);
|
||||
this.single = selection.length != 1;
|
||||
this.multiple = !selection.length;
|
||||
this.ids = selection.map((item) => item.roleId)
|
||||
this.single = selection.length != 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
// 更多操作触发
|
||||
handleCommand(command, row) {
|
||||
switch (command) {
|
||||
case "handleDataScope":
|
||||
this.handleDataScope(row);
|
||||
break;
|
||||
case "handleAuthUser":
|
||||
this.handleAuthUser(row);
|
||||
break;
|
||||
case 'handleDataScope':
|
||||
this.handleDataScope(row)
|
||||
break
|
||||
case 'handleAuthUser':
|
||||
this.handleAuthUser(row)
|
||||
break
|
||||
default:
|
||||
break;
|
||||
break
|
||||
}
|
||||
},
|
||||
// 树权限(展开/折叠)
|
||||
handleCheckedTreeExpand(value, type) {
|
||||
if (type == "menu") {
|
||||
let treeList = this.menuOptions;
|
||||
if (type == 'menu') {
|
||||
const treeList = this.menuOptions
|
||||
for (let i = 0; i < treeList.length; i++) {
|
||||
this.$refs.menu.store.nodesMap[treeList[i].id].expanded = value;
|
||||
this.$refs.menu.store.nodesMap[treeList[i].id].expanded = value
|
||||
}
|
||||
} else if (type == "dept") {
|
||||
let treeList = this.deptOptions;
|
||||
} else if (type == 'dept') {
|
||||
const treeList = this.deptOptions
|
||||
for (let i = 0; i < treeList.length; i++) {
|
||||
this.$refs.dept.store.nodesMap[treeList[i].id].expanded = value;
|
||||
this.$refs.dept.store.nodesMap[treeList[i].id].expanded = value
|
||||
}
|
||||
}
|
||||
},
|
||||
// 树权限(全选/全不选)
|
||||
handleCheckedTreeNodeAll(value, type) {
|
||||
if (type == "menu") {
|
||||
this.$refs.menu.setCheckedNodes(value ? this.menuOptions : []);
|
||||
} else if (type == "dept") {
|
||||
this.$refs.dept.setCheckedNodes(value ? this.deptOptions : []);
|
||||
if (type == 'menu') {
|
||||
this.$refs.menu.setCheckedNodes(value ? this.menuOptions : [])
|
||||
} else if (type == 'dept') {
|
||||
this.$refs.dept.setCheckedNodes(value ? this.deptOptions : [])
|
||||
}
|
||||
},
|
||||
// 树权限(父子联动)
|
||||
handleCheckedTreeConnect(value, type) {
|
||||
if (type == "menu") {
|
||||
this.form.menuCheckStrictly = value ? true : false;
|
||||
} else if (type == "dept") {
|
||||
this.form.deptCheckStrictly = value ? true : false;
|
||||
if (type == 'menu') {
|
||||
this.form.menuCheckStrictly = !!value
|
||||
} else if (type == 'dept') {
|
||||
this.form.deptCheckStrictly = !!value
|
||||
}
|
||||
},
|
||||
//菜单筛选
|
||||
menuFilterNode(value, data) {
|
||||
if (!value) return true
|
||||
return data.label.indexOf(value) !== -1
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.getDeptTreeselect();
|
||||
this.open = true;
|
||||
this.title = "添加角色";
|
||||
this.showRoleScope = false;
|
||||
this.reset()
|
||||
this.getDeptTreeselect()
|
||||
this.open = true
|
||||
this.title = '添加角色'
|
||||
this.showRoleScope = false
|
||||
},
|
||||
/** 修改按钮操作 ok */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
this.showRoleScope = false;
|
||||
const roleId = row.roleId || this.ids;
|
||||
const roleDeptTreeselect = this.getRoleDeptTreeselect(row.roleId);
|
||||
this.reset()
|
||||
this.showRoleScope = false
|
||||
const roleId = row.roleId || this.ids
|
||||
const roleDeptTreeselect = this.getRoleDeptTreeselect(row.roleId)
|
||||
getRole(roleId).then((response) => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改角色";
|
||||
this.form = response.data
|
||||
this.open = true
|
||||
this.title = '修改角色'
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.$nextTick(() => {
|
||||
roleDeptTreeselect.then((res) => {
|
||||
this.$refs.dept.setCheckedKeys(res.data.checkedKeys);
|
||||
});
|
||||
});
|
||||
});
|
||||
this.$refs.dept.setCheckedKeys(res.data.checkedKeys)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
/** 选择角色权限范围触发 */
|
||||
dataScopeSelectChange(value) {
|
||||
if (value !== "2") {
|
||||
this.$refs.dept.setCheckedKeys([]);
|
||||
if (value !== '2') {
|
||||
this.$refs.dept.setCheckedKeys([])
|
||||
}
|
||||
},
|
||||
// 数据权限
|
||||
dataScopeFormat(row, column) {
|
||||
return this.selectDictLabel(this.dataScopeOptions, row.dataScope);
|
||||
return this.selectDictLabel(this.dataScopeOptions, row.dataScope)
|
||||
},
|
||||
/** 分配角色权限按钮操作 */
|
||||
//新增 和上面代码基本相同
|
||||
// 新增 和上面代码基本相同
|
||||
handleDataScope(row) {
|
||||
if (row.roleId == 1) {
|
||||
this.showRoleScope = false;
|
||||
return;
|
||||
this.showRoleScope = false
|
||||
return
|
||||
}
|
||||
this.reset();
|
||||
this.showRoleScope = true;
|
||||
const roleId = row.roleId || this.ids;
|
||||
const roleMenu = this.getRoleMenuTreeselect(roleId);
|
||||
this.reset()
|
||||
this.showRoleScope = true
|
||||
const roleId = row.roleId || this.ids
|
||||
const roleMenu = this.getRoleMenuTreeselect(roleId)
|
||||
|
||||
roleMenu.then((res) => {
|
||||
let checkedKeys = res.data.checkedKeys;
|
||||
const checkedKeys = res.data.checkedKeys
|
||||
checkedKeys.forEach((v) => {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.menu.setChecked(v, true, false);
|
||||
});
|
||||
});
|
||||
});
|
||||
this.$refs.menu.setChecked(v, true, false)
|
||||
})
|
||||
})
|
||||
})
|
||||
this.form = {
|
||||
roleId: row.roleId,
|
||||
roleName: row.roleName,
|
||||
roleKey: row.roleKey,
|
||||
menuCheckStrictly: row.menuCheckStrictly,
|
||||
};
|
||||
menuCheckStrictly: row.menuCheckStrictly
|
||||
}
|
||||
},
|
||||
/** 分配用户操作 */
|
||||
handleAuthUser: function (row) {
|
||||
const roleId = row.roleId;
|
||||
this.$router.push({ path: "/system/roleusers", query: { roleId } });
|
||||
handleAuthUser: function(row) {
|
||||
const roleId = row.roleId
|
||||
this.$router.push({ path: '/system/roleusers', query: { roleId }})
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm: function () {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
submitForm: function() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.roleId != undefined && this.form.roleId > 0) {
|
||||
this.form.type = "edit";
|
||||
this.form.deptIds = this.getDeptAllCheckedKeys();
|
||||
this.form.type = 'edit'
|
||||
this.form.deptIds = this.getDeptAllCheckedKeys()
|
||||
updateRole(this.form).then((response) => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
this.msgSuccess('修改成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
this.form.type = "add";
|
||||
this.form.deptIds = this.getDeptAllCheckedKeys();
|
||||
this.form.type = 'add'
|
||||
this.form.deptIds = this.getDeptAllCheckedKeys()
|
||||
addRole(this.form).then((response) => {
|
||||
console.log(response);
|
||||
this.open = false;
|
||||
console.log(response)
|
||||
this.open = false
|
||||
if (response.code == 200) {
|
||||
this.msgSuccess("新增成功");
|
||||
this.getList();
|
||||
this.msgSuccess('新增成功')
|
||||
this.getList()
|
||||
} else {
|
||||
this.msgInfo(response.msg);
|
||||
this.msgInfo(response.msg)
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
/** 提交按钮(菜单数据权限) */
|
||||
submitDataScope: function () {
|
||||
submitDataScope: function() {
|
||||
if (this.form.roleId != undefined) {
|
||||
this.form.menuIds = this.getMenuAllCheckedKeys();
|
||||
this.form.menuIds = this.getMenuAllCheckedKeys()
|
||||
dataScope(this.form).then((response) => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.getList();
|
||||
this.cancel();
|
||||
});
|
||||
this.msgSuccess('修改成功')
|
||||
this.getList()
|
||||
this.cancel()
|
||||
})
|
||||
} else {
|
||||
this.msgError("请选择角色");
|
||||
this.msgError('请选择角色')
|
||||
}
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const roleIds = row.roleId || this.ids;
|
||||
const roleIds = row.roleId || this.ids
|
||||
this.$confirm(
|
||||
'是否确认删除角色编号为"' + roleIds + '"的数据项?',
|
||||
"警告",
|
||||
'警告',
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
.then(function () {
|
||||
return delRole(roleIds);
|
||||
.then(function() {
|
||||
return delRole(roleIds)
|
||||
})
|
||||
.then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
});
|
||||
this.getList()
|
||||
this.msgSuccess('删除成功')
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm("是否确认导出所有角色数据项?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
const queryParams = this.queryParams
|
||||
this.$confirm('是否确认导出所有角色数据项?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(function () {
|
||||
return exportRole(queryParams);
|
||||
.then(function() {
|
||||
return exportRole(queryParams)
|
||||
})
|
||||
.then((response) => {
|
||||
this.download(response.data.path);
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
this.download(response.data.path)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user