package test_data import ( "github.com/gin-gonic/gin" "gorm.io/gorm" "testData/model" "testData/model/response" test_data "testData/repository/test.data" "testData/utils" ) type IWarningInterface struct { } type SWarningService struct { DB *gorm.DB } func InitWarningService() *SWarningService { return &SWarningService{} } // @Tags 数据分析平台 // @Summary 调整报警设置信息 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body model.Warning{} true "调整报警设置信息" // @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}" // @Router /testData/warning [post] func (S *SWarningService) Update(c *gin.Context) { r := model.Warning{} _ = c.ShouldBind(&r) if msg, ok := utils.ValidateInfo2CN(r); !ok { response.FailWithMessage(msg, c) return } if err := test_data.UpdateWarning(&r); err != nil { response.FailWithMessage(err.Error(), c) return } else { response.Ok(c) } } // @Tags 数据分析平台 // @Summary 分页查询报警设置信息 // @Security ApiKeyAuth // @accept application/json // @Param page query int true "页数" // @Param pageSize query int true "每页显示数量" // @Param key_word query string false "关键词" // @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}" // @Router /testData/warning [get] func (S *SWarningService) ShowList(c *gin.Context) { offset, limit, err := utils.PaginationLimitAndPage(c) if err != nil { response.FailWithMessage(err.Error(), c) return } keyWord := c.Query("key_word") warning, total, err := test_data.ShowListWarning(offset, limit, keyWord) if err != nil { response.FailWithMessage(err.Error(), c) return } response.OkWithData(gin.H{"warning": warning, "total": total}, c) } // @Tags 数据分析平台 // @Summary 查询报警设置产品参考信息 // @Security ApiKeyAuth // @accept application/json // @Param product query string false "产品型号" // @Param step query string false "工序" // @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}" // @Router /testData/warning/selection [get] func (S *SWarningService) WarningSelection(c *gin.Context) { product := c.Query("product") step := c.Query("step") response.OkWithData(test_data.GetWarningSelection(product, step), c) } // @Tags 数据分析平台 // @Summary 删除报警设置信息 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body model.Warning{} true "删除报警设置信息" // @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}" // @Router /testData/warning [delete] func (S *SWarningService) Delete(c *gin.Context) { r := model.Warning{} _ = c.ShouldBind(&r) if msg, ok := utils.ValidateInfo2CN(r); !ok { response.FailWithMessage(msg, c) return } response.OkWithData(test_data.DeleteWarning(&r), c) }