1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package work
- import (
- "zhiyuan/models"
- "zhiyuan/pkg/app"
- "zhiyuan/pkg/db"
- "zhiyuan/pkg/utils"
- "zhiyuan/services/form"
- "github.com/gin-gonic/gin"
- )
- func WorkSiteQualityAcceptReportCheck(c *gin.Context) {
- id := utils.ToInt(c.Param("id"))
- if id <= 0 {
- app.ErrorMsg(c, "id must be a number", nil)
- return
- }
- var checkForm form.WorkSiteQualityAcceptReportCheckFrom
- if app.Bind(c, &checkForm) != nil {
- return
- }
- var model models.WorkSiteQualityAcceptReport
- db.GetModel(map[string]interface{}{
- "id": id,
- }, &model)
- if model.ID == 0 {
- app.ErrorMsg(c, "整改不存在", nil)
- return
- }
- err := db.UpdateModel(db.Type(model), int64(id), map[string]interface{}{
- "state": checkForm.State,
- "explain": checkForm.Explain,
- "check_id": c.GetInt("adminID"),
- })
- if err != nil {
- app.ErrorMsg(c, err.Error(), nil)
- return
- }
- err = db.UpdateModel(db.Type(models.WorkSiteQualityAcceptItem{}), int64(model.SiteItemId), map[string]interface{}{
- "state": checkForm.State - 1,
- })
- if err != nil {
- app.ErrorMsg(c, err.Error(), nil)
- return
- }
- app.Success(c, nil)
- }
|