5
5
"log"
6
6
"net/http"
7
7
"os"
8
- "strconv"
9
8
10
9
"com.lc.go.codepush/server/config"
11
10
"com.lc.go.codepush/server/db/redis"
@@ -32,7 +31,7 @@ type createAppReq struct {
32
31
func (App ) CreateApp (ctx * gin.Context ) {
33
32
createAppInfo := createAppReq {}
34
33
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 )
36
35
oldApp := model.App {}.GetAppByUidAndAppName (uid , * createAppInfo .AppName )
37
36
if oldApp != nil {
38
37
log .Panic ("AppName " + * createAppInfo .AppName + " exist" )
@@ -67,7 +66,7 @@ type createBundleReq struct {
67
66
func (App ) CreateBundle (ctx * gin.Context ) {
68
67
createBundleReq := createBundleReq {}
69
68
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 )
71
70
72
71
app := model.App {}.GetAppByUidAndAppName (uid , * createBundleReq .AppName )
73
72
if app == nil {
@@ -136,7 +135,7 @@ type createDeploymentInfo struct {
136
135
func (App ) CreateDeployment (ctx * gin.Context ) {
137
136
createDeploymentInfo := createDeploymentInfo {}
138
137
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 )
140
139
app := model.App {}.GetAppByUidAndAppName (uid , * createDeploymentInfo .AppName )
141
140
if app == nil {
142
141
log .Panic ("App not found" )
@@ -260,7 +259,7 @@ type deploymentInfo struct {
260
259
func (App ) LsDeployment (ctx * gin.Context ) {
261
260
lsAppReq := lsDeploymentReq {}
262
261
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 )
264
263
app := model.App {}.GetAppByUidAndAppName (uid , * lsAppReq .AppName )
265
264
if app == nil {
266
265
log .Panic ("App not found" )
@@ -301,7 +300,7 @@ func (App) LsDeployment(ctx *gin.Context) {
301
300
}
302
301
303
302
func (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 )
305
304
apps := model .GetList [model.App ]("uid=?" , uid )
306
305
if len (* apps ) <= 0 {
307
306
log .Panic ("No app" )
@@ -322,7 +321,7 @@ type checkBundleReq struct {
322
321
func (App ) CheckBundle (ctx * gin.Context ) {
323
322
checkBundleReq := checkBundleReq {}
324
323
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 )
326
325
327
326
app := model.App {}.GetAppByUidAndAppName (uid , * checkBundleReq .AppName )
328
327
if app == nil {
0 commit comments