package models import ( "zhiyuan/pkg/db" "github.com/gin-gonic/gin" ) type WorkQualityAccept struct { ID int64 `json:"id" prop:"add:false"` Name string `json:"name" label:"质检名称" type:"string" prop:"add edit" search:"like"` State int64 `json:"state" label:"状态" type:"int" prop:"edit" default:"0"` OrderAt int64 `json:"order_at" prop:"add:false select:false"` DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"` CreatedAt int64 `json:"created_at" prop:"add:false select:false"` UpdatedAt int64 `json:"updated_at" prop:"add:false select:false"` Items []WorkQualityAcceptItem `json:"items" prop:"ignore"` db.BaseModel } func (WorkQualityAccept) TableName() string { return "zy_work_quality_accept" } func (WorkQualityAccept) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool { return true } func (WorkQualityAccept) OnePrivilege(c *gin.Context, id int64) bool { return true } func (WorkQualityAccept) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error { return nil } func (WorkQualityAccept) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error { return nil } func (WorkQualityAccept) DelPrivilege(c *gin.Context, id int64) error { return nil } func (WorkQualityAccept) OrderField() string { return "order_at" } func (WorkQualityAccept) Page() bool { return false } func (WorkQualityAccept) Count() bool { return true } func GetWorkQualityAcceptModel(id int64, showAll bool) *WorkQualityAccept { var accept *WorkQualityAccept db.GetModel(map[string]interface{}{"id": id}, &accept) if accept != nil { var items []WorkQualityAcceptItem where := map[string]interface{}{"quality_accept_id": id, "deleted_at": 0} if !showAll { where["state"] = 1 } db.GetModel(where, &items) accept.Items = items } return accept } // 获取模板节点名称 func GetAllWorkQualityAcceptModel(showAll bool) []*WorkQualityAccept { var accepts []*WorkQualityAccept db.GetModel(map[string]interface{}{"state": 1}, &accepts) if len(accepts) > 0 { for _, accept := range accepts { var items []WorkQualityAcceptItem where := map[string]interface{}{"quality_accept_id": accept.ID, "deleted_at": 0} db.GetModel(where, &items) accept.Items = items } } return accepts }