From 0c6d425b830358f4e339430ca88e2424a226e74a Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 13 九月 2023 17:09:10 +0800
Subject: [PATCH] 适应性改动
---
api/v1/plc.go | 5 +
router/index.go | 10 +-
docs/swagger.yaml | 25 +++++++-
docs/docs.go | 37 ++++++++++-
model/request/task.go | 10 +++
api/v1/task.go | 15 +---
docs/swagger.json | 37 ++++++++++-
7 files changed, 109 insertions(+), 30 deletions(-)
diff --git a/api/v1/plc.go b/api/v1/plc.go
index cba0bbd..907e8d8 100644
--- a/api/v1/plc.go
+++ b/api/v1/plc.go
@@ -2,6 +2,7 @@
import (
"apsClient/constvar"
+ "apsClient/model/request"
"apsClient/model/response"
_ "apsClient/model/response"
"apsClient/pkg/contextx"
@@ -16,10 +17,12 @@
// @Tags 鐢熶骇鏁伴噺
// @Summary 鑾峰彇鐢熶骇杩涘害
// @Produce application/json
+// @Param object body request.SendProcessParams true "鏌ヨ鍙傛暟"
// @Success 200 {object} contextx.Response{data=response.ProductProgress} "鎴愬姛"
// @Router /v1/plc/productProgress [get]
func (slf *PlcApi) GetProductProgress(c *gin.Context) {
- ctx, ok := contextx.NewContext(c, nil)
+ var params request.SendProcessParams
+ ctx, ok := contextx.NewContext(c, ¶ms)
if !ok {
return
}
diff --git a/api/v1/task.go b/api/v1/task.go
index ae11df0..4f3b574 100644
--- a/api/v1/task.go
+++ b/api/v1/task.go
@@ -178,22 +178,17 @@
// @Tags Task
// @Summary 涓嬪彂宸ヨ壓鍙傛暟锛堝紑濮嬩换鍔★級
// @Produce application/json
-// @Param id path int true "宸ュ簭id"
+// @Param object body request.SendProcessParams true "鏌ヨ鍙傛暟"
// @Success 200 {object} contextx.Response{service.GetProcessModel} "鎴愬姛"
// @Router /v1/task/sendProcessParams/{id} [post]
func (slf *TaskApi) TaskStart(c *gin.Context) {
- ctx, ok := contextx.NewContext(c, nil)
+ var params request.SendProcessParams
+ ctx, ok := contextx.NewContext(c, ¶ms)
if !ok {
return
}
- idx := c.Param("id")
- if idx == "" {
- ctx.Fail(ecode.ParamsErr)
- return
- }
- id := convertx.Atoi(idx)
taskService := service.NewTaskService()
- procedure, code := taskService.GetProcedureById(id)
+ procedure, code := taskService.GetProcedureById(params.ProcedureId)
if code != ecode.OK {
ctx.Fail(code)
return
@@ -216,7 +211,7 @@
}
err = model.WithTransaction(func(db *gorm.DB) error {
- err = taskService.UpdateProcedureStatus(db, id, model.ProcedureStatusProcessing)
+ err = taskService.UpdateProcedureStatus(db, params.ProcedureId, model.ProcedureStatusProcessing)
if err != nil {
return err
}
diff --git a/docs/docs.go b/docs/docs.go
index d76cf46..6c17dbd 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -161,6 +161,17 @@
"鐢熶骇鏁伴噺"
],
"summary": "鑾峰彇鐢熶骇杩涘害",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.SendProcessParams"
+ }
+ }
+ ],
"responses": {
"200": {
"description": "鎴愬姛",
@@ -439,11 +450,13 @@
"summary": "涓嬪彂宸ヨ壓鍙傛暟锛堝紑濮嬩换鍔★級",
"parameters": [
{
- "type": "integer",
- "description": "宸ュ簭id",
- "name": "id",
- "in": "path",
- "required": true
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.SendProcessParams"
+ }
}
],
"responses": {
@@ -882,6 +895,20 @@
}
}
},
+ "request.SendProcessParams": {
+ "type": "object",
+ "required": [
+ "procedureId"
+ ],
+ "properties": {
+ "position": {
+ "type": "integer"
+ },
+ "procedureId": {
+ "type": "integer"
+ }
+ }
+ },
"request.UpdatePlc": {
"type": "object",
"properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 2fb263f..381b6f7 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -149,6 +149,17 @@
"鐢熶骇鏁伴噺"
],
"summary": "鑾峰彇鐢熶骇杩涘害",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.SendProcessParams"
+ }
+ }
+ ],
"responses": {
"200": {
"description": "鎴愬姛",
@@ -427,11 +438,13 @@
"summary": "涓嬪彂宸ヨ壓鍙傛暟锛堝紑濮嬩换鍔★級",
"parameters": [
{
- "type": "integer",
- "description": "宸ュ簭id",
- "name": "id",
- "in": "path",
- "required": true
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.SendProcessParams"
+ }
}
],
"responses": {
@@ -870,6 +883,20 @@
}
}
},
+ "request.SendProcessParams": {
+ "type": "object",
+ "required": [
+ "procedureId"
+ ],
+ "properties": {
+ "position": {
+ "type": "integer"
+ },
+ "procedureId": {
+ "type": "integer"
+ }
+ }
+ },
"request.UpdatePlc": {
"type": "object",
"properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 2fe29b4..ea79766 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -260,6 +260,15 @@
name:
type: string
type: object
+ request.SendProcessParams:
+ properties:
+ position:
+ type: integer
+ procedureId:
+ type: integer
+ required:
+ - procedureId
+ type: object
request.UpdatePlc:
properties:
address:
@@ -437,6 +446,13 @@
- Config
/v1/plc/productProgress:
get:
+ parameters:
+ - description: 鏌ヨ鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.SendProcessParams'
produces:
- application/json
responses:
@@ -603,11 +619,12 @@
/v1/task/sendProcessParams/{id}:
post:
parameters:
- - description: 宸ュ簭id
- in: path
- name: id
+ - description: 鏌ヨ鍙傛暟
+ in: body
+ name: object
required: true
- type: integer
+ schema:
+ $ref: '#/definitions/request.SendProcessParams'
produces:
- application/json
responses:
diff --git a/model/request/task.go b/model/request/task.go
index 70478a2..37f4a66 100644
--- a/model/request/task.go
+++ b/model/request/task.go
@@ -13,3 +13,13 @@
type TaskList struct {
PageInfo
}
+
+type SendProcessParams struct {
+ ProcedureId int `json:"procedureId" binding:"required"`
+ Position int `json:"position"`
+}
+
+type GetProductProgress struct {
+ ProcedureId int `json:"procedureId" binding:"required"`
+ Position int `json:"position"`
+}
diff --git a/router/index.go b/router/index.go
index 0ee36bb..2368213 100644
--- a/router/index.go
+++ b/router/index.go
@@ -35,11 +35,11 @@
taskApi := new(v1.TaskApi)
taskGroup := v1Group.Group("task")
{
- taskGroup.GET("countdown", taskApi.TaskCountdown) // 鏂颁换鍔″�掕鏃�
- taskGroup.GET("get", taskApi.TaskGet) // 鑾峰彇宸ュ簭
- taskGroup.GET("start/:id", taskApi.GetProcessParams) // 鑾峰彇宸ヨ壓鍙傛暟
- taskGroup.POST("sendProcessParams/:id", taskApi.TaskStart) // 涓嬪彂宸ヨ壓鍙傛暟骞跺紑濮嬪伐搴�
- taskGroup.PUT("finish/:id", taskApi.TaskFinish) // 瀹屾垚宸ュ簭
+ taskGroup.GET("countdown", taskApi.TaskCountdown) // 鏂颁换鍔″�掕鏃�
+ taskGroup.GET("get", taskApi.TaskGet) // 鑾峰彇宸ュ簭
+ taskGroup.GET("start/:id", taskApi.GetProcessParams) // 鑾峰彇宸ヨ壓鍙傛暟
+ taskGroup.POST("sendProcessParams", taskApi.TaskStart) // 涓嬪彂宸ヨ壓鍙傛暟骞跺紑濮嬪伐搴�
+ taskGroup.PUT("finish/:id", taskApi.TaskFinish) // 瀹屾垚宸ュ簭
}
configApi := new(v1.ConfigApi)
--
Gitblit v1.8.0