cbstaffmodel.go 902 B

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