Perbaikan code dinamic
This commit is contained in:
79
README.md
79
README.md
@@ -123,6 +123,85 @@ go run tools/satusehat/generate-satusehat-handler.go services-config-satusehat.y
|
|||||||
- `PUT /api/v1/products/:id` - Update product
|
- `PUT /api/v1/products/:id` - Update product
|
||||||
- `DELETE /api/v1/products/:id` - Delete product
|
- `DELETE /api/v1/products/:id` - Delete product
|
||||||
|
|
||||||
|
GET /api/v1/retribusi/dynamic
|
||||||
|
GET /api/v1/retribusi/dynamic?fields=Jenis,Pelayanan,Dinas,Tarif
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[status][_eq]=active
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[Jenis][_eq]=RETRIBUSI PELAYANAN KESEHATAN
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[status][_eq]=active&filter[Jenis][_contains]=KESEHATAN
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[_or][0][Jenis][_contains]=KESEHATAN&filter[_or][1][Jenis][_contains]=PENDIDIKAN
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[date_created][_gte]=2024-01-01&filter[date_created][_lte]=2024-12-31
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[Jenis][_contains]=KESEHATAN&filter[Pelayanan][_contains]=RUMAH SAKIT
|
||||||
|
GET /api/v1/retribusi/dynamic?limit=10&offset=20
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[status][_neq]=deleted&filter[Tarif][_gt]=100000&filter[Jenis][_contains]=KESEHATAN&sort=-date_created&limit=50
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[Dinas][_eq]=DINAS KESEHATAN
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[Kode_tarif][_contains]=RS
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[date_created][_gte]=2024-01-15&filter[date_created][_lt]=2024-01-16
|
||||||
|
GET /api/v1/retribusi/dynamic?filter[Uraian_1][_contains]=RAWAT INAP
|
||||||
|
|
||||||
|
Available Filter Operators
|
||||||
|
_eq - Equal
|
||||||
|
_neq - Not equal
|
||||||
|
_lt - Less than
|
||||||
|
_lte - Less than or equal
|
||||||
|
_gt - Greater than
|
||||||
|
_gte - Greater than or equal
|
||||||
|
_contains - Contains (case-insensitive)
|
||||||
|
_ncontains - Not contains
|
||||||
|
_starts_with - Starts with
|
||||||
|
_ends_with - Ends with
|
||||||
|
_in - In array
|
||||||
|
_nin - Not in array
|
||||||
|
_null - Is null
|
||||||
|
_nnull - Is not null
|
||||||
|
Available Fields for Filtering
|
||||||
|
id - Record ID
|
||||||
|
status - Status (active, draft, inactive, deleted)
|
||||||
|
Jenis - Type of retribution
|
||||||
|
Pelayanan - Service type
|
||||||
|
Dinas - Department
|
||||||
|
Kelompok_obyek - Object group
|
||||||
|
Kode_tarif - Tariff code
|
||||||
|
Tarif - Tariff amount
|
||||||
|
Satuan - Unit
|
||||||
|
Tarif_overtime - Overtime tariff
|
||||||
|
Satuan_overtime - Overtime unit
|
||||||
|
Rekening_pokok - Main account
|
||||||
|
Rekening_denda - Penalty account
|
||||||
|
Uraian_1, Uraian_2, Uraian_3 - Descriptions
|
||||||
|
date_created - Creation date
|
||||||
|
date_updated - Update date
|
||||||
|
user_created - Created by user
|
||||||
|
user_updated - Updated by user
|
||||||
|
Response Format
|
||||||
|
The endpoint returns data in this format:
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
"message": "Data retribusi berhasil diambil",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": "uuid",
|
||||||
|
"status": "active",
|
||||||
|
"Jenis": "RETRIBUSI PELAYANAN KESEHATAN",
|
||||||
|
"Pelayanan": "RAWAT INAP",
|
||||||
|
"Dinas": "DINAS KESEHATAN",
|
||||||
|
"Tarif": 150000,
|
||||||
|
"date_created": "2024-01-15T10:30:00Z"
|
||||||
|
// ... other fields
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meta": {
|
||||||
|
"limit": 10,
|
||||||
|
"offset": 0,
|
||||||
|
"total": 150,
|
||||||
|
"total_pages": 15,
|
||||||
|
"current_page": 1,
|
||||||
|
"has_next": true,
|
||||||
|
"has_prev": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
## 🧪 Development Workflow
|
## 🧪 Development Workflow
|
||||||
|
|
||||||
### Perintah Penting
|
### Perintah Penting
|
||||||
|
|||||||
@@ -288,6 +288,7 @@ func (h *RetribusiHandler) fetchRetribusisDynamic(ctx context.Context, dbConn *s
|
|||||||
"pelayanan": "Pelayanan",
|
"pelayanan": "Pelayanan",
|
||||||
"dinas": "Dinas",
|
"dinas": "Dinas",
|
||||||
"kelompok_obyek": "Kelompok_obyek",
|
"kelompok_obyek": "Kelompok_obyek",
|
||||||
|
"Kode_tarif": "Kode_tarif",
|
||||||
"kode_tarif": "Kode_tarif",
|
"kode_tarif": "Kode_tarif",
|
||||||
"tarif": "Tarif",
|
"tarif": "Tarif",
|
||||||
"satuan": "Satuan",
|
"satuan": "Satuan",
|
||||||
@@ -308,6 +309,8 @@ func (h *RetribusiHandler) fetchRetribusisDynamic(ctx context.Context, dbConn *s
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Add default filter to exclude deleted records
|
// Add default filter to exclude deleted records
|
||||||
|
if len(query.Filters) > 0 {
|
||||||
|
// If there are existing filters, add the default filter as the first group
|
||||||
query.Filters = append([]utils.FilterGroup{{
|
query.Filters = append([]utils.FilterGroup{{
|
||||||
Filters: []utils.DynamicFilter{{
|
Filters: []utils.DynamicFilter{{
|
||||||
Column: "status",
|
Column: "status",
|
||||||
@@ -316,6 +319,17 @@ func (h *RetribusiHandler) fetchRetribusisDynamic(ctx context.Context, dbConn *s
|
|||||||
}},
|
}},
|
||||||
LogicOp: "AND",
|
LogicOp: "AND",
|
||||||
}}, query.Filters...)
|
}}, query.Filters...)
|
||||||
|
} else {
|
||||||
|
// If no existing filters, just add the default filter
|
||||||
|
query.Filters = []utils.FilterGroup{{
|
||||||
|
Filters: []utils.DynamicFilter{{
|
||||||
|
Column: "status",
|
||||||
|
Operator: utils.OpNotEqual,
|
||||||
|
Value: "deleted",
|
||||||
|
}},
|
||||||
|
LogicOp: "AND",
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
// Execute concurrent queries
|
// Execute concurrent queries
|
||||||
var (
|
var (
|
||||||
@@ -1397,16 +1411,3 @@ func (h *RetribusiHandler) getLastSubmissionTimeExample(ctx context.Context, dbC
|
|||||||
validator := validation.NewDuplicateValidator(dbConn)
|
validator := validation.NewDuplicateValidator(dbConn)
|
||||||
return validator.GetLastSubmissionTime(ctx, "data_retribusi", "id", "date_created", identifier)
|
return validator.GetLastSubmissionTime(ctx, "data_retribusi", "id", "date_created", identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
// models/retribusi.go - pastikan struct ini memiliki semua field
|
|
||||||
type AggregateData struct {
|
|
||||||
TotalActive int `json:"total_active"`
|
|
||||||
TotalDraft int `json:"total_draft"`
|
|
||||||
TotalInactive int `json:"total_inactive"`
|
|
||||||
ByStatus map[string]int `json:"by_status"`
|
|
||||||
ByDinas map[string]int `json:"by_dinas,omitempty"`
|
|
||||||
ByJenis map[string]int `json:"by_jenis,omitempty"`
|
|
||||||
LastUpdated *time.Time `json:"last_updated,omitempty"`
|
|
||||||
CreatedToday int `json:"created_today"`
|
|
||||||
UpdatedToday int `json:"updated_today"`
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user