package db import ( "applet/app/db/model" "applet/app/utils/logx" "xorm.io/xorm" ) type AgentBase struct { Session *xorm.Session AgentBase *model.RegionalAgentBase } func NewAgentBase(session *xorm.Session, agentBase *model.RegionalAgentBase) *AgentBase { return &AgentBase{ Session: session, AgentBase: agentBase, } } func (a AgentBase) GetAgentBaseInfo() bool { isHas, err := a.Session.Get(a.AgentBase) if err != nil { return false } if !isHas { return false } return true } // GetCountByRegionalAgentBase 通过传入的参数查询数据(单条) func GetCountByRegionalAgentBase(Db *xorm.Engine) (*model.RegionalAgentBase, error) { var m model.RegionalAgentBase get, err := Db.Get(&m) if err != nil { return &m, err } if !get { return &m, logx.Warn("Not found") } return &m, nil }