// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved. package db import ( "fmt" "leit.com/leit_seat_aps/common" "xorm.io/core" ) type Pln_custorder_archive struct { Finr int `xorm:"not null pk comment('车间编号') INT(0)" json:"finr"` Custordernr string `xorm:"not null pk comment('工单号') VARCHAR(18)" json:"custordernr"` Releaseflag int `xorm:"not null comment('标记状态') INT(0)" json:"releaseflag"` Runningflag int `xorm:"not null comment('启动状态') INT(0)" json:"runningflag"` Finishflag int `xorm:"not null comment('结束状态') INT(0)" json:"finishflag"` Lastmodif string `xorm:"not null comment('上一次更改日期') VARCHAR(14)" json:"lastmodif"` Lastuser string `xorm:"not null comment('最后编辑人员') VARCHAR(20)" json:"lastuser"` Credatuz string `xorm:"not null comment('创建时间') VARCHAR(14)" json:"credatuz"` } func (t *Pln_custorder_archive) TableName() string { return "pln_custorder_archive" } // 清除string字段的右侧空格 func (t *Pln_custorder_archive) Clipped() { common.TrimStruct(t, *t) } /****************************************************************************** * * @Function Name : *----------------------------------------------------------------------------- * * @Description : * * @Function Parameters: * * @Return Value : * * @Author : Lou Wenzhi * * @Date : 2021/3/17 13:09 * ******************************************************************************/ func (t *Pln_custorder_archive) Add() error { e := G_DbEngine countrole := new(Pln_custorder_archive) affw, err := e.Table("pln_custorder_archive").ID(core.PK{G_FINR, t.Custordernr}).Count(countrole) if err != nil { return err } if affw > 0 { return nil } _, err = e.Table("pln_custorder_archive").Insert(t) if err != nil { fmt.Printf("err is :%v",err) return err } return nil } /****************************************************************************** * * @Function Name : *----------------------------------------------------------------------------- * * @Description : * * @Function Parameters: * * @Return Value : * * @Author : Lou Wenzhi * * @Date : 2021/3/17 13:09 * ******************************************************************************/ func (t *Pln_custorder_archive) Del() error { e := G_DbEngine _, err := e.ID(core.PK{G_FINR, t.Custordernr}).Delete(&Pln_custorder_archive{}) if err != nil { return err } return nil } /****************************************************************************** * * @Function Name : *----------------------------------------------------------------------------- * * @Description : * * @Function Parameters: * * @Return Value : * * @Author : Lou Wenzhi * * @Date : 2021/3/17 13:09 * ******************************************************************************/ func (t *Pln_custorder_archive) SelectAll() (data []Pln_custorder_archive,err error) { e := G_DbEngine err = e.Table("pln_custorder_archive").Where("finr = ?",G_FINR).Find(&data) if err != nil { return data, err } return data, nil }