fixing swagger documentation param
This commit is contained in:
@@ -147,6 +147,13 @@ const docTemplate = `{
|
||||
],
|
||||
"summary": "Update Antrian Operasi",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id antrian",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Update Pasien Operasi",
|
||||
"name": "body",
|
||||
@@ -171,6 +178,35 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Antrian Operasi"
|
||||
],
|
||||
"summary": "Delete Antrian Operasi",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id antrian",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/shared.BaseResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/shared.BaseErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/antrian-operasi/{id}/update-status": {
|
||||
@@ -180,6 +216,13 @@ const docTemplate = `{
|
||||
],
|
||||
"summary": "Update Status Antrian Operasi",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id antrian",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Update Status Pasien Operasi",
|
||||
"name": "body",
|
||||
|
||||
@@ -141,6 +141,13 @@
|
||||
],
|
||||
"summary": "Update Antrian Operasi",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id antrian",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Update Pasien Operasi",
|
||||
"name": "body",
|
||||
@@ -165,6 +172,35 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Antrian Operasi"
|
||||
],
|
||||
"summary": "Delete Antrian Operasi",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id antrian",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/shared.BaseResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/shared.BaseErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/antrian-operasi/{id}/update-status": {
|
||||
@@ -174,6 +210,13 @@
|
||||
],
|
||||
"summary": "Update Status Antrian Operasi",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id antrian",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Update Status Pasien Operasi",
|
||||
"name": "body",
|
||||
|
||||
@@ -491,6 +491,25 @@ paths:
|
||||
tags:
|
||||
- Antrian Operasi
|
||||
/antrian-operasi/{id}:
|
||||
delete:
|
||||
parameters:
|
||||
- description: id antrian
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/shared.BaseResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/shared.BaseErrorResponse'
|
||||
summary: Delete Antrian Operasi
|
||||
tags:
|
||||
- Antrian Operasi
|
||||
get:
|
||||
parameters:
|
||||
- description: id antrian
|
||||
@@ -512,6 +531,11 @@ paths:
|
||||
- Antrian Operasi
|
||||
put:
|
||||
parameters:
|
||||
- description: id antrian
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Update Pasien Operasi
|
||||
in: body
|
||||
name: body
|
||||
@@ -533,6 +557,11 @@ paths:
|
||||
/antrian-operasi/{id}/update-status:
|
||||
put:
|
||||
parameters:
|
||||
- description: id antrian
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Update Status Pasien Operasi
|
||||
in: body
|
||||
name: body
|
||||
|
||||
@@ -144,6 +144,7 @@ func (h AntrianOperasiHandler) GetDetailAntrianOperasi(c *gin.Context) {
|
||||
// UpdateAntrianOperasi godoc
|
||||
// @Summary Update Antrian Operasi
|
||||
// @Tags Antrian Operasi
|
||||
// @Param id path string true "id antrian"
|
||||
// @Param body body CreatePasienOperasiRequest true "Update Pasien Operasi"
|
||||
// @Success 200 {object} shared.BaseResponse
|
||||
// @Failure 500 {object} shared.BaseErrorResponse
|
||||
@@ -195,6 +196,7 @@ func (h AntrianOperasiHandler) UpdateAntrianOperasi(c *gin.Context) {
|
||||
// UpdateStatusAntrianOperasi godoc
|
||||
// @Summary Update Status Antrian Operasi
|
||||
// @Tags Antrian Operasi
|
||||
// @Param id path string true "id antrian"
|
||||
// @Param body body StatusPasienRequest true "Update Status Pasien Operasi"
|
||||
// @Success 200 {object} shared.BaseResponse
|
||||
// @Failure 500 {object} shared.BaseErrorResponse
|
||||
@@ -242,3 +244,41 @@ func (h AntrianOperasiHandler) UpdateStatusAntrianOperasi(c *gin.Context) {
|
||||
|
||||
c.JSON(200, shared.ToBaseResponse(res, true, 200, "success update antrian operasi"))
|
||||
}
|
||||
|
||||
// DeleteAntrianOperasi godoc
|
||||
// @Summary Delete Antrian Operasi
|
||||
// @Tags Antrian Operasi
|
||||
// @Param id path string true "id antrian"
|
||||
// @Success 200 {object} shared.BaseResponse
|
||||
// @Failure 500 {object} shared.BaseErrorResponse
|
||||
// @Router /antrian-operasi/{id} [delete]
|
||||
func (h AntrianOperasiHandler) DeleteAntrianOperasi(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
// check antrian is exist
|
||||
_, err := h.repo.GetAntrianOperasiById(c, id)
|
||||
if err != nil {
|
||||
log.Printf("validation error : %s", err)
|
||||
c.JSON(400, shared.BaseErrorResponse{
|
||||
Success: false,
|
||||
Code: 400,
|
||||
Message: "antrian not found",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Start delete
|
||||
err = h.repo.DeleteStatusAntrianOperasi(c, id)
|
||||
if err != nil {
|
||||
log.Printf("delete antrian error : %s", err)
|
||||
errMessage := []string{err.Error()}
|
||||
c.JSON(500, shared.BaseErrorResponse{
|
||||
Success: false,
|
||||
Code: 500,
|
||||
Message: "delete error",
|
||||
Errors: errMessage,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, shared.ToBaseResponse("", true, 200, "success delete antrian operasi"))
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ type IAntrianOperasiRepository interface {
|
||||
GetAntrianOperasiById(c *gin.Context, id string) (DetailPasienOperasiResultQuery, error)
|
||||
UpdateAntrianOperasi(c *gin.Context, id string, req CreatePasienOperasiRequest) (CreatePasienOperasiRequest, error)
|
||||
UpdateStatusAntrianOperasi(c *gin.Context, id string, req StatusPasienRequest) (StatusPasienRequest, error)
|
||||
DeleteStatusAntrianOperasi(c *gin.Context, id string) error
|
||||
}
|
||||
|
||||
type antrianOperasiRepo struct {
|
||||
@@ -889,3 +890,59 @@ func (r antrianOperasiRepo) UpdateStatusAntrianOperasi(c *gin.Context, id string
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (r antrianOperasiRepo) DeleteStatusAntrianOperasi(c *gin.Context, id string) error {
|
||||
db, err := r.db.GetSQLXDB(DB_NAME)
|
||||
if err != nil {
|
||||
log.Printf("Erorr initiating db : %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// START TRANSACTION
|
||||
tx, err := db.BeginTx(c, nil)
|
||||
if err != nil {
|
||||
log.Printf("Error initiating delete transaction : %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete all child tables
|
||||
err = r.deleteAntrianChildTables(c, tx, id)
|
||||
if err != nil {
|
||||
log.Printf("Error deleting child tables, rollback.. : %v", err)
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
// delete main antrian table
|
||||
filters := []queryUtils.FilterGroup{
|
||||
{
|
||||
Filters: []queryUtils.DynamicFilter{
|
||||
{Column: "id", Operator: queryUtils.OpEqual, Value: id},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
sql, args, err := r.queryBuilder.BuildDeleteQuery(TBL_NAME, filters)
|
||||
if err != nil {
|
||||
log.Printf("Unable to create delete main query : %v", err)
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(c, sql, args...)
|
||||
if err != nil {
|
||||
log.Printf("Unable to executing delete antrian : %v", err)
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = tx.ExecContext(c, sql, args...)
|
||||
if err != nil {
|
||||
log.Printf("Error executing main delet query : %v", err)
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -29,4 +29,5 @@ func RegisterRoutes(r *gin.RouterGroup, dbService database.Service) {
|
||||
r.GET("/antrian-operasi/:id", antrianOperasiHandler.GetDetailAntrianOperasi)
|
||||
r.PUT("/antrian-operasi/:id", antrianOperasiHandler.UpdateAntrianOperasi)
|
||||
r.PUT("/antrian-operasi/:id/update-status", antrianOperasiHandler.UpdateStatusAntrianOperasi)
|
||||
r.DELETE("/antrian-operasi/:id", antrianOperasiHandler.DeleteAntrianOperasi)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user