55 "log"
66 "net/http"
77 "os"
8- "strconv"
98
109 "com.lc.go.codepush/server/config"
1110 "com.lc.go.codepush/server/db/redis"
@@ -32,7 +31,7 @@ type createAppReq struct {
3231func (App ) CreateApp (ctx * gin.Context ) {
3332 createAppInfo := createAppReq {}
3433 if err := ctx .ShouldBindBodyWith (& createAppInfo , binding .JSON ); err == nil {
35- uid , _ := strconv . Atoi ( ctx .MustGet (constants .GIN_USER_ID ).(string ) )
34+ uid := ctx .MustGet (constants .GIN_USER_ID ).(int )
3635 oldApp := model.App {}.GetAppByUidAndAppName (uid , * createAppInfo .AppName )
3736 if oldApp != nil {
3837 log .Panic ("AppName " + * createAppInfo .AppName + " exist" )
@@ -67,7 +66,7 @@ type createBundleReq struct {
6766func (App ) CreateBundle (ctx * gin.Context ) {
6867 createBundleReq := createBundleReq {}
6968 if err := ctx .ShouldBindBodyWith (& createBundleReq , binding .JSON ); err == nil {
70- uid , _ := strconv . Atoi ( ctx .MustGet (constants .GIN_USER_ID ).(string ) )
69+ uid := ctx .MustGet (constants .GIN_USER_ID ).(int )
7170
7271 app := model.App {}.GetAppByUidAndAppName (uid , * createBundleReq .AppName )
7372 if app == nil {
@@ -136,7 +135,7 @@ type createDeploymentInfo struct {
136135func (App ) CreateDeployment (ctx * gin.Context ) {
137136 createDeploymentInfo := createDeploymentInfo {}
138137 if err := ctx .ShouldBindBodyWith (& createDeploymentInfo , binding .JSON ); err == nil {
139- uid , _ := strconv . Atoi ( ctx .MustGet (constants .GIN_USER_ID ).(string ) )
138+ uid := ctx .MustGet (constants .GIN_USER_ID ).(int )
140139 app := model.App {}.GetAppByUidAndAppName (uid , * createDeploymentInfo .AppName )
141140 if app == nil {
142141 log .Panic ("App not found" )
@@ -260,7 +259,7 @@ type deploymentInfo struct {
260259func (App ) LsDeployment (ctx * gin.Context ) {
261260 lsAppReq := lsDeploymentReq {}
262261 if err := ctx .ShouldBindBodyWith (& lsAppReq , binding .JSON ); err == nil {
263- uid , _ := strconv . Atoi ( ctx .MustGet (constants .GIN_USER_ID ).(string ) )
262+ uid := ctx .MustGet (constants .GIN_USER_ID ).(int )
264263 app := model.App {}.GetAppByUidAndAppName (uid , * lsAppReq .AppName )
265264 if app == nil {
266265 log .Panic ("App not found" )
@@ -301,7 +300,7 @@ func (App) LsDeployment(ctx *gin.Context) {
301300}
302301
303302func (App ) LsApp (ctx * gin.Context ) {
304- uid , _ := strconv . Atoi ( ctx .MustGet (constants .GIN_USER_ID ).(string ) )
303+ uid := ctx .MustGet (constants .GIN_USER_ID ).(int )
305304 apps := model .GetList [model.App ]("uid=?" , uid )
306305 if len (* apps ) <= 0 {
307306 log .Panic ("No app" )
@@ -322,7 +321,7 @@ type checkBundleReq struct {
322321func (App ) CheckBundle (ctx * gin.Context ) {
323322 checkBundleReq := checkBundleReq {}
324323 if err := ctx .ShouldBindBodyWith (& checkBundleReq , binding .JSON ); err == nil {
325- uid , _ := strconv . Atoi ( ctx .MustGet (constants .GIN_USER_ID ).(string ) )
324+ uid := ctx .MustGet (constants .GIN_USER_ID ).(int )
326325
327326 app := model.App {}.GetAppByUidAndAppName (uid , * checkBundleReq .AppName )
328327 if app == nil {
0 commit comments