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.

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