MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / ListApis

Method ListApis

internal/repository/dao/api.go:108–127  ·  view source on GitHub ↗

ListApis 分页获取API列表

(ctx context.Context, page, pageSize int)

Source from the content-addressed store, hash-verified

106
107// ListApis 分页获取API列表
108func (a *apiDAO) ListApis(ctx context.Context, page, pageSize int) ([]*Api, int, error) {
109 var apis []*Api
110 var total int64
111
112 // 构建基础查询
113 db := a.db.WithContext(ctx).Model(&Api{}).Where("is_deleted = 0")
114
115 // 获取总数
116 if err := db.Count(&total).Error; err != nil {
117 return nil, 0, err
118 }
119
120 // 获取分页数据
121 offset := (page - 1) * pageSize
122 if err := db.Offset(offset).Limit(pageSize).Order("id ASC").Find(&apis).Error; err != nil {
123 return nil, 0, err
124 }
125
126 return apis, int(total), nil
127}

Callers

nothing calls this directly

Calls 2

CountMethod · 0.65
LimitMethod · 0.65

Tested by

no test coverage detected