package db
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/go-xorm/xorm"
|
|
"leit.com/leit_seat_aps/common"
|
|
"time"
|
|
"xorm.io/core"
|
|
)
|
|
|
|
//发运包装单表
|
|
type Int_aps_out_prord struct {
|
|
Plant int `xorm:"pk"`
|
|
Ordernr string `xorm:"pk"`
|
|
Projnr string
|
|
Orderinfo string
|
|
Ordertype string
|
|
Materialnr string
|
|
Schedresource string
|
|
Partfamily string
|
|
Supplygroup string
|
|
Planqty int
|
|
Bba_seq int
|
|
Aps_seq int
|
|
Swet time.Time
|
|
Custordnr string
|
|
Vin string
|
|
Retstatus string
|
|
Creationtime time.Time
|
|
Responsetime time.Time
|
|
}
|
|
|
|
func (t *Int_aps_out_prord) Clipped() {
|
|
common.TrimStruct(t, *t)
|
|
}
|
|
func (t *Int_aps_out_prord) TableName() string {
|
|
return "int_aps_out_prord"
|
|
}
|
|
|
|
//增
|
|
func (t *Int_aps_out_prord) Add() error {
|
|
e := G_DbEngine
|
|
wotab := new(Int_aps_out_prord)
|
|
affw, err := e.Table("int_aps_out_prord").ID(core.PK{t.Plant, t.Ordernr}).Count(wotab)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if affw > 0 {
|
|
return errors.New("数据已经存在!")
|
|
}
|
|
_, err = e.Table("int_aps_out_prord").Insert(t)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
//删
|
|
func (t *Int_aps_out_prord) Del() bool {
|
|
e := G_DbEngine
|
|
_, err := e.ID(core.PK{t.Plant, t.Ordernr}).Delete(&Int_aps_out_prord{})
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
//改
|
|
func (t *Int_aps_out_prord) Update() bool {
|
|
e := G_DbEngine
|
|
_, err := e.ID(core.PK{t.Plant, t.Ordernr}).Update(t)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
//更新指定字段
|
|
func (t *Int_aps_out_prord) UpdateFields(session *xorm.Session, fields string) (err error) {
|
|
if _, err = session.ID(core.PK{t.Plant, t.Ordernr}).Cols(fields).Update(t); err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|