/// <summary> /// 根据ID删除 /// </summary> /// <param name="id"></param> /// <returns></returns> public virtual async Task <MessageModel <CurdModel> > DeleteById(object id) { var result = await baseDal.DeleteById(id); if (result) { return(HttpResult.Ok()); } else { return(HttpResult.DbError("删除失败!")); } }
/// <summary> /// 根据ID数组删除 /// </summary> /// <param name="ids"></param> /// <returns></returns> public virtual async Task <MessageModel <CurdModel> > DeleteByIds(object[] ids) { var result = await baseDal.DeleteByIds(ids); if (result == ids.Count()) { return(HttpResult.Ok($"成功删除{result}条数据!", result)); } else { return(HttpResult.DbError($"成功删除了{result}条数据,{ids.Count() - result}条数据删除失败!", null, result, ids.Count() - result)); } }
/// <summary> /// 写入实体 /// </summary> /// <param name="model"></param> /// <returns></returns> public virtual async Task <MessageModel <CurdModel> > Add(TEntity model) { var result = await baseDal.Add(model); if (result) { return(HttpResult.Ok()); } else { return(HttpResult.DbError("添加失败!")); } }