HTTP post请求工具类

一、帮助类:

using Newtonsoft.Json;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace CommonUtility.Utils
{
    public class JsonContent : StringContent
    {
        public JsonContent(object obj) :
            base(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json")
        { }
    }
    /// <summary>
    /// 基本的http封装
    /// 这里不处理异常 外边处理异常
    /// </summary>
    public static class HttpClientHelper
    {
        //返回model
        public static T PostData<T>(string url, object reposeData) where T : new()
        {

            using (HttpClient client = new HttpClient())
            {
                Task<HttpResponseMessage> response = client.PostAsync(url, new JsonContent(reposeData));
                response.Wait(15000);
                string result = response.Result.Content.ReadAsStringAsync().Result;
                return JsonConvert.DeserializeObject<T>(result);
            }
        }

        //返回string
        public static string PostData(string url)
        {
            using (HttpClient client = new HttpClient())
            {
                Task<HttpResponseMessage> response = client.PostAsync(url, null);
                response.Wait(15000);
                return response.Result.Content.ReadAsStringAsync().Result;
            }

        }

        //返回string
        public static string PostData(string url, object reposeData)
        {

            using (HttpClient client = new HttpClient())
            {
                Task<HttpResponseMessage> response = client.PostAsync(url, new JsonContent(reposeData));
                response.Wait(15000);
                return response.Result.Content.ReadAsStringAsync().Result;
            }

        }
        //返回model
        public static T GetData<T>(string url) where T : new()
        {

            using (HttpClient client = new HttpClient())
            {
                Task<HttpResponseMessage> response = client.GetAsync(url);
                response.Wait(15000);
                string result = response.Result.Content.ReadAsStringAsync().Result;
                return JsonConvert.DeserializeObject<T>(result);
            }

        }
        //返回string
        public static string GetData(string url)
        {
            using (HttpClient client = new HttpClient())
            {
                Task<HttpResponseMessage> response = client.GetAsync(url);
                response.Wait(15000);
                return response.Result.Content.ReadAsStringAsync().Result;
            }

        }
    }
}

二、调用

/// <summary>
/// 测试方法1
/// </summary>
[Test]
public void Test1()
{
    string urlgaya = "https://minthtest.gaiaworkforce.com/api/workflow/form/BatchApproveFormsByPriIds/approve";
    string par = "[{\"formNo\":\"3537157\",\"formType\":\"PROCESSLEAVEFORM\",\"approver\":\"BD90B860-7BFC-48CC-8EA9-6EF5BA352CD0\",\"priKey\":\"0de49e45-c712-11ef-90fe-00163e067bfb\",\"tableData\":[{\"approveMessage\":\"\",\"id\":\"0de49e45-c712-11ef-90fe-00163e067bfb\",\"personId\":\"BD90B860-7BFC-48CC-8EA9-6EF5BA352CD0\",\"status\":\"COMPLETED\"}]}]";
    object ss = JsonConvert.DeserializeObject(par);


    string result12 = CommonUtility.Utils.HttpClientHelper.PostData(urlgaya, ss);

    Assert.Pass();
}
    QueryResponse result1 = CommonUtility.Utils.HttpClientHelper.PostData<QueryResponse>(url,request);/

三、sqlsurger帮助类

using CommDB.Basic;
using CommDB.Exceptions;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace CommDB
{
    /// <summary>
    /// 封装ORM
    /// 使用方法基本类似于 SqlSugar ORM 的 SqlSugarClient
    /// 1.封装单表查询、两表连接查询和三表连接查询  
    /// 2.封装常用的重载方式查询 
    /// 3.封装 sql 查询 调用Ado
    /// </summary>
    public class SqlClient
    {
        //这个ado封装了 sqlsugar 的ado 

        private readonly SqlSugarClient db; //私有变量

        public readonly AdoBase Ado; //直接可以使用 执行sql 相关

        public readonly AopProvider Apo;

        #region 初始化函数
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionString">连接字符串</param>
        /// <param name="dbType">数据库类型  "MySql"、 "SqlServer"、 "Sqlite"  "Oracle";</param>
        public SqlClient(string connectionString, DbType dbType = DbType.MySql)
        {
            db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = connectionString, //连接字符串
                DbType = dbType,     // 数据库类型
                IsAutoCloseConnection = true,   //是否自动关闭连接
                //InitKeyType = InitKeyType.SystemTable 
            });
            Ado = new AdoBase(db);
            Apo = db.Aop;
        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionString">连接字符串</param>
        /// <param name="dbType">数据库类型  "MySql"、 "SqlServer"、 "Sqlite"  "Oracle";</param>
        /// <param name="isAutoCloseConnection">是否自动关闭数据库</param>
        /// <param name="initKeyType">0使用系统主键 1 使用 属性中定义的主键</param>
        public SqlClient(string connectionString, DbType dbType, bool isAutoCloseConnection = true, int initKeyType = 0)
        {
            ConnectionConfig config = new ConnectionConfig()
            {
                ConnectionString = connectionString, //连接字符串
                DbType = dbType, // 数据库类型
                IsAutoCloseConnection = isAutoCloseConnection, //是否自动关闭连接
            };
            if (initKeyType == 0)
            {
                config.InitKeyType = InitKeyType.SystemTable;
            }
            else if (initKeyType == 1)
            {
                config.InitKeyType = InitKeyType.Attribute;
            }
            db = new SqlSugarClient(config);
            Ado = new AdoBase(db);
        }

        #endregion

        #region 其他变量
        /// <summary>
        /// 临时变量 可以存一些额外的数据 
        /// </summary>
        public Dictionary<string, object> TempItems
        {
            get
            {
                return db.TempItems;
            }
            set
            {
                db.TempItems = value;
            }
        }
        #endregion

        #region 查询

        #region 递归实现查询
        public QueryBase<T> Queryable<T>() where T : class, new()
        {
            return new QueryBase<T>(db).Queryable();
        }
        public QueryBase<T, T2> Queryable<T, T2>(Expression<Func<T, T2, object[]>> joinExpression) where T : class, new()
        {
            return new QueryBase<T, T2>(db).Queryable(joinExpression);
        }
        public QueryBase<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression) where T : class, new()
        {
            return new QueryBase<T, T2, T3>(db).Queryable(joinExpression);
        }
        #endregion

        #region 单表查询 重载实现查询

        public List<T> QueryOrderBy<T>(Expression<Func<T, bool>> where = null, Expression<Func<T, object>> orderBy = null, string ascOrDesc = "asc") where T : class, new()
        {
            return Query(@where, orderBy, ascOrDesc);
        }

        public List<T> QueryGroupBy<T>(Expression<Func<T, bool>> where = null, Expression<Func<T, object>> groupBy = null) where T : class, new()
        {
            return Query(@where, null, null, groupBy);
        }

        public List<T> QueryTop<T>(Expression<Func<T, bool>> where = null, int? top = null) where T : class, new()
        {
            return Query(@where, null, null, null, top);
        }

        public List<T> QueryPageList<T>(Expression<Func<T, bool>> where = null, int? pageSize = null, int? pageIndex = null) where T : class, new()
        {
            return Query(@where, null, null, null, null, pageSize, pageIndex);
        }

        public List<T> QueryPageList<T>(Expression<Func<T, bool>> where = null, Expression<Func<T, object>> orderBy = null, string ascOrDesc = "asc", int? pageSize = null, int? pageIndex = null) where T : class, new()
        {
            return Query(@where, orderBy, ascOrDesc, null, null, pageSize, pageIndex);
        }

        public List<T> QueryPageList<T>(Expression<Func<T, bool>> where = null, Expression<Func<T, object>> groupBy = null, int? pageSize = null, int? pageIndex = null) where T : class, new()
        {
            return Query(@where, null, null, groupBy, null, pageSize, pageIndex);
        }

        public List<T> Query<T>(Expression<Func<T, bool>> where = null, Expression<Func<T, object>> orderBy = null, string ascOrDesc = "asc", Expression<Func<T, object>> groupBy = null, int? top = null, int? pageSize = null, int? pageIndex = null) where T : class, new()
        {

            var isQueryable = db.Queryable<T>();
            if (@where != null)
            {
                isQueryable = isQueryable.Where(@where);
            }
            if (orderBy != null)
            {
                if (ascOrDesc.ToLower() == "asc")
                {
                    isQueryable.OrderBy(orderBy, OrderByType.Asc);
                }
                else
                {
                    isQueryable.OrderBy(orderBy, OrderByType.Desc);
                }
            }
            if (groupBy != null)
            {
                isQueryable.GroupBy(groupBy);
            }

            if (top != null)
            {
                isQueryable.Take(top.Value);
            }
            else if (pageIndex != null && pageSize != null)
            {
                isQueryable.ToPageList(pageSize.Value, pageIndex.Value);
            }

            return isQueryable.ToList();

        }



        #endregion

        #region 两个表连接查询 重载实现

        public List<TResult> QueryOrderBy<TResult, T, T2>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, bool>> where = null, Expression<Func<T, T2, object>> orderBy = null, string ascOrDesc = "asc")
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2>(joinExpression, @where, orderBy, ascOrDesc);
        }

        public List<TResult> QueryGroupBy<TResult, T, T2>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, bool>> where = null, Expression<Func<T, T2, object>> groupBy = null)
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2>(joinExpression, @where, null, null, groupBy);
        }

        public List<TResult> QueryTop<TResult, T, T2>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, bool>> where = null, int? top = null)
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2>(joinExpression, @where, null, null, null, top);
        }

        public List<TResult> QueryPageList<TResult, T, T2>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, bool>> where = null, int? pageSize = null, int? pageIndex = null)
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2>(joinExpression, @where, null, null, null, null, pageSize, pageIndex);
        }

        public List<TResult> QueryPageList<TResult, T, T2>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, bool>> where = null, Expression<Func<T, T2, object>> orderBy = null, string ascOrDesc = "asc", int? pageSize = null, int? pageIndex = null)
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2>(joinExpression, @where, orderBy, ascOrDesc, null, null, pageSize, pageIndex);
        }

        public List<TResult> QueryPageList<TResult, T, T2>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, bool>> where = null, Expression<Func<T, T2, object>> groupBy = null, int? pageSize = null, int? pageIndex = null)
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2>(joinExpression, @where, null, null, groupBy, null, pageSize, pageIndex);
        }

        public List<TResult> Query<TResult, T, T2>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, bool>> where = null, Expression<System.Func<T, T2, object>> orderBy = null, string ascOrDesc = "asc", Expression<System.Func<T, T2, object>> groupBy = null, int? top = null, int? pageSize = null, int? pageIndex = null)
            where TResult : class, new()
            where T : class, new()
        {
            if (joinExpression == null)
            {
                throw new CusCommException("连接表达式不能为空");
            }

            var isQueryable = db.Queryable<T, T2>(joinExpression);
            if (@where != null)
            {
                isQueryable = isQueryable.Where(@where);
            }
            if (orderBy != null)
            {
                if (ascOrDesc.ToLower() == "asc")
                {
                    isQueryable.OrderBy(orderBy, OrderByType.Asc);
                }
                else
                {
                    isQueryable.OrderBy(orderBy, OrderByType.Desc);
                }
            }
            if (groupBy != null)
            {
                isQueryable.GroupBy(groupBy);
            }

            if (top != null)
            {
                isQueryable.Take(top.Value);
            }
            else if (pageIndex != null && pageSize != null)
            {
                isQueryable.ToPageList(pageSize.Value, pageIndex.Value);
            }

            return isQueryable.Select((t, t1) => new TResult()).ToList();

        }

        #endregion

        #region 三个表连接查询 重载实现

        public List<TResult> QueryOrderBy<TResult, T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, bool>> where = null, Expression<Func<T, T2, T3, object>> orderBy = null, string ascOrDesc = "asc")
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2, T3>(joinExpression, where, orderBy, ascOrDesc);
        }

        public List<TResult> QueryGroupBy<TResult, T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, bool>> where = null, Expression<Func<T, T2, T3, object>> groupBy = null)
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2, T3>(joinExpression, @where, null, null, groupBy);
        }

        public List<TResult> QueryTop<TResult, T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, bool>> where = null, int? top = null)
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2, T3>(joinExpression, where, null, null, null, top);
        }

        public List<TResult> QueryPageList<TResult, T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, bool>> where = null, int? pageSize = null, int? pageIndex = null)
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2, T3>(joinExpression, @where, null, null, null, null, pageSize, pageIndex);
        }

        public List<TResult> QueryPageList<TResult, T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, bool>> where = null, Expression<Func<T, T2, T3, object>> orderBy = null, string ascOrDesc = "asc", int? pageSize = null, int? pageIndex = null)
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2, T3>(joinExpression, @where, orderBy, ascOrDesc, null, null, pageSize, pageIndex);
        }

        public List<TResult> QueryPageList<TResult, T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, bool>> where = null, Expression<Func<T, T2, T3, object>> groupBy = null, int? pageSize = null, int? pageIndex = null)
            where TResult : class, new()
            where T : class, new()
        {
            return Query<TResult, T, T2, T3>(joinExpression, where, null, null, groupBy, null, pageSize, pageIndex);
        }

        public List<TResult> Query<TResult, T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, bool>> where = null, Expression<System.Func<T, T2, T3, object>> orderBy = null, string ascOrDesc = "asc", Expression<System.Func<T, T2, T3, object>> groupBy = null, int? top = null, int? pageSize = null, int? pageIndex = null)
            where TResult : class, new()
            where T : class, new()
        {
            if (joinExpression == null)
            {
                throw new Exception("连接表达式不能为空");
            }

            var isQueryable = db.Queryable<T, T2, T3>(joinExpression);
            if (@where != null)
            {
                isQueryable = isQueryable.Where(@where);
            }
            if (orderBy != null)
            {
                if (ascOrDesc.ToLower() == "asc")
                {
                    isQueryable.OrderBy(orderBy, OrderByType.Asc);
                }
                else
                {
                    isQueryable.OrderBy(orderBy, OrderByType.Desc);
                }
            }
            if (groupBy != null)
            {
                isQueryable.GroupBy(groupBy);
            }

            if (top != null)
            {
                isQueryable.Take(top.Value);
            }
            else if (pageIndex != null && pageSize != null)
            {
                isQueryable.ToPageList(pageSize.Value, pageIndex.Value);
            }

            return isQueryable.Select((t, t1) => new TResult()).ToList();

        }

        #endregion

        #endregion

        #region 插入


        #region 直接调用
        public virtual int Insertable<T>(List<T> insertObjs) where T : class, new()
        {
            if (insertObjs == null || insertObjs.Count == 0)
            {
                return 0;
            }

            Utity<T>.RemoveSpace(insertObjs);

            return db.Insertable<T>(insertObjs).ExecuteCommand();
        }

        public virtual int Insertable<T>(T insertObj) where T : class, new()
        {
            Utity<T>.RemoveSpace(insertObj);
            return this.Insertable(new List<T>() { insertObj });
        }

        public virtual T InsertableReturnEntity<T>(T insertObj) where T : class, new()
        {
            Utity<T>.RemoveSpace(insertObj);
            return db.Insertable<T>(insertObj).ExecuteReturnEntity();
        }

        //插入不同类型的 对象  对象必须 可以 where T : class, new()
        public virtual int Insertable(List<dynamic> insertObjs)
        {
            if (insertObjs == null || insertObjs.Count == 0)
            {
                return 0;
            }
            try
            {
                db.Ado.BeginTran();
                foreach (var insertObj in insertObjs)
                {
                    db.Insertable(insertObj).ExecuteCommand();
                }
                db.Ado.CommitTran();
                return insertObjs.Count;
            }
            catch (Exception)
            {
                db.Ado.RollbackTran();

                return 0;
            }
        }
        #endregion


        #region 递归调用
        public virtual InsertBase<T> InsertableBase<T>(List<T> insertObjs) where T : class, new()
        {
            return new InsertBase<T>(db).Insertable(insertObjs);
        }

        public virtual InsertBase<T> InsertableBase<T>(T insertObj) where T : class, new()
        {
            return new InsertBase<T>(db).Insertable(insertObj);
        }
        public virtual InsertBase<T> InsertableBase<T>(dynamic insertDynamicObject) where T : class, new()
        {
            return new InsertBase<T>(db).Insertable(insertDynamicObject);
        }
        #endregion

        #endregion

        #region 更新
        #region 直接调用
        public virtual int Updateable<T>(List<T> UpdateObjs) where T : class, new()
        {
            if (UpdateObjs == null || UpdateObjs.Count == 0)
            {
                return 0;
            }
            Utity<T>.RemoveSpace(UpdateObjs);

            return db.Updateable<T>(UpdateObjs).Where(true).ExecuteCommand();
        }

        /// <summary>
        /// 更新单个字段
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="UpdataObj"></param>
        /// <param name="columns"></param>
        public virtual void UpdateColumns<T>(T UpdataObj, Expression<Func<T, object>> columns) where T : class, new()
        {
            Utity<T>.RemoveSpace(UpdataObj);
            db.Updateable(UpdataObj).UpdateColumns(columns).ExecuteCommand();
        }
        public virtual int Updateable<T>(T UpdateObj) where T : class, new()
        {
            Utity<T>.RemoveSpace(UpdateObj);
            return this.Updateable(new List<T>() { UpdateObj });
        }

        //更新不同类型的 对象  对象必须 可以 where T : class, new()
        public virtual int Updateable(List<dynamic> UpdateObjs)
        {
            if (UpdateObjs == null || UpdateObjs.Count == 0)
            {
                return 0;
            }
            try
            {
                db.Ado.BeginTran();
                foreach (var updateObj in UpdateObjs)
                {
                    db.Updateable(updateObj).ExecuteCommand();
                }
                db.Ado.CommitTran();
                return UpdateObjs.Count;
            }
            catch (Exception)
            {
                db.Ado.RollbackTran();
                return 0;
            }
        }
        #endregion

        #region 递归调用
        public virtual UpdateBase<T> UpdateableBase<T>() where T : class, new()
        {
            return new UpdateBase<T>(db).Updateable();
        }
        public virtual UpdateBase<T> UpdateableBase<T>(List<T> UpdateObjs) where T : class, new()
        {
            return new UpdateBase<T>(db).Updateable(UpdateObjs);
        }

        public virtual UpdateBase<T> UpdateableBase<T>(T[] UpdateObjs) where T : class, new()
        {
            return new UpdateBase<T>(db).Updateable(UpdateObjs);
        }
        public virtual UpdateBase<T> UpdateableBase<T>(T UpdateObj) where T : class, new()
        {
            return new UpdateBase<T>(db).Updateable(UpdateObj);
        }
        #endregion
        #endregion

        #region 删除
        #region 直接调用
        private IDeleteable<T> Deleteable<T>() where T : class, new()
        {
            return db.Deleteable<T>();
        }

        public virtual int Deleteable<T>(Expression<Func<T, bool>> expression) where T : class, new()
        {
            return this.Deleteable<T>().Where(expression).ExecuteCommand();
        }

        public virtual int Deleteable<T>(T deleteObj) where T : class, new()
        {
            return this.Deleteable<T>().Where(deleteObj).ExecuteCommand();
        }

        public virtual int Deleteable<T>(List<T> deleteObjs) where T : class, new()
        {
            return this.Deleteable<T>().Where(deleteObjs).ExecuteCommand();
        }

        //删除不同类型的 对象  对象必须 可以 where T : class, new()
        public virtual int Deleteable(List<dynamic> deleteObjs)
        {
            if (deleteObjs == null || deleteObjs.Count == 0)
            {
                return 0;
            }
            try
            {
                db.Ado.BeginTran();
                foreach (var deleteObj in deleteObjs)
                {
                    db.Deleteable(deleteObj).ExecuteCommand();
                }
                db.Ado.CommitTran();
                return deleteObjs.Count;
            }
            catch (Exception)
            {
                db.Ado.RollbackTran();
                return 0;
            }
        }
        #endregion

        #region 递归调用
        public virtual DeleteBase<T> DeleteableBase<T>() where T : class, new()
        {
            return new DeleteBase<T>(db).Deleteable();
        }

        public virtual DeleteBase<T> DeleteableBase<T>(Expression<Func<T, bool>> expression) where T : class, new()
        {
            return new DeleteBase<T>(db).Deleteable(expression);
        }
        public virtual DeleteBase<T> DeleteableBase<T>(T deleteObj) where T : class, new()
        {
            return new DeleteBase<T>(db).Deleteable(deleteObj);
        }

        public DeleteBase<T> DeleteableBase<T>(List<T> deleteObjs) where T : class, new()
        {
            return new DeleteBase<T>(db).Deleteable(deleteObjs);
        }
        #endregion

        #endregion

    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/957831.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Python3 OS模块中的文件/目录方法六

一. 简介 前面文章简单学习了Python3中 OS模块中的文件/目录的部分函数。 本文继续来学习 OS模块中文件、目录的操作方法。 二. Python3 OS模块中的文件/目录方法 1. os.lseek() 方法、os.lstat() 方法 os.lseek() 方法用于在打开的文件中移动文件指针的位置。在Unix&#…

HTB:Heist[WriteUP]

目录 连接至HTB服务器并启动靶机 信息收集 使用rustscan对靶机TCP端口进行开放扫描 将靶机TCP开放端口号提取并保存 使用nmap对靶机TCP开放端口进行脚本、服务扫描 使用nmap对靶机TCP开放端口进行漏洞、系统扫描 使用nmap对靶机常用UDP端口进行开放扫描 使用smbclient匿…

【HarmonyOS NEXT】华为分享-碰一碰开发分享

关键词&#xff1a;鸿蒙、碰一碰、systemShare、harmonyShare、Share Kit 华为分享新推出碰一碰分享&#xff0c;支持用户通过手机碰一碰发起跨端分享&#xff0c;可实现传输图片、共享wifi等。我们只需调用系统 api 传入所需参数拉起对应分享卡片模板即可&#xff0c;无需对 U…

使用Inno Setup软件制作.exe安装包

1.下一步&#xff1a; 2. 填写 程序名字 和 版本号&#xff1a; 3.设置安装路径信息 4.添加要打包的exe和依赖文件 5.为应用程序创建关联的文件 如果不需要就直接取消勾选 6.创建快捷方式 &#xff08;1&#xff09;第一种&#xff1a;常用 &#xff08;1&#xff09;第二种&am…

CPU 缓存基础知识

并发编程首先需要简单了解下现代CPU相关知识。通过一些简单的图&#xff0c;简单的代码&#xff0c;来认识CPU以及一些常见的问题。 目录 CPU存储与缓存的引入常见的三级缓存结构缓存一致性协议MESI协议缓存行 cache line 通过代码实例认识缓存行的重要性 CPU指令的乱序执行通过…

初步搭建并使用Scrapy框架

目录 目标 版本 实战 搭建框架 获取图片链接、书名、价格 通过管道下载数据 通过多条管道下载数据 下载多页数据 目标 掌握Scrapy框架的搭建及使用&#xff0c;本文以爬取当当网魔幻小说为案例做演示。 版本 Scrapy 2.12.0 实战 搭建框架 第一步&#xff1a;在D:\pyt…

Python - itertools- pairwise函数的详解

前言&#xff1a; 最近在leetcode刷题时用到了重叠对pairwise,这里就讲解一下迭代工具函数pairwise,既介绍给大家&#xff0c;同时也提醒一下自己&#xff0c;这个pairwise其实在刷题中十分有用&#xff0c;相信能帮助到你。 参考官方讲解&#xff1a;itertools --- 为高效循…

YOLO-cls训练及踩坑记录

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言 一、模型训练 二、测试 三、踩坑记录 1、推理时设置的imgsz不生效 方法一&#xff1a; 方法二&#xff1a; 2、Windows下torchvision版本问题导致报错 总结 前…

云计算、AI与国产化浪潮下DBA职业之路风云变幻,如何谋破局启新途?

引言 在近日举办的一场「云和恩墨大讲堂」直播栏目中&#xff0c;云和恩墨联合创始人李轶楠、副总经理熊军和欧冶云商数据库首席薛晓刚共同探讨了DBA的现状与未来发展。三位专家从云计算、人工智能、国产化替代等多个角度进行了深入的分析和探讨&#xff0c;为从业者提供了宝贵…

PAT甲级-1017 Queueing at Bank

题目 题目大意 银行有k个窗口&#xff0c;每个窗口只能服务1个人。如果3个窗口已满&#xff0c;就需要等待。给出n个人到达银行的时间和服务时间&#xff0c;要求计算每个人的平均等待时间。如果某个人的到达时间超过17:00:00&#xff0c;则不被服务&#xff0c;等待时间也不计…

从零安装 LLaMA-Factory 微调 Qwen 大模型成功及所有的坑

文章目录 从零安装 LLaMA-Factory 微调 Qwen 大模型成功及所有的坑一 参考二 安装三 启动准备大模型文件 四 数据集&#xff08;关键&#xff09;&#xff01;4.1 Alapaca格式4.2 sharegpt4.3 在 dataset_info.json 中注册4.4 官方 alpaca_zh_demo 例子 999条数据, 本机微调 5分…

AI刷题-策略大师:小I与小W的数字猜谜挑战

问题描述 有 1, 2,..., n &#xff0c;n 个数字&#xff0c;其中有且仅有一个数字是中奖的&#xff0c;这个数字是等概率随机生成的。 Alice 和 Bob 进行一个游戏&#xff1a; 两人轮流猜一个 1 到 n 的数字&#xff0c;Alice 先猜。 每完成一次猜测&#xff0c;主持会大声…

【数据分享】1929-2024年全球站点的逐年最低气温数据(Shp\Excel\免费获取)

气象数据是在各项研究中都经常使用的数据&#xff0c;气象指标包括气温、风速、降水、湿度等指标&#xff01;说到气象数据&#xff0c;最详细的气象数据是具体到气象监测站点的数据&#xff01; 有关气象指标的监测站点数据&#xff0c;之前我们分享过1929-2024年全球气象站点…

CSDN 博客之星 2024:默语的技术进阶与社区耕耘之旅

CSDN 博客之星 2024&#xff1a;默语的技术进阶与社区耕耘之旅 &#x1f31f; 默语&#xff0c;是一位在技术分享与社区建设中坚持深耕的博客作者。今年&#xff0c;我有幸再次入围成为 CSDN 博客之星TOP300 的一员&#xff0c;这既是对过往努力的肯定&#xff0c;也是对未来探…

计算机网络 (56)交互式音频/视频

一、定义与特点 定义&#xff1a;交互式音频/视频是指用户使用互联网和其他人进行实时交互式通信的技术&#xff0c;包括语音、视频图像等多媒体实时通信。 特点&#xff1a; 实时性&#xff1a;音频和视频数据是实时传输和播放的&#xff0c;用户之间可以进行即时的交流。交互…

Node.js——express中间件(全局中间件、路由中间件、静态资源中间件)

个人简介 &#x1f440;个人主页&#xff1a; 前端杂货铺 &#x1f64b;‍♂️学习方向&#xff1a; 主攻前端方向&#xff0c;正逐渐往全干发展 &#x1f4c3;个人状态&#xff1a; 研发工程师&#xff0c;现效力于中国工业软件事业 &#x1f680;人生格言&#xff1a; 积跬步…

嵌入式知识点总结 ARM体系与架构 专题提升(一)-硬件基础

嵌入式知识点总结 ARM体系与架构 专题提升(一)-硬件基础 目录 1.NAND FLASH 和NOR FLASH异同 ? 2.CPU,MPU,MCU,SOC,SOPC联系与差别? 3.什么是交叉编译&#xff1f; 4.为什么要交叉编译&#xff1f; 5.描述一下嵌入式基于ROM的运行方式和基于RAM的运行方式有什么区别? 1…

【JavaSE】(8) String 类

一、String 类常用方法 1、构造方法 常用的这4种构造方法&#xff1a;直接法&#xff0c;或者传参字符串字面量、字符数组、字节数组。 在 JDK1.8 中&#xff0c;String 类的字符串实际存储在 char 数组中&#xff1a; String 类也重写了 toString 方法&#xff0c;所以可以直…

JS(6)-数组

一.数组的基本使用 1.数组&#xff1a;把多个数据存到一组 每个数组都有编号&#xff0c;从零开始&#xff0c;数组的编号叫索引或下标&#xff0c;可以存放数字&#xff0c;字符串等。 2.取值 3.遍历数组&#xff1a;用循环的方法把每个数都访问到 a)练习 首先&#xff0c;定…

查看电脑或笔记本CPU的核心数方法及CPU详细信息

一、通过任务管理器查看 1.打开任务管理器 可以按下“Ctrl Shift Esc”组合键&#xff0c;或者按下“Ctrl Alt Delete”组合键后选择“任务管理器”来打开。 2.查看CPU信息 在任务管理器界面中&#xff0c;点击“性能”标签页&#xff0c;找到CPU使用记录区域&#xff0c…