|
|
- package db
-
- import (
- "errors"
- "github.com/go-xorm/xorm"
- "leit.com/leit_seat_aps/common"
- "xorm.io/core"
- )
-
- //客户订单产品属性表
- type Pln_custorder_atcodlst struct {
- Finr int `xorm:"pk"`
- Custordernr string `xorm:"pk"`
- Pos int `xorm:"pk"`
- Supplygroupid string
- Partid string
- Attrcode int
- Attrvalue string
- Lastmodif string
- Lastuser string
- Credatuz string
- }
-
- func (t *Pln_custorder_atcodlst) Clipped(){
- common.TrimStruct(t, *t)
- }
-
- func (t *Pln_custorder_atcodlst) TableName() string {
- return "pln_custorder_atcodlst"
- }
-
- //增
- func (t *Pln_custorder_atcodlst) Add() error {
- e := G_DbEngine
- coatcodtab := new(Pln_custorder_atcodlst)
- affw, err := e.Table("pln_custorder_atcodlst").ID(core.PK{G_FINR,t.Custordernr,t.Pos}).Count(coatcodtab)
- if err != nil {
- return err
- }
- if affw > 0 {
- return errors.New("数据已经存在!")
- }
- _, err = e.Table("pln_custorder_atcodlst").Insert(t)
-
- if err != nil {
- return err
- }
- return nil
- }
- //增
- func (t *Pln_custorder_atcodlst) Insert(session *xorm.Session) error {
- coatcodtab := new(Pln_custorder_atcodlst)
- affw, err := session.Table("pln_custorder_atcodlst").ID(core.PK{G_FINR,t.Custordernr,t.Pos}).Count(coatcodtab)
- if err != nil {
- return err
- }
- if affw > 0 {
- return errors.New("数据已经存在!")
- }
- _, err = session.Table("pln_custorder_atcodlst").Insert(t)
-
- if err != nil {
- return err
- }
- return nil
- }
- //删
- func(t *Pln_custorder_atcodlst) Del() bool{
- e := G_DbEngine
- _, err := e.ID(core.PK{G_FINR,t.Custordernr,t.Pos}).Delete(&Pln_custorder_atcodlst{})
- if err !=nil{
- return false
- }
- return true
- }
- //改
- func(t *Pln_custorder_atcodlst)Update()bool{
- e := G_DbEngine
- _, err := e.ID(core.PK{G_FINR,t.Custordernr,t.Pos}).Update(t)
- if err !=nil{
- return false
- }
- return true
- }
- //查
- func(t *Pln_custorder_atcodlst)SelectOne() (data Pln_custorder_atcodlst, err error){
- e := G_DbEngine
- _, err = e.ID(core.PK{G_FINR,t.Custordernr,t.Pos}).Get(&data)
- if err !=nil{
- return data,err
- }
- return data,nil
- }
|