From 5fd608f17fca7e1c3c0e339831b226a3bcd8af41 Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期四, 24 八月 2023 19:39:30 +0800 Subject: [PATCH] add --- api/v1/test/enter.go | 1 router/test/enter.go | 1 service/test/supplier.go | 70 ++ docs/swagger.yaml | 270 ++++++++++ docs/docs.go | 441 +++++++++++++++++ docs/swagger.json | 441 +++++++++++++++++ service/test/enter.go | 1 api/v1/test/supplier.go | 183 +++++++ initialize/router.go | 1 model/test/supplier.go | 30 + router/test/supplier.go | 26 + initialize/gorm.go | 2 model/test/request/supplier.go | 14 13 files changed, 1,480 insertions(+), 1 deletions(-) diff --git a/api/v1/test/enter.go b/api/v1/test/enter.go index 4a13db9..1472d6a 100644 --- a/api/v1/test/enter.go +++ b/api/v1/test/enter.go @@ -3,4 +3,5 @@ type ApiGroup struct { SupplierTypeApi IndustryApi + SupplierApi } diff --git a/api/v1/test/supplier.go b/api/v1/test/supplier.go new file mode 100644 index 0000000..5b9df26 --- /dev/null +++ b/api/v1/test/supplier.go @@ -0,0 +1,183 @@ +package test + +import ( + "github.com/flipped-aurora/gin-vue-admin/server/global" + "github.com/flipped-aurora/gin-vue-admin/server/model/common/request" + "github.com/flipped-aurora/gin-vue-admin/server/model/common/response" + "github.com/flipped-aurora/gin-vue-admin/server/model/test" + testReq "github.com/flipped-aurora/gin-vue-admin/server/model/test/request" + "github.com/flipped-aurora/gin-vue-admin/server/service" + "github.com/flipped-aurora/gin-vue-admin/server/utils" + "github.com/gin-gonic/gin" + "go.uber.org/zap" +) + +type SupplierApi struct { +} + +var sService = service.ServiceGroupApp.TestServiceGroup.SupplierService + +// CreateSupplier 鍒涘缓Supplier +// @Tags Supplier +// @Summary 鍒涘缓Supplier +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body test.Supplier true "鍒涘缓Supplier" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}" +// @Router /s/createSupplier [post] +func (sApi *SupplierApi) CreateSupplier(c *gin.Context) { + var s test.Supplier + err := c.ShouldBindJSON(&s) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + verify := utils.Rules{ + "Name": {utils.NotEmpty()}, + "ResponsiblePersonId": {utils.NotEmpty()}, + } + if err := utils.Verify(s, verify); err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if err := sService.CreateSupplier(&s); err != nil { + global.GVA_LOG.Error("鍒涘缓澶辫触!", zap.Error(err)) + response.FailWithMessage("鍒涘缓澶辫触", c) + } else { + response.OkWithMessage("鍒涘缓鎴愬姛", c) + } +} + +// DeleteSupplier 鍒犻櫎Supplier +// @Tags Supplier +// @Summary 鍒犻櫎Supplier +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body test.Supplier true "鍒犻櫎Supplier" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鍒犻櫎鎴愬姛"}" +// @Router /s/deleteSupplier [delete] +func (sApi *SupplierApi) DeleteSupplier(c *gin.Context) { + var s test.Supplier + err := c.ShouldBindJSON(&s) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if err := sService.DeleteSupplier(s); err != nil { + global.GVA_LOG.Error("鍒犻櫎澶辫触!", zap.Error(err)) + response.FailWithMessage("鍒犻櫎澶辫触", c) + } else { + response.OkWithMessage("鍒犻櫎鎴愬姛", c) + } +} + +// DeleteSupplierByIds 鎵归噺鍒犻櫎Supplier +// @Tags Supplier +// @Summary 鎵归噺鍒犻櫎Supplier +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body request.IdsReq true "鎵归噺鍒犻櫎Supplier" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鎵归噺鍒犻櫎鎴愬姛"}" +// @Router /s/deleteSupplierByIds [delete] +func (sApi *SupplierApi) DeleteSupplierByIds(c *gin.Context) { + var IDS request.IdsReq + err := c.ShouldBindJSON(&IDS) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if err := sService.DeleteSupplierByIds(IDS); err != nil { + global.GVA_LOG.Error("鎵归噺鍒犻櫎澶辫触!", zap.Error(err)) + response.FailWithMessage("鎵归噺鍒犻櫎澶辫触", c) + } else { + response.OkWithMessage("鎵归噺鍒犻櫎鎴愬姛", c) + } +} + +// UpdateSupplier 鏇存柊Supplier +// @Tags Supplier +// @Summary 鏇存柊Supplier +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body test.Supplier true "鏇存柊Supplier" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鏇存柊鎴愬姛"}" +// @Router /s/updateSupplier [put] +func (sApi *SupplierApi) UpdateSupplier(c *gin.Context) { + var s test.Supplier + err := c.ShouldBindJSON(&s) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + verify := utils.Rules{ + "Name": {utils.NotEmpty()}, + "ResponsiblePersonId": {utils.NotEmpty()}, + } + if err := utils.Verify(s, verify); err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if err := sService.UpdateSupplier(s); err != nil { + global.GVA_LOG.Error("鏇存柊澶辫触!", zap.Error(err)) + response.FailWithMessage("鏇存柊澶辫触", c) + } else { + response.OkWithMessage("鏇存柊鎴愬姛", c) + } +} + +// FindSupplier 鐢╥d鏌ヨSupplier +// @Tags Supplier +// @Summary 鐢╥d鏌ヨSupplier +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data query test.Supplier true "鐢╥d鏌ヨSupplier" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鏌ヨ鎴愬姛"}" +// @Router /s/findSupplier [get] +func (sApi *SupplierApi) FindSupplier(c *gin.Context) { + var s test.Supplier + err := c.ShouldBindQuery(&s) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if res, err := sService.GetSupplier(s.ID); err != nil { + global.GVA_LOG.Error("鏌ヨ澶辫触!", zap.Error(err)) + response.FailWithMessage("鏌ヨ澶辫触", c) + } else { + response.OkWithData(gin.H{"res": res}, c) + } +} + +// GetSupplierList 鍒嗛〉鑾峰彇Supplier鍒楄〃 +// @Tags Supplier +// @Summary 鍒嗛〉鑾峰彇Supplier鍒楄〃 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data query testReq.SupplierSearch true "鍒嗛〉鑾峰彇Supplier鍒楄〃" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}" +// @Router /s/getSupplierList [get] +func (sApi *SupplierApi) GetSupplierList(c *gin.Context) { + var pageInfo testReq.SupplierSearch + err := c.ShouldBindQuery(&pageInfo) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if list, total, err := sService.GetSupplierInfoList(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 74b8cfe..e1ac368 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -3253,6 +3253,396 @@ } } }, + "/s/createSupplier": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鍒涘缓Supplier", + "parameters": [ + { + "description": "鍒涘缓Supplier", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Supplier" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/s/deleteSupplier": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鍒犻櫎Supplier", + "parameters": [ + { + "description": "鍒犻櫎Supplier", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Supplier" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鍒犻櫎鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/s/deleteSupplierByIds": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鎵归噺鍒犻櫎Supplier", + "parameters": [ + { + "description": "鎵归噺鍒犻櫎Supplier", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.IdsReq" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鎵归噺鍒犻櫎鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/s/findSupplier": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鐢╥d鏌ヨSupplier", + "parameters": [ + { + "type": "string", + "name": "account", + "in": "query" + }, + { + "type": "string", + "name": "accountName", + "in": "query" + }, + { + "type": "string", + "name": "bank", + "in": "query" + }, + { + "type": "string", + "name": "contact", + "in": "query" + }, + { + "type": "string", + "name": "detailAddress", + "in": "query" + }, + { + "type": "string", + "name": "email", + "in": "query" + }, + { + "type": "string", + "name": "file", + "in": "query" + }, + { + "type": "integer", + "description": "涓婚敭ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "industry", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "name": "number", + "in": "query" + }, + { + "type": "string", + "name": "phone", + "in": "query" + }, + { + "type": "integer", + "name": "responsiblePersonId", + "in": "query" + }, + { + "type": "string", + "name": "supplierType", + "in": "query" + }, + { + "type": "string", + "name": "url", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鏌ヨ鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/s/getSupplierList": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鍒嗛〉鑾峰彇Supplier鍒楄〃", + "parameters": [ + { + "type": "string", + "name": "account", + "in": "query" + }, + { + "type": "string", + "name": "accountName", + "in": "query" + }, + { + "type": "string", + "name": "bank", + "in": "query" + }, + { + "type": "string", + "name": "contact", + "in": "query" + }, + { + "type": "string", + "name": "detailAddress", + "in": "query" + }, + { + "type": "string", + "name": "email", + "in": "query" + }, + { + "type": "string", + "name": "endCreatedAt", + "in": "query" + }, + { + "type": "string", + "name": "file", + "in": "query" + }, + { + "type": "integer", + "description": "涓婚敭ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "industry", + "in": "query" + }, + { + "type": "string", + "description": "鍏抽敭瀛�", + "name": "keyword", + "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": "phone", + "in": "query" + }, + { + "type": "integer", + "name": "responsiblePersonId", + "in": "query" + }, + { + "type": "string", + "name": "startCreatedAt", + "in": "query" + }, + { + "type": "string", + "name": "supplierType", + "in": "query" + }, + { + "type": "string", + "name": "url", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/s/updateSupplier": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鏇存柊Supplier", + "parameters": [ + { + "description": "鏇存柊Supplier", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Supplier" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鏇存柊鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/st/createSupplierType": { "post": { "security": [ @@ -7335,6 +7725,57 @@ } } }, + "test.Supplier": { + "type": "object", + "properties": { + "account": { + "type": "string" + }, + "accountName": { + "type": "string" + }, + "bank": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "detailAddress": { + "type": "string" + }, + "email": { + "type": "string" + }, + "file": { + "type": "string" + }, + "id": { + "description": "涓婚敭ID", + "type": "integer" + }, + "industry": { + "type": "string" + }, + "name": { + "type": "string" + }, + "number": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "responsiblePersonId": { + "type": "integer" + }, + "supplierType": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, "test.SupplierType": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 988ca16..501125a 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3244,6 +3244,396 @@ } } }, + "/s/createSupplier": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鍒涘缓Supplier", + "parameters": [ + { + "description": "鍒涘缓Supplier", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Supplier" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/s/deleteSupplier": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鍒犻櫎Supplier", + "parameters": [ + { + "description": "鍒犻櫎Supplier", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Supplier" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鍒犻櫎鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/s/deleteSupplierByIds": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鎵归噺鍒犻櫎Supplier", + "parameters": [ + { + "description": "鎵归噺鍒犻櫎Supplier", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.IdsReq" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鎵归噺鍒犻櫎鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/s/findSupplier": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鐢╥d鏌ヨSupplier", + "parameters": [ + { + "type": "string", + "name": "account", + "in": "query" + }, + { + "type": "string", + "name": "accountName", + "in": "query" + }, + { + "type": "string", + "name": "bank", + "in": "query" + }, + { + "type": "string", + "name": "contact", + "in": "query" + }, + { + "type": "string", + "name": "detailAddress", + "in": "query" + }, + { + "type": "string", + "name": "email", + "in": "query" + }, + { + "type": "string", + "name": "file", + "in": "query" + }, + { + "type": "integer", + "description": "涓婚敭ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "industry", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "name": "number", + "in": "query" + }, + { + "type": "string", + "name": "phone", + "in": "query" + }, + { + "type": "integer", + "name": "responsiblePersonId", + "in": "query" + }, + { + "type": "string", + "name": "supplierType", + "in": "query" + }, + { + "type": "string", + "name": "url", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鏌ヨ鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/s/getSupplierList": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鍒嗛〉鑾峰彇Supplier鍒楄〃", + "parameters": [ + { + "type": "string", + "name": "account", + "in": "query" + }, + { + "type": "string", + "name": "accountName", + "in": "query" + }, + { + "type": "string", + "name": "bank", + "in": "query" + }, + { + "type": "string", + "name": "contact", + "in": "query" + }, + { + "type": "string", + "name": "detailAddress", + "in": "query" + }, + { + "type": "string", + "name": "email", + "in": "query" + }, + { + "type": "string", + "name": "endCreatedAt", + "in": "query" + }, + { + "type": "string", + "name": "file", + "in": "query" + }, + { + "type": "integer", + "description": "涓婚敭ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "industry", + "in": "query" + }, + { + "type": "string", + "description": "鍏抽敭瀛�", + "name": "keyword", + "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": "phone", + "in": "query" + }, + { + "type": "integer", + "name": "responsiblePersonId", + "in": "query" + }, + { + "type": "string", + "name": "startCreatedAt", + "in": "query" + }, + { + "type": "string", + "name": "supplierType", + "in": "query" + }, + { + "type": "string", + "name": "url", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/s/updateSupplier": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Supplier" + ], + "summary": "鏇存柊Supplier", + "parameters": [ + { + "description": "鏇存柊Supplier", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/test.Supplier" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"鏇存柊鎴愬姛\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/st/createSupplierType": { "post": { "security": [ @@ -7326,6 +7716,57 @@ } } }, + "test.Supplier": { + "type": "object", + "properties": { + "account": { + "type": "string" + }, + "accountName": { + "type": "string" + }, + "bank": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "detailAddress": { + "type": "string" + }, + "email": { + "type": "string" + }, + "file": { + "type": "string" + }, + "id": { + "description": "涓婚敭ID", + "type": "integer" + }, + "industry": { + "type": "string" + }, + "name": { + "type": "string" + }, + "number": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "responsiblePersonId": { + "type": "integer" + }, + "supplierType": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, "test.SupplierType": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 2b2722c..8a50206 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1474,6 +1474,40 @@ name: type: string type: object + test.Supplier: + properties: + account: + type: string + accountName: + type: string + bank: + type: string + contact: + type: string + detailAddress: + type: string + email: + type: string + file: + type: string + id: + description: 涓婚敭ID + type: integer + industry: + type: string + name: + type: string + number: + type: string + phone: + type: string + responsiblePersonId: + type: integer + supplierType: + type: string + url: + type: string + type: object test.SupplierType: properties: id: @@ -3330,6 +3364,242 @@ summary: 鏇存柊鑿滃崟 tags: - Menu + /s/createSupplier: + post: + consumes: + - application/json + parameters: + - description: 鍒涘缓Supplier + in: body + name: data + required: true + schema: + $ref: '#/definitions/test.Supplier' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鍒涘缓Supplier + tags: + - Supplier + /s/deleteSupplier: + delete: + consumes: + - application/json + parameters: + - description: 鍒犻櫎Supplier + in: body + name: data + required: true + schema: + $ref: '#/definitions/test.Supplier' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鍒犻櫎鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鍒犻櫎Supplier + tags: + - Supplier + /s/deleteSupplierByIds: + delete: + consumes: + - application/json + parameters: + - description: 鎵归噺鍒犻櫎Supplier + 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: 鎵归噺鍒犻櫎Supplier + tags: + - Supplier + /s/findSupplier: + get: + consumes: + - application/json + parameters: + - in: query + name: account + type: string + - in: query + name: accountName + type: string + - in: query + name: bank + type: string + - in: query + name: contact + type: string + - in: query + name: detailAddress + type: string + - in: query + name: email + type: string + - in: query + name: file + type: string + - description: 涓婚敭ID + in: query + name: id + type: integer + - in: query + name: industry + type: string + - in: query + name: name + type: string + - in: query + name: number + type: string + - in: query + name: phone + type: string + - in: query + name: responsiblePersonId + type: integer + - in: query + name: supplierType + type: string + - in: query + name: url + type: string + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鏌ヨ鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鐢╥d鏌ヨSupplier + tags: + - Supplier + /s/getSupplierList: + get: + consumes: + - application/json + parameters: + - in: query + name: account + type: string + - in: query + name: accountName + type: string + - in: query + name: bank + type: string + - in: query + name: contact + type: string + - in: query + name: detailAddress + type: string + - in: query + name: email + type: string + - in: query + name: endCreatedAt + type: string + - in: query + name: file + type: string + - description: 涓婚敭ID + in: query + name: id + type: integer + - in: query + name: industry + type: string + - description: 鍏抽敭瀛� + in: query + name: keyword + type: string + - 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: phone + type: string + - in: query + name: responsiblePersonId + type: integer + - in: query + name: startCreatedAt + type: string + - in: query + name: supplierType + type: string + - in: query + name: url + type: string + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鍒嗛〉鑾峰彇Supplier鍒楄〃 + tags: + - Supplier + /s/updateSupplier: + put: + consumes: + - application/json + parameters: + - description: 鏇存柊Supplier + in: body + name: data + required: true + schema: + $ref: '#/definitions/test.Supplier' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"鏇存柊鎴愬姛"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 鏇存柊Supplier + tags: + - Supplier /st/createSupplierType: post: consumes: diff --git a/initialize/gorm.go b/initialize/gorm.go index ce54d43..57d3be0 100644 --- a/initialize/gorm.go +++ b/initialize/gorm.go @@ -51,7 +51,7 @@ example.ExaFile{}, example.ExaCustomer{}, example.ExaFileChunk{}, - example.ExaFileUploadAndDownload{}, test.Industry{}, test.SupplierType{}, + example.ExaFileUploadAndDownload{}, test.Industry{}, test.SupplierType{}, test.Supplier{}, ) if err != nil { global.GVA_LOG.Error("register table failed", zap.Error(err)) diff --git a/initialize/router.go b/initialize/router.go index d857ef7..ff9022c 100644 --- a/initialize/router.go +++ b/initialize/router.go @@ -75,6 +75,7 @@ testRouter := router.RouterGroupApp.Test testRouter.InitIndustryRouter(PrivateGroup) testRouter.InitSupplierTypeRouter(PrivateGroup) + testRouter.InitSupplierRouter(PrivateGroup) } global.GVA_LOG.Info("router register success") diff --git a/model/test/request/supplier.go b/model/test/request/supplier.go new file mode 100644 index 0000000..f143a3a --- /dev/null +++ b/model/test/request/supplier.go @@ -0,0 +1,14 @@ +package request + +import ( + "github.com/flipped-aurora/gin-vue-admin/server/model/common/request" + "github.com/flipped-aurora/gin-vue-admin/server/model/test" + "time" +) + +type SupplierSearch struct { + test.Supplier + StartCreatedAt *time.Time `json:"startCreatedAt" form:"startCreatedAt"` + EndCreatedAt *time.Time `json:"endCreatedAt" form:"endCreatedAt"` + request.PageInfo +} diff --git a/model/test/supplier.go b/model/test/supplier.go new file mode 100644 index 0000000..d8251cd --- /dev/null +++ b/model/test/supplier.go @@ -0,0 +1,30 @@ +// 鑷姩鐢熸垚妯℃澘Supplier +package test + +import ( + "github.com/flipped-aurora/gin-vue-admin/server/global" +) + +// Supplier 缁撴瀯浣� +type Supplier struct { + global.GVA_MODEL + Number string `json:"number" form:"number" gorm:"column:number;comment:渚涘簲鍟嗙紪鍙�;size:255;"` + Name string `json:"name" form:"name" gorm:"column:name;comment:鍚嶇О;size:255;"` + SupplierType string `json:"supplierType" form:"supplierType" gorm:"column:supplier_type;comment:渚涘簲鍟嗙被鍨�;size:255;"` + Industry string `json:"industry" form:"industry" gorm:"column:industry;comment:鎵�灞炶涓�;size:255;"` + Contact string `json:"contact" form:"contact" gorm:"column:contact;comment:鑱旂郴浜�;size:255;"` + Phone string `json:"phone" form:"phone" gorm:"column:phone;comment:鐢佃瘽;size:255;"` + ResponsiblePersonId *int `json:"responsiblePersonId" form:"responsiblePersonId" gorm:"column:responsible_person_id;comment:璐熻矗浜篿d;size:11;"` + Email string `json:"email" form:"email" gorm:"column:email;comment:閭;size:255;"` + DetailAddress string `json:"detailAddress" form:"detailAddress" gorm:"column:detail_address;comment:璇︾粏鍦板潃;type:text;"` + Url string `json:"url" form:"url" gorm:"column:url;comment:缃戝潃;size:255;"` + AccountName string `json:"accountName" form:"accountName" gorm:"column:account_name;comment:鎴峰悕;size:255;"` + Account string `json:"account" form:"account" gorm:"column:account;comment:璐﹀彿;size:255;"` + Bank string `json:"bank" form:"bank" gorm:"column:bank;comment:寮�鎴疯;size:255;"` + File string `json:"file" form:"file" gorm:"column:file;comment:鏂囦欢;"` +} + +// TableName Supplier 琛ㄥ悕 +func (Supplier) TableName() string { + return "supplier" +} diff --git a/router/test/enter.go b/router/test/enter.go index 5edfdcb..d39a90e 100644 --- a/router/test/enter.go +++ b/router/test/enter.go @@ -3,4 +3,5 @@ type RouterGroup struct { SupplierTypeRouter IndustryRouter + SupplierRouter } diff --git a/router/test/supplier.go b/router/test/supplier.go new file mode 100644 index 0000000..fa8510e --- /dev/null +++ b/router/test/supplier.go @@ -0,0 +1,26 @@ +package test + +import ( + "github.com/flipped-aurora/gin-vue-admin/server/api/v1" + "github.com/gin-gonic/gin" +) + +type SupplierRouter struct { +} + +// InitSupplierRouter 鍒濆鍖� Supplier 璺敱淇℃伅 +func (s *SupplierRouter) InitSupplierRouter(Router *gin.RouterGroup) { + sRouter := Router.Group("s") + sRouterWithoutRecord := Router.Group("s") + var sApi = v1.ApiGroupApp.TestApiGroup.SupplierApi + { + sRouter.POST("createSupplier", sApi.CreateSupplier) // 鏂板缓Supplier + sRouter.DELETE("deleteSupplier", sApi.DeleteSupplier) // 鍒犻櫎Supplier + sRouter.DELETE("deleteSupplierByIds", sApi.DeleteSupplierByIds) // 鎵归噺鍒犻櫎Supplier + sRouter.PUT("updateSupplier", sApi.UpdateSupplier) // 鏇存柊Supplier + } + { + sRouterWithoutRecord.GET("findSupplier", sApi.FindSupplier) // 鏍规嵁ID鑾峰彇Supplier + sRouterWithoutRecord.GET("getSupplierList", sApi.GetSupplierList) // 鑾峰彇Supplier鍒楄〃 + } +} diff --git a/service/test/enter.go b/service/test/enter.go index 2dce8bc..e87c320 100644 --- a/service/test/enter.go +++ b/service/test/enter.go @@ -3,4 +3,5 @@ type ServiceGroup struct { SupplierTypeService IndustryService + SupplierService } diff --git a/service/test/supplier.go b/service/test/supplier.go new file mode 100644 index 0000000..915190c --- /dev/null +++ b/service/test/supplier.go @@ -0,0 +1,70 @@ +package test + +import ( + "github.com/flipped-aurora/gin-vue-admin/server/global" + "github.com/flipped-aurora/gin-vue-admin/server/model/common/request" + "github.com/flipped-aurora/gin-vue-admin/server/model/test" + testReq "github.com/flipped-aurora/gin-vue-admin/server/model/test/request" +) + +type SupplierService struct { +} + +// CreateSupplier 鍒涘缓Supplier璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (sService *SupplierService) CreateSupplier(s *test.Supplier) (err error) { + err = global.GVA_DB.Create(s).Error + return err +} + +// DeleteSupplier 鍒犻櫎Supplier璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (sService *SupplierService) DeleteSupplier(s test.Supplier) (err error) { + err = global.GVA_DB.Delete(&s).Error + return err +} + +// DeleteSupplierByIds 鎵归噺鍒犻櫎Supplier璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (sService *SupplierService) DeleteSupplierByIds(ids request.IdsReq) (err error) { + err = global.GVA_DB.Delete(&[]test.Supplier{}, "id in ?", ids.Ids).Error + return err +} + +// UpdateSupplier 鏇存柊Supplier璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (sService *SupplierService) UpdateSupplier(s test.Supplier) (err error) { + err = global.GVA_DB.Save(&s).Error + return err +} + +// GetSupplier 鏍规嵁id鑾峰彇Supplier璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (sService *SupplierService) GetSupplier(id uint) (s test.Supplier, err error) { + err = global.GVA_DB.Where("id = ?", id).First(&s).Error + return +} + +// GetSupplierInfoList 鍒嗛〉鑾峰彇Supplier璁板綍 +// Author [piexlmax](https://github.com/piexlmax) +func (sService *SupplierService) GetSupplierInfoList(info testReq.SupplierSearch) (list []test.Supplier, total int64, err error) { + limit := info.PageSize + offset := info.PageSize * (info.Page - 1) + // 鍒涘缓db + db := global.GVA_DB.Model(&test.Supplier{}) + var ss []test.Supplier + // 濡傛灉鏈夋潯浠舵悳绱� 涓嬫柟浼氳嚜鍔ㄥ垱寤烘悳绱㈣鍙� + 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+"%") + } + err = db.Count(&total).Error + if err != nil { + return + } + + err = db.Limit(limit).Offset(offset).Find(&ss).Error + return ss, total, err +} -- Gitblit v1.8.0