1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- // 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 ProjectInfo struct {
- ID int64 `gorm:"column:ID" json:"id" form:"id"`
- Code string `gorm:"column:Code" json:"code" form:"code"`
- Name string `gorm:"column:Name" json:"name" form:"name"`
- Safetyno string `gorm:"column:SafetyNo" json:"safetyno" form:"safetyno"`
- Prjcode string `gorm:"column:PrjCode" json:"prjcode" form:"prjcode"`
- Description string `gorm:"column:Description" json:"description" form:"description"`
- Category int64 `gorm:"column:Category" json:"category" form:"category"`
- Constructtype int64 `gorm:"column:ConstructType" json:"constructtype" form:"constructtype"`
- InvestType string `gorm:"column:InvestType" json:"investtype" form:"investtype"`
- Areacode string `gorm:"column:AreaCode" json:"areacode" form:"areacode"`
- Address string `gorm:"column:Address" json:"address" form:"address"`
- Buildingarea float64 `gorm:"column:BuildingArea" json:"buildingarea" form:"buildingarea"`
- Buildinglength float64 `gorm:"column:BuildingLength" json:"buildinglength" form:"buildinglength"`
- Invest float64 `gorm:"column:Invest" json:"invest" form:"invest"`
- Scale string `gorm:"column:Scale" json:"scale" form:"scale"`
- Startdate time.Time `gorm:"column:StartDate" json:"startdate" form:"startdate"`
- Enddate time.Time `gorm:"column:EndDate" json:"enddate" form:"enddate"`
- Lng float64 `gorm:"column:Lng" json:"lng" form:"lng"`
- Lat float64 `gorm:"column:Lat" json:"lat" form:"lat"`
- Thirdpartyprojectcode string `gorm:"column:ThirdpartyProjectCode" json:"thirdpartyprojectcode" form:"thirdpartyprojectcode"`
- Prjstatus int64 `gorm:"column:PrjStatus" json:"prjstatus" form:"prjstatus"`
- Effectpic string `gorm:"column:EffectPic" json:"effectpic" form:"effectpic"`
- Planpic string `gorm:"column:PlanPic" json:"planpic" form:"planpic"`
- Createdat time.Time `gorm:"column:CreatedAt" json:"createdat" form:"createdat"`
- Updatedat time.Time `gorm:"column:UpdatedAt" json:"updatedat" form:"updatedat"`
- }
- func (ProjectInfo) TableName() string {
- return "ProjectInfo"
- }
- func (p *ProjectInfo) List(db *gorm.DB, where map[string]interface{}) (list []ProjectInfo, 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
- }
- func (p *ProjectInfo) Find(db *gorm.DB, where map[string]interface{}, or map[string]interface{}) error {
- cond, val, err := whereBuildAndOr(where, or)
- if err != nil {
- return err
- }
- return db.Table(p.TableName()).Where(cond, val...).First(p).Error
- }
|