SJA APS后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.4 KiB

package db
import (
"errors"
"github.com/go-xorm/xorm"
"leit.com/leit_seat_aps/common"
"xorm.io/core"
)
//发运车模板子项表
type Jit_shiptemplate_itemlst struct {
Finr int `xorm:"pk"`
Shiptemplateid string `xorm:"pk"`
Packtypeid string `xorm:"pk"`
Pos int
Planqty int
Lastmodif string
Lastuser string
Credatuz string
}
func (t *Jit_shiptemplate_itemlst) Clipped() {
common.TrimStruct(t, *t)
}
func (t *Jit_shiptemplate_itemlst) TableName() string {
return "jit_shiptemplate_itemlst"
}
//增
func (t *Jit_shiptemplate_itemlst) Add() error {
e := G_DbEngine
sptmpitemtab := new(Jit_shiptemplate_itemlst)
affw, err := e.Table("jit_shiptemplate_itemlst").ID(core.PK{G_FINR, t.Shiptemplateid, t.Packtypeid}).Count(sptmpitemtab)
if err != nil {
return err
}
if affw > 0 {
return errors.New("数据已经存在!")
}
_, err = e.Table("jit_shiptemplate_itemlst").Insert(t)
if err != nil {
return err
}
return nil
}
//增
func (t *Jit_shiptemplate_itemlst) Insert(session *xorm.Session) error {
sptmpitemtab := new(Jit_shiptemplate_itemlst)
affw, err := session.Table("jit_shiptemplate_itemlst").ID(core.PK{G_FINR, t.Shiptemplateid, t.Packtypeid}).Count(sptmpitemtab)
if err != nil {
return err
}
if affw > 0 {
return errors.New("数据已经存在!")
}
_, err = session.Table("Jit_shiptemplate_itemlst").Insert(t)
if err != nil {
return err
}
return nil
}
//删
func (t *Jit_shiptemplate_itemlst) Del() bool {
e := G_DbEngine
_, err := e.ID(core.PK{G_FINR, t.Shiptemplateid, t.Packtypeid}).Delete(&Jit_shiptemplate_itemlst{})
if err != nil {
return false
}
return true
}
//改
func (t *Jit_shiptemplate_itemlst) Update() bool {
e := G_DbEngine
_, err := e.ID(core.PK{G_FINR, t.Shiptemplateid, t.Packtypeid}).Update(t)
if err != nil {
return false
}
return true
}
//更新指定字段
func (t *Jit_shiptemplate_itemlst) UpdateFields(session *xorm.Session, fields string) (err error) {
if _, err = session.Table("jit_shiptemplate_itemlst").ID(core.PK{G_FINR, t.Shiptemplateid, t.Packtypeid}).Cols(fields).Update(t); err != nil {
return
}
return
}
//查
func (t *Jit_shiptemplate_itemlst) SelectOne() (data Jit_shiptemplate_itemlst, err error) {
e := G_DbEngine
_, err = e.ID(core.PK{G_FINR, t.Shiptemplateid, t.Packtypeid}).Get(&data)
if err != nil {
return data, err
}
return data, nil
}