package db import ( "applet/app/db/model" "applet/app/utils" "xorm.io/xorm" ) func GetStoreQrcode(eg *xorm.Engine, args map[string]string) (*[]model.CommunityTeamStoreQrcode, int64) { var data []model.CommunityTeamStoreQrcode sess := eg.Where("uid=?", args["uid"]) size := utils.StrToInt(args["size"]) start := (utils.StrToInt(args["p"]) - 1) * size total, err := sess.Limit(size, start).Desc("id").FindAndCount(&data) if err != nil { return nil, total } return &data, total } func GetStoreQrcodeById(eg *xorm.Engine, id string) *model.CommunityTeamStoreQrcode { var data model.CommunityTeamStoreQrcode get, err := eg.Where("id=?", id).Get(&data) if get == false || err != nil { return nil } return &data } func GetStorePayQrcodeByUid(eg *xorm.Engine, uid int) *model.CommunityTeamStorePayQrcode { var data model.CommunityTeamStorePayQrcode get, err := eg.Where("uid=?", uid).Get(&data) if get == false { data = model.CommunityTeamStorePayQrcode{ Uid: uid, IsUse: 1, Name: "收款码", } eg.Insert(&data) } if err != nil { return nil } return &data }