123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package model
- import "github.com/jinzhu/gorm"
- type ProjectPMInfo struct {
- ID int64 `gorm:"column:ID;primary_key"`
- Code string `gorm:"column:Code"`
- CorpType uint32 `gorm:"column:CorpType"`
- CorpCode string `gorm:"column:CorpCode"`
- PType uint32 `gorm:"column:PType"`
- PMName string `gorm:"column:PMName"`
- PMIDCardType uint32 `gorm:"column:PMIDCardType"`
- PMIDCardNumber string `gorm:"column:PMIDCardNumber"`
- PMPhone string `gorm:"column:PMPhone"`
- ProjectId int64 `gorm:"column:ProjectId"`
- CorpName string `gorm:"column:CorpName"`
- }
- func (ProjectPMInfo) TableName() string {
- return "db_smart_attendance.ProjectPMInfo"
- }
- func (p *ProjectPMInfo) Insert(db *gorm.DB) error {
- return db.Table(p.TableName()).Create(p).Error
- }
- func (p *ProjectPMInfo) 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
- }
- func (p *ProjectPMInfo) All(db *gorm.DB, where map[string]interface{}) (list []ProjectPMInfo, err error) {
- if len(where) > 0 {
- cond, val, err := whereBuild(where)
- if err != nil {
- return nil, 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 *ProjectPMInfo) Count(db *gorm.DB, where map[string]interface{}) (int64, error) {
- if len(where) > 0 {
- cond, val, err := whereBuild(where)
- 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
- }
- func (p *ProjectPMInfo) Del(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...).Delete(p).Error
- }
|