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

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