open_api_user.go 932 B

12345678910111213141516171819202122
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type OpenApiUser struct {
  6. Appid string `orm:"column(appid);pk" json:"appid" description:"开放平台appid"`
  7. Secret string `orm:"column(secret);" json:"secret" description:"开放平台秘钥"`
  8. Ip string `orm:"column(ip);" json:"ip" description:"限制请求来源ip,多个ip用英文,隔开"`
  9. Remark string `orm:"column(remark);" json:"remark" description:"备注信息"`
  10. CreateTime string `orm:"column(create_time);" json:"create_time" description:"创建时间"`
  11. ModifyTime string `orm:"column(modify_time);" json:"modify_time" description:"最近一次更新时间"`
  12. }
  13. // GetByAppid 根据appid获取开放api用户信息
  14. func GetByAppid(appid string) (item *OpenApiUser, err error) {
  15. sql := `SELECT * FROM open_api_user WHERE appid=? LIMIT 1`
  16. o := orm.NewOrmUsingDB("weekly")
  17. err = o.Raw(sql, appid).QueryRow(&item)
  18. return
  19. }