plan_finish.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package plan
  2. import (
  3. "fmt"
  4. "zhiyuan/pkg/db"
  5. "github.com/gin-gonic/gin"
  6. )
  7. type PlanFinish struct {
  8. ID int64 `json:"id" prop:"add:false"`
  9. AdminId int64 `json:"adminId" label:"人员ID" type:"int" prop:"add:false" search:"="`
  10. Time int64 `json:"time" label:"时间" type:"int" prop:"add" search:"="`
  11. BuildingId int64 `json:"buildingId" label:"楼盘ID" type:"int" prop:"add" search:"="`
  12. TypeId int64 `json:"typeId" label:"类型ID" type:"int" prop:"add" search:"="`
  13. Num int64 `json:"num" label:"数量" type:"int" prop:"add edit"`
  14. TypeName string `json:"type_name" prop:"add:false select:plantype.name"`
  15. BuildingName string `json:"building_name" prop:"add:false select:building.name"`
  16. DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
  17. CreatedAt int64 `json:"created_at" prop:"add:false select:false"`
  18. UpdatedAt int64 `json:"updated_at" prop:"add:false select:false"`
  19. db.BaseModel
  20. }
  21. func (PlanFinish) TableName() string {
  22. return "zy_plan_finish"
  23. }
  24. func (model PlanFinish) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
  25. if _, ok := data["starttime"]; ok {
  26. if starttime, ok := db.ToInt64(data["starttime"]); ok {
  27. s.Where = append(s.Where, fmt.Sprintf("(%s >= %s)", fmt.Sprintf("`%s`.`time`", model.TableName()), s.Param(starttime)))
  28. }
  29. }
  30. if _, ok := data["endtime"]; ok {
  31. if endtime, ok := db.ToInt64(data["endtime"]); ok {
  32. s.Where = append(s.Where, fmt.Sprintf("(%s <= %s)", fmt.Sprintf("`%s`.`time`", model.TableName()), s.Param(endtime)))
  33. }
  34. }
  35. s.Where = append(s.Where, fmt.Sprintf("(%s = %s)", fmt.Sprintf("`%s`.`adminId`", model.TableName()), s.Param(c.GetInt("adminID"))))
  36. return true
  37. }
  38. func (PlanFinish) OnePrivilege(c *gin.Context, id int64) bool {
  39. return true
  40. }
  41. func (PlanFinish) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
  42. data["adminId"] = c.GetInt("adminID")
  43. return nil
  44. }
  45. func (PlanFinish) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
  46. return nil
  47. }
  48. func (PlanFinish) DelPrivilege(c *gin.Context, id int64) error {
  49. return nil
  50. }
  51. func (PlanFinish) Page() bool {
  52. return false
  53. }
  54. func (PlanFinish) Count() bool {
  55. return true
  56. }
  57. func (model PlanFinish) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
  58. return []db.JoinModel{
  59. {
  60. Model: PlanType{},
  61. As: "plantype",
  62. On: []string{"`plantype`.`id` = " + model.TableName() + ".`typeId`"},
  63. },
  64. {
  65. Model: Building{},
  66. As: "building",
  67. On: []string{"`building`.`id` = " + model.TableName() + ".`buildingId`"},
  68. },
  69. }
  70. }