58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package apis
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"gitlink.org.cn/JointCloud/pcm-openi/common"
|
|
"gitlink.org.cn/JointCloud/pcm-openi/model"
|
|
"net/http"
|
|
)
|
|
|
|
func GetRepos(ctx *gin.Context) {
|
|
token := ctx.Query(common.ACCESSTOKEN)
|
|
|
|
reqUrl := common.OPENIPREFIX + common.REPO
|
|
|
|
var resp []model.Repo
|
|
|
|
req := common.GetRestyRequest(common.TIMEOUT)
|
|
_, err := req.
|
|
SetQueryParam(common.ACCESSTOKEN, token).
|
|
SetResult(&resp).
|
|
Get(reqUrl)
|
|
|
|
if err != nil {
|
|
model.Response(ctx, 500, common.INVOKEERROR, err)
|
|
return
|
|
}
|
|
|
|
model.Response(ctx, http.StatusOK, common.SUCCESS, resp)
|
|
}
|
|
|
|
func CreateRepo(ctx *gin.Context) {
|
|
var param model.RepoCreateParam
|
|
if err := ctx.BindJSON(¶m); err != nil {
|
|
model.Response(ctx, http.StatusBadRequest, common.INVALIDPARAMS, err)
|
|
return
|
|
}
|
|
|
|
token := ctx.Query(common.ACCESSTOKEN)
|
|
|
|
reqUrl := common.OPENIPREFIX + common.REPO
|
|
|
|
var resp model.Repo
|
|
|
|
req := common.GetRestyRequest(common.TIMEOUT)
|
|
_, err := req.
|
|
SetQueryParam(common.ACCESSTOKEN, token).
|
|
SetBody(¶m).
|
|
SetResult(&resp).
|
|
Post(reqUrl)
|
|
|
|
if err != nil {
|
|
model.Response(ctx, 500, common.INVOKEERROR, err)
|
|
return
|
|
}
|
|
|
|
model.Response(ctx, http.StatusOK, common.SUCCESS, resp)
|
|
}
|