update
This commit is contained in:
@@ -28,6 +28,7 @@ func (h *Handler) Route(group *gin.RouterGroup, jwt gin.HandlerFunc) {
|
||||
route.PUT("/:id", jwt, isSuperAdmin, h.Update)
|
||||
route.GET("/:id", jwt, isSuperAdmin, h.GetByID)
|
||||
route.DELETE("/:id", jwt, isSuperAdmin, h.Delete)
|
||||
route.PUT("/update", jwt, h.UpdateMyStore)
|
||||
}
|
||||
|
||||
func NewHandler(service services.Partner) *Handler {
|
||||
@@ -268,3 +269,27 @@ func (h *Handler) toPartnerResponseList(resp []*entity.Partner, total int64, req
|
||||
Offset: req.Offset,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) UpdateMyStore(c *gin.Context) {
|
||||
ctx := request.GetMyContext(c)
|
||||
|
||||
PartnerID := ctx.GetPartnerID()
|
||||
|
||||
var req request.Partner
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.ErrorWrapper(c, errors.ErrorBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
updatedPartner, err := h.service.Update(ctx, req.ToEntityUpdate(*PartnerID))
|
||||
if err != nil {
|
||||
response.ErrorWrapper(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, response.BaseResponse{
|
||||
Success: true,
|
||||
Status: http.StatusOK,
|
||||
Data: h.toPartnerResponse(updatedPartner),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user