cbcustomermodel.go 986 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package model
  2. import (
  3. "fmt"
  4. "github.com/zeromicro/go-zero/core/stores/sqlx"
  5. )
  6. var _ CbCustomerModel = (*customCbCustomerModel)(nil)
  7. type (
  8. // CbCustomerModel is an interface to be customized, add more methods here,
  9. // and implement the added methods in customCbCustomerModel.
  10. CbCustomerModel interface {
  11. cbCustomerModel
  12. GetCustomerByExternalUserid(externalUserid string) (d *CbCustomer, err error)
  13. }
  14. customCbCustomerModel struct {
  15. *defaultCbCustomerModel
  16. }
  17. )
  18. // NewCbCustomerModel returns a model for the database table.
  19. func NewCbCustomerModel(conn sqlx.SqlConn) CbCustomerModel {
  20. return &customCbCustomerModel{
  21. defaultCbCustomerModel: newCbCustomerModel(conn),
  22. }
  23. }
  24. func (m *customCbCustomerModel) GetCustomerByExternalUserid(externalUserid string) (d *CbCustomer, err error) {
  25. query := fmt.Sprintf("select * from %s where `external_userid` = ? limit 1", m.table)
  26. var resp CbCustomer
  27. err = m.conn.QueryRow(&resp, query, externalUserid)
  28. d = &resp
  29. return
  30. }