worksitequalityacceptreport.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package work
  2. import (
  3. "zhiyuan/models"
  4. "zhiyuan/pkg/app"
  5. "zhiyuan/pkg/db"
  6. "zhiyuan/pkg/utils"
  7. "zhiyuan/services/form"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func WorkSiteQualityAcceptReportCheck(c *gin.Context) {
  11. id := utils.ToInt(c.Param("id"))
  12. if id <= 0 {
  13. app.ErrorMsg(c, "id must be a number", nil)
  14. return
  15. }
  16. var checkForm form.WorkSiteQualityAcceptReportCheckFrom
  17. if app.Bind(c, &checkForm) != nil {
  18. return
  19. }
  20. var model models.WorkSiteQualityAcceptReport
  21. db.GetModel(map[string]interface{}{
  22. "id": id,
  23. }, &model)
  24. if model.ID == 0 {
  25. app.ErrorMsg(c, "整改不存在", nil)
  26. return
  27. }
  28. err := db.UpdateModel(db.Type(model), int64(id), map[string]interface{}{
  29. "state": checkForm.State,
  30. "explain": checkForm.Explain,
  31. "check_id": c.GetInt("adminID"),
  32. })
  33. if err != nil {
  34. app.ErrorMsg(c, err.Error(), nil)
  35. return
  36. }
  37. err = db.UpdateModel(db.Type(models.WorkSiteQualityAcceptItem{}), int64(model.SiteItemId), map[string]interface{}{
  38. "state": checkForm.State - 1,
  39. })
  40. if err != nil {
  41. app.ErrorMsg(c, err.Error(), nil)
  42. return
  43. }
  44. app.Success(c, nil)
  45. }