更新
This commit is contained in:
@@ -15,14 +15,6 @@ namespace ylib
|
||||
int64 start = -1;
|
||||
int64 count = -1;
|
||||
};
|
||||
enum sort {
|
||||
ASC,
|
||||
DESC
|
||||
};
|
||||
struct order_by {
|
||||
std::string field;
|
||||
ylib::sort sort;
|
||||
};
|
||||
struct keyvalue {
|
||||
std::string name;
|
||||
std::any value;
|
||||
@@ -71,7 +63,7 @@ namespace ylib
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
select& orderby(const std::string& field, sort sort = DESC);
|
||||
select& orderby(const std::string& expression);
|
||||
/// <summary>
|
||||
/// 查询数量
|
||||
/// </summary>
|
||||
@@ -106,7 +98,7 @@ namespace ylib
|
||||
std::string m_table_name;
|
||||
std::vector<std::string> m_fields;
|
||||
ylib::limit m_limit;
|
||||
order_by m_orderby;
|
||||
std::string m_orderby;
|
||||
|
||||
};
|
||||
/// <summary>
|
||||
@@ -157,7 +149,7 @@ namespace ylib
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
update& orderby(const std::string& field, sort sort = DESC);
|
||||
update& orderby(const std::string& expression);
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
@@ -181,7 +173,7 @@ namespace ylib
|
||||
std::string m_table_name;
|
||||
std::vector<struct ylib::update::set> m_sets;
|
||||
ylib::limit m_limit;
|
||||
order_by m_orderby;
|
||||
std::string m_orderby;
|
||||
|
||||
};
|
||||
/// <summary>
|
||||
@@ -250,7 +242,7 @@ namespace ylib
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
delete_& orderby(const std::string& field, sort sort = DESC);
|
||||
delete_& orderby(const std::string& expression);
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
@@ -271,7 +263,7 @@ namespace ylib
|
||||
std::vector<ylib::where> m_wheres;
|
||||
std::string m_table_name;
|
||||
ylib::limit m_limit;
|
||||
order_by m_orderby;
|
||||
std::string m_orderby;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,104 +1,91 @@
|
||||
//#pragma once
|
||||
//#include "http_define.h"
|
||||
//#if USE_NET_HTTP_WEBSITE
|
||||
//#include "http_request.h"
|
||||
//#include "http_response.h"
|
||||
//#include "http_reqpack.h"
|
||||
//#include "http_interface.h"
|
||||
//#define _DBL_MIN 2.2250738585072014e-308 // min positive value
|
||||
//#define _DBL_MAX 1.7976931348623158e+308 // max value
|
||||
//#define _INT_MIN (-2147483647 - 1)
|
||||
//#define _INT_MAX 2147483647
|
||||
//#define _UINT_MAX 0xffffffff
|
||||
//#define _LONG_MIN (-2147483647L - 1)
|
||||
//#define _LONG_MAX 2147483647L
|
||||
//#define _ULONG_MAX 0xffffffff
|
||||
//#ifndef _LLONG_MAX
|
||||
//#define _LLONG_MAX 9223372036854775807
|
||||
//#endif
|
||||
//#define _LLONG_MIN (-9223372036854775807 - 1)
|
||||
//#define _ULLONG_MAX 0xffffffffffffffff
|
||||
//#define _INT8_MIN (-127 - 1)
|
||||
//#define _INT16_MIN (-32767 - 1)
|
||||
//#define _INT32_MIN (-2147483647 - 1)
|
||||
//#define _INT64_MIN (-9223372036854775807 - 1)
|
||||
//#define _INT8_MAX 127
|
||||
//#define _INT16_MAX 32767
|
||||
//#define _INT32_MAX 2147483647
|
||||
//#define _INT64_MAX 9223372036854775807
|
||||
//#define _UINT8_MAX 0xff
|
||||
//#define _UINT16_MAX 0xffff
|
||||
//#define _UINT32_MAX 0xffffffff
|
||||
//#define _UINT64_MAX 0xffffffffffffffff
|
||||
//#define _FLT_MIN 1.175494351e-38F // min normalized positive value
|
||||
//#define _FLT_MAX 3.402823466e+38F // max value
|
||||
//using namespace ylib::network::http;
|
||||
//
|
||||
//// 成功回复
|
||||
//#define REPLY_SUCC rpjson()["code"] = 200;return RT_OK
|
||||
//// 自定义回复
|
||||
//#define REPLY(CODE,MSG) rpjson()["code"] = CODE;rpjson()["msg"]=MSG;return RT_OK
|
||||
//// 失败回复
|
||||
//#define REPLY_ERROR(MSG) rpjson()["code"] = -1;rpjson()["msg"]=MSG;return RT_OK
|
||||
///**********************************************************
|
||||
// * Class:Http控制器接口
|
||||
// *********************************************************/
|
||||
////#define check_qry_json(NAME) request()->parser()->json()[NAME].is_empty()
|
||||
//#define qry_json_string(NAME) request()->parser()->json()[NAME].to<std::string>(true)
|
||||
//#define qry_json_uint32(NAME) request()->parser()->json()[NAME].to<uint32>(true)
|
||||
//#define qry_json_uint64(NAME) request()->parser()->json()[NAME].to<uint64>(true)
|
||||
//#define qry_json_int32(NAME) request()->parser()->json()[NAME].to<int32>(true)
|
||||
//#define qry_json_double(NAME) request()->parser()->json()[NAME].to<double>(true)
|
||||
//#define qry_json_short(NAME) request()->parser()->json()[NAME].to<short>(true)
|
||||
//#define qry_json_bool(NAME) request()->parser()->json()[NAME].to<bool>(true)
|
||||
//namespace ylib
|
||||
//{
|
||||
// namespace network
|
||||
// {
|
||||
// namespace http
|
||||
// {
|
||||
// class router;
|
||||
// class controller :public network::http::interface_
|
||||
// {
|
||||
// public:
|
||||
// controller();
|
||||
// ~controller();
|
||||
// network::http::request* request();
|
||||
// network::http::response* response();
|
||||
//
|
||||
// //min和max为<=或>= ,若填-1则不使用该条件
|
||||
// std::string qry_string(const std::string& name,bool exception = true);
|
||||
// int32 qry_int32(const std::string& name, bool exception = true);
|
||||
// uint32 qry_uint32(const std::string& name, bool exception = true);
|
||||
// int64 qry_int64(const std::string& name, bool exception = true);
|
||||
// uint64 qry_uint64(const std::string& name, bool exception = true);
|
||||
// double qry_double(const std::string& name, bool exception = true);
|
||||
// float qry_float(const std::string& name, bool exception = true);
|
||||
// bool qry_empty(const std::string& name, bool exception = true);
|
||||
// bool qry_bool(const std::string& name, bool exception = true);
|
||||
// ylib::buffer qry_buffer(const std::string& name, bool exception);
|
||||
//
|
||||
// // 请求参数
|
||||
// bool request_param(const std::string& name, std::string& value);
|
||||
//
|
||||
// // 获取回复JSON
|
||||
// inline ylib::json& rpjson() { return response()->sjson["data"]; }
|
||||
// inline ylib::json& rpcode() { return response()->sjson["code"]; }
|
||||
// //inline ylib::json& rp() { return response()->sjson["code"]; }
|
||||
// inline void rp(int code, const std::string& msg = "", const ylib::json& data = ylib::json())
|
||||
// {
|
||||
// response()->sjson["code"] = code;
|
||||
// response()->sjson["msg"] = msg;
|
||||
// response()->sjson["data"] = data;
|
||||
// };
|
||||
//
|
||||
// void send(const ylib::json& data);
|
||||
//
|
||||
// friend class router;
|
||||
// private:
|
||||
// network::http::reqpack* m_reqpack = nullptr;
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//#endif
|
||||
#pragma once
|
||||
#include "http_define.h"
|
||||
#if USE_NET_HTTP_WEBSITE
|
||||
#include "http_request.h"
|
||||
#include "http_response.h"
|
||||
#include "http_reqpack.h"
|
||||
#include "http_interface.h"
|
||||
#define _DBL_MIN 2.2250738585072014e-308 // min positive value
|
||||
#define _DBL_MAX 1.7976931348623158e+308 // max value
|
||||
#define _INT_MIN (-2147483647 - 1)
|
||||
#define _INT_MAX 2147483647
|
||||
#define _UINT_MAX 0xffffffff
|
||||
#define _LONG_MIN (-2147483647L - 1)
|
||||
#define _LONG_MAX 2147483647L
|
||||
#define _ULONG_MAX 0xffffffff
|
||||
#ifndef _LLONG_MAX
|
||||
#define _LLONG_MAX 9223372036854775807
|
||||
#endif
|
||||
#define _LLONG_MIN (-9223372036854775807 - 1)
|
||||
#define _ULLONG_MAX 0xffffffffffffffff
|
||||
#define _INT8_MIN (-127 - 1)
|
||||
#define _INT16_MIN (-32767 - 1)
|
||||
#define _INT32_MIN (-2147483647 - 1)
|
||||
#define _INT64_MIN (-9223372036854775807 - 1)
|
||||
#define _INT8_MAX 127
|
||||
#define _INT16_MAX 32767
|
||||
#define _INT32_MAX 2147483647
|
||||
#define _INT64_MAX 9223372036854775807
|
||||
#define _UINT8_MAX 0xff
|
||||
#define _UINT16_MAX 0xffff
|
||||
#define _UINT32_MAX 0xffffffff
|
||||
#define _UINT64_MAX 0xffffffffffffffff
|
||||
#define _FLT_MIN 1.175494351e-38F // min normalized positive value
|
||||
#define _FLT_MAX 3.402823466e+38F // max value
|
||||
using namespace ylib::network::http;
|
||||
|
||||
// 成功回复
|
||||
#define REPLY_SUCC rpjson()["code"] = 200;return RT_OK
|
||||
// 自定义回复
|
||||
#define REPLY(CODE,MSG) rpjson()["code"] = CODE;rpjson()["msg"]=MSG;return RT_OK
|
||||
// 失败回复
|
||||
#define REPLY_ERROR(MSG) rpjson()["code"] = -1;rpjson()["msg"]=MSG;return RT_OK
|
||||
/**********************************************************
|
||||
* Class:Http控制器接口
|
||||
*********************************************************/
|
||||
//#define check_qry_json(NAME) request()->parser()->json()[NAME].is_empty()
|
||||
#define qry_json_string(NAME) request()->parser()->json()[NAME].to<std::string>(true)
|
||||
#define qry_json_uint32(NAME) request()->parser()->json()[NAME].to<uint32>(true)
|
||||
#define qry_json_uint64(NAME) request()->parser()->json()[NAME].to<uint64>(true)
|
||||
#define qry_json_int32(NAME) request()->parser()->json()[NAME].to<int32>(true)
|
||||
#define qry_json_double(NAME) request()->parser()->json()[NAME].to<double>(true)
|
||||
#define qry_json_short(NAME) request()->parser()->json()[NAME].to<short>(true)
|
||||
#define qry_json_bool(NAME) request()->parser()->json()[NAME].to<bool>(true)
|
||||
namespace ylib
|
||||
{
|
||||
namespace network
|
||||
{
|
||||
namespace http
|
||||
{
|
||||
class router;
|
||||
class controller :public network::http::interface_
|
||||
{
|
||||
public:
|
||||
controller();
|
||||
~controller();
|
||||
const std::shared_ptr<network::http::request>& request();
|
||||
const std::shared_ptr<network::http::response>& response();
|
||||
|
||||
|
||||
|
||||
// 获取回复JSON
|
||||
inline ylib::json& rpjson() { return response()->sjson["data"]; }
|
||||
inline ylib::json& rpcode() { return response()->sjson["code"]; }
|
||||
//inline ylib::json& rp() { return response()->sjson["code"]; }
|
||||
inline void rp(int code, const std::string& msg = "", const ylib::json& data = ylib::json())
|
||||
{
|
||||
response()->sjson["code"] = code;
|
||||
response()->sjson["msg"] = msg;
|
||||
response()->sjson["data"] = data;
|
||||
};
|
||||
inline ylib::json rqjson() { return ylib::json::from(request()->body().to_string()); }
|
||||
void send(const ylib::json& data);
|
||||
|
||||
friend class router;
|
||||
private:
|
||||
network::http::reqpack* m_reqpack = nullptr;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace ylib
|
||||
void merge(const std::string& ck);
|
||||
std::string to_string();
|
||||
void clear();
|
||||
std::map<std::string, std::string>& toSTL();
|
||||
private:
|
||||
std::map<std::string, std::string> m_param;
|
||||
};
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace ylib
|
||||
std::regex regex;
|
||||
std::string pattern;
|
||||
std::string extra;
|
||||
std::function<void(network::http::request* request,network::http::response* response,const std::string& pattern,const std::string& extra)> callback;
|
||||
std::function<void(network::http::request* request, network::http::response* response, const std::string& pattern, const std::string& extra)> callback;
|
||||
std::function<void(network::http::request* request, network::http::response* response)> callback2;
|
||||
};
|
||||
/******************************************************
|
||||
* class:订阅器
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ylib
|
||||
ylib::buffer de(const std::string& data);
|
||||
}
|
||||
namespace url {
|
||||
std::string en(const ylib::buffer& data);
|
||||
std::string en(const std::string& data);
|
||||
ylib::buffer de(const std::string& data);
|
||||
}
|
||||
#if 1
|
||||
|
||||
Reference in New Issue
Block a user