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