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.

136 lines
3.7 KiB

4 years ago
  1. // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
  2. package models
  3. import (
  4. "leit.com/LAPP_GAAS_GFrame/db"
  5. "time"
  6. "errors"
  7. "xorm.io/core"
  8. )
  9. type Worklinespecialtime struct {
  10. Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
  11. Worklineid string `json:"WorkLineid" xorm:"not null pk NVARCHAR(80)"`
  12. Addminus int `json:"AddMinus" xorm:"not null INT(4)"`
  13. Begtime time.Time `json:"BegTime" xorm:"not null pk DATETIME(8)"`
  14. Endtime time.Time `json:"EndTime" xorm:"DATETIME(8)"`
  15. Timeobjid string `json:"TimeObjId" xorm:"not null NVARCHAR(80)"`
  16. Lastmodify time.Time `json:"LastModify" xorm:"DATETIME(8)"`
  17. Lastuser string `json:"LastUser" xorm:"not null NVARCHAR(40)"`
  18. Createtime time.Time `json:"CreateTime" xorm:"DATETIME(8)"`
  19. }
  20. /******数据表名******/
  21. func (t *Worklinespecialtime) TableName() string {
  22. return "Worklinespecialtime"
  23. }
  24. /******************************************************************************
  25. *
  26. * @Function Name :
  27. *-----------------------------------------------------------------------------
  28. *
  29. * @Description : 数据添加
  30. *
  31. * @Function Parameters:
  32. *
  33. * @Return Value :
  34. *
  35. * @Author : Lou Wenzhi
  36. *
  37. * @Date : 2021/3/6 8:47
  38. *
  39. ******************************************************************************/
  40. func (t *Worklinespecialtime) Add() error {
  41. e := db.Eloquent.Master()
  42. count := new(Worklinespecialtime)
  43. affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Worklineid, t.Begtime}).Count(count)
  44. if err != nil {
  45. return err
  46. }
  47. if affw > 0 {
  48. return errors.New("数据已经存在!")
  49. }
  50. _, err = e.Table(t.TableName()).Insert(t)
  51. if err != nil {
  52. return err
  53. }
  54. return nil
  55. }
  56. /******************************************************************************
  57. *
  58. * @Function Name :
  59. *-----------------------------------------------------------------------------
  60. *
  61. * @Description : 数据删除
  62. *
  63. * @Function Parameters:
  64. *
  65. * @Return Value :
  66. *
  67. * @Author : Lou Wenzhi
  68. *
  69. * @Date : 2021/3/6 8:47
  70. *
  71. ******************************************************************************/
  72. func (t *Worklinespecialtime) Del() bool {
  73. e := db.Eloquent.Master()
  74. _, err := e.ID(core.PK{t.Plantnr, t.Worklineid, t.Begtime}).Delete(&Worklinespecialtime{})
  75. if err != nil {
  76. return false
  77. }
  78. return true
  79. }
  80. /******************************************************************************
  81. *
  82. * @Function Name :
  83. *-----------------------------------------------------------------------------
  84. *
  85. * @Description : 数据修改
  86. *
  87. * @Function Parameters:
  88. *
  89. * @Return Value :
  90. *
  91. * @Author : Lou Wenzhi
  92. *
  93. * @Date : 2021/3/6 8:47
  94. *
  95. ******************************************************************************/
  96. func (t *Worklinespecialtime) Update() error {
  97. e := db.Eloquent.Master()
  98. _, err := e.ID(core.PK{t.Plantnr, t.Worklineid, t.Begtime}).Update(t)
  99. if err != nil {
  100. return err
  101. }
  102. return nil
  103. }
  104. /******************************************************************************
  105. *
  106. * @Function Name :
  107. *-----------------------------------------------------------------------------
  108. *
  109. * @Description : 数据查找
  110. *
  111. * @Function Parameters:
  112. *
  113. * @Return Value :
  114. *
  115. * @Author : Lou Wenzhi
  116. *
  117. * @Date : 2021/3/6 8:47
  118. *
  119. ******************************************************************************/
  120. func (t *Worklinespecialtime) SelectOne() (Worklinespecialtime, error) {
  121. e := db.Eloquent.Master()
  122. var data Worklinespecialtime
  123. _, err := e.ID(core.PK{t.Plantnr, t.Worklineid, t.Begtime}).Get(&data)
  124. if err != nil {
  125. return data, err
  126. }
  127. return data, nil
  128. }