package models import ( "errors" "zhiyuan/pkg/db" "github.com/gin-gonic/gin" ) type WorkSiteQualityAcceptReport struct { ID int64 `json:"id" prop:"add:false"` SiteItemId int64 `json:"site_item_id" type:"int" prop:"add" search:"="` Pictures string `json:"pictures" label:"图片列表" type:"string" prop:"add"` Mark string `json:"mark" label:"备注" type:"string"` State int64 `json:"state" label:"状态" type:"int" prop:"add:false" default:"0"` AdminId int64 `json:"admin_id" label:"整改人" type:"int" prop:"add:false"` Explain string `json:"explain" label:"确认说明" type:"int" prop:"add:false"` CheckId int64 `json:"check_id" label:"确认人" type:"int" prop:"add:false"` DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"` CreatedAt int64 `json:"created_at" prop:"add:false"` UpdatedAt int64 `json:"updated_at" prop:"add:false"` AdminName string `json:"admin_name" prop:"select:admin.username"` AdminPhone string `json:"admin_phone" prop:"select:admin.phone"` AdminHeadImgUrl string `json:"admin_headimgurl" prop:"select:admin.headimgurl"` CheckName string `json:"check_name" prop:"select:check.username"` CheckPhone string `json:"check_phone" prop:"select:check.phone"` CheckHeadImgUrl string `json:"check_headimgurl" prop:"select:check.headimgurl"` db.BaseModel } func (WorkSiteQualityAcceptReport) TableName() string { return "zy_work_site_quality_accept_report" } func (WorkSiteQualityAcceptReport) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool { return true } func (WorkSiteQualityAcceptReport) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error { var item WorkSiteQualityAcceptItem db.GetModel(map[string]interface{}{ "id": data["site_item_id"].(int64), }, &item) if item.ID == 0 || item.State != 0 { return errors.New("没有权限") } db.UpdateModel(db.Type(item), item.ID, map[string]interface{}{ "state": 2, }) data["admin_id"] = c.GetInt("adminID") return nil } func (WorkSiteQualityAcceptReport) OrderBy() string { return "updated_at" } func (WorkSiteQualityAcceptReport) Page() bool { return false } func (WorkSiteQualityAcceptReport) Count() bool { return true } func (model WorkSiteQualityAcceptReport) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel { return []db.JoinModel{ { Model: Admin{}, As: "admin", On: []string{"`admin`.`id` = " + model.TableName() + ".`admin_id`"}, }, { Model: Admin{}, As: "check", On: []string{"`check`.`id` = " + model.TableName() + ".`check_id`"}, }, } }