| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package model
- import (
- "fmt"
- "github.com/zeromicro/go-zero/core/stores/sqlx"
- )
- var _ CbCustomerModel = (*customCbCustomerModel)(nil)
- type (
- // CbCustomerModel is an interface to be customized, add more methods here,
- // and implement the added methods in customCbCustomerModel.
- CbCustomerModel interface {
- cbCustomerModel
- GetCustomerByExternalUserid(openKfid, externalUserid string) (d *CbCustomer, err error)
- GetCustomerByPage(page, size int) (list []CbCustomer, err error)
- UpdateServiceState(openKfid, externalUserid string, state int) (err error)
- }
- customCbCustomerModel struct {
- *defaultCbCustomerModel
- }
- )
- // NewCbCustomerModel returns a model for the database table.
- func NewCbCustomerModel(conn sqlx.SqlConn) CbCustomerModel {
- return &customCbCustomerModel{
- defaultCbCustomerModel: newCbCustomerModel(conn),
- }
- }
- func (m *customCbCustomerModel) GetCustomerByExternalUserid(openKfid, externalUserid string) (d *CbCustomer, err error) {
- query := fmt.Sprintf("select * from %s where `open_kfid` = ? AND `external_userid` = ? limit 1", m.table)
- var resp CbCustomer
- err = m.conn.QueryRow(&resp, query, openKfid, externalUserid)
- d = &resp
- return
- }
- func (m *customCbCustomerModel) UpdateServiceState(openKfid, externalUserid string, state int) (err error) {
- query := fmt.Sprintf("update %s set `service_state` = ? where `open_kfid` = ? AND `external_userid` = ?", m.table)
- _, err = m.conn.Exec(query, state, openKfid, externalUserid)
- return err
- }
- func (m *customCbCustomerModel) GetCustomerByPage(page, size int) (list []CbCustomer, err error) {
- query := fmt.Sprintf("select * from %s where service_state != 4 limit ?,?", m.table)
- err = m.conn.QueryRows(&list, query, (page-1)*size, size)
- return
- }
|