|
|
- package db
-
- import (
- "errors"
- "github.com/go-xorm/xorm"
- "leit.com/leit_seat_aps/common"
- "xorm.io/core"
- )
-
- //生产订单属性清单表
- type Pln_workorder_atcodlst struct {
- Finr int `xorm:"pk" json:"pln_workorder_atcodlst.finr"`
- Workordernr string `xorm:"pk" json:"pln_workorder_atcodlst.workordernr"`
- Pos int `xorm:"pk" json:"pln_workorder_atcodlst.pos"`
- Attrcode int `json:"pln_workorder_atcodlst.attrcode"`
- Attrvalue string `json:"pln_workorder_atcodlst.attrvalue"`
- Lastmodif string `json:"pln_workorder_atcodlst.lastmodif"`
- Lastuser string `json:"pln_workorder_atcodlst.lastuser"`
- Credatuz string `json:"pln_workorder_atcodlst.credatuz"`
- }
-
- func (t *Pln_workorder_atcodlst) Clipped() {
- common.TrimStruct(t, *t)
- }
-
- func (t *Pln_workorder_atcodlst) TableName() string {
- return "pln_workorder_atcodlst"
- }
-
- //增
- func (t *Pln_workorder_atcodlst) Add() error {
- e := G_DbEngine
- woattrtab := new(Pln_workorder_atcodlst)
- affw, err := e.Table("pln_workorder_atcodlst").ID(core.PK{G_FINR, t.Workordernr, t.Pos}).Count(woattrtab)
- if err != nil {
- return err
- }
- if affw > 0 {
- return errors.New("数据已经存在!")
- }
- _, err = e.Table("pln_workorder_atcodlst").Insert(t)
-
- if err != nil {
- return err
- }
- return nil
- }
-
- //增
- func (t *Pln_workorder_atcodlst) Insert(session *xorm.Session) error {
- woattrtab := new(Pln_workorder_atcodlst)
- affw, err := session.Table("pln_workorder_atcodlst").ID(core.PK{G_FINR, t.Workordernr, t.Pos}).Count(woattrtab)
- if err != nil {
- return err
- }
- if affw > 0 {
- return errors.New("数据已经存在!")
- }
- _, err = session.Table("pln_workorder_atcodlst").Insert(t)
-
- if err != nil {
- return err
- }
- return nil
- }
-
- //删
- func (t *Pln_workorder_atcodlst) Del() bool {
- e := G_DbEngine
- _, err := e.ID(core.PK{G_FINR, t.Workordernr, t.Pos}).Delete(&Pln_workorder_atcodlst{})
- if err != nil {
- return false
- }
- return true
- }
-
- //改
- func (t *Pln_workorder_atcodlst) Update() bool {
- e := G_DbEngine
- _, err := e.ID(core.PK{G_FINR, t.Workordernr, t.Pos}).Update(t)
- if err != nil {
- return false
- }
- return true
- }
-
- //查
- func (t *Pln_workorder_atcodlst) SelectOne() (data Pln_workorder_atcodlst, err error) {
- e := G_DbEngine
- _, err = e.ID(core.PK{G_FINR, t.Workordernr, t.Pos}).Get(&data)
- if err != nil {
- return data, err
- }
- return data, nil
- }
|