From 5bc3db60e7fe513873b0e8dd81b8ae9019a907ee Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Wed, 31 May 2023 21:43:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E5=90=88=20amis=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/index.html | 197 +++++++++++++++++++++ frontend/pages/question.json | 152 ++++++++++++++++ frontend/pages/site.json | 23 +++ frontend/public/logo.png | Bin 0 -> 6242 bytes frontend/x-pages/console.json | 5 + frontend/x-pages/crud-advance.json | 274 +++++++++++++++++++++++++++++ frontend/x-pages/crud-edit.json | 64 +++++++ frontend/x-pages/crud-list.json | 149 ++++++++++++++++ frontend/x-pages/crud-new.json | 69 ++++++++ frontend/x-pages/crud-view.json | 65 +++++++ frontend/x-pages/editor.json | 18 ++ frontend/x-pages/excel.json | 50 ++++++ frontend/x-pages/form-basic.json | 241 +++++++++++++++++++++++++ frontend/x-pages/jsonp.js | 12 ++ frontend/x-pages/pageA.json | 177 +++++++++++++++++++ frontend/x-pages/site.json | 126 +++++++++++++ frontend/x-pages/wizard.json | 105 +++++++++++ handler/car.py | 14 +- main.py | 8 +- utils/common.py | 12 ++ 20 files changed, 1759 insertions(+), 2 deletions(-) create mode 100644 frontend/index.html create mode 100644 frontend/pages/question.json create mode 100644 frontend/pages/site.json create mode 100644 frontend/public/logo.png create mode 100644 frontend/x-pages/console.json create mode 100644 frontend/x-pages/crud-advance.json create mode 100644 frontend/x-pages/crud-edit.json create mode 100644 frontend/x-pages/crud-list.json create mode 100644 frontend/x-pages/crud-new.json create mode 100644 frontend/x-pages/crud-view.json create mode 100644 frontend/x-pages/editor.json create mode 100644 frontend/x-pages/excel.json create mode 100644 frontend/x-pages/form-basic.json create mode 100644 frontend/x-pages/jsonp.js create mode 100644 frontend/x-pages/pageA.json create mode 100644 frontend/x-pages/site.json create mode 100644 frontend/x-pages/wizard.json diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..ebac447 --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,197 @@ + + + + + amis admin + + + + + + + + + + + +
+ + + diff --git a/frontend/pages/question.json b/frontend/pages/question.json new file mode 100644 index 0000000..4d6c1e5 --- /dev/null +++ b/frontend/pages/question.json @@ -0,0 +1,152 @@ +{ + "type": "page", + "body": [ + { + "title": "查询条件", + "type": "form", + "target": "dataTable", + "body": [ + { + "type": "input-text", + "name": "keyword", + "label": "关键字:" + } + ], + "submitText": "搜索" + }, + { + "type": "crud", + "name": "dataTable", + "api": { + "method": "post", + "url": "/api/car/amis/list", + "data": { + "page": "${page}", + "size": "${perPage}", + "keyword": "$keyword" + } + }, + "mode": "cards", + "data": { + "answerMap": [ + "", + "", + "", + "", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H" + ] + }, + "columnsCount": 1, + "card": { + "body": [ + { + "name": "id", + "label": "id", + "hidden": true + }, + { + "name": "question_id", + "label": "题目id", + "hidden": true + }, + { + "name": "keywords", + "label": "关键字", + "hidden": true + }, + { + "name": "answer", + "label": "答案", + + "type": "tpl", + "tpl": "<%= data.answerMap.filter((_,index)=>{return (data.answer).toString(2).split('').reverse()[index] == '1'}) %>" + + }, + { + "name": "question", + "label": "题目" + }, + { + "name": "media_content", + "label": "图片", + "width": "400px", + "height": "300px", + "type": "image", + "enlargeAble": true, + "hiddenOn": "this.media_content == 'None'" + }, + { + "name": "option_a", + "label": "A", + "hiddenOn": "this.option_a.length == 0" + }, + { + "name": "option_b", + "label": "B", + "hiddenOn": "this.option_b.length == 0" + }, + { + "name": "option_c", + "label": "C", + "hiddenOn": "this.option_c.length == 0" + }, + { + "name": "option_d", + "label": "D", + "hiddenOn": "this.option_d.length == 0" + }, + { + "name": "option_e", + "label": "E", + "hiddenOn": "this.option_e.length == 0" + }, + { + "name": "option_f", + "label": "F", + "hiddenOn": "this.option_f.length == 0" + }, + { + "name": "option_g", + "label": "G", + "hiddenOn": "this.option_g.length == 0" + }, + { + "name": "option_h", + "label": "H", + "hiddenOn": "this.option_h.length == 0" + }, + { + "name": "explain", + "label": "解析", + "body": "$explain" + }, + { + "name": "illiteracy_explain", + "label": "相关规定" + }, + { + "name": "knack", + "label": "窍门" + }, + { + "name": "concise_explain", + "label": "简单解析" + }, + { + "name": "wrong_rate", + "label": "错误率", + "type": "tpl", + "tpl": "${wrong_rate * 100}%" + } + ] + } + } + ] +} diff --git a/frontend/pages/site.json b/frontend/pages/site.json new file mode 100644 index 0000000..bd4c660 --- /dev/null +++ b/frontend/pages/site.json @@ -0,0 +1,23 @@ +{ + "status": 0, + "msg": "", + "data": { + "pages": [ + { + "label": "Home", + "url": "/", + "redirect": "/index" + }, + { + "label": "题库", + "children": [ + { + "label": "题库", + "url": "/index", + "schemaApi": "get:/pages/question.json" + } + ] + } + ] + } +} diff --git a/frontend/public/logo.png b/frontend/public/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..c9ea77efc0fa29c8b19473270cbc35858c0e0e82 GIT binary patch literal 6242 zcmZ`-Wmr^e*WNS&64H#Mbj^@McPfo^#}Lv(r=+xm#LyA~5+W@Pf;b=@(jbkLC?E|V zdd_>!`Ofve`?~gi)?Vwr*S*$$)}Q@EYp5yS#i7Ch0N}2&lAPAs?q>Zoq&63fpPmzXQia23IKl001zAw0Oz-^;4J{~gaE*{IRJ_l``;{exIOIlv;3m{rSebTzwsJ&E*>toTLibaQg-%$!Ea0all>pT|Bd)Zu3vqN zXxRI}9QEbwonX$tyA%=@1OL~+zlpLgjxKO*R|_lHubO{T{^9yJ`nQb1|C0Gf;7_6$ z_}3KtV=Dd_x!>N~nUlZ~1OGL@5;&?hFS-GMBvx5Y`mqnno{4`7wR}d^cDpw-B;f)P z9*lX18+bRNvvtg z@TSE!!o*i84fw>aoT6yse3FAj&)3-U^W->3^y~ar+vA+RON%_dr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ANhkVS%&uk|JS(BCXuRVM3#<-9~HM)2`B}s+b>L8~JZJ@U1k2CJ7Oy zGKxa_bT6`KSIi^ZB0|1>a+}3r57S$L`!F@Tib7o%_QOT*qUBL?<{X!aMyumTm`qyl z5VhCir117upru+`lVP0d(`kDmt``uxjL7vjyxE|hgM5`Tk{?p_Jc5t>P){Zzb;H5NBCHohnVTlKTil#@gM|oQLJExSbmRQM}76h0mZAa z&vjm=m`qo&=@ZTet%-OI+P*yxeNc{2!BAthdmEd#%sG~3T^?_sdI4L^yZ1r*6XE!Y zZWxb77wmje63B78<~4`mhmzVz5w)5Fapi^Jaa`q1bqbh=<;w)bEqh6`mnd+=9gi0!g7d(6NvQifaQ_nRmK% z_?&y*tBDFw4#My--{qs1fNM?JS5{6yIM%V0GtTApPrK}bhdKL8VA>vj(7+!fS#9?_ z6Y+yWY3cUQE(N*%R=^~w;^Q0Ss-LOu>e9bbVWD{#81cmA z1wT@r8HVFV6`DJz{YKl&>7!TxXfNeBISw`3Ux8zVBMiB~K%>@?B+bnmp?MWBq?$Z+ zqpyN{5o^%~$}`}{v)-n`HA>s+^AvQ{6$m95NUT}3FW-^Zxn=_)bxk4;N;tl| z!LTT3K`(>I?_C#_Q5|2!^DPe%xKby#kYo!%rS2%+v%{G<8Fc`Z#Mlxhf~{&^yY!l~&vdU=h??v<;FZRR`M84M_RpYcRr`htX0)$+Qxt4m zfwwe!h4%A1h)EKIyT%uHyh9v{4md{6rG91g{&YXnwz`3}A8licT6}_l_!eb0qhfQXuzg-=f7F&pI7BNMDFs z-?8hk2pvSW(*^#_e+`ik9g-9A{nQKD-6KM4njVos0CO>$O&{uNuEvyWg?7添加其他 Html 片段 需要支持变量替换(todo).

" + } + ] + } + ] +} diff --git a/frontend/x-pages/editor.json b/frontend/x-pages/editor.json new file mode 100644 index 0000000..a6bb29c --- /dev/null +++ b/frontend/x-pages/editor.json @@ -0,0 +1,18 @@ +{ + "type": "page", + "title": "代码编辑器", + "subTitle": "使用的monaco-editor,用到了 worker, 如果控制台没有报错,说明一起正常。", + "body": [ + { + "type": "form", + "controls": [ + { + "type": "editor", + "name": "js", + "label": "Javascript", + "size": "md" + } + ] + } + ] +} diff --git a/frontend/x-pages/excel.json b/frontend/x-pages/excel.json new file mode 100644 index 0000000..bd1cbf6 --- /dev/null +++ b/frontend/x-pages/excel.json @@ -0,0 +1,50 @@ +{ + "type": "page", + "body": { + "type": "crud", + "syncLocation": false, + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample", + "headerToolbar": [ + { + "type": "export-csv", + "label": "全量导出 CSV", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample" + }, + { + "type": "export-excel", + "label": "全量导出 Excel", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample" + } + ], + "columns": [ + { + "name": "id", + "label": "ID" + }, + { + "name": "engine", + "label": "Rendering engine" + }, + { + "name": "browser", + "label": "Browser" + }, + { + "name": "platform", + "label": "Platform(s)" + }, + { + "name": "version", + "label": "Engine version" + }, + { + "name": "grade", + "label": "CSS grade", + "type": "mapping", + "map": { + "*": "${grade}" + } + } + ] + } +} \ No newline at end of file diff --git a/frontend/x-pages/form-basic.json b/frontend/x-pages/form-basic.json new file mode 100644 index 0000000..7040b9c --- /dev/null +++ b/frontend/x-pages/form-basic.json @@ -0,0 +1,241 @@ +{ + "type": "page", + "title": "基础表单", + "subTitle": "展示一些常规的表单,包括验证、提示等等", + "body": [ + { + "type": "form", + "mode": "horizontal", + "title": "常规表单示例", + "affixFooter": true, + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/form/save", + "actions": [ + { + "label": "保存", + "type": "submit", + "level": "success" + } + ], + "controls": [ + { + "label": " 标题", + "type": "text", + "placeholder": "请输入标题", + "description": "请输入一个能吸引眼球的标题", + "name": "title", + "size": "md" + }, + + { + "label": "编号", + "required": true, + "type": "text", + "placeholder": "请输入编号", + "name": "b", + "size": "md", + "validations": { + "matchRegexp": "/^\\w{4}-\\w{4}-\\w{4}$/" + }, + "validationErrors": { + "matchRegexp": "您输入的内容格式不对,请按提示输入!" + }, + "hint": "输入范例:xxxx-xxxx-xxxx" + }, + + { + "label": "置顶", + "type": "switch", + "name": "c", + "inline": true, + "labelRemark": "开启后将置顶这条数据!" + }, + + { + "label": "活动时间", + "type": "date-range", + "name": "range", + "size": "md", + "remark": "这是一个字段时间范围" + }, + + { + "label": "日期范围", + "type": "group", + "controls": [ + { + "type": "date", + "size": "md", + "name": "start", + "mode": "inline", + "maxDate": "${end}" + }, + + { + "label": "到", + "type": "date", + "size": "md", + "name": "end", + "inputClassName": "m-l-sm", + "mode": "inline", + "minDate": "${start}", + "remark": "这是两个字段的时间范围" + } + ] + }, + + { + "label": "浏览器", + "type": "button-group", + "name": "browser", + "value": "chrome", + "options": [ + { + "label": "Chrome", + "value": "chrome" + }, + + { + "label": "火狐", + "value": "firefox" + }, + + { + "label": "IE", + "value": "ie" + } + ] + }, + + { + "type": "list", + "name": "taocan", + "label": "套餐选择", + "options": [ + { + "value": 1, + "body": "
套餐:C01
CPU:2核
内存:1GB
SSD盘:10GB
" + }, + { + "value": 2, + "body": "
套餐:C02
CPU:4核
内存:4GB
SSD盘:20GB
" + }, + { + "value": 3, + "disabled": true, + "body": "
套餐:C03
CPU:8核
内存:8GB
SSD盘:50GB
" + } + ] + }, + + { + "label": "最爱周几", + "type": "select", + "name": "select", + "size": "md", + "clearable": true, + "options": [ + { + "label": "周一", + "value": "0" + }, + + { + "label": "周二", + "value": "1" + }, + + { + "label": "周三", + "value": "2" + }, + + { + "label": "周四", + "value": "3" + }, + + { + "label": "周五", + "value": "4" + }, + + { + "label": "周六", + "value": "5" + }, + + { + "label": "周日", + "value": "6" + } + ] + }, + + { + "label": "休息日", + "type": "list", + "name": "freeday", + "value": ["5", "6"], + "multiple": true, + "extractValue": true, + "options": [ + { + "label": "周一", + "value": "0" + }, + + { + "label": "周二", + "value": "1" + }, + + { + "label": "周三", + "value": "2" + }, + + { + "label": "周四", + "value": "3" + }, + + { + "label": "周五", + "value": "4" + }, + + { + "label": "周六", + "value": "5" + }, + + { + "label": "周日", + "value": "6" + } + ] + }, + + { + "label": "人数", + "type": "number", + "name": "num", + "size": "md", + "value": 10 + }, + + { + "label": "比率", + "type": "range", + "name": "percent" + }, + + { + "label": "简介", + "type": "textarea", + "name": "textarea" + } + ] + } + ] +} diff --git a/frontend/x-pages/jsonp.js b/frontend/x-pages/jsonp.js new file mode 100644 index 0000000..9612fb8 --- /dev/null +++ b/frontend/x-pages/jsonp.js @@ -0,0 +1,12 @@ +(function() { + const response = { + data: { + type: "page", + title: "标题", + body: "this result is from jsonp" + }, + status: 0 + } + + window.jsonpCallback && window.jsonpCallback(response); +})(); diff --git a/frontend/x-pages/pageA.json b/frontend/x-pages/pageA.json new file mode 100644 index 0000000..f2921c5 --- /dev/null +++ b/frontend/x-pages/pageA.json @@ -0,0 +1,177 @@ +{ + "type": "page", + "toolbar": [ + { + "type": "form", + "panelClassName": "mb-0", + "title": "", + "body": [ + { + "type": "select", + "label": "区域", + "name": "businessLineId", + "selectFirst": true, + "mode": "inline", + "options": [ + "北京", + "上海" + ], + "checkAll": false + }, + { + "label": "时间范围", + "type": "input-date-range", + "name": "dateRange", + "inline": true, + "value": "-1month,+0month", + "inputFormat": "YYYY-MM-DD", + "format": "YYYY-MM-DD", + "closeOnSelect": true, + "clearable": false + } + ], + "actions": [], + "mode": "inline", + "target": "mainPage", + "submitOnChange": true, + "submitOnInit": true + } + ], + "body": [ + { + "type": "table", + "title": "表格1", + "source": "$rows", + "columns": [ + { + "name": "engine", + "label": "Engine" + }, + { + "name": "version", + "label": "Version" + } + ] + }, + { + "type": "grid", + "columns": [ + { + "type": "panel", + "className": "h-full", + "body": { + "type": "tabs", + "tabs": [ + { + "title": "消费趋势", + "tab": [ + { + "type": "chart", + "config": { + "title": { + "text": "消费趋势" + }, + "tooltip": {}, + "xAxis": { + "type": "category", + "boundaryGap": false, + "data": [ + "一月", + "二月", + "三月", + "四月", + "五月", + "六月" + ] + }, + "yAxis": {}, + "series": [ + { + "name": "销量", + "type": "line", + "areaStyle": { + "color": { + "type": "linear", + "x": 0, + "y": 0, + "x2": 0, + "y2": 1, + "colorStops": [ + { + "offset": 0, + "color": "rgba(84, 112, 197, 1)" + }, + { + "offset": 1, + "color": "rgba(84, 112, 197, 0)" + } + ], + "global": false + } + }, + "data": [ + 5, + 20, + 36, + 10, + 10, + 20 + ] + } + ] + } + } + ] + }, + { + "title": "账户余额", + "tab": "0" + } + ] + } + }, + { + "type": "panel", + "className": "h-full", + "body": [ + { + "type": "chart", + "config": { + "title": { + "text": "使用资源占比" + }, + "series": [ + { + "type": "pie", + "data": [ + { + "name": "BOS", + "value": 70 + }, + { + "name": "CDN", + "value": 68 + }, + { + "name": "BCC", + "value": 48 + }, + { + "name": "DCC", + "value": 40 + }, + { + "name": "RDS", + "value": 32 + } + ] + } + ] + } + } + ] + } + ] + } + ] + } \ No newline at end of file diff --git a/frontend/x-pages/site.json b/frontend/x-pages/site.json new file mode 100644 index 0000000..f853737 --- /dev/null +++ b/frontend/x-pages/site.json @@ -0,0 +1,126 @@ +{ + "status": 0, + "msg": "", + "data": { + "pages": [ + { + "label": "Home", + "url": "/", + "redirect": "/index/1" + }, + { + "label": "示例", + "children": [ + { + "label": "表格", + "schemaApi": "get:/pages/excel.json" + }, + { + "label": "页面A", + "url": "index", + "schema": { + "type": "page", + "title": "页面A", + "body": "页面A" + }, + "children": [ + { + "label": "页面A-1", + "schemaApi": "get:/pages/pageA.json" + }, + { + "label": "页面A-2", + "url": "2", + "schema": { + "type": "page", + "title": "页面A-2", + "body": "页面A-2" + } + }, + { + "label": "页面A-3", + "url": "3", + "schema": { + "type": "page", + "title": "页面A-3", + "body": "页面A-3" + } + } + ] + }, + { + "label": "页面B", + "schema": { + "type": "page", + "title": "页面B", + "body": "页面B" + } + }, + { + "label": "页面C", + "schema": { + "type": "page", + "title": "页面C", + "body": "页面C" + } + }, + { + "label": "列表示例", + "url": "/crud", + "rewrite": "/crud/list", + "icon": "fa fa-cube", + "children": [ + { + "label": "列表", + "url": "/crud/list", + "icon": "fa fa-list", + "schemaApi": "get:/pages/crud-list.json" + }, + { + "label": "新增", + "url": "/crud/new", + "icon": "fa fa-plus", + "schemaApi": "get:/pages/crud-new.json" + }, + { + "label": "查看", + "url": "/crud/:id", + "schemaApi": "get:/pages/crud-view.json" + }, + { + "label": "修改", + "url": "/crud/:id/edit", + "schemaApi": "get:/pages/crud-edit.json" + } + ] + } + ] + }, + { + "label": "分组2", + "children": [ + { + "label": "用户管理", + "schema": { + "type": "page", + "title": "用户管理", + "body": "页面C" + } + }, + { + "label": "外部链接", + "link": "http://baidu.gitee.io/amis" + }, + { + "label": "部门管理", + "schemaApi": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/service/form?tpl=tpl3" + }, + { + "label": "jsonp 返回示例", + "schemaApi": "jsonp:/pages/jsonp.js?callback=jsonpCallback" + } + ] + } + ] + } +} diff --git a/frontend/x-pages/wizard.json b/frontend/x-pages/wizard.json new file mode 100644 index 0000000..11ed771 --- /dev/null +++ b/frontend/x-pages/wizard.json @@ -0,0 +1,105 @@ +{ + "type": "page", + "title": "表单向导", + "subTitle": "可以通过表单向导,将一个超长的表单页面拆分成多个步骤,一步一步指引用户完成。", + "body": [ + { + "type": "wizard", + "actionFinishLabel": "确认", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/saveWizard", + "steps": [ + { + "title": "填写活动信息", + "controls": [ + { + "type": "text", + "name": "title", + "label": "活动标题", + "required": true, + "size": "md" + }, + + { + "type": "date", + "name": "date", + "label": "举办时间", + "size": "md" + }, + + { + "type": "number", + "name": "num", + "label": "参与人数", + "value": 10, + "size": "md" + } + ] + }, + + { + "title": "填写赞助商信息", + "controls": [ + { + "type": "text", + "name": "company", + "label": "公司名称", + "required": true, + "size": "md" + }, + + { + "type": "text", + "name": "money", + "label": "赞助金额", + "addOn": { + "type": "text", + "label": "¥" + }, + "size": "md" + } + ] + }, + + { + "title": "确认", + "mode": "horizontal", + "horizontal": { + "leftFixed": "sm" + }, + "controls": [ + { + "type": "static", + "name": "company", + "label": "活动标题", + "labelClassName": "text-muted" + }, + { + "type": "static-date", + "name": "date", + "label": "举办时间", + "labelClassName": "text-muted" + }, + { + "type": "static", + "name": "num", + "label": "参与人数", + "labelClassName": "text-muted" + }, + { + "type": "static", + "name": "company", + "label": "公司名称", + "labelClassName": "text-muted" + }, + { + "type": "static", + "name": "money", + "label": "赞助金额", + "labelClassName": "text-muted" + } + ] + } + ] + } + ] +} diff --git a/handler/car.py b/handler/car.py index 32ea668..75aa63d 100644 --- a/handler/car.py +++ b/handler/car.py @@ -5,7 +5,7 @@ import logger from db.mysql import database from model.car.dto.list import ListDto from orm.jiakaobaodian import JiaKaoBaoDian -from utils.common import response +from utils.common import response, amis_response from utils.model import model_list router = APIRouter(tags=["Car"], prefix="/api/car") @@ -36,3 +36,15 @@ def get_list(dto: ListDto, db: Session = Depends(database)): "size": size, "total": total }) + + +@router.post("/amis/list", summary="amis 题目列表") +def amis_get_list(dto: ListDto, db: Session = Depends(database)): + result = get_list(dto, db)['data'] + + return amis_response({ + "rows": result['data'], + "page": result['page'], + "size": result['size'], + "total": result['total'] + }) diff --git a/main.py b/main.py index 5d7e1f4..7ed0526 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,10 @@ +import os.path + import logger import uvicorn -from fastapi import FastAPI, APIRouter +from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware +from fastapi.staticfiles import StaticFiles from handler import car, health # 禁用 redoc @@ -18,6 +21,9 @@ app.add_middleware( app.include_router(health.router) app.include_router(car.router) +frontend = os.path.join(os.path.dirname(__file__), "frontend") +app.mount("/", StaticFiles(directory=frontend, html=True)) + @app.on_event("startup") async def startup(): diff --git a/utils/common.py b/utils/common.py index 624f68b..c5276d0 100644 --- a/utils/common.py +++ b/utils/common.py @@ -19,3 +19,15 @@ def response(data: any, code=200, msg="OK"): "data": data, "msg": msg, } + + +def amis_response(data: any, code=0, msg="OK"): + return { + "status": code, + "data": data, + "msg": msg, + } + + +def response_to_amis_response(_response): + return amis_response(_response['data'], 0 if _response['code'] == 200 else _response['code'], _response['msg'])