| 1234567891011121314151617181920212223242526272829303132333435 |
- package model
- import (
- "fmt"
- "github.com/zeromicro/go-zero/core/stores/sqlx"
- )
- var _ CbMsgModel = (*customCbMsgModel)(nil)
- type (
- // CbMsgModel is an interface to be customized, add more methods here,
- // and implement the added methods in customCbMsgModel.
- CbMsgModel interface {
- cbMsgModel
- GetCustomerLastMsg(openKfid, externalUserid string) (CbMsg, error)
- }
- customCbMsgModel struct {
- *defaultCbMsgModel
- }
- )
- // NewCbMsgModel returns a model for the database table.
- func NewCbMsgModel(conn sqlx.SqlConn) CbMsgModel {
- return &customCbMsgModel{
- defaultCbMsgModel: newCbMsgModel(conn),
- }
- }
- func (c *customCbMsgModel) GetCustomerLastMsg(openKfid, externalUserid string) (msg CbMsg, err error) {
- query := fmt.Sprintf("select * from %s where id IN (select MAX(id) from %s where `open_kfid` = ? AND `external_userid` = ?)", c.table, c.table)
- err = c.conn.QueryRow(&msg, query, openKfid, externalUserid)
- return
- }
|