From 403374b80743f015e782871ed69ddc8d0c3e160c Mon Sep 17 00:00:00 2001 From: armadamuhammad <armada_muhammad@student.uns.ac.id> Date: Mon, 8 Aug 2022 20:20:23 +0700 Subject: [PATCH] enable --- app/controller/setting/enable_put.go | 299 ++++++++++++ app/controller/setting/user_make_admin_put.go | 6 +- app/model/base.go | 3 + app/routes/router.go | 6 + docs/swagger-dev.yaml | 302 ++++++++++++ docs/swagger-local.yaml | 302 ++++++++++++ docs/swagger-stg.yaml | 302 ++++++++++++ docs/swagger.json | 448 ++++++++++++++++++ docs/swagger.yaml | 302 ++++++++++++ 9 files changed, 1969 insertions(+), 1 deletion(-) create mode 100644 app/controller/setting/enable_put.go diff --git a/app/controller/setting/enable_put.go b/app/controller/setting/enable_put.go new file mode 100644 index 0000000..20d93e7 --- /dev/null +++ b/app/controller/setting/enable_put.go @@ -0,0 +1,299 @@ +package setting + +import ( + "api/app/controller/user" + "api/app/lib" + "api/app/model" + "api/app/services" + + "github.com/gofiber/fiber/v2" + "github.com/google/uuid" +) + +// PutBalanceEnable godoc +// @Summary Update status Balance by id +// @Description Update Balance by id +// @Param X-User-ID header string false "User ID" +// @Param id path string true "Balance ID" +// @Accept application/json +// @Produce application/json +// @Success 200 {object} model.Balance "Balance data" +// @Failure 400 {object} lib.Response +// @Failure 404 {object} lib.Response +// @Failure 409 {object} lib.Response +// @Failure 500 {object} lib.Response +// @Failure default {object} lib.Response +// @Router /settings/balance/{id}/enable [put] +// @Tags Setting +func PutBalanceEnable(c *fiber.Ctx) error { + db := services.DB + id, _ := uuid.Parse(c.Params("id")) + + userID := lib.GetXUserID(c) + ver, _ := user.GetUserData(userID) + if *ver.Super != 1 { + return lib.ErrorUnauthorized(c) + } + + var data model.Balance + result := db.Model(&data). + Where(db.Where(model.Balance{ + Base: model.Base{ + ID: &id, + }, + })).First(&data) + + if result.RowsAffected < 1 { + return lib.ErrorNotFound(c) + } + + if *data.Status == 1 { + data.Status = lib.Intptr(0) + } else { + data.Status = lib.Intptr(1) + } + if err := db.Model(&data).Updates(&data).Error; nil != err { + return lib.ErrorConflict(c, err) + } + return lib.OK(c, data) +} + +// PutCategoryEnable godoc +// @Summary Update status Category by id +// @Description Update Category by id +// @Param X-User-ID header string false "User ID" +// @Param id path string true "Category ID" +// @Accept application/json +// @Produce application/json +// @Success 200 {object} model.Category "Category data" +// @Failure 400 {object} lib.Response +// @Failure 404 {object} lib.Response +// @Failure 409 {object} lib.Response +// @Failure 500 {object} lib.Response +// @Failure default {object} lib.Response +// @Router /settings/category/{id}/enable [put] +// @Tags Setting +func PutCategoryEnable(c *fiber.Ctx) error { + db := services.DB + id, _ := uuid.Parse(c.Params("id")) + + userID := lib.GetXUserID(c) + ver, _ := user.GetUserData(userID) + if *ver.IsAdmin != 1 { + return lib.ErrorUnauthorized(c) + } + + var data model.Category + result := db.Model(&data). + Where(db.Where(model.Category{ + Base: model.Base{ + ID: &id, + }, + })).First(&data) + + if result.RowsAffected < 1 { + return lib.ErrorNotFound(c) + } + + if *data.Status == 1 { + data.Status = lib.Intptr(0) + } else { + data.Status = lib.Intptr(1) + } + if err := db.Model(&data).Updates(&data).Error; nil != err { + return lib.ErrorConflict(c, err) + } + return lib.OK(c, data) +} + +// PutAccountEnable godoc +// @Summary Update status Account by id +// @Description Update Account by id +// @Param X-User-ID header string false "User ID" +// @Param id path string true "Account ID" +// @Accept application/json +// @Produce application/json +// @Success 200 {object} model.Account "Account data" +// @Failure 400 {object} lib.Response +// @Failure 404 {object} lib.Response +// @Failure 409 {object} lib.Response +// @Failure 500 {object} lib.Response +// @Failure default {object} lib.Response +// @Router /settings/account/{id}/enable [put] +// @Tags Setting +func PutAccountEnable(c *fiber.Ctx) error { + db := services.DB + id, _ := uuid.Parse(c.Params("id")) + + userID := lib.GetXUserID(c) + ver, _ := user.GetUserData(userID) + if *ver.IsAdmin != 1 { + return lib.ErrorUnauthorized(c) + } + + var data model.Account + result := db.Model(&data). + Where(db.Where(model.Account{ + Base: model.Base{ + ID: &id, + }, + })).First(&data) + + if result.RowsAffected < 1 { + return lib.ErrorNotFound(c) + } + + if *data.Status == 1 { + data.Status = lib.Intptr(0) + } else { + data.Status = lib.Intptr(1) + } + if err := db.Model(&data).Updates(&data).Error; nil != err { + return lib.ErrorConflict(c, err) + } + return lib.OK(c, data) +} + +// PutGroupEnable godoc +// @Summary Update status Group by id +// @Description Update Group by id +// @Param X-User-ID header string false "User ID" +// @Param id path string true "Group ID" +// @Accept application/json +// @Produce application/json +// @Success 200 {object} model.Group "Group data" +// @Failure 400 {object} lib.Response +// @Failure 404 {object} lib.Response +// @Failure 409 {object} lib.Response +// @Failure 500 {object} lib.Response +// @Failure default {object} lib.Response +// @Router /settings/group/{id}/enable [put] +// @Tags Setting +func PutGroupEnable(c *fiber.Ctx) error { + db := services.DB + id, _ := uuid.Parse(c.Params("id")) + + userID := lib.GetXUserID(c) + ver, _ := user.GetUserData(userID) + if *ver.IsAdmin != 1 { + return lib.ErrorUnauthorized(c) + } + + var data model.Group + result := db.Model(&data). + Where(db.Where(model.Group{ + Base: model.Base{ + ID: &id, + }, + })).First(&data) + + if result.RowsAffected < 1 { + return lib.ErrorNotFound(c) + } + + if *data.Status == 1 { + data.Status = lib.Intptr(0) + } else { + data.Status = lib.Intptr(1) + } + if err := db.Model(&data).Updates(&data).Error; nil != err { + return lib.ErrorConflict(c, err) + } + return lib.OK(c, data) +} + +// PutPaymentEnable godoc +// @Summary Update status Payment by id +// @Description Update Payment by id +// @Param X-User-ID header string false "User ID" +// @Param id path string true "Payment ID" +// @Accept application/json +// @Produce application/json +// @Success 200 {object} model.Payment "Payment data" +// @Failure 400 {object} lib.Response +// @Failure 404 {object} lib.Response +// @Failure 409 {object} lib.Response +// @Failure 500 {object} lib.Response +// @Failure default {object} lib.Response +// @Router /settings/payment/{id}/enable [put] +// @Tags Setting +func PutPaymentEnable(c *fiber.Ctx) error { + db := services.DB + id, _ := uuid.Parse(c.Params("id")) + + userID := lib.GetXUserID(c) + ver, _ := user.GetUserData(userID) + if *ver.IsAdmin != 1 { + return lib.ErrorUnauthorized(c) + } + + var data model.Payment + result := db.Model(&data). + Where(db.Where(model.Payment{ + Base: model.Base{ + ID: &id, + }, + })).First(&data) + + if result.RowsAffected < 1 { + return lib.ErrorNotFound(c) + } + + if *data.Status == 1 { + data.Status = lib.Intptr(0) + } else { + data.Status = lib.Intptr(1) + } + if err := db.Model(&data).Updates(&data).Error; nil != err { + return lib.ErrorConflict(c, err) + } + return lib.OK(c, data) +} + +// PutUserEnable godoc +// @Summary Update status User by id +// @Description Update User by id +// @Param X-User-ID header string false "User ID" +// @Param id path string true "User ID" +// @Accept application/json +// @Produce application/json +// @Success 200 {object} model.User "User data" +// @Failure 400 {object} lib.Response +// @Failure 404 {object} lib.Response +// @Failure 409 {object} lib.Response +// @Failure 500 {object} lib.Response +// @Failure default {object} lib.Response +// @Router /settings/user/{id}/enable [put] +// @Tags Setting +func PutUserEnable(c *fiber.Ctx) error { + db := services.DB + id, _ := uuid.Parse(c.Params("id")) + + userID := lib.GetXUserID(c) + ver, _ := user.GetUserData(userID) + if *ver.IsAdmin != 1 { + return lib.ErrorUnauthorized(c) + } + + var data model.User + result := db.Model(&data). + Where(db.Where(model.User{ + Base: model.Base{ + ID: &id, + }, + })).First(&data) + + if result.RowsAffected < 1 { + return lib.ErrorNotFound(c) + } + + if *data.Status == 1 { + data.Status = lib.Intptr(0) + } else { + data.Status = lib.Intptr(1) + } + if err := db.Model(&data).Updates(&data).Error; nil != err { + return lib.ErrorConflict(c, err) + } + return lib.OK(c, data) +} diff --git a/app/controller/setting/user_make_admin_put.go b/app/controller/setting/user_make_admin_put.go index 1f11b78..184e5b3 100644 --- a/app/controller/setting/user_make_admin_put.go +++ b/app/controller/setting/user_make_admin_put.go @@ -46,7 +46,11 @@ func PutUserMakeAdmin(c *fiber.Ctx) error { if result.RowsAffected < 1 { return lib.ErrorNotFound(c) } - data.IsAdmin = lib.Intptr(1) + if *data.IsAdmin == 0 { + data.IsAdmin = lib.Intptr(1) + } else { + data.IsAdmin = lib.Intptr(0) + } if err := db.Model(&data).Updates(&data).Error; nil != err { return lib.ErrorConflict(c, err) diff --git a/app/model/base.go b/app/model/base.go index 822f9b2..02749ca 100644 --- a/app/model/base.go +++ b/app/model/base.go @@ -1,6 +1,7 @@ package model import ( + "api/app/lib" "time" "github.com/go-openapi/strfmt" @@ -12,6 +13,7 @@ import ( type Base struct { ID *uuid.UUID `json:"id,omitempty" gorm:"primaryKey;unique;type:varchar(36);not null" format:"uuid"` // model ID Sort *int64 `json:"sort,omitempty" gorm:"default:0" example:"1"` // sort (increment) + Status *int `json:"status,omitempty" gorm:"default:1" example:"1"` // sort (increment) CreatedAt *strfmt.DateTime `json:"created_at,omitempty" gorm:"type:timestamptz" format:"date-time" swaggertype:"string"` // created at automatically inserted on post UpdatedAt *strfmt.DateTime `json:"updated_at,omitempty" gorm:"type:timestamptz" format:"date-time" swaggertype:"string"` // updated at automatically changed on put or add on post DeletedAt gorm.DeletedAt `json:"-" gorm:"index" swaggerignore:"true"` @@ -32,6 +34,7 @@ func (b *Base) BeforeCreate(tx *gorm.DB) error { id, e := uuid.NewRandom() now := strfmt.DateTime(time.Now()) b.ID = &id + b.Status = lib.Intptr(1) b.CreatedAt = &now b.UpdatedAt = &now return e diff --git a/app/routes/router.go b/app/routes/router.go index 46e69cc..9fa8b83 100644 --- a/app/routes/router.go +++ b/app/routes/router.go @@ -108,6 +108,12 @@ func Handle(app *fiber.App) { api.Put("/settings/user/:id/role/:role_id", setting.PutUserRole) api.Put("/settings/user/:id/verify", setting.PutUserVerify) api.Put("/settings/user/:id/make-admin", setting.PutUserMakeAdmin) + api.Put("/settings/balance/:id/enable", setting.PutBalanceEnable) + api.Put("/settings/account/:id/enable", setting.PutAccountEnable) + api.Put("/settings/category/:id/enable", setting.PutCategoryEnable) + api.Put("/settings/group/:id/enable", setting.PutGroupEnable) + api.Put("/settings/payment/:id/enable", setting.PutPaymentEnable) + api.Put("/settings/user/:id/enable", setting.PutUserEnable) // Transaction api.Post("/transactions", transaction.PostTransaction) diff --git a/docs/swagger-dev.yaml b/docs/swagger-dev.yaml index d634f61..6f50960 100644 --- a/docs/swagger-dev.yaml +++ b/docs/swagger-dev.yaml @@ -47,6 +47,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -108,6 +112,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -167,6 +175,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer transaction: $ref: '#/definitions/model.Transaction' transaction_id: @@ -257,6 +269,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -332,6 +348,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -389,6 +409,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -491,6 +515,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -542,6 +570,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -3340,6 +3372,276 @@ paths: summary: Update Role by id tags: - Role + /settings/account/{id}/enable: + put: + consumes: + - application/json + description: Update Account by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Account ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Account data + schema: + $ref: '#/definitions/model.Account' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Account by id + tags: + - Setting + /settings/balance/{id}/enable: + put: + consumes: + - application/json + description: Update Balance by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Balance ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Balance data + schema: + $ref: '#/definitions/model.Balance' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Balance by id + tags: + - Setting + /settings/category/{id}/enable: + put: + consumes: + - application/json + description: Update Category by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Category ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Category data + schema: + $ref: '#/definitions/model.Category' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Category by id + tags: + - Setting + /settings/group/{id}/enable: + put: + consumes: + - application/json + description: Update Group by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Group ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Group data + schema: + $ref: '#/definitions/model.Group' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Group by id + tags: + - Setting + /settings/payment/{id}/enable: + put: + consumes: + - application/json + description: Update Payment by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Payment ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Payment data + schema: + $ref: '#/definitions/model.Payment' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Payment by id + tags: + - Setting + /settings/user/{id}/enable: + put: + consumes: + - application/json + description: Update User by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: User ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: User data + schema: + $ref: '#/definitions/model.User' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status User by id + tags: + - Setting /settings/user/{id}/group/{group_id}: put: consumes: diff --git a/docs/swagger-local.yaml b/docs/swagger-local.yaml index d634f61..6f50960 100644 --- a/docs/swagger-local.yaml +++ b/docs/swagger-local.yaml @@ -47,6 +47,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -108,6 +112,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -167,6 +175,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer transaction: $ref: '#/definitions/model.Transaction' transaction_id: @@ -257,6 +269,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -332,6 +348,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -389,6 +409,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -491,6 +515,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -542,6 +570,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -3340,6 +3372,276 @@ paths: summary: Update Role by id tags: - Role + /settings/account/{id}/enable: + put: + consumes: + - application/json + description: Update Account by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Account ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Account data + schema: + $ref: '#/definitions/model.Account' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Account by id + tags: + - Setting + /settings/balance/{id}/enable: + put: + consumes: + - application/json + description: Update Balance by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Balance ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Balance data + schema: + $ref: '#/definitions/model.Balance' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Balance by id + tags: + - Setting + /settings/category/{id}/enable: + put: + consumes: + - application/json + description: Update Category by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Category ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Category data + schema: + $ref: '#/definitions/model.Category' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Category by id + tags: + - Setting + /settings/group/{id}/enable: + put: + consumes: + - application/json + description: Update Group by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Group ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Group data + schema: + $ref: '#/definitions/model.Group' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Group by id + tags: + - Setting + /settings/payment/{id}/enable: + put: + consumes: + - application/json + description: Update Payment by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Payment ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Payment data + schema: + $ref: '#/definitions/model.Payment' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Payment by id + tags: + - Setting + /settings/user/{id}/enable: + put: + consumes: + - application/json + description: Update User by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: User ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: User data + schema: + $ref: '#/definitions/model.User' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status User by id + tags: + - Setting /settings/user/{id}/group/{group_id}: put: consumes: diff --git a/docs/swagger-stg.yaml b/docs/swagger-stg.yaml index d634f61..6f50960 100644 --- a/docs/swagger-stg.yaml +++ b/docs/swagger-stg.yaml @@ -47,6 +47,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -108,6 +112,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -167,6 +175,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer transaction: $ref: '#/definitions/model.Transaction' transaction_id: @@ -257,6 +269,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -332,6 +348,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -389,6 +409,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -491,6 +515,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -542,6 +570,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -3340,6 +3372,276 @@ paths: summary: Update Role by id tags: - Role + /settings/account/{id}/enable: + put: + consumes: + - application/json + description: Update Account by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Account ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Account data + schema: + $ref: '#/definitions/model.Account' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Account by id + tags: + - Setting + /settings/balance/{id}/enable: + put: + consumes: + - application/json + description: Update Balance by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Balance ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Balance data + schema: + $ref: '#/definitions/model.Balance' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Balance by id + tags: + - Setting + /settings/category/{id}/enable: + put: + consumes: + - application/json + description: Update Category by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Category ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Category data + schema: + $ref: '#/definitions/model.Category' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Category by id + tags: + - Setting + /settings/group/{id}/enable: + put: + consumes: + - application/json + description: Update Group by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Group ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Group data + schema: + $ref: '#/definitions/model.Group' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Group by id + tags: + - Setting + /settings/payment/{id}/enable: + put: + consumes: + - application/json + description: Update Payment by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Payment ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Payment data + schema: + $ref: '#/definitions/model.Payment' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Payment by id + tags: + - Setting + /settings/user/{id}/enable: + put: + consumes: + - application/json + description: Update User by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: User ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: User data + schema: + $ref: '#/definitions/model.User' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status User by id + tags: + - Setting /settings/user/{id}/group/{group_id}: put: consumes: diff --git a/docs/swagger.json b/docs/swagger.json index 4cf77e0..4646e5d 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3537,6 +3537,414 @@ } } }, + "/settings/account/{id}/enable": { + "put": { + "description": "Update Account by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Setting" + ], + "summary": "Update status Account by id", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "X-User-ID", + "in": "header" + }, + { + "type": "string", + "description": "Account ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Account data", + "schema": { + "$ref": "#/definitions/model.Account" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "default": { + "description": "", + "schema": { + "$ref": "#/definitions/lib.Response" + } + } + } + } + }, + "/settings/balance/{id}/enable": { + "put": { + "description": "Update Balance by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Setting" + ], + "summary": "Update status Balance by id", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "X-User-ID", + "in": "header" + }, + { + "type": "string", + "description": "Balance ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Balance data", + "schema": { + "$ref": "#/definitions/model.Balance" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "default": { + "description": "", + "schema": { + "$ref": "#/definitions/lib.Response" + } + } + } + } + }, + "/settings/category/{id}/enable": { + "put": { + "description": "Update Category by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Setting" + ], + "summary": "Update status Category by id", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "X-User-ID", + "in": "header" + }, + { + "type": "string", + "description": "Category ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Category data", + "schema": { + "$ref": "#/definitions/model.Category" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "default": { + "description": "", + "schema": { + "$ref": "#/definitions/lib.Response" + } + } + } + } + }, + "/settings/group/{id}/enable": { + "put": { + "description": "Update Group by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Setting" + ], + "summary": "Update status Group by id", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "X-User-ID", + "in": "header" + }, + { + "type": "string", + "description": "Group ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Group data", + "schema": { + "$ref": "#/definitions/model.Group" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "default": { + "description": "", + "schema": { + "$ref": "#/definitions/lib.Response" + } + } + } + } + }, + "/settings/payment/{id}/enable": { + "put": { + "description": "Update Payment by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Setting" + ], + "summary": "Update status Payment by id", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "X-User-ID", + "in": "header" + }, + { + "type": "string", + "description": "Payment ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Payment data", + "schema": { + "$ref": "#/definitions/model.Payment" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "default": { + "description": "", + "schema": { + "$ref": "#/definitions/lib.Response" + } + } + } + } + }, + "/settings/user/{id}/enable": { + "put": { + "description": "Update User by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Setting" + ], + "summary": "Update status User by id", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "X-User-ID", + "in": "header" + }, + { + "type": "string", + "description": "User ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "User data", + "schema": { + "$ref": "#/definitions/model.User" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/lib.Response" + } + }, + "default": { + "description": "", + "schema": { + "$ref": "#/definitions/lib.Response" + } + } + } + } + }, "/settings/user/{id}/group/{group_id}": { "put": { "description": "Assingn Group User", @@ -5449,6 +5857,11 @@ "type": "integer", "example": 1 }, + "status": { + "description": "sort (increment)", + "type": "integer", + "example": 1 + }, "updated_at": { "description": "updated at automatically changed on put or add on post", "type": "string", @@ -5528,6 +5941,11 @@ "type": "integer", "example": 1 }, + "status": { + "description": "sort (increment)", + "type": "integer", + "example": 1 + }, "updated_at": { "description": "updated at automatically changed on put or add on post", "type": "string", @@ -5605,6 +6023,11 @@ "type": "integer", "example": 1 }, + "status": { + "description": "sort (increment)", + "type": "integer", + "example": 1 + }, "transaction": { "$ref": "#/definitions/model.Transaction" }, @@ -5722,6 +6145,11 @@ "type": "integer", "example": 1 }, + "status": { + "description": "sort (increment)", + "type": "integer", + "example": 1 + }, "updated_at": { "description": "updated at automatically changed on put or add on post", "type": "string", @@ -5819,6 +6247,11 @@ "type": "integer", "example": 1 }, + "status": { + "description": "sort (increment)", + "type": "integer", + "example": 1 + }, "updated_at": { "description": "updated at automatically changed on put or add on post", "type": "string", @@ -5894,6 +6327,11 @@ "type": "integer", "example": 1 }, + "status": { + "description": "sort (increment)", + "type": "integer", + "example": 1 + }, "updated_at": { "description": "updated at automatically changed on put or add on post", "type": "string", @@ -6026,6 +6464,11 @@ "type": "integer", "example": 1 }, + "status": { + "description": "sort (increment)", + "type": "integer", + "example": 1 + }, "updated_at": { "description": "updated at automatically changed on put or add on post", "type": "string", @@ -6093,6 +6536,11 @@ "type": "integer", "example": 1 }, + "status": { + "description": "sort (increment)", + "type": "integer", + "example": 1 + }, "updated_at": { "description": "updated at automatically changed on put or add on post", "type": "string", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index d634f61..6f50960 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -47,6 +47,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -108,6 +112,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -167,6 +175,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer transaction: $ref: '#/definitions/model.Transaction' transaction_id: @@ -257,6 +269,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -332,6 +348,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -389,6 +409,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -491,6 +515,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -542,6 +570,10 @@ definitions: description: sort (increment) example: 1 type: integer + status: + description: sort (increment) + example: 1 + type: integer updated_at: description: updated at automatically changed on put or add on post format: date-time @@ -3340,6 +3372,276 @@ paths: summary: Update Role by id tags: - Role + /settings/account/{id}/enable: + put: + consumes: + - application/json + description: Update Account by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Account ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Account data + schema: + $ref: '#/definitions/model.Account' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Account by id + tags: + - Setting + /settings/balance/{id}/enable: + put: + consumes: + - application/json + description: Update Balance by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Balance ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Balance data + schema: + $ref: '#/definitions/model.Balance' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Balance by id + tags: + - Setting + /settings/category/{id}/enable: + put: + consumes: + - application/json + description: Update Category by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Category ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Category data + schema: + $ref: '#/definitions/model.Category' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Category by id + tags: + - Setting + /settings/group/{id}/enable: + put: + consumes: + - application/json + description: Update Group by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Group ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Group data + schema: + $ref: '#/definitions/model.Group' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Group by id + tags: + - Setting + /settings/payment/{id}/enable: + put: + consumes: + - application/json + description: Update Payment by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: Payment ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Payment data + schema: + $ref: '#/definitions/model.Payment' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status Payment by id + tags: + - Setting + /settings/user/{id}/enable: + put: + consumes: + - application/json + description: Update User by id + parameters: + - description: User ID + in: header + name: X-User-ID + type: string + - description: User ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: User data + schema: + $ref: '#/definitions/model.User' + "400": + description: Bad Request + schema: + $ref: '#/definitions/lib.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/lib.Response' + "409": + description: Conflict + schema: + $ref: '#/definitions/lib.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/lib.Response' + default: + description: "" + schema: + $ref: '#/definitions/lib.Response' + summary: Update status User by id + tags: + - Setting /settings/user/{id}/group/{group_id}: put: consumes: -- GitLab