|
@@ -5,7 +5,6 @@ import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
|
|
- "git.i2edu.net/i2/go-zero/core/stores/cache"
|
|
|
|
|
"git.i2edu.net/i2/go-zero/core/stores/sqlc"
|
|
"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/stores/sqlx"
|
|
|
"git.i2edu.net/i2/go-zero/core/stringx"
|
|
"git.i2edu.net/i2/go-zero/core/stringx"
|
|
@@ -17,8 +16,6 @@ var (
|
|
|
I2billAcquirerStudentRows = strings.Join(I2billAcquirerStudentFieldNames, ",")
|
|
I2billAcquirerStudentRows = strings.Join(I2billAcquirerStudentFieldNames, ",")
|
|
|
I2billAcquirerStudentRowsExpectAutoSet = strings.Join(stringx.Remove(I2billAcquirerStudentFieldNames, "`create_time`", "`update_time`"), ",")
|
|
I2billAcquirerStudentRowsExpectAutoSet = strings.Join(stringx.Remove(I2billAcquirerStudentFieldNames, "`create_time`", "`update_time`"), ",")
|
|
|
I2billAcquirerStudentRowsWithPlaceHolder = strings.Join(stringx.Remove(I2billAcquirerStudentFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
|
I2billAcquirerStudentRowsWithPlaceHolder = strings.Join(stringx.Remove(I2billAcquirerStudentFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
|
|
-
|
|
|
|
|
- cacheI2billAcquirerStudentIdPrefix = "cache:i2billAcquirerStudent:id:"
|
|
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
type (
|
|
@@ -30,51 +27,47 @@ type (
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
defaultI2billAcquirerStudentModel struct {
|
|
defaultI2billAcquirerStudentModel struct {
|
|
|
- sqlc.CachedConn
|
|
|
|
|
|
|
+ conn sqlx.SqlConn
|
|
|
table string
|
|
table string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
I2billAcquirerStudent struct {
|
|
I2billAcquirerStudent struct {
|
|
|
- StuPhone sql.NullString `db:"stu_phone"` // 联系方式
|
|
|
|
|
- SchId sql.NullInt64 `db:"sch_id"` // 意向校区
|
|
|
|
|
- DelFlag sql.NullString `db:"del_flag"`
|
|
|
|
|
- CheckState sql.NullInt64 `db:"check_state"` // 收单宝状态
|
|
|
|
|
- UserId sql.NullInt64 `db:"user_id"` // 收单宝用户id
|
|
|
|
|
- StuLinkPerson sql.NullString `db:"stu_link_person"` // 联系人
|
|
|
|
|
- CheckTime sql.NullTime `db:"check_time"` // 审核日期
|
|
|
|
|
- CheckBy sql.NullString `db:"check_by"` // 审核人
|
|
|
|
|
- AgeGroup string `db:"age_group"` // 学员年龄
|
|
|
|
|
- Address sql.NullString `db:"address"` // 当前位置
|
|
|
|
|
- CreateTime sql.NullTime `db:"create_time"`
|
|
|
|
|
- Id int64 `db:"id"` // 主键
|
|
|
|
|
- PartTimeUserId sql.NullInt64 `db:"part_time_user_id"`
|
|
|
|
|
- NetworkDetailId sql.NullString `db:"network_detail_id"` // 渠道
|
|
|
|
|
- MkId sql.NullString `db:"mk_id"` // 所属mk erp id
|
|
|
|
|
- StuName sql.NullString `db:"stu_name"` // 学员名称
|
|
|
|
|
|
|
+ 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, c cache.CacheConf) I2billAcquirerStudentModel {
|
|
|
|
|
|
|
+func NewI2billAcquirerStudentModel(conn sqlx.SqlConn) I2billAcquirerStudentModel {
|
|
|
return &defaultI2billAcquirerStudentModel{
|
|
return &defaultI2billAcquirerStudentModel{
|
|
|
- CachedConn: sqlc.NewConn(conn, c),
|
|
|
|
|
- table: "`i2bill_acquirer_student`",
|
|
|
|
|
|
|
+ conn: conn,
|
|
|
|
|
+ table: "`i2bill_acquirer_student`",
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultI2billAcquirerStudentModel) Insert(data I2billAcquirerStudent) (sql.Result, error) {
|
|
func (m *defaultI2billAcquirerStudentModel) Insert(data I2billAcquirerStudent) (sql.Result, error) {
|
|
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, I2billAcquirerStudentRowsExpectAutoSet)
|
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, I2billAcquirerStudentRowsExpectAutoSet)
|
|
|
- ret, err := m.ExecNoCache(query, data.StuPhone, data.SchId, data.DelFlag, data.CheckState, data.UserId, data.StuLinkPerson, data.CheckTime, data.CheckBy, data.AgeGroup, data.Address, data.Id, data.PartTimeUserId, data.NetworkDetailId, data.MkId, data.StuName)
|
|
|
|
|
-
|
|
|
|
|
|
|
+ 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
|
|
return ret, err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultI2billAcquirerStudentModel) FindOne(id int64) (*I2billAcquirerStudent, error) {
|
|
func (m *defaultI2billAcquirerStudentModel) FindOne(id int64) (*I2billAcquirerStudent, error) {
|
|
|
- i2billAcquirerStudentIdKey := fmt.Sprintf("%s%v", cacheI2billAcquirerStudentIdPrefix, id)
|
|
|
|
|
|
|
+ query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", I2billAcquirerStudentRows, m.table)
|
|
|
var resp I2billAcquirerStudent
|
|
var resp I2billAcquirerStudent
|
|
|
- err := m.QueryRow(&resp, i2billAcquirerStudentIdKey, func(conn sqlx.SqlConn, v interface{}) error {
|
|
|
|
|
- query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", I2billAcquirerStudentRows, m.table)
|
|
|
|
|
- return conn.QueryRow(v, query, id)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ err := m.conn.QueryRow(&resp, query, id)
|
|
|
switch err {
|
|
switch err {
|
|
|
case nil:
|
|
case nil:
|
|
|
return &resp, nil
|
|
return &resp, nil
|
|
@@ -86,29 +79,13 @@ func (m *defaultI2billAcquirerStudentModel) FindOne(id int64) (*I2billAcquirerSt
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultI2billAcquirerStudentModel) Update(data I2billAcquirerStudent) error {
|
|
func (m *defaultI2billAcquirerStudentModel) Update(data I2billAcquirerStudent) error {
|
|
|
- i2billAcquirerStudentIdKey := fmt.Sprintf("%s%v", cacheI2billAcquirerStudentIdPrefix, data.Id)
|
|
|
|
|
- _, err := m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
|
|
|
|
|
- query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, I2billAcquirerStudentRowsWithPlaceHolder)
|
|
|
|
|
- return conn.Exec(query, data.StuPhone, data.SchId, data.DelFlag, data.CheckState, data.UserId, data.StuLinkPerson, data.CheckTime, data.CheckBy, data.AgeGroup, data.Address, data.PartTimeUserId, data.NetworkDetailId, data.MkId, data.StuName, data.Id)
|
|
|
|
|
- }, i2billAcquirerStudentIdKey)
|
|
|
|
|
|
|
+ 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
|
|
return err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultI2billAcquirerStudentModel) Delete(id int64) error {
|
|
func (m *defaultI2billAcquirerStudentModel) Delete(id int64) error {
|
|
|
-
|
|
|
|
|
- i2billAcquirerStudentIdKey := fmt.Sprintf("%s%v", cacheI2billAcquirerStudentIdPrefix, id)
|
|
|
|
|
- _, err := m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
|
|
|
|
|
- query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
|
|
|
|
- return conn.Exec(query, id)
|
|
|
|
|
- }, i2billAcquirerStudentIdKey)
|
|
|
|
|
|
|
+ query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
|
|
|
|
+ _, err := m.conn.Exec(query, id)
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-func (m *defaultI2billAcquirerStudentModel) formatPrimary(primary interface{}) string {
|
|
|
|
|
- return fmt.Sprintf("%s%v", cacheI2billAcquirerStudentIdPrefix, primary)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (m *defaultI2billAcquirerStudentModel) queryPrimary(conn sqlx.SqlConn, v, primary interface{}) error {
|
|
|
|
|
- query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", I2billAcquirerStudentRows, m.table)
|
|
|
|
|
- return conn.QueryRow(v, query, primary)
|
|
|
|
|
-}
|
|
|