|
|
- // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
- package models
-
- import (
- "errors"
- "leit.com/LAPP_GAAS_GFrame/db"
- "time"
- "xorm.io/core"
- )
-
- type OmSerialorderstatus struct {
- Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
- Serialorderid string `json:"SerialOrderId" xorm:"not null pk NVARCHAR(40)"`
- Status int `json:"Status" xorm:"not null INT(4)"`
- Triggerevent string `json:"TriggerEvent" xorm:"not null NVARCHAR(40)"`
- Triggerobjectid string `json:"TriggerObjectId" xorm:"not null NVARCHAR(40)"`
- Triggersubobjectid string `json:"TriggerSubObjectId" xorm:"not null NVARCHAR(40)"`
- Lastmodify time.Time `json:"LastModify" xorm:"DATETIME(8)"`
- Lastuser string `json:"LastUser" xorm:"not null NVARCHAR(40)"`
- Createtime time.Time `json:"CreateTime" xorm:"DATETIME(8)"`
- Itemlst []OmSerialorderstatusrecLst `json:"itemlst" xorm:"-"`
- }
-
- /******数据表名******/
- func (t *OmSerialorderstatus) TableName() string {
- return "OmSerialOrderStatus"
- }
-
- /******************************************************************************
- *
- * @Function Name :
- *-----------------------------------------------------------------------------
- *
- * @Description : 数据添加
- *
- * @Function Parameters:
- *
- * @Return Value :
- *
- * @Author : Lou Wenzhi
- *
- * @Date : 2021/3/6 8:47
- *
- ******************************************************************************/
- func (t *OmSerialorderstatus) Add() error {
- e := db.Eloquent.Master()
- count := new(OmSerialorderstatus)
- /**主键:****/
- affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Serialorderid}).Count(count)
- if err != nil {
- return err
- }
- if affw > 0 {
- return errors.New("数据已经存在!")
- }
- _, err = e.Table(t.TableName()).Insert(t)
-
- if err != nil {
- return err
- }
- return nil
- }
-
- /******************************************************************************
- *
- * @Function Name :
- *-----------------------------------------------------------------------------
- *
- * @Description : 数据删除
- *
- * @Function Parameters:
- *
- * @Return Value :
- *
- * @Author : Lou Wenzhi
- *
- * @Date : 2021/3/6 8:47
- *
- ******************************************************************************/
- func (t *OmSerialorderstatus) Del() error {
- e := db.Eloquent.Master()
- /**主键:****/
- _, err := e.ID(core.PK{t.Plantnr, t.Serialorderid}).Delete(&OmSerialorderstatus{})
- if err != nil {
- return errors.New("删除失败!")
- }
- // 删除该订单所有的状态记录
-
- return nil
- }
-
- /******************************************************************************
- *
- * @Function Name :
- *-----------------------------------------------------------------------------
- *
- * @Description : 数据修改
- *
- * @Function Parameters:
- *
- * @Return Value :
- *
- * @Author : Lou Wenzhi
- *
- * @Date : 2021/3/6 8:47
- *
- ******************************************************************************/
- func (t *OmSerialorderstatus) Update() error {
- e := db.Eloquent.Master()
- /**主键:****/
- _, err := e.ID(core.PK{t.Plantnr, t.Serialorderid}).Update(t)
- if err != nil {
- return err
- }
- return nil
- }
-
- /******************************************************************************
- *
- * @Function Name :
- *-----------------------------------------------------------------------------
- *
- * @Description : 数据查找
- *
- * @Function Parameters:
- *
- * @Return Value :
- *
- * @Author : Lou Wenzhi
- *
- * @Date : 2021/3/6 8:47
- *
- ******************************************************************************/
- func (t *OmSerialorderstatus) SelectOne() (data OmSerialorderstatus, err error) {
- e := db.Eloquent.Master()
-
- /**主键:****/
- _, err = e.ID(core.PK{t.Plantnr, t.Serialorderid}).Get(&data)
- if err != nil {
- return
- }
- // 获取值列表
- if err = e.Where("Plantnr = ? and SerialOrderId = ? ",
- t.Plantnr, t.Serialorderid).OrderBy("pos").Find(&data.Itemlst); err != nil {
- return
- }
- return
- }
|