You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

138 lines
4.0 KiB

// 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 Worklineworkshiftspecialtime struct {
Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
Worklineid string `json:"WorkLineId" xorm:"not null pk NVARCHAR(80)"`
Workday string `json:"WorkDay" xorm:"not null pk NVARCHAR(16)"`
Pos int `json:"Pos" xorm:"not null pk INT(4)"`
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 *Worklineworkshiftspecialtime) TableName() string {
return "Worklineworkshiftspecialtime"
}
/******************************************************************************
*
* @Function Name :
*-----------------------------------------------------------------------------
*
* @Description : 数据添加
*
* @Function Parameters:
*
* @Return Value :
*
* @Author : Lou Wenzhi
*
* @Date : 2021/3/6 8:47
*
******************************************************************************/
func (t *Worklineworkshiftspecialtime) Add() error {
e := db.Eloquent.Master()
count := new(Worklineworkshiftspecialtime)
affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Worklineid, t.Workday, t.Pos, 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 *Worklineworkshiftspecialtime) Del() bool {
e := db.Eloquent.Master()
_, err := e.ID(core.PK{t.Plantnr, t.Worklineid, t.Workday, t.Pos, t.Begtime}).Delete(&Worklineworkshiftspecialtime{})
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 *Worklineworkshiftspecialtime) Update() error {
e := db.Eloquent.Master()
_, err := e.ID(core.PK{t.Plantnr, t.Worklineid, t.Workday, t.Pos, 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 *Worklineworkshiftspecialtime) SelectOne() (Worklineworkshiftspecialtime, error) {
e := db.Eloquent.Master()
var data Worklineworkshiftspecialtime
_, err := e.ID(core.PK{t.Plantnr, t.Worklineid, t.Workday, t.Pos, t.Begtime}).Get(&data)
if err != nil {
return data, err
}
return data, nil
}