14#include <QPrinterInfo>
17#include <qjsonarray.h>
18#include <qjsonobject.h>
36 std::optional<int>
uid;
51 obj[
"is_success"] =
false;
52 if (
uid.has_value()) {
53 obj[
"uid"] =
uid.value();
64 static constexpr inline std::string_view
method{
"add_config"};
65 std::optional<int>
uid;
82 obj[
"is_success"] =
true;
83 if (
uid.has_value()) {
84 obj[
"uid"] =
uid.value();
95 static constexpr inline std::string_view
method{
"update_config"};
96 std::optional<int>
uid;
107 obj[
"is_success"] =
true;
108 if (
uid.has_value()) {
109 obj[
"uid"] =
uid.value();
119 static constexpr inline std::string_view
method{
"del_config"};
134 obj[
"is_success"] =
true;
135 if (
uid.has_value()) {
136 obj[
"uid"] =
uid.value();
146 static constexpr inline std::string_view
method{
"get_all_configs"};
154 std::deque<PrinterConfig>
data{};
156 const std::deque<PrinterConfig>& configs) {
158 obj[
"is_success"] =
true;
159 if (
uid.has_value()) {
160 obj[
"uid"] =
uid.value();
163 for (
auto& config : configs) {
175 static constexpr inline std::string_view
method{
"get_pages_desc"};
185 std::deque<PrinterConfig>
data{};
193 const std::deque<PrintedPage>& configs,
int count) {
195 obj[
"is_success"] =
true;
196 if (
uid.has_value()) {
197 obj[
"uid"] =
uid.value();
200 for (
auto& config : configs) {
204 obj[
"count"] =
count;
213 static constexpr inline std::string_view
method{
"get_websocket_server_port"};
228 obj[
"is_success"] =
true;
229 if (
uid.has_value()) {
230 obj[
"uid"] =
uid.value();
241 static constexpr inline std::string_view
method{
"get_printers_info"};
256 static QJsonObject
toJsonObject(std::optional<int>
uid,
const QList<QPrinterInfo>& printers) {
258 obj[
"is_success"] =
true;
259 if (
uid.has_value()) {
260 obj[
"uid"] =
uid.value();
263 for (
auto& printer : printers) {
264 QJsonObject printer_obj;
265 printer_obj[
"printer_name"] = printer.printerName();
266 QJsonArray paper_names_arr;
267 for (
auto& paper_name : printer.supportedPageSizes()) {
268 paper_names_arr.append(paper_name.name());
270 printer_obj[
"supported_paper_names"] = paper_names_arr;
271 arr.append(printer_obj);
283 static constexpr inline std::string_view
method{
"print_page"};
305 obj[
"is_success"] =
true;
306 if (
uid.has_value()) {
307 obj[
"uid"] =
uid.value();
QJsonObject toPrinterConfigJson(const PrinterConfig &config)
定义 ModelsJson.cpp:88
QJsonObject toPrintedPageJson(const PrintedPage &page)
定义 ModelsJson.cpp:6
QList< QString > supported_paper_names
定义 WebInterface.h:246
QString printer_name
定义 WebInterface.h:245
添加打印配置 request
定义 WebInterface.h:63
PrinterConfig data
定义 WebInterface.h:66
std::optional< int > uid
定义 WebInterface.h:65
static constexpr std::string_view method
定义 WebInterface.h:64
删除打印配置 request
定义 WebInterface.h:118
std::optional< int > uid
定义 WebInterface.h:120
static constexpr std::string_view method
定义 WebInterface.h:119
int data
打印配置id
定义 WebInterface.h:125
获取所有打印配置 request
定义 WebInterface.h:145
std::optional< int > uid
定义 WebInterface.h:147
static constexpr std::string_view method
定义 WebInterface.h:146
倒序打印页面获取 request
定义 WebInterface.h:174
int page_size
定义 WebInterface.h:178
std::optional< int > uid
定义 WebInterface.h:176
int page_index
定义 WebInterface.h:177
static constexpr std::string_view method
定义 WebInterface.h:175
获取打印机信息 request
定义 WebInterface.h:240
static constexpr std::string_view method
定义 WebInterface.h:241
std::optional< int > uid
定义 WebInterface.h:242
获取 websocket 服务器端口号 request
定义 WebInterface.h:212
std::optional< int > uid
定义 WebInterface.h:214
static constexpr std::string_view method
定义 WebInterface.h:213
打印页面 request
定义 WebInterface.h:282
static constexpr std::string_view method
定义 WebInterface.h:283
std::optional< int > uid
定义 WebInterface.h:284
PrintedPage data
定义 WebInterface.h:285
更新打印配置 request
定义 WebInterface.h:94
std::optional< int > uid
定义 WebInterface.h:96
static constexpr std::string_view method
定义 WebInterface.h:95
PrinterConfig data
定义 WebInterface.h:97
添加打印配置 response
定义 WebInterface.h:72
static QJsonObject toJsonObject(std::optional< int > uid, int config_id)
定义 WebInterface.h:79
int config_id
打印配置id,由sqlite 生成
定义 WebInterface.h:77
bool is_success
是否成功
定义 WebInterface.h:30
std::optional< int > uid
uid,websocket 的消息request 和 resp 不限制对应关系,uid 保证了他们的联系, 也就是 uid 相同 的 request 和 response 对应 由request端生成
定义 WebInterface.h:36
删除打印配置 response
定义 WebInterface.h:131
static QJsonObject toJsonObject(std::optional< int > uid)
定义 WebInterface.h:132
所有接口的错误返回
定义 WebInterface.h:43
static QJsonObject toJsonObject(std::optional< int > uid, const QString &msg)
定义 WebInterface.h:49
QString msg
错误信息
定义 WebInterface.h:48
获取所有打印配置 response
定义 WebInterface.h:153
std::deque< PrinterConfig > data
定义 WebInterface.h:154
static QJsonObject toJsonObject(std::optional< int > uid, const std::deque< PrinterConfig > &configs)
定义 WebInterface.h:155
倒序打印页面获取 response
定义 WebInterface.h:184
std::deque< PrinterConfig > data
定义 WebInterface.h:185
int count
总数目
定义 WebInterface.h:191
static QJsonObject toJsonObject(std::optional< int > uid, const std::deque< PrintedPage > &configs, int count)
定义 WebInterface.h:192
获取打印机信息 response
定义 WebInterface.h:252
QList< PrinterInfo > data
定义 WebInterface.h:254
static QJsonObject toJsonObject(std::optional< int > uid, const QList< QPrinterInfo > &printers)
定义 WebInterface.h:256
获取 websocket 服务器端口号 response
定义 WebInterface.h:220
QString data
websocket 端口号
定义 WebInterface.h:225
static QJsonObject toJsonObject(std::optional< int > uid, const QString &port)
定义 WebInterface.h:226
打印页面 response
定义 WebInterface.h:291
QString file_path
输出的文件路径,不包含后缀,(.pdf 或.png)
定义 WebInterface.h:296
int page_id
sqlite中存储的对应数据的id
定义 WebInterface.h:301
static QJsonObject toJsonObject(std::optional< int > uid, const QString &file_path, int page_id)
定义 WebInterface.h:303
更新打印配置 response
定义 WebInterface.h:103
static QJsonObject toJsonObject(std::optional< int > uid)
定义 WebInterface.h:105