// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved. package models import ( "errors" "leit.com/aps_engine/db" "time" "xorm.io/core" ) type OmWooperationstatus struct { Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"` Workorderid string `json:"WorkOrderId" xorm:"not null pk NVARCHAR(80)"` Operationnr int `json:"OperationNr" xorm:"not null pk INT(4)"` Splitnr int `json:"SplitNr" xorm:"not null pk INT(4)"` Status int `json:"Status" xorm:"not null INT(4)"` Triggerevent string `json:"TriggerEvent" xorm:"not null NVARCHAR(80)"` Triggerobjectid string `json:"TriggerObjectId" xorm:"not null NVARCHAR(80)"` Triggersubobjectid string `json:"TriggerSubObjectId" xorm:"not null NVARCHAR(80)"` 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)"` } /******数据表名******/ func (t *OmWooperationstatus) TableName() string { return "OmWooperationstatus" } /****************************************************************************** * * @Function Name : *----------------------------------------------------------------------------- * * @Description : 数据添加 * * @Function Parameters: * * @Return Value : * * @Author : Lou Wenzhi * * @Date : 2021/3/6 8:47 * ******************************************************************************/ func (t *OmWooperationstatus) Add() error { e := db.Eloquent.Master() count := new(OmWooperationstatus) /**主键:****/ affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Workorderid, t.Operationnr, t.Splitnr}).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 *OmWooperationstatus) Del() (err error) { e := db.Eloquent.Master() /**主键:****/ _, err = e.ID(core.PK{t.Plantnr, t.Workorderid, t.Operationnr, t.Splitnr}).Delete(&OmWooperationstatus{}) if err != nil { return } return nil } /****************************************************************************** * * @Function Name : *----------------------------------------------------------------------------- * * @Description : 数据修改 * * @Function Parameters: * * @Return Value : * * @Author : Lou Wenzhi * * @Date : 2021/3/6 8:47 * ******************************************************************************/ func (t *OmWooperationstatus) Update() error { e := db.Eloquent.Master() /**主键:****/ _, err := e.ID(core.PK{t.Plantnr, t.Workorderid, t.Operationnr, t.Splitnr}).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 *OmWooperationstatus) SelectOne() (OmWooperationstatus, error) { e := db.Eloquent.Master() var data OmWooperationstatus /**主键:****/ _, err := e.ID(core.PK{t.Plantnr, t.Workorderid, t.Operationnr, t.Splitnr}).Get(&data) if err != nil { return data, err } return data, nil }