handle.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package budget
  2. import (
  3. "zhiyuan/pkg/db"
  4. "github.com/gin-gonic/gin"
  5. )
  6. type Handle struct {
  7. ID int64 `json:"id" prop:"add:false"`
  8. QuoteId int64 `json:"quoteId" type:"int" prop:"add" search:"="`
  9. TableId int64 `json:"tableId" type:"int" prop:"add" search:"="`
  10. ModuleId int64 `json:"moduleId" type:"int" prop:"add" search:"="`
  11. RowId int64 `json:"rowId" type:"int" prop:"add" search:"="`
  12. Name string `json:"name" label:"名称" type:"string" prop:"add edit" search:"like"`
  13. Value string `json:"value" label:"属性值" type:"string" prop:"edit"`
  14. OrderAt int64 `json:"order_at" prop:"add:false select:false"`
  15. DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
  16. CreatedAt int64 `json:"created_at" prop:"add:false select:false"`
  17. UpdatedAt int64 `json:"updated_at" prop:"add:false select:false"`
  18. db.BaseModel
  19. }
  20. func (Handle) TableName() string {
  21. return "zy_budget_handle"
  22. }
  23. func (Handle) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
  24. return true
  25. }
  26. func (Handle) OnePrivilege(c *gin.Context, id int64) bool {
  27. return true
  28. }
  29. func (Handle) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
  30. return nil
  31. }
  32. func (Handle) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
  33. return nil
  34. }
  35. func (Handle) DelPrivilege(c *gin.Context, id int64) error {
  36. return nil
  37. }
  38. func (Handle) OrderField() string {
  39. return "order_at"
  40. }
  41. func (Handle) Page() bool {
  42. return false
  43. }
  44. func (Handle) Count() bool {
  45. return false
  46. }
  47. func findModuleHandles(tableId int64, list []Handle) map[int64][]Handle {
  48. handles := make(map[int64][]Handle, 0)
  49. for _, v := range list {
  50. if v.TableId == tableId && v.RowId == 0 {
  51. if _, ok := handles[v.ModuleId]; !ok {
  52. handles[v.ModuleId] = make([]Handle, 0)
  53. }
  54. handles[v.ModuleId] = append(handles[v.ModuleId], v)
  55. }
  56. }
  57. return handles
  58. }
  59. func findHandles(tableId int64, rowId int64, list []Handle) []Handle {
  60. handles := make([]Handle, 0)
  61. for _, v := range list {
  62. if v.TableId == tableId && v.RowId == rowId {
  63. handles = append(handles, v)
  64. }
  65. }
  66. return handles
  67. }