team_inout.go 970 B

123456789101112131415161718192021222324252627282930313233343536
  1. package model
  2. import (
  3. "time"
  4. "github.com/jaryhe/gopkgs/logger"
  5. "github.com/jinzhu/gorm"
  6. "go.uber.org/zap"
  7. )
  8. type TeamInoutInfo struct {
  9. ID int64 `gorm:"column:ID;PRIMARY_KEY" json:"id"`
  10. Code string `gorm:"column:Code" json:"code"`
  11. TeamSysNo int `gorm:"column:TeamSysNo" json:"team_sys_no"`
  12. InOut int `gorm:"column:InOut" json:"in_out"`
  13. OccurTime time.Time `gorm:"column:OccurTime" json:"occur_time"`
  14. AttInfo string `gorm:"column:AttInfo" json:"att_info"`
  15. ProjectId int64 `gorm:"column:ProjectId" json:"project_id"`
  16. }
  17. func (TeamInoutInfo) TableName() string {
  18. return "db_smart_attendance.TeamInoutInfo"
  19. }
  20. // Insert 插入一条记录
  21. func (p *TeamInoutInfo) Insert(db *gorm.DB) error {
  22. err := db.Table(p.TableName()).Create(p).Error
  23. if err != nil {
  24. fields, _ := json.MarshalToString(*p)
  25. logger.Error("mysql",
  26. zap.String("sql", "insert into TeamInoutInfo"),
  27. zap.String("fields", fields),
  28. zap.String("error", err.Error()))
  29. }
  30. return err
  31. }