From 632bef19cd6229014644e4394d43e95c6707d773 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期一, 22 四月 2024 11:49:36 +0800 Subject: [PATCH] 机台信息增删改查接口 --- controllers/workshop_manage_controller.go | 40 ++++++++++++++++++++++++++++++++++++---- 1 files changed, 36 insertions(+), 4 deletions(-) diff --git a/controllers/workshop_manage_controller.go b/controllers/workshop_manage_controller.go index 0cc7e7e..6c34217 100644 --- a/controllers/workshop_manage_controller.go +++ b/controllers/workshop_manage_controller.go @@ -2,7 +2,7 @@ import ( "github.com/gin-gonic/gin" - "silkserver/constvar" + "gorm.io/gorm" "silkserver/controllers/request" "silkserver/controllers/response" "silkserver/extend/code" @@ -93,6 +93,37 @@ util.ResponseFormat(c, code.Success, "鍒犻櫎鎴愬姛") } +// GetCarNumber +// +// @Tags 绯荤粺璁剧疆/杞﹂棿绠$悊 +// @Summary 鑾峰彇杞﹁締缂栧彿 +// @Produce application/json +// @Param Authorization header string true "token" +// @Param object body request.GetWorkshopManageCar true "鍙傛暟" +// @Success 200 {object} util.Response{data=[]int} "鎴愬姛" +// @Router /api-jl/v1/system/getCarNumber [post] +func (slf WorkshopManageController) GetCarNumber(c *gin.Context) { + var params request.GetWorkshopManageCar + err := c.BindJSON(¶ms) + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") + return + } + all, err := models.NewWorkshopManageSearch().SetWorkshopName(params.WorkshopName).SetGroupNumber(params.GroupNumber).FindAll() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触") + return + } + carNumbers := make([]int, 0) + for _, manage := range all { + i := manage.StartCarNumber + for ; i <= manage.EndCarNumber; i++ { + carNumbers = append(carNumbers, i) + } + } + util.ResponseFormat(c, code.Success, carNumbers) +} + // GetWorkshopManageGroup // // @Tags 绯荤粺璁剧疆/杞﹂棿绠$悊 @@ -144,6 +175,10 @@ fineness, err := models.NewFinenessRegisterSearch().SetWorkshop(params.WorkshopName).SetWorkshopGroup(params.GroupNumber). SetMarket(params.MarketName).First() if err != nil { + if err == gorm.ErrRecordNotFound { + util.ResponseFormat(c, code.RequestParamError, "褰撳墠搴勫彛,杞﹂棿,缁勫埆涓�,娌℃湁绾ゅ害鐧昏淇℃伅") + return + } util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触") return } @@ -159,9 +194,6 @@ for _, manage := range all { car := make([]int, 0) i := manage.StartCarNumber - if manage.CarFlag == constvar.RightHalfCar { - i++ - } for ; i <= manage.EndCarNumber; i++ { car = append(car, i) } -- Gitblit v1.8.0