final_mat_auxiliary.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package final
  2. import (
  3. "fmt"
  4. "zhiyuan/pkg/db"
  5. "github.com/gin-gonic/gin"
  6. )
  7. type FinalMatAuxiliary struct {
  8. ID int64 `json:"id" prop:"add:false"`
  9. Name string `json:"name" label:"名称" type:"string" prop:"add edit" search:"like"`
  10. Type int64 `json:"type" label:"类型" type:"int" prop:"add edit" search:"="`
  11. Preset int64 `json:"preset" label:"是否预置" type:"int" prop:"add edit" search:"="`
  12. MatTypeIds string `json:"mattype_ids" label:"选材类型" type:"string" prop:"add edit"`
  13. Settlement int64 `json:"settlement" type:"int" prop:"edit" default:"0" search:"="`
  14. CalcValue string `json:"calc_value" type:"string" prop:"edit" default:"" search:"="`
  15. OrderAt int64 `json:"order_at" prop:"add:false select:false"`
  16. DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
  17. CreatedAt int64 `json:"created_at" prop:"add:false"`
  18. UpdatedAt int64 `json:"updated_at" prop:"add:false"`
  19. db.BaseModel
  20. }
  21. func (FinalMatAuxiliary) TableName() string {
  22. return "zy_final_mat_auxiliary"
  23. }
  24. func (model FinalMatAuxiliary) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
  25. return true
  26. }
  27. func (model FinalMatAuxiliary) ListAfter(c *gin.Context, data map[string]interface{}, list []map[string]interface{}) []map[string]interface{} {
  28. ids := make([]int64, 0)
  29. idmap := make(map[int64]int)
  30. for i, v := range list {
  31. id, _ := db.ToInt64(v["id"])
  32. ids = append(ids, id)
  33. idmap[id] = i
  34. }
  35. datas, _ := db.GetModelMap(db.Type(FinalMatItem{}), map[string]interface{}{
  36. fmt.Sprintf("`%s`.`type_id` in", FinalMatItem{}.TableName()): ids,
  37. fmt.Sprintf("`%s`.`deleted_at`", FinalMatItem{}.TableName()): 0,
  38. }, nil)
  39. for _, v := range datas {
  40. id, _ := db.ToInt64(v["type_id"])
  41. if n, ok := idmap[id]; ok {
  42. items := make([]map[string]interface{}, 0)
  43. if is, ok := list[n]["items"].([]map[string]interface{}); ok {
  44. items = is
  45. }
  46. items = append(items, v)
  47. list[n]["items"] = items
  48. }
  49. }
  50. return list
  51. }
  52. func (FinalMatAuxiliary) OnePrivilege(c *gin.Context, id int64) bool {
  53. return true
  54. }
  55. func (FinalMatAuxiliary) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
  56. return nil
  57. }
  58. func (FinalMatAuxiliary) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
  59. return nil
  60. }
  61. func (FinalMatAuxiliary) DelPrivilege(c *gin.Context, id int64) error {
  62. return nil
  63. }
  64. func (FinalMatAuxiliary) OrderField() string {
  65. return "order_at"
  66. }
  67. func (FinalMatAuxiliary) Page() bool {
  68. return false
  69. }
  70. func (FinalMatAuxiliary) Count() bool {
  71. return true
  72. }
  73. func (model FinalMatAuxiliary) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
  74. return []db.JoinModel{}
  75. }