|
- package db
-
- import (
- "applet/app/db/model"
- "applet/app/utils"
- "xorm.io/xorm"
- )
-
- func GetGoodsCateAllArg(eg *xorm.Engine, arg map[string]string) *[]model.CommunityTeamCate {
- var data []model.CommunityTeamCate
- err := eg.Where("uid=? and store_type=?", arg["uid"], arg["store_type"]).OrderBy("sort desc,id desc").Find(&data)
- if err != nil {
- return nil
- }
- return &data
- }
- func GetGoodsCateAll(eg *xorm.Engine) *[]model.CommunityTeamCate {
- var data []model.CommunityTeamCate
- err := eg.Where("uid=0").OrderBy("sort desc,id desc").Find(&data)
- if err != nil {
- return nil
- }
- return &data
- }
- func GetGoodsCate(eg *xorm.Engine, req map[string]string) (*[]model.CommunityTeamCate, int64) {
- var data []model.CommunityTeamCate
- limit := utils.StrToInt(req["size"])
- start := (utils.StrToInt(req["p"]) - 1) * limit
- sess := eg.Where("uid=?", req["uid"]).OrderBy("sort desc,id desc").Limit(limit, start)
- if req["title"] != "" {
- sess.And("title like ?", "%"+req["title"]+"%")
- }
- if req["store_type"] != "" {
- sess.And("store_type=?", req["store_type"])
- }
- count, err := sess.FindAndCount(&data)
- if err != nil {
- return nil, count
- }
- return &data, count
- }
-
- func GetGoodsCateById(eg *xorm.Engine, id string) *model.CommunityTeamCate {
- var data model.CommunityTeamCate
- get, err := eg.Where("id=?", id).Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
- }
|