// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package model import ( "github.com/jinzhu/gorm" "time" ) type TProject struct { ID int64 `gorm:"column:id" json:"id" form:"id"` Cid int64 `gorm:"column:cid" json:"cid" form:"cid"` SafetyRecordNo string `gorm:"column:safety_record_no" json:"safety_record_no" form:"safety_record_no"` ProjectNo string `gorm:"column:project_no" json:"project_no" form:"project_no"` Name string `gorm:"column:name" json:"name" form:"name"` ShortName string `gorm:"column:short_name" json:"short_name" form:"short_name"` ProjectFunction string `gorm:"column:project_function" json:"project_function" form:"project_function"` ProjectType string `gorm:"column:project_type" json:"project_type" form:"project_type"` Price float64 `gorm:"column:price" json:"price" form:"price"` Desc string `gorm:"column:desc" json:"desc" form:"desc"` ProjectLeader string `gorm:"column:project_leader" json:"project_leader" form:"project_leader"` CoveredArea float64 `gorm:"column:covered_area" json:"covered_area" form:"covered_area"` Phone string `gorm:"column:phone" json:"phone" form:"phone"` TotalLevel int64 `gorm:"column:total_level" json:"total_level" form:"total_level"` BuildingStorey string `gorm:"column:building_storey" json:"building_storey" form:"building_storey"` Construction string `gorm:"column:construction" json:"construction" form:"construction"` Development string `gorm:"column:development" json:"development" form:"development"` Oversee string `gorm:"column:oversee" json:"oversee" form:"oversee"` Design string `gorm:"column:design" json:"design" form:"design"` Exploration string `gorm:"column:exploration" json:"exploration" form:"exploration"` Location string `gorm:"column:location" json:"location" form:"location"` Lon float64 `gorm:"column:lon" json:"lon" form:"lon"` Lat float64 `gorm:"column:lat" json:"lat" form:"lat"` IsFinish int64 `gorm:"column:is_finish" json:"is_finish" form:"is_finish"` CreatedAt time.Time `gorm:"column:created_at" json:"created_at" form:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at" form:"updated_at"` Status int64 `gorm:"column:status" json:"status" form:"status"` } func (TProject) TableName() string { return "t_project" } func (p *TProject) List(db *gorm.DB, where map[string]interface{}) (list []TProject, err error) { if len(where) > 0 { cond, val, err := whereBuild(where) if err != nil { return list, err } result := db.Table(p.TableName()).Where(cond, val...).Find(&list) return list, result.Error } result := db.Table(p.TableName()).Find(&list) return list, result.Error }