work_quality_accept.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package models
  2. import (
  3. "zhiyuan/pkg/db"
  4. "github.com/gin-gonic/gin"
  5. )
  6. type WorkQualityAccept struct {
  7. ID int64 `json:"id" prop:"add:false"`
  8. Name string `json:"name" label:"质检名称" type:"string" prop:"add edit" search:"like"`
  9. State int64 `json:"state" label:"状态" type:"int" prop:"edit" default:"0"`
  10. OrderAt int64 `json:"order_at" prop:"add:false select:false"`
  11. DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
  12. CreatedAt int64 `json:"created_at" prop:"add:false select:false"`
  13. UpdatedAt int64 `json:"updated_at" prop:"add:false select:false"`
  14. Items []WorkQualityAcceptItem `json:"items" prop:"ignore"`
  15. db.BaseModel
  16. }
  17. func (WorkQualityAccept) TableName() string {
  18. return "zy_work_quality_accept"
  19. }
  20. func (WorkQualityAccept) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
  21. return true
  22. }
  23. func (WorkQualityAccept) OnePrivilege(c *gin.Context, id int64) bool {
  24. return true
  25. }
  26. func (WorkQualityAccept) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
  27. return nil
  28. }
  29. func (WorkQualityAccept) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
  30. return nil
  31. }
  32. func (WorkQualityAccept) DelPrivilege(c *gin.Context, id int64) error {
  33. return nil
  34. }
  35. func (WorkQualityAccept) OrderField() string {
  36. return "order_at"
  37. }
  38. func (WorkQualityAccept) Page() bool {
  39. return false
  40. }
  41. func (WorkQualityAccept) Count() bool {
  42. return true
  43. }
  44. func GetWorkQualityAcceptModel(id int64, showAll bool) *WorkQualityAccept {
  45. var accept *WorkQualityAccept
  46. db.GetModel(map[string]interface{}{"id": id}, &accept)
  47. if accept != nil {
  48. var items []WorkQualityAcceptItem
  49. where := map[string]interface{}{"quality_accept_id": id, "deleted_at": 0}
  50. if !showAll {
  51. where["state"] = 1
  52. }
  53. db.GetModel(where, &items)
  54. accept.Items = items
  55. }
  56. return accept
  57. }
  58. // 获取模板节点名称
  59. func GetAllWorkQualityAcceptModel(showAll bool) []*WorkQualityAccept {
  60. var accepts []*WorkQualityAccept
  61. db.GetModel(map[string]interface{}{"state": 1}, &accepts)
  62. if len(accepts) > 0 {
  63. for _, accept := range accepts {
  64. var items []WorkQualityAcceptItem
  65. where := map[string]interface{}{"quality_accept_id": accept.ID, "deleted_at": 0}
  66. db.GetModel(where, &items)
  67. accept.Items = items
  68. }
  69. }
  70. return accepts
  71. }