package db
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/go-xorm/xorm"
|
|
"leit.com/leit_seat_aps/common"
|
|
"xorm.io/core"
|
|
)
|
|
|
|
// 生产包装打印设置表
|
|
type Prod_packtemplate_printlst struct {
|
|
Finr int `xorm:"pk"`
|
|
Packtemplateid string `xorm:"pk"`
|
|
Pos int `xorm:"pk"`
|
|
Varname string
|
|
Varvalue string
|
|
Vartype string
|
|
Varpos string
|
|
Picture string
|
|
Isidx int
|
|
Keyval string
|
|
Lastmodif string
|
|
Lastuser string
|
|
Credatuz string
|
|
}
|
|
|
|
func (t *Prod_packtemplate_printlst) Clipped() {
|
|
common.TrimStruct(t, *t)
|
|
}
|
|
func (t *Prod_packtemplate_printlst) TableName() string {
|
|
return "prod_packtemplate_printlst"
|
|
}
|
|
|
|
//增
|
|
func (t *Prod_packtemplate_printlst) Add() error {
|
|
e := G_DbEngine
|
|
ptprinttab := new(Prod_packtemplate_printlst)
|
|
affw, err := e.Table("prod_packtemplate_printlst").ID(core.PK{G_FINR, t.Packtemplateid, t.Pos}).Count(ptprinttab)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if affw > 0 {
|
|
return errors.New("数据已经存在!")
|
|
}
|
|
_, err = e.Table("prod_packtemplate_printlst").Insert(t)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
//增
|
|
func (t *Prod_packtemplate_printlst) Insert(session *xorm.Session) error {
|
|
ptprinttab := new(Jit_packtemplate_printlst)
|
|
affw, err := session.Table("prod_picktemplate_printlst").ID(core.PK{G_FINR, t.Packtemplateid, t.Pos}).Count(ptprinttab)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if affw > 0 {
|
|
return errors.New("数据已经存在!")
|
|
}
|
|
_, err = session.Table("prod_picktemplate_printlst").Insert(t)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
//删
|
|
func (t *Prod_packtemplate_printlst) Del() bool {
|
|
e := G_DbEngine
|
|
_, err := e.ID(core.PK{G_FINR, t.Packtemplateid, t.Pos}).Delete(&Prod_packtemplate_printlst{})
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
//改
|
|
func (t *Prod_packtemplate_printlst) Update() bool {
|
|
e := G_DbEngine
|
|
_, err := e.ID(core.PK{G_FINR, t.Packtemplateid, t.Pos}).Update(t)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
//更新指定字段
|
|
func (t *Prod_packtemplate_printlst) UpdateFields(session *xorm.Session, fields string) (err error) {
|
|
if _, err = session.Table("prod_packtemplate_printlst").ID(core.PK{G_FINR, t.Packtemplateid, t.Pos}).Cols(fields).Update(t); err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
//查
|
|
func (t *Prod_packtemplate_printlst) SelectOne() (data Prod_packtemplate_printlst, err error) {
|
|
e := G_DbEngine
|
|
_, err = e.ID(core.PK{G_FINR, t.Packtemplateid, t.Pos}).Get(&data)
|
|
if err != nil {
|
|
return data, err
|
|
}
|
|
data.Clipped()
|
|
return data, nil
|
|
}
|