// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
|
|
package models
|
|
|
|
import (
|
|
"leit.com/aps_engine/db"
|
|
"errors"
|
|
"leit.com/aps_engine/grmi"
|
|
"xorm.io/core"
|
|
)
|
|
|
|
type WeekModelLst struct {
|
|
PlantNr int `xorm:"pk int 'PlantNr'" json:"WeekModelLst-PlantNr"`
|
|
WeekModelNr int `xorm:"pk int 'WeekModelNr'" json:"WeekModelLst-WeekModelNr"`
|
|
WorkDate grmi.Date `xorm:"pk date 'WorkDate'" json:"WeekModelLst-WorkDate"`
|
|
DayModelNr int `xorm:"int 'DayModelNr' not null" json:"WeekModelLst-DayModelNr"`
|
|
LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null updated" json:"WeekModelLst-LastModify"`
|
|
LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"WeekModelLst-LastUser"`
|
|
CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"WeekModelLst-CreateTime"`
|
|
}
|
|
|
|
/******数据表名******/
|
|
func (t *WeekModelLst) TableName() string {
|
|
return "WeekModelLst"
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : GetKey
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 获取实体的主键
|
|
*
|
|
* @Return Value : 实体的主键
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-23 17:06:57
|
|
*
|
|
******************************************************************************/
|
|
func (self *WeekModelLst) GetKey() core.PK {
|
|
return core.PK{self.PlantNr, self.WeekModelNr, self.WorkDate}
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name :
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 数据添加
|
|
*
|
|
* @Function Parameters:
|
|
*
|
|
* @Return Value :
|
|
*
|
|
* @Author : Lou Wenzhi
|
|
*
|
|
* @Date : 2021/3/6 8:47
|
|
*
|
|
******************************************************************************/
|
|
func (t *WeekModelLst) Add() error {
|
|
e := db.Eloquent.Master()
|
|
count := new(WeekModelLst)
|
|
affw, err := e.Table(t.TableName()).ID(t.GetKey()).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 *WeekModelLst) Del() bool {
|
|
e := db.Eloquent.Master()
|
|
_, err := e.ID(t.GetKey()).Delete(&WeekModelLst{})
|
|
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 *WeekModelLst) Update() error {
|
|
e := db.Eloquent.Master()
|
|
_, err := e.ID(t.GetKey()).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 *WeekModelLst) SelectOne() (WeekModelLst, error) {
|
|
e := db.Eloquent.Master()
|
|
var data WeekModelLst
|
|
_, err := e.ID(t.GetKey()).Get(&data)
|
|
if err != nil {
|
|
return data, err
|
|
}
|
|
return data, nil
|
|
}
|