12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- // Copyright 2019 github.com. All rights reserved.
- // Use of this source code is governed by github.com.
- package model
- import (
- "time"
- "github.com/jinzhu/gorm"
- )
- type ProjectInfo struct {
- ID int64 `gorm:"column:ID;PRIMARY_KEY" 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 uint32 `gorm:"column:Category" json:"Category" form:"category"`
- Constructtype uint32 `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 uint32 `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"`
- Cid int64 `gorm:"column:Cid" json:"cid"`
- }
- func (ProjectInfo) TableName() string {
- return "ProjectInfo"
- }
- func (p *ProjectInfo) Find(db *gorm.DB, where map[string]interface{}) error {
- cond, val, err := whereBuild(where)
- if err != nil {
- return err
- }
- return db.Table(p.TableName()).Where(cond, val...).First(p).Error
- }
- func (p *ProjectInfo) Count(db *gorm.DB, where map[string]interface{}, or map[string]interface{}) (int64, error) {
- if len(where) > 0 || len(or) > 0 {
- cond, val, err := whereBuildAndOr(where, or)
- if err != nil {
- return 0, err
- }
- ret := int64(0)
- err = db.Table(p.TableName()).Where(cond, val...).Count(&ret).Error
- return ret, err
- }
- ret := int64(0)
- err := db.Table(p.TableName()).Count(&ret).Error
- return ret, err
- }
|