12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package work
- import (
- "zhiyuan/models"
- "zhiyuan/pkg/app"
- "zhiyuan/pkg/db"
- "zhiyuan/pkg/utils"
- "zhiyuan/services/form"
- "github.com/gin-gonic/gin"
- )
- func WorkSiteProblemReportCheck(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.WorkSiteProblemReport
- 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
- }
- state := 0
- if model.Type == 0 {
- if checkForm.State == 2 {
- state = 2
- } else {
- state = 0
- }
- } else if model.Type == 1 {
- if checkForm.State == 2 {
- state = 4
- } else {
- state = 2
- }
- } else {
- if checkForm.State == 2 {
- state = 6
- } else {
- state = 4
- }
- }
- if checkForm.State == 3 {
- state = 6
- }
- err = db.UpdateModel(db.Type(models.WorkSiteProblem{}), int64(model.SiteProblemId), map[string]interface{}{
- "state": state,
- })
- if err != nil {
- app.ErrorMsg(c, err.Error(), nil)
- return
- }
- app.Success(c, nil)
- }
|