|
|
@ -0,0 +1,113 @@ |
|
|
|
package db |
|
|
|
|
|
|
|
import ( |
|
|
|
"github.com/go-xorm/xorm" |
|
|
|
"github.com/pkg/errors" |
|
|
|
"leit.com/leit_seat_aps/common" |
|
|
|
"xorm.io/core" |
|
|
|
) |
|
|
|
|
|
|
|
// EDI控制表
|
|
|
|
type Edi_control struct { |
|
|
|
Finr int `xorm:"pk" json:"edi_control.finr"` |
|
|
|
Projectid string `xorm:"pk" json:"edi_control.projectid"` |
|
|
|
Ediid string `xorm:"pk" json:"edi_control.ediid"` |
|
|
|
Descr string `json:"edi_control.descr"` |
|
|
|
Enabled int `json:"edi_control.enabled"` |
|
|
|
Ctrlpara1 int `json:"edi_control.ctrlpara1"` |
|
|
|
Ctrlpara2 int `json:"edi_control.ctrlpara2"` |
|
|
|
Lastmodif string `json:"edi_control.lastmodif"` |
|
|
|
Lastuser string `json:"edi_control.lastuser"` |
|
|
|
Credatuz string `json:"edi_control.credatuz"` |
|
|
|
} |
|
|
|
|
|
|
|
func (t *Edi_control) Clipped() { |
|
|
|
common.TrimStruct(t, *t) |
|
|
|
} |
|
|
|
|
|
|
|
func (t *Edi_control) TableName() string { |
|
|
|
return "edi_control" |
|
|
|
} |
|
|
|
|
|
|
|
//增
|
|
|
|
func (t *Edi_control) Add() (err error) { |
|
|
|
var ( |
|
|
|
affw int64 |
|
|
|
editab Edi_control |
|
|
|
) |
|
|
|
|
|
|
|
e := G_DbEngine |
|
|
|
editab = Edi_control{} |
|
|
|
affw, err = e.Table("edi_control").ID(core.PK{G_FINR, t.Projectid, t.Ediid}).Count(editab) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if affw > 0 { |
|
|
|
return errors.New("数据已经存在!") |
|
|
|
} |
|
|
|
_, err = e.Table("edi_control").Insert(t) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
//增
|
|
|
|
func (t *Edi_control) Insert(session *xorm.Session) (err error) { |
|
|
|
var ( |
|
|
|
affw int64 |
|
|
|
editab Edi_control |
|
|
|
) |
|
|
|
|
|
|
|
editab = Edi_control{} |
|
|
|
affw, err = session.Table("edi_control").ID(core.PK{G_FINR, t.Projectid, t.Ediid}).Count(editab) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if affw > 0 { |
|
|
|
return errors.New("数据已经存在!") |
|
|
|
} |
|
|
|
_, err = session.Table("edi_control").Insert(t) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
//删
|
|
|
|
func (t *Edi_control) Del() bool { |
|
|
|
e := G_DbEngine |
|
|
|
_, err := e.ID(core.PK{G_FINR, t.Projectid, t.Ediid}).Delete(&Edi_control{}) |
|
|
|
if err != nil { |
|
|
|
return false |
|
|
|
} |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
//改
|
|
|
|
func (t *Edi_control) Update() bool { |
|
|
|
e := G_DbEngine |
|
|
|
_, err := e.ID(core.PK{G_FINR, t.Projectid, t.Ediid}).Update(t) |
|
|
|
if err != nil { |
|
|
|
return false |
|
|
|
} |
|
|
|
return true |
|
|
|
} |
|
|
|
//更新指定字段
|
|
|
|
func (t *Edi_control) UpdateFields(session *xorm.Session, fields string) (err error) { |
|
|
|
if _, err = session.Table("edi_control").ID(core.PK{G_FINR, t.Projectid, t.Ediid}).Cols(fields).Update(t); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
//查
|
|
|
|
func (t *Edi_control) SelectOne() (data Edi_control, err error) { |
|
|
|
e := G_DbEngine |
|
|
|
_, err = e.ID(core.PK{G_FINR, t.Projectid, t.Ediid}).Get(&data) |
|
|
|
if err != nil { |
|
|
|
return data, err |
|
|
|
} |
|
|
|
return data, nil |
|
|
|
} |