From 1c74c0ea4b66429563a40ab855626a3f2c522c84 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Wed, 5 Jul 2023 19:00:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0s3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constants/faq.go | 12 +-- constants/field_status.go | 4 +- go.mod | 7 +- go.sum | 30 ++++++- .../backend/test/quotationdetaillogic_test.go | 2 +- .../test/acceptcookielogic_test.go | 4 +- server/home-user-auth/test/basic.go | 8 +- .../test/useraddaddresslogic_test.go | 4 +- .../test/useraddresslistlogic_test.go | 4 +- .../test/userbasicinfologic_test.go | 4 +- .../test/usercontactservicelogic_test.go | 4 +- .../test/userfontslogic_test.go | 4 +- .../test/usergettypelogic_test.go | 4 +- .../test/useroderdeletelogic_test.go | 4 +- .../test/usersavebasicinfologic_test.go | 4 +- .../test/userstatusconfiglogic_test.go | 4 +- .../internal/logic/getproductinfologic.go | 5 +- server/upload/test/basic.go | 41 +++++++++ server/upload/test/fusen.webp | Bin 0 -> 1242 bytes .../test/uploadfilefrontendhandler_test.go | 67 ++++++++++++++ server/webset/test/wetset_test.go | 2 +- server_api/upload.api | 22 +++-- utils/basic/basic.go | 4 + utils/tests/basic.go | 83 ------------------ 24 files changed, 196 insertions(+), 131 deletions(-) create mode 100644 server/upload/test/basic.go create mode 100644 server/upload/test/fusen.webp create mode 100644 server/upload/test/uploadfilefrontendhandler_test.go delete mode 100644 utils/tests/basic.go diff --git a/constants/faq.go b/constants/faq.go index 6529b365..9ec7dc23 100644 --- a/constants/faq.go +++ b/constants/faq.go @@ -2,13 +2,13 @@ package constants type TypeFaq int64 -const STATUS_ON TypeFaq = 1 -const STATUS_OFF TypeFaq = 0 +const FAQ_STATUS_ON TypeFaq = 1 +const FAQ_STATUS_OFF TypeFaq = 0 /** * 定义类型 */ -const TAG_ORDER TypeFaq = 1 -const TAG_SHIPPING TypeFaq = 2 -const TAG_PAYMENT TypeFaq = 3 -const TAG_RETURN TypeFaq = 4 +const FAQ_TAG_ORDER TypeFaq = 1 +const FAQ_TAG_SHIPPING TypeFaq = 2 +const FAQ_TAG_PAYMENT TypeFaq = 3 +const FAQ_TAG_RETURN TypeFaq = 4 diff --git a/constants/field_status.go b/constants/field_status.go index fdf96379..56e52bbe 100644 --- a/constants/field_status.go +++ b/constants/field_status.go @@ -1,5 +1,5 @@ package constants // 普通表中status状态 -const STATUS_ON = 1 -const STATUS_OFF = 0 +// const STATUS_ON = 1 +// const STATUS_OFF = 0 diff --git a/go.mod b/go.mod index 8bba335f..7190e595 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,8 @@ go 1.20 require ( github.com/SebastiaanKlippert/go-wkhtmltopdf v1.9.0 + github.com/aws/aws-sdk-go v1.44.295 + github.com/bwmarrin/snowflake v0.3.0 github.com/golang-jwt/jwt v3.2.2+incompatible github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e @@ -15,13 +17,14 @@ require ( ) require ( - github.com/bwmarrin/snowflake v0.3.0 // indirect + github.com/andybalholm/brotli v1.0.5 // indirect github.com/google/uuid v1.3.0 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/schollz/progressbar v1.0.0 // indirect ) require ( - github.com/474420502/requests v1.33.4 + github.com/474420502/requests v1.36.0 github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/tidwall/gjson v1.12.0 diff --git a/go.sum b/go.sum index 01f352c9..e8b9a6b7 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/474420502/random v0.4.1 h1:HUUyLXRWMijVb7CJoEC16f0aFQOW25Lkr80Mut6PoKU= -github.com/474420502/requests v1.33.4 h1:cTz78KQdH5iKu9BPYuSFc45xxiGqSuKJB9BHCPzV+/0= -github.com/474420502/requests v1.33.4/go.mod h1:5qAlksMg7JIrEXrpkxw1++4Z5W2tUkZbHA6M7oq1r/0= +github.com/474420502/requests v1.36.0 h1:oaIRAoi8vhPwdR3AOnYUsYMMN+2Mi1rI9r/fvXA3wiE= +github.com/474420502/requests v1.36.0/go.mod h1:r1Uwbbq/t3Cn95VOfgJjZmD7sfwp+gjldq/zDncNYRc= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= @@ -42,7 +42,11 @@ github.com/SebastiaanKlippert/go-wkhtmltopdf v1.9.0 h1:DNrExYwvyyI404SxdUCCANAj9 github.com/SebastiaanKlippert/go-wkhtmltopdf v1.9.0/go.mod h1:SQq4xfIdvf6WYKSDxAJc+xOJdolt+/bc1jnQKMtPMvQ= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk= github.com/alicebob/miniredis/v2 v2.30.2 h1:lc1UAUT9ZA7h4srlfBmBt2aorm5Yftk9nBjxz7EyY9I= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/aws/aws-sdk-go v1.44.295 h1:SGjU1+MqttXfRiWHD6WU0DRhaanJgAFY+xIhEaugV8Y= +github.com/aws/aws-sdk-go v1.44.295/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0= @@ -173,6 +177,10 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -198,6 +206,7 @@ github.com/openzipkin/zipkin-go v0.4.1 h1:kNd/ST2yLLWhaWrkgchya40TJabe8Hioj9udfP github.com/openzipkin/zipkin-go v0.4.1/go.mod h1:qY0VqDSN1pOBN94dBc6w2GJlWLiovAyg7Qt6/I9HecM= github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us= github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= @@ -242,6 +251,7 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE= github.com/zeromicro/go-zero v1.5.2 h1:vpMlZacCMtgdtYzKI3OMyhS6mZ9UQctiAh0J7gIq31I= github.com/zeromicro/go-zero v1.5.2/go.mod h1:ndCd1nMMAdEMZgPfdm1fpavHUdBW0ykB6ckCRaSG10w= @@ -279,6 +289,7 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -310,6 +321,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -336,8 +348,11 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -354,6 +369,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -383,11 +399,17 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -395,6 +417,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -440,6 +464,7 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -540,6 +565,7 @@ gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/server/backend/test/quotationdetaillogic_test.go b/server/backend/test/quotationdetaillogic_test.go index cb8e293d..8f9fa837 100644 --- a/server/backend/test/quotationdetaillogic_test.go +++ b/server/backend/test/quotationdetaillogic_test.go @@ -2,7 +2,7 @@ package test import ( "fmt" - fstests "fusenapi/utils/tests" + fstests "fusenapi/utils/fstests" "log" "testing" ) diff --git a/server/home-user-auth/test/acceptcookielogic_test.go b/server/home-user-auth/test/acceptcookielogic_test.go index a7098c58..136688e4 100644 --- a/server/home-user-auth/test/acceptcookielogic_test.go +++ b/server/home-user-auth/test/acceptcookielogic_test.go @@ -1,8 +1,8 @@ -package logic +package test import ( "fmt" - fstests "fusenapi/utils/tests" + "fusenapi/utils/fstests" "testing" diff --git a/server/home-user-auth/test/basic.go b/server/home-user-auth/test/basic.go index 8daa0e1c..4b56bde8 100644 --- a/server/home-user-auth/test/basic.go +++ b/server/home-user-auth/test/basic.go @@ -1,17 +1,19 @@ -package logic +package test import ( "fmt" "fusenapi/server/home-user-auth/internal/config" "fusenapi/server/home-user-auth/internal/handler" "fusenapi/server/home-user-auth/internal/svc" + "fusenapi/utils/fstests" + "log" "github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/rest" ) -var testConfigFile = "../etc/home-user-auth.yaml" +var testConfigFile = "home-user-auth" var cnf config.Config var gserver *rest.Server @@ -22,7 +24,7 @@ func init() { func GetTestServer() *rest.Server { - conf.MustLoad(testConfigFile, &cnf) + conf.MustLoad(fstests.GetEtcYamlPathAuto(testConfigFile), &cnf) server := rest.MustNewServer(cnf.RestConf) defer server.Stop() diff --git a/server/home-user-auth/test/useraddaddresslogic_test.go b/server/home-user-auth/test/useraddaddresslogic_test.go index 2f33bc2c..7305c1e5 100644 --- a/server/home-user-auth/test/useraddaddresslogic_test.go +++ b/server/home-user-auth/test/useraddaddresslogic_test.go @@ -1,9 +1,9 @@ -package logic +package test import ( "fmt" "fusenapi/server/home-user-auth/internal/types" - fstests "fusenapi/utils/tests" + "fusenapi/utils/fstests" "testing" "github.com/474420502/requests" diff --git a/server/home-user-auth/test/useraddresslistlogic_test.go b/server/home-user-auth/test/useraddresslistlogic_test.go index 163b74e3..25a85ae1 100644 --- a/server/home-user-auth/test/useraddresslistlogic_test.go +++ b/server/home-user-auth/test/useraddresslistlogic_test.go @@ -1,8 +1,8 @@ -package logic +package test import ( "fmt" - fstests "fusenapi/utils/tests" + fstests "fusenapi/utils/fstests" "testing" "github.com/474420502/requests" diff --git a/server/home-user-auth/test/userbasicinfologic_test.go b/server/home-user-auth/test/userbasicinfologic_test.go index 818e65a4..f365f679 100644 --- a/server/home-user-auth/test/userbasicinfologic_test.go +++ b/server/home-user-auth/test/userbasicinfologic_test.go @@ -1,8 +1,8 @@ -package logic +package test import ( "fmt" - fstests "fusenapi/utils/tests" + fstests "fusenapi/utils/fstests" "testing" "github.com/474420502/requests" diff --git a/server/home-user-auth/test/usercontactservicelogic_test.go b/server/home-user-auth/test/usercontactservicelogic_test.go index 30483af5..590d52c2 100644 --- a/server/home-user-auth/test/usercontactservicelogic_test.go +++ b/server/home-user-auth/test/usercontactservicelogic_test.go @@ -1,9 +1,9 @@ -package logic +package test import ( "fmt" "fusenapi/server/home-user-auth/internal/types" - fstests "fusenapi/utils/tests" + fstests "fusenapi/utils/fstests" "testing" "github.com/474420502/requests" diff --git a/server/home-user-auth/test/userfontslogic_test.go b/server/home-user-auth/test/userfontslogic_test.go index cb0e1241..feb51f6c 100644 --- a/server/home-user-auth/test/userfontslogic_test.go +++ b/server/home-user-auth/test/userfontslogic_test.go @@ -1,8 +1,8 @@ -package logic +package test import ( "fmt" - fstests "fusenapi/utils/tests" + fstests "fusenapi/utils/fstests" "testing" "github.com/474420502/requests" diff --git a/server/home-user-auth/test/usergettypelogic_test.go b/server/home-user-auth/test/usergettypelogic_test.go index 777912e0..971a1034 100644 --- a/server/home-user-auth/test/usergettypelogic_test.go +++ b/server/home-user-auth/test/usergettypelogic_test.go @@ -1,8 +1,8 @@ -package logic +package test import ( "fmt" - fstests "fusenapi/utils/tests" + fstests "fusenapi/utils/fstests" "testing" "github.com/474420502/requests" diff --git a/server/home-user-auth/test/useroderdeletelogic_test.go b/server/home-user-auth/test/useroderdeletelogic_test.go index f1ebbfe3..2e6e0309 100644 --- a/server/home-user-auth/test/useroderdeletelogic_test.go +++ b/server/home-user-auth/test/useroderdeletelogic_test.go @@ -1,9 +1,9 @@ -package logic +package test import ( "fmt" "fusenapi/server/home-user-auth/internal/types" - fstests "fusenapi/utils/tests" + fstests "fusenapi/utils/fstests" "testing" "github.com/474420502/requests" diff --git a/server/home-user-auth/test/usersavebasicinfologic_test.go b/server/home-user-auth/test/usersavebasicinfologic_test.go index b95f3d19..2b7d6ac8 100644 --- a/server/home-user-auth/test/usersavebasicinfologic_test.go +++ b/server/home-user-auth/test/usersavebasicinfologic_test.go @@ -1,10 +1,10 @@ -package logic +package test import ( "encoding/json" "fmt" "fusenapi/server/home-user-auth/internal/types" - fstests "fusenapi/utils/tests" + fstests "fusenapi/utils/fstests" "testing" "github.com/474420502/requests" diff --git a/server/home-user-auth/test/userstatusconfiglogic_test.go b/server/home-user-auth/test/userstatusconfiglogic_test.go index b5436a4b..b9017d4a 100644 --- a/server/home-user-auth/test/userstatusconfiglogic_test.go +++ b/server/home-user-auth/test/userstatusconfiglogic_test.go @@ -1,8 +1,8 @@ -package logic +package test import ( "fmt" - fstests "fusenapi/utils/tests" + fstests "fusenapi/utils/fstests" "testing" "github.com/474420502/requests" diff --git a/server/product/internal/logic/getproductinfologic.go b/server/product/internal/logic/getproductinfologic.go index f289cf84..852d89be 100644 --- a/server/product/internal/logic/getproductinfologic.go +++ b/server/product/internal/logic/getproductinfologic.go @@ -9,10 +9,11 @@ import ( "fusenapi/utils/basic" "fusenapi/utils/format" "fusenapi/utils/image" - "gorm.io/gorm" "strconv" "strings" + "gorm.io/gorm" + "context" "fusenapi/server/product/internal/svc" @@ -68,7 +69,7 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri } } //尺寸列表[这里要处理数据中的title] - sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByStatus(l.ctx, int64(constants.STATUS_ON), 1, "id,title,capacity,cover,sort,parts_can_deleted") + sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByStatus(l.ctx, int64(constants.FAQ_STATUS_ON), 1, "id,title,capacity,cover,sort,parts_can_deleted") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product size list") diff --git a/server/upload/test/basic.go b/server/upload/test/basic.go new file mode 100644 index 00000000..11999937 --- /dev/null +++ b/server/upload/test/basic.go @@ -0,0 +1,41 @@ +package test + +import ( + "fmt" + "fusenapi/server/home-user-auth/test" + "fusenapi/server/upload/internal/config" + "fusenapi/server/upload/internal/handler" + "fusenapi/server/upload/internal/svc" + "fusenapi/utils/fstests" + "log" + + "github.com/zeromicro/go-zero/core/conf" + "github.com/zeromicro/go-zero/rest" +) + +var env = "test" + +var testConfigFile = "upload.yaml" +var cnf config.Config +var userServer *rest.Server +var gserver *rest.Server + +func init() { + log.SetFlags(log.Llongfile) + userServer = test.GetTestServer() + gserver = GetTestServer() +} + +func GetTestServer() *rest.Server { + + conf.MustLoad(fstests.GetEtcYamlPathAuto(fstests.GetCurrentServiceName()+".yaml"), &cnf) + + server := rest.MustNewServer(cnf.RestConf) + defer server.Stop() + + ctx := svc.NewServiceContext(cnf) + handler.RegisterHandlers(server, ctx) + + fmt.Printf("Starting server at %s:%d...\n", cnf.Host, cnf.Port) + return server +} diff --git a/server/upload/test/fusen.webp b/server/upload/test/fusen.webp new file mode 100644 index 0000000000000000000000000000000000000000..b24c4ffa95ea09a67a0294073689a30586567494 GIT binary patch literal 1242 zcmV<01SR`YNk&G}1ONb6MM6+kP&gpQ1ONbV8UUREDtG{R06x)TsZXdSqoOJkIY|H- z2|yaf!Kb;)L!durT5nW;?l*69r|z`+)la7Oz5Y+6xh8+5;Wk+ZBkm~Gm%X~j-bLsS z(fdMQ(iUr@T9F>{d@;~(|G@S*ZmD{QC+7xRlNSRsoSitA(FH&_2Bv$kB~KZv9Ov8R z@;p?Bn+Dt=ck+YwunF{;Ol;bdWLAA**IEGA{+YH5xc>xFh=@__ON&kLn$8&BXi4gl z7l_+axkoI|=VB8^&kd*`xk7+mUH0o#Z@ItwI0*{`Yx+1M<`OV$>m< zUMP#uow1N;5ueh!bg30}@Iv8I&V z*&lZ84P?CzgQ{Bd45_(*sId}a8}@??F#0%FpMD~r4yn)AeB z(8nV%U>dzbfsQQ!f~d56$nE5+AS{e$c$ImKvA~laUob&16bX;!#@!+oTv{EEPJsJS z;kd@j*XK1yO9v6lRf&mf)dGlY-N-ba;aTLA=dpZE9=MP4CC$!nDcVBkzfx!*F_Q^f zMRh{`Y#KXc>R3lmWFJ@gcx7z7RU_@pYEW#hxjj;MiAw0F?~QH9LZJoukg~E`eRem0 zO91ON{XPpcu7C2D&*l)1SBJxu-1n_noRsf12z5V`H6T7&(?yNzTlFSz#0N%~zKbM3 zPy((dwR48iW>%hlAl5(Rv54~Cb`hH=62U2F~@|K)GE#{)&k&DB)n{skzz&ur>Y0sx|yIJ^qEu!S_ zcS9YaC{Aa?QAg;rfLWqbNac!JDz2RgYWa{j>+b7=lwA>|bkd(xezAX3<=$STJiadx zzZJG9_FqaquldUVx9Pyq!)Wv_+~Jbl1_4ddd12c9e`)-uPvya$F<1SgWQ{u$*nK$M|d$^ecIr~jJoj)4R~34{DvXIT?Q9v7XEoIH>a4m)CaitADWB>pF E0Bm+^l>h($ literal 0 HcmV?d00001 diff --git a/server/upload/test/uploadfilefrontendhandler_test.go b/server/upload/test/uploadfilefrontendhandler_test.go new file mode 100644 index 00000000..63373e57 --- /dev/null +++ b/server/upload/test/uploadfilefrontendhandler_test.go @@ -0,0 +1,67 @@ +package test + +import ( + "fmt" + "fusenapi/server/upload/internal/types" + fstests "fusenapi/utils/fstests" + "io/ioutil" + "log" + "testing" + + "github.com/474420502/requests" + "github.com/tidwall/gjson" +) + +func TestCaseUploadfileFrontend(t *testing.T) { + var err error + var resp *requests.Response + var result gjson.Result + + // 获取 session,并携带 JWT token + ses := fstests.GetSessionWithUserToken(t, userServer, cnf.Host, cnf.Port) + tp := ses.Post(fmt.Sprintf("http://%s:%d/upload/upload-file-frontend", cnf.Host, cnf.Port)) + + data, err := ioutil.ReadFile("./fusen.webp") + if err != nil { + t.Error(err) + return + } + + req := types.RequestUploadFile{ + FileName: "fusen.webp", FileType: "image", FileSize: int64(len(data)), + Category: "personalization", + } + tp.SetBodyJson(req) + // 向服务器发送 GET 请求,获取用户基本信息 + resp, err = tp.TestExecute(gserver) + if err != nil { + t.Error(err) + } + + result = resp.Json() + if result.Get("code").Int() != 200 { + t.Error("code != 200") + } + + if !result.Get("data").Exists() { + t.Error("data not exists") + } + + if !result.Get("data.upload_url").Exists() { + t.Error("upload_url not exists") + } + + log.Println(result) + uri := result.Get("data.upload_url").String() + + tpUpload := requests.NewSession().Put(uri) + + tpUpload.SetBodyStream(data) + + resp, err = tpUpload.Execute() + if err != nil { + panic(err) + } + + log.Println(resp.Json()) +} diff --git a/server/webset/test/wetset_test.go b/server/webset/test/wetset_test.go index 0689f54a..ff783f3b 100644 --- a/server/webset/test/wetset_test.go +++ b/server/webset/test/wetset_test.go @@ -3,7 +3,7 @@ package logic import ( "fmt" "fusenapi/constants" - fstests "fusenapi/utils/tests" + fstests "fusenapi/utils/fstests" "testing" "github.com/474420502/requests" diff --git a/server_api/upload.api b/server_api/upload.api index 3aef42db..a05abcd4 100644 --- a/server_api/upload.api +++ b/server_api/upload.api @@ -1,4 +1,4 @@ - syntax = "v1" +syntax = "v1" info ( title: // TODO: add title @@ -10,20 +10,24 @@ info ( import "basic.api" type RequestUpFile { - UpFile string `json:"upfile"` - IsCut string `json:"upfile"` // 是否裁剪 + UpFile string `form:"upfile"` + IsCut string `form:"is_cut"` // 是否裁剪 } type RequestUploadFile { - FileName string `json:"file_name"` - FileType string `json:"file_type"` // Image / fbx / hdr - FileSize int64 `json:"file_size"` + FileName string `json:"file_name"` // 文件名 + FileType string `json:"file_type"` // Image / fbx / hdr + FileSize int64 `json:"file_size"` // 文件大小 + Category string `json:"category"` // 类别 } service upload { @handler UploadUpFileHandler get /upload/up-file(RequestUpFile) returns (response); - - @handler UploadUpFileHandler - get /upload/up-all-type-file(RequestUploadFile) returns (response); + + @handler UploadFileFrontendHandler + post /upload/upload-file-frontend(RequestUploadFile) returns (response); + + @handler UploadFileBackendHandler + post /upload/upload-file-backend(RequestUploadFile) returns (response); } \ No newline at end of file diff --git a/utils/basic/basic.go b/utils/basic/basic.go index 292f7111..79eb86bc 100644 --- a/utils/basic/basic.go +++ b/utils/basic/basic.go @@ -13,6 +13,10 @@ var ( CodeServiceErr = &StatusResponse{510, "server logic error"} // 服务逻辑错误 CodeUnAuth = &StatusResponse{401, "unauthorized"} // 未授权 + CodeS3PutObjectRequestErr = &StatusResponse{5060, "s3 PutObjectRequest error"} // s3 PutObjectRequest 错误 + CodeS3PutSizeLimitErr = &StatusResponse{5060, "s3 over limit size error"} // s3 超过文件大小限制 错误 + CodeS3CategoryErr = &StatusResponse{5060, "s3 category not exists error"} // s3 类别不存在 错误 + CodeEmailNotFoundErr = &StatusResponse{5050, "email not found"} // 未找到email CodeUserIdNotFoundErr = &StatusResponse{5051, "user not found"} // 未找到用户 CodePasswordErr = &StatusResponse{5052, "invalid password"} // 无效密码 diff --git a/utils/tests/basic.go b/utils/tests/basic.go deleted file mode 100644 index 1de9aace..00000000 --- a/utils/tests/basic.go +++ /dev/null @@ -1,83 +0,0 @@ -package fstests - -import ( - "fmt" - "testing" - - "github.com/474420502/requests" -) - -func GetSesssion() *requests.Session { - ses := requests.NewSession() - return ses -} - -func GetSessionWithUserToken(t *testing.T, server requests.ITestServer, Host string, Port int) *requests.Session { - ses := requests.NewSession() - tp := ses.Post(fmt.Sprintf("http://%s:%d/user/login", Host, Port)) - tp.SetBodyJson(map[string]interface{}{ - "name": "9107058@qq.com", - "pwd": "$2y$13$2y4O4OIz/zcK5C0vlSc9LuSpjWySjInLBSe49yDkE.iURb.R1hDsy", - }) - resp, err := tp.TestExecute(server) - if err != nil { - t.Error(err) - } - result := resp.Json() - code := result.Get("code").Int() - if code != 200 { - t.Error("code is not 200") - } - - token := result.Get("data.token") - if !token.Exists() { - t.Error("data.token is not exists") - } - ses.Header.Add("Authorization", token.String()) - - return ses -} - -func GetBackendSessionWithUserToken(t *testing.T, server requests.ITestServer, Host string, Port int) *requests.Session { - ses := requests.NewSession() - tp := ses.Post(fmt.Sprintf("http://%s:%d/backend-user/login", Host, Port)) - tp.SetBodyJson(map[string]interface{}{ - "name": "admin@admin.com", - "pwd": "ZnVzZW5fYmFja2VuZF8yMDIz47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU=", - }) - resp, err := tp.TestExecute(server) - if err != nil { - t.Error(err) - } - result := resp.Json() - code := result.Get("code").Int() - if code != 200 { - t.Error("code is not 200") - } - - token := result.Get("data.token") - if !token.Exists() { - t.Error("data.token is not exists") - } - ses.Header.Add("Authorization", token.String()) - - return ses -} - -func GetSesssionWithGuestToken(t *testing.T, server requests.ITestServer, Host string, Port int) *requests.Session { - ses := requests.NewSession() - tp := ses.Post(fmt.Sprintf("http://%s:%d/accept/cookie", Host, Port)) - - resp, err := tp.TestExecute(server) - if err != nil { - t.Error(err) - } - result := resp.Json() - token := result.Get("data.token") - if !token.Exists() { - t.Error("data.token is not exists") - } - ses.Header.Add("Authorization", token.String()) - - return ses -}