project.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package model
  4. import (
  5. "github.com/jinzhu/gorm"
  6. "time"
  7. )
  8. type TProject struct {
  9. ID int64 `gorm:"column:id" json:"id" form:"id"`
  10. Cid int64 `gorm:"column:cid" json:"cid" form:"cid"`
  11. SafetyRecordNo string `gorm:"column:safety_record_no" json:"safety_record_no" form:"safety_record_no"`
  12. ProjectNo string `gorm:"column:project_no" json:"project_no" form:"project_no"`
  13. Name string `gorm:"column:name" json:"name" form:"name"`
  14. ShortName string `gorm:"column:short_name" json:"short_name" form:"short_name"`
  15. ProjectFunction string `gorm:"column:project_function" json:"project_function" form:"project_function"`
  16. ProjectType string `gorm:"column:project_type" json:"project_type" form:"project_type"`
  17. Price float64 `gorm:"column:price" json:"price" form:"price"`
  18. Desc string `gorm:"column:desc" json:"desc" form:"desc"`
  19. ProjectLeader string `gorm:"column:project_leader" json:"project_leader" form:"project_leader"`
  20. CoveredArea float64 `gorm:"column:covered_area" json:"covered_area" form:"covered_area"`
  21. Phone string `gorm:"column:phone" json:"phone" form:"phone"`
  22. TotalLevel int64 `gorm:"column:total_level" json:"total_level" form:"total_level"`
  23. BuildingStorey string `gorm:"column:building_storey" json:"building_storey" form:"building_storey"`
  24. Construction string `gorm:"column:construction" json:"construction" form:"construction"`
  25. Development string `gorm:"column:development" json:"development" form:"development"`
  26. Oversee string `gorm:"column:oversee" json:"oversee" form:"oversee"`
  27. Design string `gorm:"column:design" json:"design" form:"design"`
  28. Exploration string `gorm:"column:exploration" json:"exploration" form:"exploration"`
  29. Location string `gorm:"column:location" json:"location" form:"location"`
  30. Lon float64 `gorm:"column:lon" json:"lon" form:"lon"`
  31. Lat float64 `gorm:"column:lat" json:"lat" form:"lat"`
  32. IsFinish int64 `gorm:"column:is_finish" json:"is_finish" form:"is_finish"`
  33. CreatedAt time.Time `gorm:"column:created_at" json:"created_at" form:"created_at"`
  34. UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at" form:"updated_at"`
  35. Status int64 `gorm:"column:status" json:"status" form:"status"`
  36. }
  37. func (TProject) TableName() string {
  38. return "t_project"
  39. }
  40. func (p *TProject) List(db *gorm.DB, where map[string]interface{}) (list []TProject, err error) {
  41. if len(where) > 0 {
  42. cond, val, err := whereBuild(where)
  43. if err != nil {
  44. return list, err
  45. }
  46. result := db.Table(p.TableName()).Where(cond, val...).Find(&list)
  47. return list, result.Error
  48. }
  49. result := db.Table(p.TableName()).Find(&list)
  50. return list, result.Error
  51. }