|
@@ -1,10 +1,12 @@
|
|
|
package api
|
|
|
|
|
|
import (
|
|
|
+ "cr-svc/conf"
|
|
|
"cr-svc/db/model"
|
|
|
"cr-svc/db/repo"
|
|
|
"cr-svc/log"
|
|
|
"errors"
|
|
|
+ "fmt"
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
@@ -20,12 +22,22 @@ func Version(r *GinRouter) {
|
|
|
|
|
|
func GetVersion(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
page, size, query := UtilQueryPageSize(c)
|
|
|
- return repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
+ result, err := repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
CollectName: repo.CollectionVersions,
|
|
|
Page: page,
|
|
|
Size: size,
|
|
|
Query: query,
|
|
|
})
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if len(result.List) > 0 {
|
|
|
+ for _, v := range result.List {
|
|
|
+ url := v["url"]
|
|
|
+ v["url"] = fmt.Sprintf("http://%s:%d%s", conf.AppConfig.MasterIp, conf.AppConfig.ServerPort, url)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result.List, nil
|
|
|
}
|
|
|
|
|
|
func VersionLatest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
@@ -41,7 +53,10 @@ func VersionLatest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
if len(out.List) < 1 {
|
|
|
return map[string]interface{}{}, nil
|
|
|
}
|
|
|
- return out.List[0], nil
|
|
|
+ latestVersion := out.List[0]
|
|
|
+ url := out.List[0]["url"]
|
|
|
+ latestVersion["url"] = fmt.Sprintf("http://%s:%d%s", conf.AppConfig.MasterIp, conf.AppConfig.ServerPort, url)
|
|
|
+ return latestVersion, nil
|
|
|
}
|
|
|
|
|
|
func UpdateVersion(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|