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