SJA APS后端代码
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.

100 lines
2.1 KiB

  1. package db
  2. import (
  3. "errors"
  4. "github.com/go-xorm/xorm"
  5. "leit.com/leit_seat_aps/common"
  6. "xorm.io/core"
  7. )
  8. //客户订单错误表
  9. type Pln_custorder_errorlst struct {
  10. Finr int `xorm:"pk"`
  11. Custordernr string `xorm:"pk"`
  12. Pos int `xorm:"pk"`
  13. Errortype int
  14. Partid string
  15. Supplygroupid string
  16. Partfamilyid string
  17. Attrcode int
  18. Errorstatus string
  19. Errorinfo string
  20. Lastmodif string
  21. Lastuser string
  22. Credatuz string
  23. }
  24. func (t *Pln_custorder_errorlst) Clipped() {
  25. common.TrimStruct(t, *t)
  26. }
  27. func (t *Pln_custorder_errorlst) TableName() string {
  28. return "pln_custorder_errorlst"
  29. }
  30. //增
  31. func (t *Pln_custorder_errorlst) Add() error {
  32. e := G_DbEngine
  33. coerrtab := new(Pln_custorder_errorlst)
  34. affw, err := e.Table("pln_custorder_errorlst").ID(core.PK{G_FINR, t.Custordernr, t.Pos}).Count(coerrtab)
  35. if err != nil {
  36. return err
  37. }
  38. if affw > 0 {
  39. return errors.New("数据已经存在!")
  40. }
  41. _, err = e.Table("pln_custorder_errorlst").Insert(t)
  42. if err != nil {
  43. return err
  44. }
  45. return nil
  46. }
  47. //增
  48. func (t *Pln_custorder_errorlst) Insert(session *xorm.Session) error {
  49. coerrtab := new(Pln_custorder_errorlst)
  50. affw, err := session.Table("pln_custorder_errorlst").ID(core.PK{G_FINR, t.Custordernr, t.Pos}).Count(coerrtab)
  51. if err != nil {
  52. return err
  53. }
  54. if affw > 0 {
  55. return errors.New("数据已经存在!")
  56. }
  57. _, err = session.Table("pln_custorder_errorlst").Insert(t)
  58. if err != nil {
  59. return err
  60. }
  61. return nil
  62. }
  63. //删
  64. func (t *Pln_custorder_errorlst) Del() bool {
  65. e := G_DbEngine
  66. _, err := e.ID(core.PK{G_FINR, t.Custordernr, t.Pos}).Delete(&Pln_custorder_errorlst{})
  67. if err != nil {
  68. return false
  69. }
  70. return true
  71. }
  72. //改
  73. func (t *Pln_custorder_errorlst) Update() bool {
  74. e := G_DbEngine
  75. _, err := e.ID(core.PK{G_FINR, t.Custordernr, t.Pos}).Update(t)
  76. if err != nil {
  77. return false
  78. }
  79. return true
  80. }
  81. //查
  82. func (t *Pln_custorder_errorlst) SelectOne() (data Pln_custorder_errorlst, err error) {
  83. e := G_DbEngine
  84. _, err = e.ID(core.PK{G_FINR, t.Custordernr, t.Pos}).Get(&data)
  85. if err != nil {
  86. return data, err
  87. }
  88. return data, nil
  89. }