final_select_material_item.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package final
  2. import (
  3. "errors"
  4. "fmt"
  5. _ "image/gif"
  6. _ "image/jpeg"
  7. _ "image/png"
  8. "zhiyuan/pkg/db"
  9. "github.com/gin-gonic/gin"
  10. )
  11. type FinalSelectMaterialItem struct {
  12. ID int64 `json:"id" prop:"add:false"`
  13. SelectId int64 `json:"select_id" label:"订单号" type:"int" prop:"add:false" search:"="`
  14. ItemId int64 `json:"item_id" label:"项目类型ID" type:"int"`
  15. MatId int64 `json:"mat_id" label:"材料ID" type:"int" prop:"add"`
  16. Num float64 `json:"num" label:"数量" type:"float" prop:"edit"`
  17. Remark string `json:"remark" label:"备注" type:"string" prop:"edit"`
  18. DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
  19. CreatedAt int64 `json:"created_at" prop:"add:false"`
  20. UpdatedAt int64 `json:"updated_at" prop:"add:false"`
  21. db.BaseModel
  22. }
  23. func (FinalSelectMaterialItem) TableName() string {
  24. return "zy_final_select_material_item"
  25. }
  26. func (model FinalSelectMaterialItem) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
  27. return true
  28. }
  29. func (FinalSelectMaterialItem) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
  30. return errors.New("没有权限")
  31. }
  32. func (FinalSelectMaterialItem) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
  33. return nil
  34. }
  35. func (FinalSelectMaterialItem) DelPrivilege(c *gin.Context, id int64) error {
  36. return errors.New("没有权限")
  37. }
  38. func (FinalSelectMaterialItem) Page() bool {
  39. return false
  40. }
  41. func (FinalSelectMaterialItem) Count() bool {
  42. return false
  43. }
  44. type FinalSelectMaterialItemMobile struct {
  45. Typename string `json:"type_name" label:"类型名称" prop:"select:finalmattype.name" search:"like"`
  46. Unit string `json:"unit" label:"单位" prop:"select:finalmattype.unit" search:"like"`
  47. MatName string `json:"mat_name" type:"string" prop:"select:concat(finalmat.brand,'\\t',finalmat.series,'\\t',finalmat.model,'\\t',finalmat.specs,'\\t',finalmat.color)"`
  48. MatPrice float64 `json:"mat_price" type:"float" prop:"select:finalmat.price"`
  49. ItemName string `json:"item_name" label:"项目名称" prop:"select:finalmatitem.name"`
  50. Type int64 `json:"type" label:"类型" type:"int" prop:"select:finalmattype.type" search:"="`
  51. IsCustom int64 `json:"is_custom" label:"是否定制" prop:"select:finalmattype.is_custom" search:"="`
  52. PType string `json:"ptype" prop:"select:finalmatitem.ptype"`
  53. TypeId int64 `json:"type_id" label:"类型" type:"int" prop:"select:finalmat.type_id"`
  54. SupplierId int64 `json:"supplier_id" label:"材料商ID" prop:"select:finalmat.supplier_id"`
  55. SupplierName string `json:"supplier_name" type:"string" prop:"select:supplier.name"`
  56. SupplierAdminId string `json:"supplier_admin_id" type:"string" prop:"select:supplier.adminId"`
  57. FinalSelectMaterialItem
  58. }
  59. func (model FinalSelectMaterialItemMobile) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
  60. return model.FinalSelectMaterialItem.EditPrivilege(c, id, data, post)
  61. }
  62. func (model FinalSelectMaterialItemMobile) GroupBy() string {
  63. return fmt.Sprintf("`%s`.`id`", model.TableName())
  64. }
  65. func (model FinalSelectMaterialItemMobile) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
  66. return append(model.FinalSelectMaterialItem.LeftJoin(data, s), db.JoinModel{
  67. Model: FinalMat{},
  68. As: "finalmat",
  69. On: []string{"`finalmat`.`id` = " + model.TableName() + ".`mat_id` AND `finalmat`.`deleted_at` = 0"},
  70. }, db.JoinModel{
  71. Model: FinalMatType{},
  72. As: "finalmattype",
  73. On: []string{"`finalmattype`.`id` = `finalmat`.`type_id` AND `finalmattype`.`deleted_at` = 0"},
  74. }, db.JoinModel{
  75. Model: FinalMatItem{},
  76. As: "finalmatitem",
  77. On: []string{"`finalmatitem`.`id` = " + model.TableName() + ".`item_id`"},
  78. }, db.JoinModel{
  79. Model: FinalSupplier{},
  80. As: "supplier",
  81. On: []string{"`supplier`.`id` = `finalmat`.`supplier_id`"},
  82. })
  83. }