|
@@ -30,15 +30,19 @@ func GetVersion(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
}
|
|
|
|
|
|
func VersionLatest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
- version := &model.Versions{}
|
|
|
- ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
|
+ out, err := repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
CollectName: repo.CollectionVersions,
|
|
|
- Sort: bson.M{"createTime": -1},
|
|
|
- }, version)
|
|
|
- if !ok || err != nil {
|
|
|
- return nil, errors.New("未找到数据")
|
|
|
+ Page: 1,
|
|
|
+ Size: 1,
|
|
|
+ Sort: bson.D{bson.E{Key: "createTime", Value: -1}},
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return map[string]interface{}{}, nil
|
|
|
+ }
|
|
|
+ if len(out.List) < 1 {
|
|
|
+ return map[string]interface{}{}, nil
|
|
|
}
|
|
|
- c.JSON(http.StatusOK, version)
|
|
|
+ c.JSON(http.StatusOK, out.List[0])
|
|
|
return nil, nil
|
|
|
}
|
|
|
|