From aee70200966b1e4e34a14e7762e0fb7eb710ef13 Mon Sep 17 00:00:00 2001 From: Meninjar Date: Mon, 18 Aug 2025 09:13:11 +0700 Subject: [PATCH] perbaikan Swagger --- docs/docs.go | 1006 +++++++++++++++--------- docs/swagger.json | 1001 ++++++++++++++--------- docs/swagger.yaml | 699 ++++++++++------ internal/models/retribusi/retribusi.go | 30 +- 4 files changed, 1747 insertions(+), 989 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index f628fda6..ce68b761 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,5 +1,4 @@ -// Code generated by swaggo/swag. DO NOT EDIT. - +// Package docs Code generated by swaggo/swag. DO NOT EDIT package docs import "github.com/swaggo/swag" @@ -25,29 +24,6 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/": { - "get": { - "description": "Returns a hello world message", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "root" - ], - "summary": "Hello World endpoint", - "responses": { - "200": { - "description": "Hello world message", - "schema": { - "$ref": "#/definitions/models.HelloWorldResponse" - } - } - } - } - }, "/api/v1/auth/login": { "post": { "description": "Authenticate user with username and password to receive JWT token", @@ -68,7 +44,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.LoginRequest" + "$ref": "#/definitions/api-service_internal_models_auth.LoginRequest" } } ], @@ -76,7 +52,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/models.TokenResponse" + "$ref": "#/definitions/api-service_internal_models_auth.TokenResponse" } }, "400": { @@ -119,7 +95,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/models.User" + "$ref": "#/definitions/api-service_internal_models_auth.User" } }, "401": { @@ -165,7 +141,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/models.TokenResponse" + "$ref": "#/definitions/api-service_internal_models_auth.TokenResponse" } }, "400": { @@ -238,9 +214,9 @@ const docTemplate = `{ } } }, - "/api/v1/example": { + "/api/v1/retribusi/{id}": { "get": { - "description": "Returns a simple message for GET request", + "description": "Returns a single retribusi by ID", "consumes": [ "application/json" ], @@ -248,135 +224,13 @@ const docTemplate = `{ "application/json" ], "tags": [ - "example" + "retribusi" ], - "summary": "Example GET service", - "responses": { - "200": { - "description": "Example GET response", - "schema": { - "$ref": "#/definitions/models.ExampleGetResponse" - } - } - } - }, - "post": { - "description": "Accepts a JSON payload and returns a response with an ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "example" - ], - "summary": "Example POST service", - "parameters": [ - { - "description": "Example POST request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/models.ExamplePostRequest" - } - } - ], - "responses": { - "200": { - "description": "Example POST response", - "schema": { - "$ref": "#/definitions/models.ExamplePostResponse" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/models.ErrorResponse" - } - } - } - } - }, - "/api/v1/products": { - "get": { - "description": "Returns a list of products", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "product" - ], - "summary": "Get product", - "responses": { - "200": { - "description": "Product GET response", - "schema": { - "$ref": "#/definitions/models.ProductGetResponse" - } - } - } - }, - "post": { - "description": "Creates a new product", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "product" - ], - "summary": "Create product", - "parameters": [ - { - "description": "Product creation request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/models.ProductCreateRequest" - } - } - ], - "responses": { - "201": { - "description": "Product created successfully", - "schema": { - "$ref": "#/definitions/models.ProductCreateResponse" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/models.ErrorResponse" - } - } - } - } - }, - "/api/v1/products/{id}": { - "get": { - "description": "Returns a single product by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "product" - ], - "summary": "Get product by ID", + "summary": "Get Retribusi by ID", "parameters": [ { "type": "string", - "description": "Product ID", + "description": "Retribusi ID (UUID)", "name": "id", "in": "path", "required": true @@ -384,21 +238,33 @@ const docTemplate = `{ ], "responses": { "200": { - "description": "Product GET by ID response", + "description": "Success response", "schema": { - "$ref": "#/definitions/models.ProductGetByIDResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiGetByIDResponse" + } + }, + "400": { + "description": "Invalid ID format", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } }, "404": { - "description": "Product not found", + "description": "Retribusi not found", "schema": { - "$ref": "#/definitions/models.ErrorResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } } } }, "put": { - "description": "Updates an existing product", + "description": "Updates an existing retribusi record", "consumes": [ "application/json" ], @@ -406,50 +272,56 @@ const docTemplate = `{ "application/json" ], "tags": [ - "product" + "retribusi" ], - "summary": "Update product", + "summary": "Update retribusi", "parameters": [ { "type": "string", - "description": "Product ID", + "description": "Retribusi ID (UUID)", "name": "id", "in": "path", "required": true }, { - "description": "Product update request", + "description": "Retribusi update request", "name": "request", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.ProductUpdateRequest" + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiUpdateRequest" } } ], "responses": { "200": { - "description": "Product updated successfully", + "description": "Retribusi updated successfully", "schema": { - "$ref": "#/definitions/models.ProductUpdateResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiUpdateResponse" } }, "400": { - "description": "Bad request", + "description": "Bad request or validation error", "schema": { - "$ref": "#/definitions/models.ErrorResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } }, "404": { - "description": "Product not found", + "description": "Retribusi not found", "schema": { - "$ref": "#/definitions/models.ErrorResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } } } }, "delete": { - "description": "Deletes a product by ID", + "description": "Soft deletes a retribusi by setting status to 'deleted'", "consumes": [ "application/json" ], @@ -457,13 +329,13 @@ const docTemplate = `{ "application/json" ], "tags": [ - "product" + "retribusi" ], - "summary": "Delete product", + "summary": "Delete retribusi", "parameters": [ { "type": "string", - "description": "Product ID", + "description": "Retribusi ID (UUID)", "name": "id", "in": "path", "required": true @@ -471,15 +343,190 @@ const docTemplate = `{ ], "responses": { "200": { - "description": "Product deleted successfully", + "description": "Retribusi deleted successfully", "schema": { - "$ref": "#/definitions/models.ProductDeleteResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiDeleteResponse" + } + }, + "400": { + "description": "Invalid ID format", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } }, "404": { - "description": "Product not found", + "description": "Retribusi not found", "schema": { - "$ref": "#/definitions/models.ErrorResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + } + } + } + }, + "/api/v1/retribusis": { + "get": { + "description": "Returns a paginated list of retribusis with optional summary statistics", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "retribusi" + ], + "summary": "Get retribusi with pagination and optional aggregation", + "parameters": [ + { + "type": "integer", + "default": 10, + "description": "Limit (max 100)", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Include aggregation summary", + "name": "include_summary", + "in": "query" + }, + { + "type": "string", + "description": "Filter by status", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "Filter by jenis", + "name": "jenis", + "in": "query" + }, + { + "type": "string", + "description": "Filter by dinas", + "name": "dinas", + "in": "query" + }, + { + "type": "string", + "description": "Search in multiple fields", + "name": "search", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success response", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiGetResponse" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + } + } + }, + "post": { + "description": "Creates a new retribusi record", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "retribusi" + ], + "summary": "Create retribusi", + "parameters": [ + { + "description": "Retribusi creation request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiCreateRequest" + } + } + ], + "responses": { + "201": { + "description": "Retribusi created successfully", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiCreateResponse" + } + }, + "400": { + "description": "Bad request or validation error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + } + } + } + }, + "/api/v1/retribusis/stats": { + "get": { + "description": "Returns comprehensive statistics about retribusi data", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "retribusi" + ], + "summary": "Get retribusi statistics", + "parameters": [ + { + "type": "string", + "description": "Filter statistics by status", + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Statistics data", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.AggregateData" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } } } @@ -505,7 +552,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.LoginRequest" + "$ref": "#/definitions/api-service_internal_models_auth.LoginRequest" } } ], @@ -513,7 +560,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/models.TokenResponse" + "$ref": "#/definitions/api-service_internal_models_auth.TokenResponse" } }, "400": { @@ -568,7 +615,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/models.TokenResponse" + "$ref": "#/definitions/api-service_internal_models_auth.TokenResponse" } }, "400": { @@ -582,115 +629,10 @@ const docTemplate = `{ } } } - }, - "/health": { - "get": { - "description": "Returns the health status of the API service", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "health" - ], - "summary": "Health check endpoint", - "responses": { - "200": { - "description": "Health status", - "schema": { - "$ref": "#/definitions/models.HealthResponse" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/models.ErrorResponse" - } - } - } - } } }, "definitions": { - "models.ErrorResponse": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "error": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.ExampleGetResponse": { - "type": "object", - "properties": { - "message": { - "type": "string" - } - } - }, - "models.ExamplePostRequest": { - "type": "object", - "required": [ - "age", - "name" - ], - "properties": { - "age": { - "type": "integer" - }, - "name": { - "type": "string" - } - } - }, - "models.ExamplePostResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.HealthResponse": { - "type": "object", - "properties": { - "details": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "status": { - "type": "string" - }, - "timestamp": { - "type": "string" - } - } - }, - "models.HelloWorldResponse": { - "type": "object", - "properties": { - "message": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "models.LoginRequest": { + "api-service_internal_models_auth.LoginRequest": { "type": "object", "required": [ "password", @@ -705,84 +647,7 @@ const docTemplate = `{ } } }, - "models.ProductCreateRequest": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - } - } - }, - "models.ProductCreateResponse": { - "type": "object", - "properties": { - "data": {}, - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.ProductDeleteResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.ProductGetByIDResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.ProductGetResponse": { - "type": "object", - "properties": { - "data": {}, - "message": { - "type": "string" - } - } - }, - "models.ProductUpdateRequest": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - } - } - }, - "models.ProductUpdateResponse": { - "type": "object", - "properties": { - "data": {}, - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.TokenResponse": { + "api-service_internal_models_auth.TokenResponse": { "type": "object", "properties": { "access_token": { @@ -796,7 +661,7 @@ const docTemplate = `{ } } }, - "models.User": { + "api-service_internal_models_auth.User": { "type": "object", "properties": { "email": { @@ -812,6 +677,409 @@ const docTemplate = `{ "type": "string" } } + }, + "api-service_internal_models_retribusi.AggregateData": { + "type": "object", + "properties": { + "by_dinas": { + "type": "object", + "additionalProperties": { + "type": "integer" + } + }, + "by_jenis": { + "type": "object", + "additionalProperties": { + "type": "integer" + } + }, + "by_status": { + "type": "object", + "additionalProperties": { + "type": "integer" + } + }, + "created_today": { + "type": "integer" + }, + "last_updated": { + "type": "string" + }, + "total_active": { + "type": "integer" + }, + "total_draft": { + "type": "integer" + }, + "total_inactive": { + "type": "integer" + }, + "updated_today": { + "type": "integer" + } + } + }, + "api-service_internal_models_retribusi.ErrorResponse": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "error": { + "type": "string" + }, + "message": { + "type": "string" + }, + "timestamp": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.MetaResponse": { + "type": "object", + "properties": { + "current_page": { + "type": "integer" + }, + "has_next": { + "type": "boolean" + }, + "has_prev": { + "type": "boolean" + }, + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "total_pages": { + "type": "integer" + } + } + }, + "api-service_internal_models_retribusi.NullableInt32": { + "type": "object", + "properties": { + "int32": { + "type": "integer" + }, + "valid": { + "type": "boolean" + } + } + }, + "api-service_internal_models_retribusi.Retribusi": { + "type": "object", + "properties": { + "date_created": { + "$ref": "#/definitions/sql.NullTime" + }, + "date_updated": { + "$ref": "#/definitions/sql.NullTime" + }, + "dinas": { + "$ref": "#/definitions/sql.NullString" + }, + "id": { + "type": "string" + }, + "jenis": { + "$ref": "#/definitions/sql.NullString" + }, + "kelompok_obyek": { + "$ref": "#/definitions/sql.NullString" + }, + "kode_tarif": { + "$ref": "#/definitions/sql.NullString" + }, + "pelayanan": { + "$ref": "#/definitions/sql.NullString" + }, + "rekening_denda": { + "$ref": "#/definitions/sql.NullString" + }, + "rekening_pokok": { + "$ref": "#/definitions/sql.NullString" + }, + "satuan": { + "$ref": "#/definitions/sql.NullString" + }, + "satuan_overtime": { + "$ref": "#/definitions/sql.NullString" + }, + "sort": { + "$ref": "#/definitions/api-service_internal_models_retribusi.NullableInt32" + }, + "status": { + "type": "string" + }, + "tarif": { + "$ref": "#/definitions/sql.NullString" + }, + "tarif_overtime": { + "$ref": "#/definitions/sql.NullString" + }, + "uraian_1": { + "$ref": "#/definitions/sql.NullString" + }, + "uraian_2": { + "$ref": "#/definitions/sql.NullString" + }, + "uraian_3": { + "$ref": "#/definitions/sql.NullString" + }, + "user_created": { + "$ref": "#/definitions/sql.NullString" + }, + "user_updated": { + "$ref": "#/definitions/sql.NullString" + } + } + }, + "api-service_internal_models_retribusi.RetribusiCreateRequest": { + "type": "object", + "required": [ + "status" + ], + "properties": { + "dinas": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "jenis": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "kelompok_obyek": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "kode_tarif": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "pelayanan": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "rekening_denda": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "rekening_pokok": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "satuan": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "satuan_overtime": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "status": { + "type": "string", + "enum": [ + "draft", + "active", + "inactive" + ] + }, + "tarif": { + "type": "string" + }, + "tarif_overtime": { + "type": "string" + }, + "uraian_1": { + "type": "string" + }, + "uraian_2": { + "type": "string" + }, + "uraian_3": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.RetribusiCreateResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/api-service_internal_models_retribusi.Retribusi" + }, + "message": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.RetribusiDeleteResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "message": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.RetribusiGetByIDResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/api-service_internal_models_retribusi.Retribusi" + }, + "message": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.RetribusiGetResponse": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/api-service_internal_models_retribusi.Retribusi" + } + }, + "message": { + "type": "string" + }, + "meta": { + "$ref": "#/definitions/api-service_internal_models_retribusi.MetaResponse" + }, + "summary": { + "$ref": "#/definitions/api-service_internal_models_retribusi.AggregateData" + } + } + }, + "api-service_internal_models_retribusi.RetribusiUpdateRequest": { + "type": "object", + "required": [ + "status" + ], + "properties": { + "dinas": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "jenis": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "kelompok_obyek": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "kode_tarif": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "pelayanan": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "rekening_denda": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "rekening_pokok": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "satuan": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "satuan_overtime": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "status": { + "type": "string", + "enum": [ + "draft", + "active", + "inactive" + ] + }, + "tarif": { + "type": "string" + }, + "tarif_overtime": { + "type": "string" + }, + "uraian_1": { + "type": "string" + }, + "uraian_2": { + "type": "string" + }, + "uraian_3": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.RetribusiUpdateResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/api-service_internal_models_retribusi.Retribusi" + }, + "message": { + "type": "string" + } + } + }, + "sql.NullString": { + "type": "object", + "properties": { + "string": { + "type": "string" + }, + "valid": { + "description": "Valid is true if String is not NULL", + "type": "boolean" + } + } + }, + "sql.NullTime": { + "type": "object", + "properties": { + "time": { + "type": "string" + }, + "valid": { + "description": "Valid is true if Time is not NULL", + "type": "boolean" + } + } } } }` @@ -826,6 +1094,8 @@ var SwaggerInfo = &swag.Spec{ Description: "A comprehensive Go API service with Swagger documentation", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/docs/swagger.json b/docs/swagger.json index de164848..71267837 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -22,29 +22,6 @@ "host": "localhost:8080", "basePath": "/api/v1", "paths": { - "/": { - "get": { - "description": "Returns a hello world message", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "root" - ], - "summary": "Hello World endpoint", - "responses": { - "200": { - "description": "Hello world message", - "schema": { - "$ref": "#/definitions/models.HelloWorldResponse" - } - } - } - } - }, "/api/v1/auth/login": { "post": { "description": "Authenticate user with username and password to receive JWT token", @@ -65,7 +42,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.LoginRequest" + "$ref": "#/definitions/api-service_internal_models_auth.LoginRequest" } } ], @@ -73,7 +50,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/models.TokenResponse" + "$ref": "#/definitions/api-service_internal_models_auth.TokenResponse" } }, "400": { @@ -116,7 +93,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/models.User" + "$ref": "#/definitions/api-service_internal_models_auth.User" } }, "401": { @@ -162,7 +139,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/models.TokenResponse" + "$ref": "#/definitions/api-service_internal_models_auth.TokenResponse" } }, "400": { @@ -235,9 +212,9 @@ } } }, - "/api/v1/example": { + "/api/v1/retribusi/{id}": { "get": { - "description": "Returns a simple message for GET request", + "description": "Returns a single retribusi by ID", "consumes": [ "application/json" ], @@ -245,135 +222,13 @@ "application/json" ], "tags": [ - "example" + "retribusi" ], - "summary": "Example GET service", - "responses": { - "200": { - "description": "Example GET response", - "schema": { - "$ref": "#/definitions/models.ExampleGetResponse" - } - } - } - }, - "post": { - "description": "Accepts a JSON payload and returns a response with an ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "example" - ], - "summary": "Example POST service", - "parameters": [ - { - "description": "Example POST request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/models.ExamplePostRequest" - } - } - ], - "responses": { - "200": { - "description": "Example POST response", - "schema": { - "$ref": "#/definitions/models.ExamplePostResponse" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/models.ErrorResponse" - } - } - } - } - }, - "/api/v1/products": { - "get": { - "description": "Returns a list of products", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "product" - ], - "summary": "Get product", - "responses": { - "200": { - "description": "Product GET response", - "schema": { - "$ref": "#/definitions/models.ProductGetResponse" - } - } - } - }, - "post": { - "description": "Creates a new product", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "product" - ], - "summary": "Create product", - "parameters": [ - { - "description": "Product creation request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/models.ProductCreateRequest" - } - } - ], - "responses": { - "201": { - "description": "Product created successfully", - "schema": { - "$ref": "#/definitions/models.ProductCreateResponse" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/models.ErrorResponse" - } - } - } - } - }, - "/api/v1/products/{id}": { - "get": { - "description": "Returns a single product by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "product" - ], - "summary": "Get product by ID", + "summary": "Get Retribusi by ID", "parameters": [ { "type": "string", - "description": "Product ID", + "description": "Retribusi ID (UUID)", "name": "id", "in": "path", "required": true @@ -381,21 +236,33 @@ ], "responses": { "200": { - "description": "Product GET by ID response", + "description": "Success response", "schema": { - "$ref": "#/definitions/models.ProductGetByIDResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiGetByIDResponse" + } + }, + "400": { + "description": "Invalid ID format", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } }, "404": { - "description": "Product not found", + "description": "Retribusi not found", "schema": { - "$ref": "#/definitions/models.ErrorResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } } } }, "put": { - "description": "Updates an existing product", + "description": "Updates an existing retribusi record", "consumes": [ "application/json" ], @@ -403,50 +270,56 @@ "application/json" ], "tags": [ - "product" + "retribusi" ], - "summary": "Update product", + "summary": "Update retribusi", "parameters": [ { "type": "string", - "description": "Product ID", + "description": "Retribusi ID (UUID)", "name": "id", "in": "path", "required": true }, { - "description": "Product update request", + "description": "Retribusi update request", "name": "request", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.ProductUpdateRequest" + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiUpdateRequest" } } ], "responses": { "200": { - "description": "Product updated successfully", + "description": "Retribusi updated successfully", "schema": { - "$ref": "#/definitions/models.ProductUpdateResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiUpdateResponse" } }, "400": { - "description": "Bad request", + "description": "Bad request or validation error", "schema": { - "$ref": "#/definitions/models.ErrorResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } }, "404": { - "description": "Product not found", + "description": "Retribusi not found", "schema": { - "$ref": "#/definitions/models.ErrorResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } } } }, "delete": { - "description": "Deletes a product by ID", + "description": "Soft deletes a retribusi by setting status to 'deleted'", "consumes": [ "application/json" ], @@ -454,13 +327,13 @@ "application/json" ], "tags": [ - "product" + "retribusi" ], - "summary": "Delete product", + "summary": "Delete retribusi", "parameters": [ { "type": "string", - "description": "Product ID", + "description": "Retribusi ID (UUID)", "name": "id", "in": "path", "required": true @@ -468,15 +341,190 @@ ], "responses": { "200": { - "description": "Product deleted successfully", + "description": "Retribusi deleted successfully", "schema": { - "$ref": "#/definitions/models.ProductDeleteResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiDeleteResponse" + } + }, + "400": { + "description": "Invalid ID format", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } }, "404": { - "description": "Product not found", + "description": "Retribusi not found", "schema": { - "$ref": "#/definitions/models.ErrorResponse" + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + } + } + } + }, + "/api/v1/retribusis": { + "get": { + "description": "Returns a paginated list of retribusis with optional summary statistics", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "retribusi" + ], + "summary": "Get retribusi with pagination and optional aggregation", + "parameters": [ + { + "type": "integer", + "default": 10, + "description": "Limit (max 100)", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Include aggregation summary", + "name": "include_summary", + "in": "query" + }, + { + "type": "string", + "description": "Filter by status", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "Filter by jenis", + "name": "jenis", + "in": "query" + }, + { + "type": "string", + "description": "Filter by dinas", + "name": "dinas", + "in": "query" + }, + { + "type": "string", + "description": "Search in multiple fields", + "name": "search", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success response", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiGetResponse" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + } + } + }, + "post": { + "description": "Creates a new retribusi record", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "retribusi" + ], + "summary": "Create retribusi", + "parameters": [ + { + "description": "Retribusi creation request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiCreateRequest" + } + } + ], + "responses": { + "201": { + "description": "Retribusi created successfully", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.RetribusiCreateResponse" + } + }, + "400": { + "description": "Bad request or validation error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" + } + } + } + } + }, + "/api/v1/retribusis/stats": { + "get": { + "description": "Returns comprehensive statistics about retribusi data", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "retribusi" + ], + "summary": "Get retribusi statistics", + "parameters": [ + { + "type": "string", + "description": "Filter statistics by status", + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Statistics data", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.AggregateData" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/api-service_internal_models_retribusi.ErrorResponse" } } } @@ -502,7 +550,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.LoginRequest" + "$ref": "#/definitions/api-service_internal_models_auth.LoginRequest" } } ], @@ -510,7 +558,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/models.TokenResponse" + "$ref": "#/definitions/api-service_internal_models_auth.TokenResponse" } }, "400": { @@ -565,7 +613,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/models.TokenResponse" + "$ref": "#/definitions/api-service_internal_models_auth.TokenResponse" } }, "400": { @@ -579,115 +627,10 @@ } } } - }, - "/health": { - "get": { - "description": "Returns the health status of the API service", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "health" - ], - "summary": "Health check endpoint", - "responses": { - "200": { - "description": "Health status", - "schema": { - "$ref": "#/definitions/models.HealthResponse" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/models.ErrorResponse" - } - } - } - } } }, "definitions": { - "models.ErrorResponse": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "error": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.ExampleGetResponse": { - "type": "object", - "properties": { - "message": { - "type": "string" - } - } - }, - "models.ExamplePostRequest": { - "type": "object", - "required": [ - "age", - "name" - ], - "properties": { - "age": { - "type": "integer" - }, - "name": { - "type": "string" - } - } - }, - "models.ExamplePostResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.HealthResponse": { - "type": "object", - "properties": { - "details": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "status": { - "type": "string" - }, - "timestamp": { - "type": "string" - } - } - }, - "models.HelloWorldResponse": { - "type": "object", - "properties": { - "message": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "models.LoginRequest": { + "api-service_internal_models_auth.LoginRequest": { "type": "object", "required": [ "password", @@ -702,84 +645,7 @@ } } }, - "models.ProductCreateRequest": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - } - } - }, - "models.ProductCreateResponse": { - "type": "object", - "properties": { - "data": {}, - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.ProductDeleteResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.ProductGetByIDResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.ProductGetResponse": { - "type": "object", - "properties": { - "data": {}, - "message": { - "type": "string" - } - } - }, - "models.ProductUpdateRequest": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - } - } - }, - "models.ProductUpdateResponse": { - "type": "object", - "properties": { - "data": {}, - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "models.TokenResponse": { + "api-service_internal_models_auth.TokenResponse": { "type": "object", "properties": { "access_token": { @@ -793,7 +659,7 @@ } } }, - "models.User": { + "api-service_internal_models_auth.User": { "type": "object", "properties": { "email": { @@ -809,6 +675,409 @@ "type": "string" } } + }, + "api-service_internal_models_retribusi.AggregateData": { + "type": "object", + "properties": { + "by_dinas": { + "type": "object", + "additionalProperties": { + "type": "integer" + } + }, + "by_jenis": { + "type": "object", + "additionalProperties": { + "type": "integer" + } + }, + "by_status": { + "type": "object", + "additionalProperties": { + "type": "integer" + } + }, + "created_today": { + "type": "integer" + }, + "last_updated": { + "type": "string" + }, + "total_active": { + "type": "integer" + }, + "total_draft": { + "type": "integer" + }, + "total_inactive": { + "type": "integer" + }, + "updated_today": { + "type": "integer" + } + } + }, + "api-service_internal_models_retribusi.ErrorResponse": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "error": { + "type": "string" + }, + "message": { + "type": "string" + }, + "timestamp": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.MetaResponse": { + "type": "object", + "properties": { + "current_page": { + "type": "integer" + }, + "has_next": { + "type": "boolean" + }, + "has_prev": { + "type": "boolean" + }, + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "total_pages": { + "type": "integer" + } + } + }, + "api-service_internal_models_retribusi.NullableInt32": { + "type": "object", + "properties": { + "int32": { + "type": "integer" + }, + "valid": { + "type": "boolean" + } + } + }, + "api-service_internal_models_retribusi.Retribusi": { + "type": "object", + "properties": { + "date_created": { + "$ref": "#/definitions/sql.NullTime" + }, + "date_updated": { + "$ref": "#/definitions/sql.NullTime" + }, + "dinas": { + "$ref": "#/definitions/sql.NullString" + }, + "id": { + "type": "string" + }, + "jenis": { + "$ref": "#/definitions/sql.NullString" + }, + "kelompok_obyek": { + "$ref": "#/definitions/sql.NullString" + }, + "kode_tarif": { + "$ref": "#/definitions/sql.NullString" + }, + "pelayanan": { + "$ref": "#/definitions/sql.NullString" + }, + "rekening_denda": { + "$ref": "#/definitions/sql.NullString" + }, + "rekening_pokok": { + "$ref": "#/definitions/sql.NullString" + }, + "satuan": { + "$ref": "#/definitions/sql.NullString" + }, + "satuan_overtime": { + "$ref": "#/definitions/sql.NullString" + }, + "sort": { + "$ref": "#/definitions/api-service_internal_models_retribusi.NullableInt32" + }, + "status": { + "type": "string" + }, + "tarif": { + "$ref": "#/definitions/sql.NullString" + }, + "tarif_overtime": { + "$ref": "#/definitions/sql.NullString" + }, + "uraian_1": { + "$ref": "#/definitions/sql.NullString" + }, + "uraian_2": { + "$ref": "#/definitions/sql.NullString" + }, + "uraian_3": { + "$ref": "#/definitions/sql.NullString" + }, + "user_created": { + "$ref": "#/definitions/sql.NullString" + }, + "user_updated": { + "$ref": "#/definitions/sql.NullString" + } + } + }, + "api-service_internal_models_retribusi.RetribusiCreateRequest": { + "type": "object", + "required": [ + "status" + ], + "properties": { + "dinas": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "jenis": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "kelompok_obyek": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "kode_tarif": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "pelayanan": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "rekening_denda": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "rekening_pokok": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "satuan": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "satuan_overtime": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "status": { + "type": "string", + "enum": [ + "draft", + "active", + "inactive" + ] + }, + "tarif": { + "type": "string" + }, + "tarif_overtime": { + "type": "string" + }, + "uraian_1": { + "type": "string" + }, + "uraian_2": { + "type": "string" + }, + "uraian_3": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.RetribusiCreateResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/api-service_internal_models_retribusi.Retribusi" + }, + "message": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.RetribusiDeleteResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "message": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.RetribusiGetByIDResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/api-service_internal_models_retribusi.Retribusi" + }, + "message": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.RetribusiGetResponse": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/api-service_internal_models_retribusi.Retribusi" + } + }, + "message": { + "type": "string" + }, + "meta": { + "$ref": "#/definitions/api-service_internal_models_retribusi.MetaResponse" + }, + "summary": { + "$ref": "#/definitions/api-service_internal_models_retribusi.AggregateData" + } + } + }, + "api-service_internal_models_retribusi.RetribusiUpdateRequest": { + "type": "object", + "required": [ + "status" + ], + "properties": { + "dinas": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "jenis": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "kelompok_obyek": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "kode_tarif": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "pelayanan": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "rekening_denda": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "rekening_pokok": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "satuan": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "satuan_overtime": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "status": { + "type": "string", + "enum": [ + "draft", + "active", + "inactive" + ] + }, + "tarif": { + "type": "string" + }, + "tarif_overtime": { + "type": "string" + }, + "uraian_1": { + "type": "string" + }, + "uraian_2": { + "type": "string" + }, + "uraian_3": { + "type": "string" + } + } + }, + "api-service_internal_models_retribusi.RetribusiUpdateResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/api-service_internal_models_retribusi.Retribusi" + }, + "message": { + "type": "string" + } + } + }, + "sql.NullString": { + "type": "object", + "properties": { + "string": { + "type": "string" + }, + "valid": { + "description": "Valid is true if String is not NULL", + "type": "boolean" + } + } + }, + "sql.NullTime": { + "type": "object", + "properties": { + "time": { + "type": "string" + }, + "valid": { + "description": "Valid is true if Time is not NULL", + "type": "boolean" + } + } } } } \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index b190e41b..d32ff426 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,55 +1,6 @@ basePath: /api/v1 definitions: - models.ErrorResponse: - properties: - code: - type: integer - error: - type: string - message: - type: string - type: object - models.ExampleGetResponse: - properties: - message: - type: string - type: object - models.ExamplePostRequest: - properties: - age: - type: integer - name: - type: string - required: - - age - - name - type: object - models.ExamplePostResponse: - properties: - id: - type: string - message: - type: string - type: object - models.HealthResponse: - properties: - details: - additionalProperties: - type: string - type: object - status: - type: string - timestamp: - type: string - type: object - models.HelloWorldResponse: - properties: - message: - type: string - version: - type: string - type: object - models.LoginRequest: + api-service_internal_models_auth.LoginRequest: properties: password: type: string @@ -59,57 +10,7 @@ definitions: - password - username type: object - models.ProductCreateRequest: - properties: - name: - type: string - required: - - name - type: object - models.ProductCreateResponse: - properties: - data: {} - id: - type: string - message: - type: string - type: object - models.ProductDeleteResponse: - properties: - id: - type: string - message: - type: string - type: object - models.ProductGetByIDResponse: - properties: - id: - type: string - message: - type: string - type: object - models.ProductGetResponse: - properties: - data: {} - message: - type: string - type: object - models.ProductUpdateRequest: - properties: - name: - type: string - required: - - name - type: object - models.ProductUpdateResponse: - properties: - data: {} - id: - type: string - message: - type: string - type: object - models.TokenResponse: + api-service_internal_models_auth.TokenResponse: properties: access_token: type: string @@ -118,7 +19,7 @@ definitions: token_type: type: string type: object - models.User: + api-service_internal_models_auth.User: properties: email: type: string @@ -129,6 +30,284 @@ definitions: username: type: string type: object + api-service_internal_models_retribusi.AggregateData: + properties: + by_dinas: + additionalProperties: + type: integer + type: object + by_jenis: + additionalProperties: + type: integer + type: object + by_status: + additionalProperties: + type: integer + type: object + created_today: + type: integer + last_updated: + type: string + total_active: + type: integer + total_draft: + type: integer + total_inactive: + type: integer + updated_today: + type: integer + type: object + api-service_internal_models_retribusi.ErrorResponse: + properties: + code: + type: integer + error: + type: string + message: + type: string + timestamp: + type: string + type: object + api-service_internal_models_retribusi.MetaResponse: + properties: + current_page: + type: integer + has_next: + type: boolean + has_prev: + type: boolean + limit: + type: integer + offset: + type: integer + total: + type: integer + total_pages: + type: integer + type: object + api-service_internal_models_retribusi.NullableInt32: + properties: + int32: + type: integer + valid: + type: boolean + type: object + api-service_internal_models_retribusi.Retribusi: + properties: + date_created: + $ref: '#/definitions/sql.NullTime' + date_updated: + $ref: '#/definitions/sql.NullTime' + dinas: + $ref: '#/definitions/sql.NullString' + id: + type: string + jenis: + $ref: '#/definitions/sql.NullString' + kelompok_obyek: + $ref: '#/definitions/sql.NullString' + kode_tarif: + $ref: '#/definitions/sql.NullString' + pelayanan: + $ref: '#/definitions/sql.NullString' + rekening_denda: + $ref: '#/definitions/sql.NullString' + rekening_pokok: + $ref: '#/definitions/sql.NullString' + satuan: + $ref: '#/definitions/sql.NullString' + satuan_overtime: + $ref: '#/definitions/sql.NullString' + sort: + $ref: '#/definitions/api-service_internal_models_retribusi.NullableInt32' + status: + type: string + tarif: + $ref: '#/definitions/sql.NullString' + tarif_overtime: + $ref: '#/definitions/sql.NullString' + uraian_1: + $ref: '#/definitions/sql.NullString' + uraian_2: + $ref: '#/definitions/sql.NullString' + uraian_3: + $ref: '#/definitions/sql.NullString' + user_created: + $ref: '#/definitions/sql.NullString' + user_updated: + $ref: '#/definitions/sql.NullString' + type: object + api-service_internal_models_retribusi.RetribusiCreateRequest: + properties: + dinas: + maxLength: 255 + minLength: 1 + type: string + jenis: + maxLength: 255 + minLength: 1 + type: string + kelompok_obyek: + maxLength: 255 + minLength: 1 + type: string + kode_tarif: + maxLength: 255 + minLength: 1 + type: string + pelayanan: + maxLength: 255 + minLength: 1 + type: string + rekening_denda: + maxLength: 255 + minLength: 1 + type: string + rekening_pokok: + maxLength: 255 + minLength: 1 + type: string + satuan: + maxLength: 255 + minLength: 1 + type: string + satuan_overtime: + maxLength: 255 + minLength: 1 + type: string + status: + enum: + - draft + - active + - inactive + type: string + tarif: + type: string + tarif_overtime: + type: string + uraian_1: + type: string + uraian_2: + type: string + uraian_3: + type: string + required: + - status + type: object + api-service_internal_models_retribusi.RetribusiCreateResponse: + properties: + data: + $ref: '#/definitions/api-service_internal_models_retribusi.Retribusi' + message: + type: string + type: object + api-service_internal_models_retribusi.RetribusiDeleteResponse: + properties: + id: + type: string + message: + type: string + type: object + api-service_internal_models_retribusi.RetribusiGetByIDResponse: + properties: + data: + $ref: '#/definitions/api-service_internal_models_retribusi.Retribusi' + message: + type: string + type: object + api-service_internal_models_retribusi.RetribusiGetResponse: + properties: + data: + items: + $ref: '#/definitions/api-service_internal_models_retribusi.Retribusi' + type: array + message: + type: string + meta: + $ref: '#/definitions/api-service_internal_models_retribusi.MetaResponse' + summary: + $ref: '#/definitions/api-service_internal_models_retribusi.AggregateData' + type: object + api-service_internal_models_retribusi.RetribusiUpdateRequest: + properties: + dinas: + maxLength: 255 + minLength: 1 + type: string + jenis: + maxLength: 255 + minLength: 1 + type: string + kelompok_obyek: + maxLength: 255 + minLength: 1 + type: string + kode_tarif: + maxLength: 255 + minLength: 1 + type: string + pelayanan: + maxLength: 255 + minLength: 1 + type: string + rekening_denda: + maxLength: 255 + minLength: 1 + type: string + rekening_pokok: + maxLength: 255 + minLength: 1 + type: string + satuan: + maxLength: 255 + minLength: 1 + type: string + satuan_overtime: + maxLength: 255 + minLength: 1 + type: string + status: + enum: + - draft + - active + - inactive + type: string + tarif: + type: string + tarif_overtime: + type: string + uraian_1: + type: string + uraian_2: + type: string + uraian_3: + type: string + required: + - status + type: object + api-service_internal_models_retribusi.RetribusiUpdateResponse: + properties: + data: + $ref: '#/definitions/api-service_internal_models_retribusi.Retribusi' + message: + type: string + type: object + sql.NullString: + properties: + string: + type: string + valid: + description: Valid is true if String is not NULL + type: boolean + type: object + sql.NullTime: + properties: + time: + type: string + valid: + description: Valid is true if Time is not NULL + type: boolean + type: object host: localhost:8080 info: contact: @@ -143,21 +322,6 @@ info: title: API Service version: 1.0.0 paths: - /: - get: - consumes: - - application/json - description: Returns a hello world message - produces: - - application/json - responses: - "200": - description: Hello world message - schema: - $ref: '#/definitions/models.HelloWorldResponse' - summary: Hello World endpoint - tags: - - root /api/v1/auth/login: post: consumes: @@ -169,14 +333,14 @@ paths: name: login required: true schema: - $ref: '#/definitions/models.LoginRequest' + $ref: '#/definitions/api-service_internal_models_auth.LoginRequest' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/models.TokenResponse' + $ref: '#/definitions/api-service_internal_models_auth.TokenResponse' "400": description: Bad request schema: @@ -201,7 +365,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/models.User' + $ref: '#/definitions/api-service_internal_models_auth.User' "401": description: Unauthorized schema: @@ -233,7 +397,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/models.TokenResponse' + $ref: '#/definitions/api-service_internal_models_auth.TokenResponse' "400": description: Bad request schema: @@ -281,169 +445,217 @@ paths: summary: Register new user tags: - Authentication - /api/v1/example: - get: + /api/v1/retribusi/{id}: + delete: consumes: - application/json - description: Returns a simple message for GET request + description: Soft deletes a retribusi by setting status to 'deleted' + parameters: + - description: Retribusi ID (UUID) + in: path + name: id + required: true + type: string produces: - application/json responses: "200": - description: Example GET response + description: Retribusi deleted successfully schema: - $ref: '#/definitions/models.ExampleGetResponse' - summary: Example GET service + $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiDeleteResponse' + "400": + description: Invalid ID format + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + "404": + description: Retribusi not found + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + "500": + description: Internal server error + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + summary: Delete retribusi tags: - - example - post: + - retribusi + get: consumes: - application/json - description: Accepts a JSON payload and returns a response with an ID + description: Returns a single retribusi by ID parameters: - - description: Example POST request + - description: Retribusi ID (UUID) + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Success response + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiGetByIDResponse' + "400": + description: Invalid ID format + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + "404": + description: Retribusi not found + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + "500": + description: Internal server error + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + summary: Get Retribusi by ID + tags: + - retribusi + put: + consumes: + - application/json + description: Updates an existing retribusi record + parameters: + - description: Retribusi ID (UUID) + in: path + name: id + required: true + type: string + - description: Retribusi update request in: body name: request required: true schema: - $ref: '#/definitions/models.ExamplePostRequest' + $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiUpdateRequest' produces: - application/json responses: "200": - description: Example POST response + description: Retribusi updated successfully schema: - $ref: '#/definitions/models.ExamplePostResponse' + $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiUpdateResponse' + "400": + description: Bad request or validation error + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + "404": + description: Retribusi not found + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + "500": + description: Internal server error + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + summary: Update retribusi + tags: + - retribusi + /api/v1/retribusis: + get: + consumes: + - application/json + description: Returns a paginated list of retribusis with optional summary statistics + parameters: + - default: 10 + description: Limit (max 100) + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + - default: false + description: Include aggregation summary + in: query + name: include_summary + type: boolean + - description: Filter by status + in: query + name: status + type: string + - description: Filter by jenis + in: query + name: jenis + type: string + - description: Filter by dinas + in: query + name: dinas + type: string + - description: Search in multiple fields + in: query + name: search + type: string + produces: + - application/json + responses: + "200": + description: Success response + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiGetResponse' "400": description: Bad request schema: - $ref: '#/definitions/models.ErrorResponse' - summary: Example POST service - tags: - - example - /api/v1/products: - get: - consumes: - - application/json - description: Returns a list of products - produces: - - application/json - responses: - "200": - description: Product GET response + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + "500": + description: Internal server error schema: - $ref: '#/definitions/models.ProductGetResponse' - summary: Get product + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + summary: Get retribusi with pagination and optional aggregation tags: - - product + - retribusi post: consumes: - application/json - description: Creates a new product + description: Creates a new retribusi record parameters: - - description: Product creation request + - description: Retribusi creation request in: body name: request required: true schema: - $ref: '#/definitions/models.ProductCreateRequest' + $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiCreateRequest' produces: - application/json responses: "201": - description: Product created successfully + description: Retribusi created successfully schema: - $ref: '#/definitions/models.ProductCreateResponse' + $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiCreateResponse' "400": - description: Bad request + description: Bad request or validation error schema: - $ref: '#/definitions/models.ErrorResponse' - summary: Create product + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + "500": + description: Internal server error + schema: + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + summary: Create retribusi tags: - - product - /api/v1/products/{id}: - delete: - consumes: - - application/json - description: Deletes a product by ID - parameters: - - description: Product ID - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: Product deleted successfully - schema: - $ref: '#/definitions/models.ProductDeleteResponse' - "404": - description: Product not found - schema: - $ref: '#/definitions/models.ErrorResponse' - summary: Delete product - tags: - - product + - retribusi + /api/v1/retribusis/stats: get: consumes: - application/json - description: Returns a single product by ID + description: Returns comprehensive statistics about retribusi data parameters: - - description: Product ID - in: path - name: id - required: true + - description: Filter statistics by status + in: query + name: status type: string produces: - application/json responses: "200": - description: Product GET by ID response + description: Statistics data schema: - $ref: '#/definitions/models.ProductGetByIDResponse' - "404": - description: Product not found + $ref: '#/definitions/api-service_internal_models_retribusi.AggregateData' + "500": + description: Internal server error schema: - $ref: '#/definitions/models.ErrorResponse' - summary: Get product by ID + $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse' + summary: Get retribusi statistics tags: - - product - put: - consumes: - - application/json - description: Updates an existing product - parameters: - - description: Product ID - in: path - name: id - required: true - type: string - - description: Product update request - in: body - name: request - required: true - schema: - $ref: '#/definitions/models.ProductUpdateRequest' - produces: - - application/json - responses: - "200": - description: Product updated successfully - schema: - $ref: '#/definitions/models.ProductUpdateResponse' - "400": - description: Bad request - schema: - $ref: '#/definitions/models.ErrorResponse' - "404": - description: Product not found - schema: - $ref: '#/definitions/models.ErrorResponse' - summary: Update product - tags: - - product + - retribusi /api/v1/token/generate: post: consumes: @@ -455,14 +667,14 @@ paths: name: token required: true schema: - $ref: '#/definitions/models.LoginRequest' + $ref: '#/definitions/api-service_internal_models_auth.LoginRequest' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/models.TokenResponse' + $ref: '#/definitions/api-service_internal_models_auth.TokenResponse' "400": description: Bad request schema: @@ -499,7 +711,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/models.TokenResponse' + $ref: '#/definitions/api-service_internal_models_auth.TokenResponse' "400": description: Bad request schema: @@ -509,25 +721,6 @@ paths: summary: Generate token directly tags: - Token - /health: - get: - consumes: - - application/json - description: Returns the health status of the API service - produces: - - application/json - responses: - "200": - description: Health status - schema: - $ref: '#/definitions/models.HealthResponse' - "500": - description: Internal server error - schema: - $ref: '#/definitions/models.ErrorResponse' - summary: Health check endpoint - tags: - - health schemes: - http - https diff --git a/internal/models/retribusi/retribusi.go b/internal/models/retribusi/retribusi.go index 3693deb9..b23e13c4 100644 --- a/internal/models/retribusi/retribusi.go +++ b/internal/models/retribusi/retribusi.go @@ -2,16 +2,42 @@ package models import ( "database/sql" + "database/sql/driver" "encoding/json" "time" ) +// NullableInt32 is a custom type to replace sql.NullInt32 for swagger compatibility +type NullableInt32 struct { + Int32 int32 `json:"int32,omitempty"` + Valid bool `json:"valid"` +} + +// Scan implements the sql.Scanner interface for NullableInt32 +func (n *NullableInt32) Scan(value interface{}) error { + var ni sql.NullInt32 + if err := ni.Scan(value); err != nil { + return err + } + n.Int32 = ni.Int32 + n.Valid = ni.Valid + return nil +} + +// Value implements the driver.Valuer interface for NullableInt32 +func (n NullableInt32) Value() (driver.Value, error) { + if !n.Valid { + return nil, nil + } + return n.Int32, nil +} + // Retribusi represents the data structure for the retribusi table // with proper null handling and optimized JSON marshaling type Retribusi struct { ID string `json:"id" db:"id"` Status string `json:"status" db:"status"` - Sort sql.NullInt32 `json:"sort,omitempty" db:"sort"` + Sort NullableInt32 `json:"sort,omitempty" db:"sort"` UserCreated sql.NullString `json:"user_created,omitempty" db:"user_created"` DateCreated sql.NullTime `json:"date_created,omitempty" db:"date_created"` UserUpdated sql.NullString `json:"user_updated,omitempty" db:"user_updated"` @@ -60,7 +86,7 @@ func (r Retribusi) MarshalJSON() ([]byte, error) { Alias: (*Alias)(&r), } - // Convert sql.Null* to pointers + // Convert NullableInt32 to pointer if r.Sort.Valid { sort := int(r.Sort.Int32) aux.Sort = &sort