From d8e60a242489d448cf9c0af8d3636ddadbc6476f Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期六, 26 八月 2023 11:58:57 +0800 Subject: [PATCH] add --- model/test/product.go | 25 api/v1/test/enter.go | 1 router/test/enter.go | 1 .idea/.gitignore | 8 docs/swagger.yaml | 288 ++++++++++ api/v1/test/product.go | 166 ++++++ docs/docs.go | 457 ++++++++++++++++- docs/swagger.json | 457 ++++++++++++++++- service/test/enter.go | 1 .idea/vcs.xml | 6 .idea/modules.xml | 8 service/test/product.go | 76 ++ .idea/srm.iml | 9 log/2023-08-26/info.log | 8 router/test/product.go | 27 + initialize/router.go | 1 model/test/request/product.go | 14 17 files changed, 1,460 insertions(+), 93 deletions(-) diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..bd5790d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/srm.iml" filepath="$PROJECT_DIR$/.idea/srm.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/.idea/srm.iml b/.idea/srm.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/srm.iml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="WEB_MODULE" version="4"> + <component name="Go" enabled="true" /> + <component name="NewModuleRootManager"> + <content url="file://$MODULE_DIR$" /> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/api/v1/test/enter.go b/api/v1/test/enter.go index 4cb543a..b73c8f6 100644 --- a/api/v1/test/enter.go +++ b/api/v1/test/enter.go @@ -5,4 +5,5 @@ IndustryApi SupplierApi ContractApi + ProductApi } diff --git a/api/v1/test/product.go b/api/v1/test/product.go new file mode 100644 index 0000000..c7b7457 --- /dev/null +++ b/api/v1/test/product.go @@ -0,0 +1,166 @@ +package test + +import ( + "github.com/gin-gonic/gin" + "go.uber.org/zap" + "srm/global" + "srm/model/common/request" + "srm/model/common/response" + "srm/model/test" + testReq "srm/model/test/request" + "srm/service" +) + +type ProductApi struct { +} + +var pService = service.ServiceGroupApp.TestServiceGroup.ProductService + +// CreateProduct 鍒涘缓Product +// @Tags Product +// @Summary 鍒涘缓Product +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body test.Product true "鍒涘缓Product" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}" +// @Router /p/createProduct [post] +func (pApi *ProductApi) CreateProduct(c *gin.Context) { + var p test.Product + err := c.ShouldBindJSON(&p) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if err := pService.CreateProduct(&p); err != nil { + global.GVA_LOG.Error("鍒涘缓澶辫触!", zap.Error(err)) + response.FailWithMessage("鍒涘缓澶辫触", c) + } else { + response.OkWithMessage("鍒涘缓鎴愬姛", c) + } +} + +// DeleteProduct 鍒犻櫎Product +// @Tags Product +// @Summary 鍒犻櫎Product +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body test.Product true "鍒犻櫎Product" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鍒犻櫎鎴愬姛"}" +// @Router /p/deleteProduct [delete] +func (pApi *ProductApi) DeleteProduct(c *gin.Context) { + var p test.Product + err := c.ShouldBindJSON(&p) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if err := pService.DeleteProduct(p); err != nil { + global.GVA_LOG.Error("鍒犻櫎澶辫触!", zap.Error(err)) + response.FailWithMessage("鍒犻櫎澶辫触", c) + } else { + response.OkWithMessage("鍒犻櫎鎴愬姛", c) + } +} + +// DeleteProductByIds 鎵归噺鍒犻櫎Product +// @Tags Product +// @Summary 鎵归噺鍒犻櫎Product +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body request.IdsReq true "鎵归噺鍒犻櫎Product" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鎵归噺鍒犻櫎鎴愬姛"}" +// @Router /p/deleteProductByIds [delete] +func (pApi *ProductApi) DeleteProductByIds(c *gin.Context) { + var IDS request.IdsReq + err := c.ShouldBindJSON(&IDS) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if err := pService.DeleteProductByIds(IDS); err != nil { + global.GVA_LOG.Error("鎵归噺鍒犻櫎澶辫触!", zap.Error(err)) + response.FailWithMessage("鎵归噺鍒犻櫎澶辫触", c) + } else { + response.OkWithMessage("鎵归噺鍒犻櫎鎴愬姛", c) + } +} + +// UpdateProduct 鏇存柊Product +// @Tags Product +// @Summary 鏇存柊Product +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body test.Product true "鏇存柊Product" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鏇存柊鎴愬姛"}" +// @Router /p/updateProduct [put] +func (pApi *ProductApi) UpdateProduct(c *gin.Context) { + var p test.Product + err := c.ShouldBindJSON(&p) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if err := pService.UpdateProduct(p); err != nil { + global.GVA_LOG.Error("鏇存柊澶辫触!", zap.Error(err)) + response.FailWithMessage("鏇存柊澶辫触", c) + } else { + response.OkWithMessage("鏇存柊鎴愬姛", c) + } +} + +// FindProduct 鐢╥d鏌ヨProduct +// @Tags Product +// @Summary 鐢╥d鏌ヨProduct +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data query test.Product true "鐢╥d鏌ヨProduct" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鏌ヨ鎴愬姛"}" +// @Router /p/findProduct [get] +func (pApi *ProductApi) FindProduct(c *gin.Context) { + var p test.Product + err := c.ShouldBindQuery(&p) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if rep, err := pService.GetProduct(p.ID); err != nil { + global.GVA_LOG.Error("鏌ヨ澶辫触!", zap.Error(err)) + response.FailWithMessage("鏌ヨ澶辫触", c) + } else { + response.OkWithData(gin.H{"rep": rep}, c) + } +} + +// GetProductList 鍒嗛〉鑾峰彇Product鍒楄〃 +// @Tags Product +// @Summary 鍒嗛〉鑾峰彇Product鍒楄〃 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data query testReq.ProductSearch true "鍒嗛〉鑾峰彇Product鍒楄〃" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}" +// @Router /p/getProductList [get] +func (pApi *ProductApi) GetProductList(c *gin.Context) { + var pageInfo testReq.ProductSearch + err := c.ShouldBindQuery(&pageInfo) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if list, total, err := pService.GetProductInfoList(pageInfo); err != nil { + global.GVA_LOG.Error("鑾峰彇澶辫触!", zap.Error(err)) + response.FailWithMessage("鑾峰彇澶辫触", c) + } else { + response.OkWithDetailed(response.PageResult{ + List: list, + Total: total, + Page: pageInfo.Page, + PageSize: pageInfo.PageSize, + }, "鑾峰彇鎴愬姛", c) + } +} diff --git a/docs/docs.go b/docs/docs.go index f7ba6c5..6290ec0 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -3600,6 +3600,356 @@ } } }, + "/p/createProduct": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鍒涘缓Product", + "parameters": [ + { + "description": "鍒涘缓Product", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Product" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/p/deleteProduct": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鍒犻櫎Product", + "parameters": [ + { + "description": "鍒犻櫎Product", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Product" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鍒犻櫎鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/p/deleteProductByIds": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鎵归噺鍒犻櫎Product", + "parameters": [ + { + "description": "鎵归噺鍒犻櫎Product", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.IdsReq" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鎵归噺鍒犻櫎鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/p/findProduct": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鐢╥d鏌ヨProduct", + "parameters": [ + { + "type": "integer", + "name": "deliveryTime", + "in": "query" + }, + { + "type": "integer", + "description": "涓婚敭ID", + "name": "id", + "in": "query" + }, + { + "type": "integer", + "name": "maximumStock", + "in": "query" + }, + { + "type": "integer", + "name": "minimumStock", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "name": "number", + "in": "query" + }, + { + "type": "string", + "name": "productType", + "in": "query" + }, + { + "type": "number", + "name": "purchasePrice", + "in": "query" + }, + { + "type": "string", + "name": "remark", + "in": "query" + }, + { + "type": "integer", + "name": "shippingDuration", + "in": "query" + }, + { + "type": "string", + "name": "unit", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鏌ヨ鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/p/getProductList": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鍒嗛〉鑾峰彇Product鍒楄〃", + "parameters": [ + { + "type": "integer", + "name": "deliveryTime", + "in": "query" + }, + { + "type": "string", + "name": "endCreatedAt", + "in": "query" + }, + { + "type": "integer", + "description": "涓婚敭ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "鍏抽敭瀛�", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "name": "maximumStock", + "in": "query" + }, + { + "type": "integer", + "name": "minimumStock", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "name": "number", + "in": "query" + }, + { + "type": "integer", + "description": "椤电爜", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "姣忛〉澶у皬", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "name": "productType", + "in": "query" + }, + { + "type": "number", + "name": "purchasePrice", + "in": "query" + }, + { + "type": "string", + "name": "remark", + "in": "query" + }, + { + "type": "integer", + "name": "shippingDuration", + "in": "query" + }, + { + "type": "string", + "name": "startCreatedAt", + "in": "query" + }, + { + "type": "string", + "name": "unit", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/p/updateProduct": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鏇存柊Product", + "parameters": [ + { + "description": "鏇存柊Product", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Product" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鏇存柊鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/s/changeSupplierStatus": { "post": { "security": [ @@ -6535,7 +6885,7 @@ } }, "email": { - "$ref": "#/definitions/github_com_flipped-aurora_gin-vue-admin_server_config.Email" + "$ref": "#/definitions/srm_config.Email" }, "excel": { "$ref": "#/definitions/config.Excel" @@ -6940,39 +7290,6 @@ }, "url": { "description": "鏂囦欢鍦板潃", - "type": "string" - } - } - }, - "github_com_flipped-aurora_gin-vue-admin_server_config.Email": { - "type": "object", - "properties": { - "from": { - "description": "鍙戜欢浜� 浣犺嚜宸辫鍙戦偖浠剁殑閭", - "type": "string" - }, - "host": { - "description": "鏈嶅姟鍣ㄥ湴鍧� 渚嬪 smtp.qq.com 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚", - "type": "string" - }, - "is-ssl": { - "description": "鏄惁SSL 鏄惁寮�鍚疭SL", - "type": "boolean" - }, - "nickname": { - "description": "鏄电О 鍙戜欢浜烘樀绉� 閫氬父涓鸿嚜宸辩殑閭", - "type": "string" - }, - "port": { - "description": "绔彛 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚 澶у涓� 465", - "type": "integer" - }, - "secret": { - "description": "瀵嗛挜 鐢ㄤ簬鐧诲綍鐨勫瘑閽� 鏈�濂戒笉瑕佺敤閭瀵嗙爜 鍘婚偖绠眘mtp鐢宠涓�涓敤浜庣櫥褰曠殑瀵嗛挜", - "type": "string" - }, - "to": { - "description": "鏀朵欢浜�:澶氫釜浠ヨ嫳鏂囬�楀彿鍒嗛殧 渚嬶細a@qq.com b@qq.com 姝e紡寮�鍙戜腑璇锋妸姝ら」鐩綔涓哄弬鏁颁娇鐢�", "type": "string" } } @@ -7540,6 +7857,39 @@ "properties": { "user": { "$ref": "#/definitions/system.SysUser" + } + } + }, + "srm_config.Email": { + "type": "object", + "properties": { + "from": { + "description": "鍙戜欢浜� 浣犺嚜宸辫鍙戦偖浠剁殑閭", + "type": "string" + }, + "host": { + "description": "鏈嶅姟鍣ㄥ湴鍧� 渚嬪 smtp.qq.com 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚", + "type": "string" + }, + "is-ssl": { + "description": "鏄惁SSL 鏄惁寮�鍚疭SL", + "type": "boolean" + }, + "nickname": { + "description": "鏄电О 鍙戜欢浜烘樀绉� 閫氬父涓鸿嚜宸辩殑閭", + "type": "string" + }, + "port": { + "description": "绔彛 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚 澶у涓� 465", + "type": "integer" + }, + "secret": { + "description": "瀵嗛挜 鐢ㄤ簬鐧诲綍鐨勫瘑閽� 鏈�濂戒笉瑕佺敤閭瀵嗙爜 鍘婚偖绠眘mtp鐢宠涓�涓敤浜庣櫥褰曠殑瀵嗛挜", + "type": "string" + }, + "to": { + "description": "鏀朵欢浜�:澶氫釜浠ヨ嫳鏂囬�楀彿鍒嗛殧 渚嬶細a@qq.com b@qq.com 姝e紡寮�鍙戜腑璇锋妸姝ら」鐩綔涓哄弬鏁颁娇鐢�", + "type": "string" } } }, @@ -8174,6 +8524,45 @@ } } }, + "test.Product": { + "type": "object", + "properties": { + "deliveryTime": { + "type": "integer" + }, + "id": { + "description": "涓婚敭ID", + "type": "integer" + }, + "maximumStock": { + "type": "integer" + }, + "minimumStock": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "number": { + "type": "string" + }, + "productType": { + "type": "string" + }, + "purchasePrice": { + "type": "number" + }, + "remark": { + "type": "string" + }, + "shippingDuration": { + "type": "integer" + }, + "unit": { + "type": "string" + } + } + }, "test.Supplier": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index ae2bff8..b0e64f4 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3591,6 +3591,356 @@ } } }, + "/p/createProduct": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鍒涘缓Product", + "parameters": [ + { + "description": "鍒涘缓Product", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Product" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/p/deleteProduct": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鍒犻櫎Product", + "parameters": [ + { + "description": "鍒犻櫎Product", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Product" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鍒犻櫎鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/p/deleteProductByIds": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鎵归噺鍒犻櫎Product", + "parameters": [ + { + "description": "鎵归噺鍒犻櫎Product", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.IdsReq" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鎵归噺鍒犻櫎鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/p/findProduct": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鐢╥d鏌ヨProduct", + "parameters": [ + { + "type": "integer", + "name": "deliveryTime", + "in": "query" + }, + { + "type": "integer", + "description": "涓婚敭ID", + "name": "id", + "in": "query" + }, + { + "type": "integer", + "name": "maximumStock", + "in": "query" + }, + { + "type": "integer", + "name": "minimumStock", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "name": "number", + "in": "query" + }, + { + "type": "string", + "name": "productType", + "in": "query" + }, + { + "type": "number", + "name": "purchasePrice", + "in": "query" + }, + { + "type": "string", + "name": "remark", + "in": "query" + }, + { + "type": "integer", + "name": "shippingDuration", + "in": "query" + }, + { + "type": "string", + "name": "unit", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鏌ヨ鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/p/getProductList": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鍒嗛〉鑾峰彇Product鍒楄〃", + "parameters": [ + { + "type": "integer", + "name": "deliveryTime", + "in": "query" + }, + { + "type": "string", + "name": "endCreatedAt", + "in": "query" + }, + { + "type": "integer", + "description": "涓婚敭ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "鍏抽敭瀛�", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "name": "maximumStock", + "in": "query" + }, + { + "type": "integer", + "name": "minimumStock", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "name": "number", + "in": "query" + }, + { + "type": "integer", + "description": "椤电爜", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "姣忛〉澶у皬", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "name": "productType", + "in": "query" + }, + { + "type": "number", + "name": "purchasePrice", + "in": "query" + }, + { + "type": "string", + "name": "remark", + "in": "query" + }, + { + "type": "integer", + "name": "shippingDuration", + "in": "query" + }, + { + "type": "string", + "name": "startCreatedAt", + "in": "query" + }, + { + "type": "string", + "name": "unit", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/p/updateProduct": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Product" + ], + "summary": "鏇存柊Product", + "parameters": [ + { + "description": "鏇存柊Product", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Product" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鏇存柊鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/s/changeSupplierStatus": { "post": { "security": [ @@ -6526,7 +6876,7 @@ } }, "email": { - "$ref": "#/definitions/github_com_flipped-aurora_gin-vue-admin_server_config.Email" + "$ref": "#/definitions/srm_config.Email" }, "excel": { "$ref": "#/definitions/config.Excel" @@ -6931,39 +7281,6 @@ }, "url": { "description": "鏂囦欢鍦板潃", - "type": "string" - } - } - }, - "github_com_flipped-aurora_gin-vue-admin_server_config.Email": { - "type": "object", - "properties": { - "from": { - "description": "鍙戜欢浜� 浣犺嚜宸辫鍙戦偖浠剁殑閭", - "type": "string" - }, - "host": { - "description": "鏈嶅姟鍣ㄥ湴鍧� 渚嬪 smtp.qq.com 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚", - "type": "string" - }, - "is-ssl": { - "description": "鏄惁SSL 鏄惁寮�鍚疭SL", - "type": "boolean" - }, - "nickname": { - "description": "鏄电О 鍙戜欢浜烘樀绉� 閫氬父涓鸿嚜宸辩殑閭", - "type": "string" - }, - "port": { - "description": "绔彛 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚 澶у涓� 465", - "type": "integer" - }, - "secret": { - "description": "瀵嗛挜 鐢ㄤ簬鐧诲綍鐨勫瘑閽� 鏈�濂戒笉瑕佺敤閭瀵嗙爜 鍘婚偖绠眘mtp鐢宠涓�涓敤浜庣櫥褰曠殑瀵嗛挜", - "type": "string" - }, - "to": { - "description": "鏀朵欢浜�:澶氫釜浠ヨ嫳鏂囬�楀彿鍒嗛殧 渚嬶細a@qq.com b@qq.com 姝e紡寮�鍙戜腑璇锋妸姝ら」鐩綔涓哄弬鏁颁娇鐢�", "type": "string" } } @@ -7531,6 +7848,39 @@ "properties": { "user": { "$ref": "#/definitions/system.SysUser" + } + } + }, + "srm_config.Email": { + "type": "object", + "properties": { + "from": { + "description": "鍙戜欢浜� 浣犺嚜宸辫鍙戦偖浠剁殑閭", + "type": "string" + }, + "host": { + "description": "鏈嶅姟鍣ㄥ湴鍧� 渚嬪 smtp.qq.com 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚", + "type": "string" + }, + "is-ssl": { + "description": "鏄惁SSL 鏄惁寮�鍚疭SL", + "type": "boolean" + }, + "nickname": { + "description": "鏄电О 鍙戜欢浜烘樀绉� 閫氬父涓鸿嚜宸辩殑閭", + "type": "string" + }, + "port": { + "description": "绔彛 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚 澶у涓� 465", + "type": "integer" + }, + "secret": { + "description": "瀵嗛挜 鐢ㄤ簬鐧诲綍鐨勫瘑閽� 鏈�濂戒笉瑕佺敤閭瀵嗙爜 鍘婚偖绠眘mtp鐢宠涓�涓敤浜庣櫥褰曠殑瀵嗛挜", + "type": "string" + }, + "to": { + "description": "鏀朵欢浜�:澶氫釜浠ヨ嫳鏂囬�楀彿鍒嗛殧 渚嬶細a@qq.com b@qq.com 姝e紡寮�鍙戜腑璇锋妸姝ら」鐩綔涓哄弬鏁颁娇鐢�", + "type": "string" } } }, @@ -8165,6 +8515,45 @@ } } }, + "test.Product": { + "type": "object", + "properties": { + "deliveryTime": { + "type": "integer" + }, + "id": { + "description": "涓婚敭ID", + "type": "integer" + }, + "maximumStock": { + "type": "integer" + }, + "minimumStock": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "number": { + "type": "string" + }, + "productType": { + "type": "string" + }, + "purchasePrice": { + "type": "number" + }, + "remark": { + "type": "string" + }, + "shippingDuration": { + "type": "integer" + }, + "unit": { + "type": "string" + } + } + }, "test.Supplier": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 09a96c0..477fa41 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -377,7 +377,7 @@ $ref: '#/definitions/config.SpecializedDB' type: array email: - $ref: '#/definitions/github_com_flipped-aurora_gin-vue-admin_server_config.Email' + $ref: '#/definitions/srm_config.Email' excel: $ref: '#/definitions/config.Excel' hua-wei-obs: @@ -657,30 +657,6 @@ type: string url: description: 鏂囦欢鍦板潃 - type: string - type: object - github_com_flipped-aurora_gin-vue-admin_server_config.Email: - properties: - from: - description: 鍙戜欢浜� 浣犺嚜宸辫鍙戦偖浠剁殑閭 - type: string - host: - description: 鏈嶅姟鍣ㄥ湴鍧� 渚嬪 smtp.qq.com 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚 - type: string - is-ssl: - description: 鏄惁SSL 鏄惁寮�鍚疭SL - type: boolean - nickname: - description: 鏄电О 鍙戜欢浜烘樀绉� 閫氬父涓鸿嚜宸辩殑閭 - type: string - port: - description: 绔彛 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚 澶у涓� 465 - type: integer - secret: - description: 瀵嗛挜 鐢ㄤ簬鐧诲綍鐨勫瘑閽� 鏈�濂戒笉瑕佺敤閭瀵嗙爜 鍘婚偖绠眘mtp鐢宠涓�涓敤浜庣櫥褰曠殑瀵嗛挜 - type: string - to: - description: 鏀朵欢浜�:澶氫釜浠ヨ嫳鏂囬�楀彿鍒嗛殧 渚嬶細a@qq.com b@qq.com 姝e紡寮�鍙戜腑璇锋妸姝ら」鐩綔涓哄弬鏁颁娇鐢� type: string type: object request.AddMenuAuthorityInfo: @@ -1064,6 +1040,30 @@ properties: user: $ref: '#/definitions/system.SysUser' + type: object + srm_config.Email: + properties: + from: + description: 鍙戜欢浜� 浣犺嚜宸辫鍙戦偖浠剁殑閭 + type: string + host: + description: 鏈嶅姟鍣ㄥ湴鍧� 渚嬪 smtp.qq.com 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚 + type: string + is-ssl: + description: 鏄惁SSL 鏄惁寮�鍚疭SL + type: boolean + nickname: + description: 鏄电О 鍙戜欢浜烘樀绉� 閫氬父涓鸿嚜宸辩殑閭 + type: string + port: + description: 绔彛 璇峰墠寰�QQ鎴栬�呬綘瑕佸彂閭欢鐨勯偖绠辨煡鐪嬪叾smtp鍗忚 澶у涓� 465 + type: integer + secret: + description: 瀵嗛挜 鐢ㄤ簬鐧诲綍鐨勫瘑閽� 鏈�濂戒笉瑕佺敤閭瀵嗙爜 鍘婚偖绠眘mtp鐢宠涓�涓敤浜庣櫥褰曠殑瀵嗛挜 + type: string + to: + description: 鏀朵欢浜�:澶氫釜浠ヨ嫳鏂囬�楀彿鍒嗛殧 渚嬶細a@qq.com b@qq.com 姝e紡寮�鍙戜腑璇锋妸姝ら」鐩綔涓哄弬鏁颁娇鐢� + type: string type: object system.AutoCodeStruct: properties: @@ -1507,6 +1507,32 @@ description: 涓婚敭ID type: integer name: + type: string + type: object + test.Product: + properties: + deliveryTime: + type: integer + id: + description: 涓婚敭ID + type: integer + maximumStock: + type: integer + minimumStock: + type: integer + name: + type: string + number: + type: string + productType: + type: string + purchasePrice: + type: number + remark: + type: string + shippingDuration: + type: integer + unit: type: string type: object test.Supplier: @@ -3614,6 +3640,218 @@ summary: 鏇存柊鑿滃崟 tags: - Menu + /p/createProduct: + post: + consumes: + - application/json + parameters: + - description: 鍒涘缓Product + in: body + name: data + required: true + schema: + $ref: '#/definitions/test.Product' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鍒涘缓Product + tags: + - Product + /p/deleteProduct: + delete: + consumes: + - application/json + parameters: + - description: 鍒犻櫎Product + in: body + name: data + required: true + schema: + $ref: '#/definitions/test.Product' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鍒犻櫎鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鍒犻櫎Product + tags: + - Product + /p/deleteProductByIds: + delete: + consumes: + - application/json + parameters: + - description: 鎵归噺鍒犻櫎Product + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.IdsReq' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鎵归噺鍒犻櫎鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鎵归噺鍒犻櫎Product + tags: + - Product + /p/findProduct: + get: + consumes: + - application/json + parameters: + - in: query + name: deliveryTime + type: integer + - description: 涓婚敭ID + in: query + name: id + type: integer + - in: query + name: maximumStock + type: integer + - in: query + name: minimumStock + type: integer + - in: query + name: name + type: string + - in: query + name: number + type: string + - in: query + name: productType + type: string + - in: query + name: purchasePrice + type: number + - in: query + name: remark + type: string + - in: query + name: shippingDuration + type: integer + - in: query + name: unit + type: string + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鏌ヨ鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鐢╥d鏌ヨProduct + tags: + - Product + /p/getProductList: + get: + consumes: + - application/json + parameters: + - in: query + name: deliveryTime + type: integer + - in: query + name: endCreatedAt + type: string + - description: 涓婚敭ID + in: query + name: id + type: integer + - description: 鍏抽敭瀛� + in: query + name: keyword + type: string + - in: query + name: maximumStock + type: integer + - in: query + name: minimumStock + type: integer + - in: query + name: name + type: string + - in: query + name: number + type: string + - description: 椤电爜 + in: query + name: page + type: integer + - description: 姣忛〉澶у皬 + in: query + name: pageSize + type: integer + - in: query + name: productType + type: string + - in: query + name: purchasePrice + type: number + - in: query + name: remark + type: string + - in: query + name: shippingDuration + type: integer + - in: query + name: startCreatedAt + type: string + - in: query + name: unit + type: string + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鍒嗛〉鑾峰彇Product鍒楄〃 + tags: + - Product + /p/updateProduct: + put: + consumes: + - application/json + parameters: + - description: 鏇存柊Product + in: body + name: data + required: true + schema: + $ref: '#/definitions/test.Product' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鏇存柊鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鏇存柊Product + tags: + - Product /s/changeSupplierStatus: post: consumes: diff --git a/initialize/router.go b/initialize/router.go index 7094d28..fda059b 100644 --- a/initialize/router.go +++ b/initialize/router.go @@ -77,6 +77,7 @@ testRouter.InitSupplierTypeRouter(PrivateGroup) testRouter.InitSupplierRouter(PrivateGroup) testRouter.InitContractRouter(PrivateGroup) + testRouter.InitProductRouter(PrivateGroup) } global.GVA_LOG.Info("router register success") diff --git a/log/2023-08-26/info.log b/log/2023-08-26/info.log new file mode 100644 index 0000000..45d11d8 --- /dev/null +++ b/log/2023-08-26/info.log @@ -0,0 +1,8 @@ +[srm]2023/08/26 - 11:53:44.694 [34minfo[0m D:/basic.com/srm/initialize/gorm.go:60 register table success +[srm]2023/08/26 - 11:53:44.703 [34minfo[0m D:/basic.com/srm/initialize/router.go:37 register swagger handler +[srm]2023/08/26 - 11:53:44.734 [34minfo[0m D:/basic.com/srm/initialize/router.go:82 router register success +[srm]2023/08/26 - 11:53:44.748 [34minfo[0m D:/basic.com/srm/core/server.go:36 server run success on {"address": ":8889"} +[srm]2023/08/26 - 11:54:33.203 [34minfo[0m D:/basic.com/srm/initialize/gorm.go:60 register table success +[srm]2023/08/26 - 11:54:33.210 [34minfo[0m D:/basic.com/srm/initialize/router.go:37 register swagger handler +[srm]2023/08/26 - 11:54:33.230 [34minfo[0m D:/basic.com/srm/initialize/router.go:83 router register success +[srm]2023/08/26 - 11:54:33.231 [34minfo[0m D:/basic.com/srm/core/server.go:36 server run success on {"address": ":8889"} diff --git a/model/test/product.go b/model/test/product.go new file mode 100644 index 0000000..b7ef7d4 --- /dev/null +++ b/model/test/product.go @@ -0,0 +1,25 @@ +package test + +import ( + "srm/global" +) + +// Product 缁撴瀯浣� +type Product struct { + global.GVA_MODEL + Name string `json:"name" form:"name" gorm:"column:name;comment:鍚嶇О;size:255;"` + Number string `json:"number" form:"number" gorm:"column:number;comment:缂栫爜;size:255;"` + Unit string `json:"unit" form:"unit" gorm:"column:unit;comment:璁¢噺鍗曚綅;size:255;"` + PurchasePrice *float64 `json:"purchasePrice" form:"purchasePrice" gorm:"column:purchase_price;comment:閲囪喘浠锋牸;"` + DeliveryTime *int `json:"deliveryTime" form:"deliveryTime" gorm:"column:delivery_time;comment:;size:11;"` + ShippingDuration *int `json:"shippingDuration" form:"shippingDuration" gorm:"column:shipping_duration;comment:鐗╂祦鏃堕暱;size:11;"` + ProductType string `json:"productType" form:"productType" gorm:"column:product_type;comment:浜у搧绫诲埆;size:255;"` + MinimumStock *int `json:"minimumStock" form:"minimumStock" gorm:"column:minimum_stock;comment:鏈�浣庡簱瀛�;"` + MaximumStock *int `json:"maximumStock" form:"maximumStock" gorm:"column:maximum_stock;comment:鏈�楂樺簱瀛�;"` + Remark string `json:"remark" form:"remark" gorm:"column:remark;comment:澶囨敞;size:255;"` +} + +// TableName Product 琛ㄥ悕 +func (Product) TableName() string { + return "Product" +} diff --git a/model/test/request/product.go b/model/test/request/product.go new file mode 100644 index 0000000..16a171c --- /dev/null +++ b/model/test/request/product.go @@ -0,0 +1,14 @@ +package request + +import ( + "srm/model/common/request" + "srm/model/test" + "time" +) + +type ProductSearch struct { + test.Product + StartCreatedAt *time.Time `json:"startCreatedAt" form:"startCreatedAt"` + EndCreatedAt *time.Time `json:"endCreatedAt" form:"endCreatedAt"` + request.PageInfo +} diff --git a/router/test/enter.go b/router/test/enter.go index e7e1919..9c7187e 100644 --- a/router/test/enter.go +++ b/router/test/enter.go @@ -5,4 +5,5 @@ IndustryRouter SupplierRouter ContractRouter + ProductRouter } diff --git a/router/test/product.go b/router/test/product.go new file mode 100644 index 0000000..4a98419 --- /dev/null +++ b/router/test/product.go @@ -0,0 +1,27 @@ +package test + +import ( + "github.com/gin-gonic/gin" + "srm/api/v1" + "srm/middleware" +) + +type ProductRouter struct { +} + +// InitProductRouter 鍒濆鍖� Product 璺敱淇℃伅 +func (s *ProductRouter) InitProductRouter(Router *gin.RouterGroup) { + pRouter := Router.Group("p").Use(middleware.OperationRecord()) + pRouterWithoutRecord := Router.Group("p") + var pApi = v1.ApiGroupApp.TestApiGroup.ProductApi + { + pRouter.POST("createProduct", pApi.CreateProduct) // 鏂板缓Product + pRouter.DELETE("deleteProduct", pApi.DeleteProduct) // 鍒犻櫎Product + pRouter.DELETE("deleteProductByIds", pApi.DeleteProductByIds) // 鎵归噺鍒犻櫎Product + pRouter.PUT("updateProduct", pApi.UpdateProduct) // 鏇存柊Product + } + { + pRouterWithoutRecord.GET("findProduct", pApi.FindProduct) // 鏍规嵁ID鑾峰彇Product + pRouterWithoutRecord.GET("getProductList", pApi.GetProductList) // 鑾峰彇Product鍒楄〃 + } +} diff --git a/service/test/enter.go b/service/test/enter.go index 75a514f..d035d5b 100644 --- a/service/test/enter.go +++ b/service/test/enter.go @@ -5,4 +5,5 @@ IndustryService SupplierService ContractService + ProductService } diff --git a/service/test/product.go b/service/test/product.go new file mode 100644 index 0000000..65a2f7e --- /dev/null +++ b/service/test/product.go @@ -0,0 +1,76 @@ +package test + +import ( + "srm/global" + "srm/model/common/request" + "srm/model/test" + testReq "srm/model/test/request" +) + +type ProductService struct { +} + +// CreateProduct 鍒涘缓Product璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (pService *ProductService) CreateProduct(p *test.Product) (err error) { + err = global.GVA_DB.Create(p).Error + return err +} + +// DeleteProduct 鍒犻櫎Product璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (pService *ProductService) DeleteProduct(p test.Product) (err error) { + err = global.GVA_DB.Delete(&p).Error + return err +} + +// DeleteProductByIds 鎵归噺鍒犻櫎Product璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (pService *ProductService) DeleteProductByIds(ids request.IdsReq) (err error) { + err = global.GVA_DB.Delete(&[]test.Product{}, "id in ?", ids.Ids).Error + return err +} + +// UpdateProduct 鏇存柊Product璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (pService *ProductService) UpdateProduct(p test.Product) (err error) { + err = global.GVA_DB.Save(&p).Error + return err +} + +// GetProduct 鏍规嵁id鑾峰彇Product璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (pService *ProductService) GetProduct(id uint) (p test.Product, err error) { + err = global.GVA_DB.Where("id = ?", id).First(&p).Error + return +} + +// GetProductInfoList 鍒嗛〉鑾峰彇Product璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (pService *ProductService) GetProductInfoList(info testReq.ProductSearch) (list []test.Product, total int64, err error) { + limit := info.PageSize + offset := info.PageSize * (info.Page - 1) + // 鍒涘缓db + db := global.GVA_DB.Model(&test.Product{}) + var ps []test.Product + // 濡傛灉鏈夋潯浠舵悳绱� 涓嬫柟浼氳嚜鍔ㄥ垱寤烘悳绱㈣鍙� + if info.StartCreatedAt != nil && info.EndCreatedAt != nil { + db = db.Where("created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt) + } + if info.Name != "" { + db = db.Where("name LIKE ?", "%"+info.Name+"%") + } + if info.Number != "" { + db = db.Where("number LIKE ?", "%"+info.Number+"%") + } + if info.Unit != "" { + db = db.Where("unit LIKE ?", "%"+info.Unit+"%") + } + err = db.Count(&total).Error + if err != nil { + return + } + + err = db.Limit(limit).Offset(offset).Find(&ps).Error + return ps, total, err +} -- Gitblit v1.8.0