| New file |
| | |
| | | # Default ignored files |
| | | /shelf/ |
| | | /workspace.xml |
| | | # Editor-based HTTP Client requests |
| | | /httpRequests/ |
| | | # Datasource local storage ignored files |
| | | /dataSources/ |
| | | /dataSources.local.xml |
| New file |
| | |
| | | <?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> |
| New file |
| | |
| | | <?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> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project version="4"> |
| | | <component name="VcsDirectoryMappings"> |
| | | <mapping directory="" vcs="Git" /> |
| | | </component> |
| | | </project> |
| | |
| | | IndustryApi |
| | | SupplierApi |
| | | ContractApi |
| | | ProductApi |
| | | } |
| New file |
| | |
| | | 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 用id查询Product |
| | | // @Tags Product |
| | | // @Summary 用id查询Product |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data query test.Product true "用id查询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) |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": "用id查询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": [ |
| | |
| | | } |
| | | }, |
| | | "email": { |
| | | "$ref": "#/definitions/github_com_flipped-aurora_gin-vue-admin_server_config.Email" |
| | | "$ref": "#/definitions/srm_config.Email" |
| | | }, |
| | | "excel": { |
| | | "$ref": "#/definitions/config.Excel" |
| | |
| | | }, |
| | | "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 是否开启SSL", |
| | | "type": "boolean" |
| | | }, |
| | | "nickname": { |
| | | "description": "昵称 发件人昵称 通常为自己的邮箱", |
| | | "type": "string" |
| | | }, |
| | | "port": { |
| | | "description": "端口 请前往QQ或者你要发邮件的邮箱查看其smtp协议 大多为 465", |
| | | "type": "integer" |
| | | }, |
| | | "secret": { |
| | | "description": "密钥 用于登录的密钥 最好不要用邮箱密码 去邮箱smtp申请一个用于登录的密钥", |
| | | "type": "string" |
| | | }, |
| | | "to": { |
| | | "description": "收件人:多个以英文逗号分隔 例:a@qq.com b@qq.com 正式开发中请把此项目作为参数使用", |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | "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 是否开启SSL", |
| | | "type": "boolean" |
| | | }, |
| | | "nickname": { |
| | | "description": "昵称 发件人昵称 通常为自己的邮箱", |
| | | "type": "string" |
| | | }, |
| | | "port": { |
| | | "description": "端口 请前往QQ或者你要发邮件的邮箱查看其smtp协议 大多为 465", |
| | | "type": "integer" |
| | | }, |
| | | "secret": { |
| | | "description": "密钥 用于登录的密钥 最好不要用邮箱密码 去邮箱smtp申请一个用于登录的密钥", |
| | | "type": "string" |
| | | }, |
| | | "to": { |
| | | "description": "收件人:多个以英文逗号分隔 例:a@qq.com b@qq.com 正式开发中请把此项目作为参数使用", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": "用id查询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": [ |
| | |
| | | } |
| | | }, |
| | | "email": { |
| | | "$ref": "#/definitions/github_com_flipped-aurora_gin-vue-admin_server_config.Email" |
| | | "$ref": "#/definitions/srm_config.Email" |
| | | }, |
| | | "excel": { |
| | | "$ref": "#/definitions/config.Excel" |
| | |
| | | }, |
| | | "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 是否开启SSL", |
| | | "type": "boolean" |
| | | }, |
| | | "nickname": { |
| | | "description": "昵称 发件人昵称 通常为自己的邮箱", |
| | | "type": "string" |
| | | }, |
| | | "port": { |
| | | "description": "端口 请前往QQ或者你要发邮件的邮箱查看其smtp协议 大多为 465", |
| | | "type": "integer" |
| | | }, |
| | | "secret": { |
| | | "description": "密钥 用于登录的密钥 最好不要用邮箱密码 去邮箱smtp申请一个用于登录的密钥", |
| | | "type": "string" |
| | | }, |
| | | "to": { |
| | | "description": "收件人:多个以英文逗号分隔 例:a@qq.com b@qq.com 正式开发中请把此项目作为参数使用", |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | "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 是否开启SSL", |
| | | "type": "boolean" |
| | | }, |
| | | "nickname": { |
| | | "description": "昵称 发件人昵称 通常为自己的邮箱", |
| | | "type": "string" |
| | | }, |
| | | "port": { |
| | | "description": "端口 请前往QQ或者你要发邮件的邮箱查看其smtp协议 大多为 465", |
| | | "type": "integer" |
| | | }, |
| | | "secret": { |
| | | "description": "密钥 用于登录的密钥 最好不要用邮箱密码 去邮箱smtp申请一个用于登录的密钥", |
| | | "type": "string" |
| | | }, |
| | | "to": { |
| | | "description": "收件人:多个以英文逗号分隔 例:a@qq.com b@qq.com 正式开发中请把此项目作为参数使用", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": { |
| | |
| | | $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: |
| | |
| | | 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 是否开启SSL |
| | | type: boolean |
| | | nickname: |
| | | description: 昵称 发件人昵称 通常为自己的邮箱 |
| | | type: string |
| | | port: |
| | | description: 端口 请前往QQ或者你要发邮件的邮箱查看其smtp协议 大多为 465 |
| | | type: integer |
| | | secret: |
| | | description: 密钥 用于登录的密钥 最好不要用邮箱密码 去邮箱smtp申请一个用于登录的密钥 |
| | | type: string |
| | | to: |
| | | description: 收件人:多个以英文逗号分隔 例:a@qq.com b@qq.com 正式开发中请把此项目作为参数使用 |
| | | type: string |
| | | type: object |
| | | request.AddMenuAuthorityInfo: |
| | |
| | | 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 是否开启SSL |
| | | type: boolean |
| | | nickname: |
| | | description: 昵称 发件人昵称 通常为自己的邮箱 |
| | | type: string |
| | | port: |
| | | description: 端口 请前往QQ或者你要发邮件的邮箱查看其smtp协议 大多为 465 |
| | | type: integer |
| | | secret: |
| | | description: 密钥 用于登录的密钥 最好不要用邮箱密码 去邮箱smtp申请一个用于登录的密钥 |
| | | type: string |
| | | to: |
| | | description: 收件人:多个以英文逗号分隔 例:a@qq.com b@qq.com 正式开发中请把此项目作为参数使用 |
| | | type: string |
| | | type: object |
| | | system.AutoCodeStruct: |
| | | properties: |
| | |
| | | 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: |
| | |
| | | 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: 用id查询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: |
| | |
| | | testRouter.InitSupplierTypeRouter(PrivateGroup) |
| | | testRouter.InitSupplierRouter(PrivateGroup) |
| | | testRouter.InitContractRouter(PrivateGroup) |
| | | testRouter.InitProductRouter(PrivateGroup) |
| | | } |
| | | |
| | | global.GVA_LOG.Info("router register success") |
| New file |
| | |
| | | [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"} |
| New file |
| | |
| | | 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" |
| | | } |
| New file |
| | |
| | | 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 |
| | | } |
| | |
| | | IndustryRouter |
| | | SupplierRouter |
| | | ContractRouter |
| | | ProductRouter |
| | | } |
| New file |
| | |
| | | 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列表 |
| | | } |
| | | } |
| | |
| | | IndustryService |
| | | SupplierService |
| | | ContractService |
| | | ProductService |
| | | } |
| New file |
| | |
| | | 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 |
| | | } |