diff options
| author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2025-10-11 20:55:48 +0530 | 
|---|---|---|
| committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2025-10-11 20:55:48 +0530 | 
| commit | bc154857fb5569d7c1fa9785cc891cb927a6a156 (patch) | |
| tree | 590c9f6a00a1b97b2ee45cfa5a767558089affe0 /item/controller.go | |
| parent | 8a47978ca17d2f251d67d12b0e34fa26bb1e4ace (diff) | |
removed per-user itemsv0.17.0
Diffstat (limited to 'item/controller.go')
| -rw-r--r-- | item/controller.go | 101 | 
1 files changed, 5 insertions, 96 deletions
diff --git a/item/controller.go b/item/controller.go index 9993688..bb2eb94 100644 --- a/item/controller.go +++ b/item/controller.go @@ -31,17 +31,8 @@ func handleGetBrandItems (ctx *gin.Context) {  		return  	} -	uId, ok := ctx.Get("UserID") -	if !ok { -		ctx.Error(e.ErrUnauthorized) -		ctx.Abort() -		return -	} - -	userId := uId.(uint) -  	var items []SavedItem -	err = getBrandItems(&items, uint(id), userId) +	err = getBrandItems(&items, uint(id))  	if err != nil {  		ctx.Error(err)  		ctx.Abort() @@ -49,7 +40,6 @@ func handleGetBrandItems (ctx *gin.Context) {  	}  	ctx.JSON(http.StatusOK, gin.H{ -		"message": "success",  		"data": items,  	})  } @@ -57,16 +47,7 @@ func handleGetBrandItems (ctx *gin.Context) {  func handleGetBrands (ctx *gin.Context) {  	var brands []Brand -	uId, ok := ctx.Get("UserID") -	if !ok { -		ctx.Error(e.ErrUnauthorized) -		ctx.Abort() -		return -	} - -	userId := uId.(uint) - -	err := getBrands(&brands, userId) +	err := getBrands(&brands)  	if err != nil {  		ctx.Error(err)  		ctx.Abort() @@ -74,7 +55,6 @@ func handleGetBrands (ctx *gin.Context) {  	}  	ctx.JSON(http.StatusOK, gin.H{ -		"message": "success",  		"data": brands,  	})  } @@ -83,16 +63,6 @@ func handleSaveBrand (ctx *gin.Context) {  	var brand Brand  	ctx.Bind(&brand) -	uId, ok := ctx.Get("UserID") -	if !ok { -		ctx.Error(e.ErrUnauthorized) -		ctx.Abort() -		return -	} - -	userId := uId.(uint) -	brand.UserID = userId -  	err := brand.upsert()  	if err != nil {  		ctx.Error(err) @@ -101,7 +71,6 @@ func handleSaveBrand (ctx *gin.Context) {  	}  	ctx.JSON(http.StatusOK, gin.H{ -		"message": "success",  		"data": brand,  	})  } @@ -116,24 +85,6 @@ func handleDelBrand (ctx *gin.Context) {  	var brand Brand  	brand.ID = uint(id) - -	uId, ok := ctx.Get("UserID") -	if !ok { -		ctx.Error(e.ErrUnauthorized) -		ctx.Abort() -		return -	} - -	userId := uId.(uint) -	brand.UserID = userId - -	err = checkBrandOwnership(brand.ID, brand.UserID) -	if err != nil { -		ctx.Error(err) -		ctx.Abort() -		return -	} -  	err = brand.del()  	if err != nil {  		ctx.Error(err) @@ -141,24 +92,13 @@ func handleDelBrand (ctx *gin.Context) {  		return  	} -	ctx.JSON(http.StatusOK, gin.H{ -		"message": "success", -	}) +	ctx.JSON(http.StatusOK, nil)  }  func handleGetItems (ctx *gin.Context) {  	var items []SavedItem -	uId, ok := ctx.Get("UserID") -	if !ok { -		ctx.Error(e.ErrUnauthorized) -		ctx.Abort() -		return -	} - -	userId := uId.(uint) - -	err := getItems(&items, userId) +	err := getItems(&items)  	if err != nil {  		ctx.Error(err)  		ctx.Abort() @@ -166,7 +106,6 @@ func handleGetItems (ctx *gin.Context) {  	}  	ctx.JSON(http.StatusOK, gin.H{ -		"message": "success",  		"data": items,  	})  } @@ -175,16 +114,6 @@ func handleSaveItem (ctx *gin.Context) {  	var item SavedItem  	ctx.Bind(&item) -	uId, ok := ctx.Get("UserID") -	if !ok { -		ctx.Error(e.ErrUnauthorized) -		ctx.Abort() -		return -	} - -	userId := uId.(uint) -	item.UserID = userId -  	err := item.upsert()  	if err != nil {  		ctx.Error(err) @@ -193,7 +122,6 @@ func handleSaveItem (ctx *gin.Context) {  	}  	ctx.JSON(http.StatusOK, gin.H{ -		"message": "success",  		"data": item,  	})  } @@ -208,23 +136,6 @@ func handleDelItem (ctx *gin.Context) {  	var item SavedItem  	item.ID = uint(id) -	uId, ok := ctx.Get("UserID") -	if !ok { -		ctx.Error(e.ErrUnauthorized) -		ctx.Abort() -		return -	} - -	userId := uId.(uint) -	item.UserID = userId - -	err = checkItemOwnership(item.ID, item.UserID) -	if err != nil { -		ctx.Error(err) -		ctx.Abort() -		return -	} -  	err = item.del()  	if err != nil {  		ctx.Error(err) @@ -232,7 +143,5 @@ func handleDelItem (ctx *gin.Context) {  		return  	} -	ctx.JSON(http.StatusOK, gin.H{ -		"message": "success", -	}) +	ctx.JSON(http.StatusOK, nil)  }  |