更换update返回结果为int

This commit is contained in:
不做码农 2021-12-14 21:51:19 +08:00
parent 50c48077d7
commit 487c7f31ff
9 changed files with 37 additions and 38 deletions

View File

@ -19,6 +19,7 @@ namespace Infrastructure
[Description("NO_DATA")] [Description("NO_DATA")]
NODATA = 106, NODATA = 106,
[Description("操作失败")]
FAIL = 1, FAIL = 1,
[Description("服务端出错啦")] [Description("服务端出错啦")]

View File

@ -15,8 +15,6 @@ namespace ZR.Admin.WebApi.Controllers
[LogActionFilter] [LogActionFilter]
public class BaseController : ControllerBase public class BaseController : ControllerBase
{ {
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public static string TIME_FORMAT_FULL = "yyyy-MM-dd HH:mm:ss"; public static string TIME_FORMAT_FULL = "yyyy-MM-dd HH:mm:ss";
public static string TIME_FORMAT_FULL_2 = "MM-dd HH:mm:ss"; public static string TIME_FORMAT_FULL_2 = "MM-dd HH:mm:ss";

View File

@ -95,7 +95,7 @@ namespace ZR.Admin.WebApi.Controllers.System
throw new CustomException($"修改岗位{post.PostName}失败,岗位编码已存在"); throw new CustomException($"修改岗位{post.PostName}失败,岗位编码已存在");
} }
post.Update_by = User.Identity.Name; post.Update_by = User.Identity.Name;
return ToResponse(ToJson(PostService.Update(post) ? 1 : 0)); return ToResponse(PostService.Update(post));
} }
/// <summary> /// <summary>

View File

@ -141,7 +141,7 @@ namespace ZR.Admin.WebApi.Controllers
Update_by = User.Identity.Name, Update_by = User.Identity.Name,
Update_time = DateTime.Now Update_time = DateTime.Now
}); });
if (response) if (response > 0)
{ {
//先暂停原先的任务 //先暂停原先的任务
var respon = await _schedulerServer.UpdateTaskScheduleAsync(tasksQz, tasksQz.JobGroup); var respon = await _schedulerServer.UpdateTaskScheduleAsync(tasksQz, tasksQz.JobGroup);

View File

@ -4,7 +4,7 @@
"commandName": "Project", "commandName": "Project",
"launchBrowser": false, "launchBrowser": false,
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production" "ASPNETCORE_ENVIRONMENT": "Stage"
}, },
"applicationUrl": "http://localhost:8888" "applicationUrl": "http://localhost:8888"
} }

View File

@ -121,24 +121,24 @@ namespace ZR.Repository
#region update #region update
public bool Update(T entity, bool ignoreNullColumns = false) public int Update(T entity, bool ignoreNullColumns = false)
{ {
return Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommand() > 0; return Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommand();
} }
public bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false) public int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
{ {
return Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommand() > 0; return Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommand();
} }
public bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where) public int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
{ {
return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0; return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
} }
public bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> 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() > 0; return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
} }
/// <summary> /// <summary>
@ -148,7 +148,7 @@ namespace ZR.Repository
/// <param name="list"></param> /// <param name="list"></param>
/// <param name="isNull">默认为true</param> /// <param name="isNull">默认为true</param>
/// <returns></returns> /// <returns></returns>
public bool Update(T entity, List<string> list = null, bool isNull = true) public int Update(T entity, List<string> list = null, bool isNull = true)
{ {
if (list == null) if (list == null)
{ {
@ -158,7 +158,7 @@ namespace ZR.Repository
"Create_time" "Create_time"
}; };
} }
return Context.Updateable(entity).IgnoreColumns(isNull).IgnoreColumns(list.ToArray()).ExecuteCommand() > 0; return Context.Updateable(entity).IgnoreColumns(isNull).IgnoreColumns(list.ToArray()).ExecuteCommand();
} }
//public bool Update(List<T> entity) //public bool Update(List<T> entity)
@ -169,9 +169,9 @@ namespace ZR.Repository
// }); // });
// return result.IsSuccess; // return result.IsSuccess;
//} //}
public bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns) public int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
{ {
return Context.Updateable<T>().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommand() > 0; return Context.Updateable<T>().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommand();
} }
#endregion update #endregion update
@ -218,9 +218,9 @@ namespace ZR.Repository
{ {
return Context.Deleteable<T>(id).ExecuteCommand(); return Context.Deleteable<T>(id).ExecuteCommand();
} }
public bool DeleteTable() public int DeleteTable()
{ {
return Context.Deleteable<T>().ExecuteCommand() > 0; return Context.Deleteable<T>().ExecuteCommand();
} }
#endregion delete #endregion delete

View File

@ -44,7 +44,7 @@ namespace ZR.Repository
#region update #region update
bool Update(T entity, bool ignoreNullColumns = false); int Update(T entity, bool ignoreNullColumns = false);
/// <summary> /// <summary>
/// 只更新表达式的值 /// 只更新表达式的值
@ -52,13 +52,13 @@ namespace ZR.Repository
/// <param name="entity"></param> /// <param name="entity"></param>
/// <param name="expression"></param> /// <param name="expression"></param>
/// <returns></returns> /// <returns></returns>
bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false); int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where); int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
bool Update(SqlSugarClient client, 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);
bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns); int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
#endregion update #endregion update
@ -73,7 +73,7 @@ namespace ZR.Repository
int Delete(Expression<Func<T, bool>> expression); int Delete(Expression<Func<T, bool>> expression);
int Delete(object[] obj); int Delete(object[] obj);
int Delete(object id); int Delete(object id);
bool DeleteTable(); int DeleteTable();
#endregion delete #endregion delete

View File

@ -122,24 +122,24 @@ namespace ZR.Service
#region update #region update
public bool Update(T entity, bool ignoreNullColumns = false) public int Update(T entity, bool ignoreNullColumns = false)
{ {
return baseRepository.Update(entity, ignoreNullColumns); return baseRepository.Update(entity, ignoreNullColumns);
} }
public bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false) public int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
{ {
return baseRepository.Update(entity, expression, ignoreAllNull); return baseRepository.Update(entity, expression, ignoreAllNull);
} }
public bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where) public int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
{ {
return baseRepository.Update(entity, expression, where); return baseRepository.Update(entity, expression, where);
} }
public bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> 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() > 0; return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
} }
///// <summary> ///// <summary>
@ -171,7 +171,7 @@ namespace ZR.Service
// }); // });
// return result.IsSuccess; // return result.IsSuccess;
//} //}
public bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns) public int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
{ {
return baseRepository.Update(where, columns); return baseRepository.Update(where, columns);
} }
@ -220,7 +220,7 @@ namespace ZR.Service
{ {
return baseRepository.Delete(id); return baseRepository.Delete(id);
} }
public bool DeleteTable() public int DeleteTable()
{ {
return baseRepository.DeleteTable(); return baseRepository.DeleteTable();
} }

View File

@ -46,7 +46,7 @@ namespace ZR.Service
#region update #region update
bool Update(T entity, bool ignoreNullColumns = false); int Update(T entity, bool ignoreNullColumns = false);
/// <summary> /// <summary>
/// 只更新表达式的值 /// 只更新表达式的值
@ -54,11 +54,11 @@ namespace ZR.Service
/// <param name="entity"></param> /// <param name="entity"></param>
/// <param name="expression"></param> /// <param name="expression"></param>
/// <returns></returns> /// <returns></returns>
bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false); int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where); int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
bool Update(SqlSugarClient client, 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>
/// ///
@ -70,7 +70,7 @@ namespace ZR.Service
//bool Update(T entity, List<string> list = null, bool isNull = true); //bool Update(T entity, List<string> list = null, bool isNull = true);
//bool Update(List<T> entity); //bool Update(List<T> entity);
bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns); int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
#endregion update #endregion update
@ -85,7 +85,7 @@ namespace ZR.Service
int Delete(Expression<Func<T, bool>> expression); int Delete(Expression<Func<T, bool>> expression);
int Delete(object[] obj); int Delete(object[] obj);
int Delete(object id); int Delete(object id);
bool DeleteTable(); int DeleteTable();
#endregion delete #endregion delete