| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package model
- import (
- "database/sql"
- "fmt"
- "strings"
- "git.i2edu.net/i2/go-zero/core/stores/sqlc"
- "git.i2edu.net/i2/go-zero/core/stores/sqlx"
- "git.i2edu.net/i2/go-zero/core/stringx"
- "git.i2edu.net/i2/go-zero/tools/goctl/model/sql/builderx"
- )
- var (
- I2billAcquirerStudentFieldNames = builderx.RawFieldNames(&I2billAcquirerStudent{})
- I2billAcquirerStudentRows = strings.Join(I2billAcquirerStudentFieldNames, ",")
- I2billAcquirerStudentRowsExpectAutoSet = strings.Join(stringx.Remove(I2billAcquirerStudentFieldNames, "`create_time`", "`update_time`"), ",")
- I2billAcquirerStudentRowsWithPlaceHolder = strings.Join(stringx.Remove(I2billAcquirerStudentFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
- )
- type (
- I2billAcquirerStudentModel interface {
- Insert(data I2billAcquirerStudent) (sql.Result, error)
- FindOne(id int64) (*I2billAcquirerStudent, error)
- Update(data I2billAcquirerStudent) error
- Delete(id int64) error
- }
- defaultI2billAcquirerStudentModel struct {
- conn sqlx.SqlConn
- table string
- }
- I2billAcquirerStudent struct {
- AgeGroup string `db:"age_group" json:"age_group"` // 学员年龄
- StuPhone sql.NullString `db:"stu_phone" json:"stu_phone"` // 联系方式
- Address sql.NullString `db:"address" json:"address"` // 当前位置
- NetworkDetailId sql.NullString `db:"network_detail_id" json:"network_detail_id"` // 渠道
- Id int64 `db:"id" json:"id"` // 主键
- MkId sql.NullString `db:"mk_id" json:"mk_id"` // 所属mk erp id
- PartTimeUserId sql.NullInt64 `db:"part_time_user_id" json:"part_time_user_id"`
- DelFlag sql.NullString `db:"del_flag" json:"del_flag"`
- CheckBy sql.NullString `db:"check_by" json:"check_by"` // 审核人
- CheckState sql.NullInt64 `db:"check_state" json:"check_state"` // 收单宝状态
- CheckTime sql.NullTime `db:"check_time" json:"check_time"` // 审核日期
- UserId sql.NullInt64 `db:"user_id" json:"user_id"` // 收单宝用户id
- StuName sql.NullString `db:"stu_name" json:"stu_name"` // 学员名称
- StuLinkPerson sql.NullString `db:"stu_link_person" json:"stu_link_person"` // 联系人
- SchId sql.NullInt64 `db:"sch_id" json:"sch_id"` // 意向校区
- CreateTime sql.NullTime `db:"create_time" json:"create_time"`
- }
- )
- func NewI2billAcquirerStudentModel(conn sqlx.SqlConn) I2billAcquirerStudentModel {
- return &defaultI2billAcquirerStudentModel{
- conn: conn,
- table: "`i2bill_acquirer_student`",
- }
- }
- func (m *defaultI2billAcquirerStudentModel) Insert(data I2billAcquirerStudent) (sql.Result, error) {
- query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, I2billAcquirerStudentRowsExpectAutoSet)
- ret, err := m.conn.Exec(query, data.AgeGroup, data.StuPhone, data.Address, data.NetworkDetailId, data.Id, data.MkId, data.PartTimeUserId, data.DelFlag, data.CheckBy, data.CheckState, data.CheckTime, data.UserId, data.StuName, data.StuLinkPerson, data.SchId)
- return ret, err
- }
- func (m *defaultI2billAcquirerStudentModel) FindOne(id int64) (*I2billAcquirerStudent, error) {
- query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", I2billAcquirerStudentRows, m.table)
- var resp I2billAcquirerStudent
- err := m.conn.QueryRow(&resp, query, id)
- switch err {
- case nil:
- return &resp, nil
- case sqlc.ErrNotFound:
- return nil, ErrNotFound
- default:
- return nil, err
- }
- }
- func (m *defaultI2billAcquirerStudentModel) Update(data I2billAcquirerStudent) error {
- query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, I2billAcquirerStudentRowsWithPlaceHolder)
- _, err := m.conn.Exec(query, data.AgeGroup, data.StuPhone, data.Address, data.NetworkDetailId, data.MkId, data.PartTimeUserId, data.DelFlag, data.CheckBy, data.CheckState, data.CheckTime, data.UserId, data.StuName, data.StuLinkPerson, data.SchId, data.Id)
- return err
- }
- func (m *defaultI2billAcquirerStudentModel) Delete(id int64) error {
- query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
- _, err := m.conn.Exec(query, id)
- return err
- }
|