i2bill_acquirer_student_model.go 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. }
  53. I2billAcquirerStudentXorm struct {
  54. StuLinkPerson int `db:"stu_link_person" json:"stu_link_person"` // 联系人关系
  55. StuPhone string `db:"stu_phone" json:"stu_phone"` // 联系方式
  56. CreateTime time.Time `db:"create_time" json:"create_time"`
  57. CheckTime time.Time `db:"check_time" json:"check_time"` // 审核日期
  58. CheckBy string `db:"check_by" json:"check_by"` // 审核人
  59. MkId string `db:"mk_id" json:"mk_id"` // 所属mk erp id
  60. UserId int64 `db:"user_id" json:"user_id"` // 收单宝用户id
  61. Address string `db:"address" json:"address"` // 当前位置
  62. CheckState int64 `db:"check_state" json:"check_state"` // 收单宝状态
  63. Id int64 `db:"id" json:"id"` // 主键
  64. PartTimeUserId int64 `db:"part_time_user_id" json:"part_time_user_id"`
  65. StuName string `db:"stu_name" json:"stu_name"` // 学员名称
  66. AgeGroup int64 `db:"age_group" json:"age_group"` // 学员年龄
  67. SchId int64 `db:"sch_id" json:"sch_id"` // 意向校区
  68. DelFlag int64 `db:"del_flag" json:"del_flag"`
  69. QuaoYji int64 `db:"quao_yji" json:"quao_yji"` // 渠道一级
  70. CallType int64 `db:"call_type" json:"call_type"` // 渠道二级
  71. MaType int64 `db:"ma_type" json:"ma_type"` //渠道三级
  72. NetworkDetailId int64 `db:"network_detail_id" json:"network_detail_id"` //渠道四级
  73. LoadSchId int64 `db:"load_sch_id" json:"load_sch_id"` //收集收集校区
  74. ActiveId int64 `db:"active_id" json:"active_id"` //活动
  75. }
  76. )
  77. func (t *I2billAcquirerStudentXorm) TableName() string {
  78. return "i2bill_acquirer_student"
  79. }
  80. func NewI2billAcquirerStudentModel(conn sqlx.SqlConn) I2billAcquirerStudentModel {
  81. return &defaultI2billAcquirerStudentModel{
  82. conn: conn,
  83. table: "`i2bill_acquirer_student`",
  84. }
  85. }
  86. func (m *defaultI2billAcquirerStudentModel) Insert(data I2billAcquirerStudent) (sql.Result, error) {
  87. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?)", m.table, i2billAcquirerStudentRowsExpectAutoSet)
  88. 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)
  89. return ret, err
  90. }
  91. func (m *defaultI2billAcquirerStudentModel) FindOne(id int64) (*I2billAcquirerStudent, error) {
  92. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", i2billAcquirerStudentRows, m.table)
  93. var resp I2billAcquirerStudent
  94. err := m.conn.QueryRow(&resp, query, id)
  95. switch err {
  96. case nil:
  97. return &resp, nil
  98. case sqlc.ErrNotFound:
  99. return nil, ErrNotFound
  100. default:
  101. return nil, err
  102. }
  103. }
  104. func (m *defaultI2billAcquirerStudentModel) Update(data I2billAcquirerStudent) error {
  105. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, i2billAcquirerStudentRowsWithPlaceHolder)
  106. _, 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)
  107. return err
  108. }
  109. func (m *defaultI2billAcquirerStudentModel) Delete(id int64) error {
  110. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  111. _, err := m.conn.Exec(query, id)
  112. return err
  113. }