i2bill_acquirer_student_model.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package model
  2. import (
  3. "database/sql"
  4. "fmt"
  5. "strings"
  6. "time"
  7. "git.i2edu.net/i2/go-zero/core/stores/sqlc"
  8. "git.i2edu.net/i2/go-zero/core/stores/sqlx"
  9. "git.i2edu.net/i2/go-zero/core/stringx"
  10. "git.i2edu.net/i2/go-zero/tools/goctl/model/sql/builderx"
  11. )
  12. var (
  13. i2billAcquirerStudentFieldNames = builderx.RawFieldNames(&I2billAcquirerStudent{})
  14. i2billAcquirerStudentRows = strings.Join(i2billAcquirerStudentFieldNames, ",")
  15. I2billAcquirerStudentRows = strings.Join(i2billAcquirerStudentFieldNames, ",")
  16. i2billAcquirerStudentRowsExpectAutoSet = strings.Join(stringx.Remove(i2billAcquirerStudentFieldNames, "`create_time`", "`update_time`"), ",")
  17. i2billAcquirerStudentRowsWithPlaceHolder = strings.Join(stringx.Remove(i2billAcquirerStudentFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
  18. )
  19. type (
  20. I2billAcquirerStudentModel interface {
  21. Insert(data I2billAcquirerStudent) (sql.Result, error)
  22. FindOne(id int64) (*I2billAcquirerStudent, error)
  23. Update(data I2billAcquirerStudent) error
  24. Delete(id int64) error
  25. }
  26. defaultI2billAcquirerStudentModel struct {
  27. conn sqlx.SqlConn
  28. table string
  29. }
  30. I2billAcquirerStudent struct {
  31. StuLinkPerson sql.NullInt64 `db:"stu_link_person" json:"stu_link_person"` // 联系人关系
  32. StuPhone sql.NullString `db:"stu_phone" json:"stu_phone"` // 联系方式
  33. CreateTime sql.NullTime `db:"create_time" json:"create_time"`
  34. CheckTime sql.NullTime `db:"check_time" json:"check_time"` // 审核日期
  35. CheckBy sql.NullString `db:"check_by" json:"check_by"` // 审核人
  36. MkId sql.NullString `db:"mk_id" json:"mk_id"` // 所属mk erp id
  37. UserId sql.NullInt64 `db:"user_id" json:"user_id"` // 收单宝用户id
  38. Address sql.NullString `db:"address" json:"address"` // 当前位置
  39. CheckState sql.NullInt64 `db:"check_state" json:"check_state"` // 收单宝状态
  40. Id int64 `db:"id" json:"id"` // 主键
  41. PartTimeUserId sql.NullInt64 `db:"part_time_user_id" json:"part_time_user_id"`
  42. StuName sql.NullString `db:"stu_name" json:"stu_name"` // 学员名称
  43. AgeGroup int64 `db:"age_group" json:"age_group"` // 学员年龄
  44. SchId sql.NullInt64 `db:"sch_id" json:"sch_id"` // 意向校区
  45. DelFlag int64 `db:"del_flag" json:"del_flag"`
  46. QuaoYji sql.NullInt64 `db:"quao_yji" json:"quao_yji"` // 渠道一级
  47. CallType sql.NullInt64 `db:"call_type" json:"call_type"` // 渠道二级
  48. MaType sql.NullInt64 `db:"ma_type" json:"ma_type"` //渠道三级
  49. NetworkDetailId sql.NullInt64 `db:"network_detail_id" json:"network_detail_id"` //渠道四级
  50. LoadSchId sql.NullInt64 `db:"load_sch_id" json:"load_sch_id"` //资源收集校区
  51. ActiveId sql.NullInt64 `db:"active_id" json:"active_id"` //活动
  52. Remark sql.NullString `db:"remark" json:"remark"` //备注
  53. }
  54. I2billAcquirerStudentXorm struct {
  55. StuLinkPerson int `db:"stu_link_person" json:"stu_link_person"` // 联系人关系
  56. StuPhone string `db:"stu_phone" json:"stu_phone"` // 联系方式
  57. CreateTime time.Time `db:"create_time" json:"create_time"`
  58. CheckTime time.Time `db:"check_time" json:"check_time"` // 审核日期
  59. CheckBy string `db:"check_by" json:"check_by"` // 审核人
  60. MkId string `db:"mk_id" json:"mk_id"` // 所属mk erp id
  61. UserId int64 `db:"user_id" json:"user_id"` // 收单宝用户id
  62. Address string `db:"address" json:"address"` // 当前位置
  63. CheckState int64 `db:"check_state" json:"check_state"` // 收单宝状态
  64. Id int64 `db:"id" json:"id"` // 主键
  65. PartTimeUserId int64 `db:"part_time_user_id" json:"part_time_user_id"`
  66. StuName string `db:"stu_name" json:"stu_name"` // 学员名称
  67. AgeGroup int64 `db:"age_group" json:"age_group"` // 学员年龄
  68. SchId int64 `db:"sch_id" json:"sch_id"` // 意向校区
  69. DelFlag int64 `db:"del_flag" json:"del_flag"`
  70. QuaoYji int64 `db:"quao_yji" json:"quao_yji"` // 渠道一级
  71. CallType int64 `db:"call_type" json:"call_type"` // 渠道二级
  72. MaType int64 `db:"ma_type" json:"ma_type"` //渠道三级
  73. NetworkDetailId int64 `db:"network_detail_id" json:"network_detail_id"` //渠道四级
  74. LoadSchId int64 `db:"load_sch_id" json:"load_sch_id"` //收集收集校区
  75. ActiveId int64 `db:"active_id" json:"active_id"` //活动
  76. Remark string `db:"remark" json:"remark"` //备注
  77. }
  78. )
  79. func (t *I2billAcquirerStudentXorm) TableName() string {
  80. return "i2bill_acquirer_student"
  81. }
  82. func NewI2billAcquirerStudentModel(conn sqlx.SqlConn) I2billAcquirerStudentModel {
  83. return &defaultI2billAcquirerStudentModel{
  84. conn: conn,
  85. table: "`i2bill_acquirer_student`",
  86. }
  87. }
  88. func (m *defaultI2billAcquirerStudentModel) Insert(data I2billAcquirerStudent) (sql.Result, error) {
  89. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?)", m.table, i2billAcquirerStudentRowsExpectAutoSet)
  90. ret, err := m.conn.Exec(query, data.StuLinkPerson, data.StuPhone, data.CheckTime, data.CheckBy, data.MkId, data.UserId, data.Address, data.CheckState, data.Id, data.PartTimeUserId, data.StuName, data.AgeGroup, data.SchId, data.DelFlag, data.QuaoYji, data.CallType, data.MaType, data.NetworkDetailId, data.LoadSchId, data.ActiveId)
  91. return ret, err
  92. }
  93. func (m *defaultI2billAcquirerStudentModel) FindOne(id int64) (*I2billAcquirerStudent, error) {
  94. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", i2billAcquirerStudentRows, m.table)
  95. var resp I2billAcquirerStudent
  96. err := m.conn.QueryRow(&resp, query, id)
  97. switch err {
  98. case nil:
  99. return &resp, nil
  100. case sqlc.ErrNotFound:
  101. return nil, ErrNotFound
  102. default:
  103. return nil, err
  104. }
  105. }
  106. func (m *defaultI2billAcquirerStudentModel) Update(data I2billAcquirerStudent) error {
  107. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, i2billAcquirerStudentRowsWithPlaceHolder)
  108. _, err := m.conn.Exec(query, data.StuLinkPerson, data.StuPhone, data.CheckTime, data.CheckBy, data.MkId, data.UserId, data.Address, data.CheckState, data.PartTimeUserId, data.StuName, data.AgeGroup, data.SchId, data.DelFlag, data.QuaoYji, data.CallType, data.MaType, data.NetworkDetailId, data.LoadSchId, data.ActiveId, data.Id)
  109. return err
  110. }
  111. func (m *defaultI2billAcquirerStudentModel) Delete(id int64) error {
  112. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  113. _, err := m.conn.Exec(query, id)
  114. return err
  115. }