Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

44 lines
1.0 KiB
Go

package locationser
import (
"91porn-server/models/v/locmod"
"91porn-server/models/v/vidmod"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// CityPages CityPages
func CityPages(city string, page, size uint64) (locmod.CityPageResp, error) {
var resp locmod.CityPageResp
lModel, total, err := locmod.GetLocationList(city, page, size)
if err != nil {
return resp, err
}
lmodelLen := len(lModel)
tids := make([]primitive.ObjectID, lmodelLen)
for i, l := range lModel {
tids[i] = l.ID
}
mPlayCnt, err := vidmod.GetCityPlayCount2Map(tids)
if err != nil {
return resp, err
}
mVideosCnt, _ := vidmod.GetCityPublishedVideoCount2Map(tids)
resp.List = make([]locmod.LocInfo, lmodelLen)
for i, l := range lModel {
resp.List[i] = locmod.LocInfo{
ID: l.ID.Hex(),
City: l.City,
Cover: l.Cover,
Visit: l.Visit,
FakeVisit: l.FakeVisit,
SortKey: l.SortKey,
CreatedAt: l.CreatedAt,
VideoCount: mVideosCnt[l.ID],
PlayCount: mPlayCnt[l.ID],
}
}
resp.Total = int(total)
return resp, nil
}