// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
|
|
package models
|
|
|
|
import (
|
|
"leit.com/LAPP_GAAS_GFrame/db"
|
|
"time"
|
|
"errors"
|
|
"xorm.io/core"
|
|
)
|
|
|
|
type Worklinespecialtime struct {
|
|
Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
|
|
Worklineid string `json:"WorkLineid" xorm:"not null pk NVARCHAR(80)"`
|
|
Addminus int `json:"AddMinus" xorm:"not null INT(4)"`
|
|
Begtime time.Time `json:"BegTime" xorm:"not null pk DATETIME(8)"`
|
|
Endtime time.Time `json:"EndTime" xorm:"DATETIME(8)"`
|
|
Timeobjid string `json:"TimeObjId" 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 *Worklinespecialtime) TableName() string {
|
|
return "Worklinespecialtime"
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name :
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 数据添加
|
|
*
|
|
* @Function Parameters:
|
|
*
|
|
* @Return Value :
|
|
*
|
|
* @Author : Lou Wenzhi
|
|
*
|
|
* @Date : 2021/3/6 8:47
|
|
*
|
|
******************************************************************************/
|
|
func (t *Worklinespecialtime) Add() error {
|
|
e := db.Eloquent.Master()
|
|
count := new(Worklinespecialtime)
|
|
affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Worklineid, t.Begtime}).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 *Worklinespecialtime) Del() bool {
|
|
e := db.Eloquent.Master()
|
|
_, err := e.ID(core.PK{t.Plantnr, t.Worklineid, t.Begtime}).Delete(&Worklinespecialtime{})
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name :
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 数据修改
|
|
*
|
|
* @Function Parameters:
|
|
*
|
|
* @Return Value :
|
|
*
|
|
* @Author : Lou Wenzhi
|
|
*
|
|
* @Date : 2021/3/6 8:47
|
|
*
|
|
******************************************************************************/
|
|
func (t *Worklinespecialtime) Update() error {
|
|
e := db.Eloquent.Master()
|
|
_, err := e.ID(core.PK{t.Plantnr, t.Worklineid, t.Begtime}).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 *Worklinespecialtime) SelectOne() (Worklinespecialtime, error) {
|
|
e := db.Eloquent.Master()
|
|
var data Worklinespecialtime
|
|
_, err := e.ID(core.PK{t.Plantnr, t.Worklineid, t.Begtime}).Get(&data)
|
|
if err != nil {
|
|
return data, err
|
|
}
|
|
return data, nil
|
|
}
|