Perbaikan Service Satu sehat
This commit is contained in:
+2
-58
@@ -10,18 +10,10 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"service/internal/auth"
|
"service/internal/auth"
|
||||||
antrol "service/internal/bpjs/antrol/reference"
|
|
||||||
aplicareBed "service/internal/bpjs/aplicare/bed"
|
|
||||||
apotekDpho "service/internal/bpjs/apotek/reference/dpho"
|
|
||||||
apotekPoli "service/internal/bpjs/apotek/reference/poli"
|
|
||||||
"service/internal/bpjs/vclaim/peserta"
|
|
||||||
"service/internal/bpjs/vclaim/sep"
|
|
||||||
"service/internal/infrastructure/cache"
|
"service/internal/infrastructure/cache"
|
||||||
"service/internal/infrastructure/config"
|
"service/internal/infrastructure/config"
|
||||||
"service/internal/infrastructure/database"
|
"service/internal/infrastructure/database"
|
||||||
grpcHandlers "service/internal/infrastructure/transport/grpc/handlers"
|
|
||||||
httpServer "service/internal/infrastructure/transport/http/servers"
|
httpServer "service/internal/infrastructure/transport/http/servers"
|
||||||
bpjsFactory "service/internal/interfaces/bpjs"
|
|
||||||
"service/internal/interfaces/minio"
|
"service/internal/interfaces/minio"
|
||||||
satuSehatFactory "service/internal/interfaces/satusehat"
|
satuSehatFactory "service/internal/interfaces/satusehat"
|
||||||
|
|
||||||
@@ -170,40 +162,6 @@ func main() {
|
|||||||
// roleComponentQueryRepo := roleComponent.NewQueryRepository(dbService, "postgres")
|
// roleComponentQueryRepo := roleComponent.NewQueryRepository(dbService, "postgres")
|
||||||
// roleComponentService := roleComponent.NewService(roleComponentCmdRepo, roleComponentQueryRepo)
|
// roleComponentService := roleComponent.NewService(roleComponentCmdRepo, roleComponentQueryRepo)
|
||||||
|
|
||||||
// --- [NEW] Inisialisasi Modul CQRS Baru (Memanfaatkan DB Service) ---
|
|
||||||
// Contoh ketika mengimplementasikan entity "Province" atau "Person":
|
|
||||||
// provinceCmdRepo := province.NewCommandRepository(dbService, "default")
|
|
||||||
// provinceQueryRepo := province.NewQueryRepository(dbService, "default")
|
|
||||||
// provinceSvc := province.NewService(provinceCmdRepo, provinceQueryRepo)
|
|
||||||
|
|
||||||
// --- [NEW] Inisialisasi Factory BPJS ---
|
|
||||||
bpjsServices := bpjsFactory.NewBPJSFactory(cfg.Bpjs)
|
|
||||||
|
|
||||||
// 1. Modul VClaim (Lama)
|
|
||||||
vclaimServiceEngine := bpjsServices.VClaim()
|
|
||||||
sepRepo := sep.NewRepository(vclaimServiceEngine)
|
|
||||||
sepService := sep.NewService(sepRepo)
|
|
||||||
pesertaRepo := peserta.NewRepository(vclaimServiceEngine)
|
|
||||||
pesertaService := peserta.NewService(pesertaRepo)
|
|
||||||
|
|
||||||
// 2. Modul Antrean RS (Baru)
|
|
||||||
antreanClient := bpjsServices.AntreanRS()
|
|
||||||
antrolRepo := antrol.NewRepository(antreanClient)
|
|
||||||
antrolService := antrol.NewService(antrolRepo)
|
|
||||||
|
|
||||||
// 3. Modul Aplicares (Bed Ketersediaan Tempat Tidur)
|
|
||||||
aplicareClient := bpjsServices.Aplicare()
|
|
||||||
bedRepo := aplicareBed.NewRepository(aplicareClient)
|
|
||||||
bedService := aplicareBed.NewService(bedRepo)
|
|
||||||
|
|
||||||
// 4. Modul Apotek (Referensi DPHO dan Poli)
|
|
||||||
apotekClient := bpjsServices.Apotek()
|
|
||||||
dphoRepo := apotekDpho.NewRepository(apotekClient)
|
|
||||||
dphoService := apotekDpho.NewService(dphoRepo)
|
|
||||||
|
|
||||||
poliApotekRepo := apotekPoli.NewRepository(apotekClient)
|
|
||||||
poliApotekService := apotekPoli.NewService(poliApotekRepo)
|
|
||||||
|
|
||||||
// --- [NEW] Inisialisasi Modul Satu Sehat ---
|
// --- [NEW] Inisialisasi Modul Satu Sehat ---
|
||||||
satusehatFact := satuSehatFactory.NewSatuSehatFactory(cfg.SatuSehat)
|
satusehatFact := satuSehatFactory.NewSatuSehatFactory(cfg.SatuSehat)
|
||||||
satusehatClient := satusehatFact.Client()
|
satusehatClient := satusehatFact.Client()
|
||||||
@@ -273,20 +231,6 @@ func main() {
|
|||||||
RolePermission: rolePermissionService,
|
RolePermission: rolePermissionService,
|
||||||
RoleMaster: roleMasterService,
|
RoleMaster: roleMasterService,
|
||||||
},
|
},
|
||||||
VClaim: &httpServer.VClaimServices{
|
|
||||||
Sep: sepService,
|
|
||||||
Peserta: pesertaService,
|
|
||||||
},
|
|
||||||
Antrol: &httpServer.AntrolServices{
|
|
||||||
Reference: antrolService,
|
|
||||||
},
|
|
||||||
Aplicare: &httpServer.AplicaresServices{
|
|
||||||
Bed: bedService,
|
|
||||||
},
|
|
||||||
Apotek: &httpServer.ApotekServices{
|
|
||||||
DPHO: dphoService,
|
|
||||||
Poli: poliApotekService,
|
|
||||||
},
|
|
||||||
SatuSehat: &httpServer.SatuSehatServices{
|
SatuSehat: &httpServer.SatuSehatServices{
|
||||||
Auth: satuSehatAuthSvc,
|
Auth: satuSehatAuthSvc,
|
||||||
Patient: satuSehatPatientSvc,
|
Patient: satuSehatPatientSvc,
|
||||||
@@ -334,10 +278,10 @@ func main() {
|
|||||||
serverCount++
|
serverCount++
|
||||||
|
|
||||||
// 1. Buat gRPC handlers
|
// 1. Buat gRPC handlers
|
||||||
permissionHandler := grpcHandlers.NewPermissionHandler(rolePermissionService)
|
// permissionHandler := grpcHandlers.NewPermissionHandler(rolePermissionService)
|
||||||
// 2. Buat dan isi gRPC service registry
|
// 2. Buat dan isi gRPC service registry
|
||||||
grpcRegistry := &grpcServers.ServiceRegistry{
|
grpcRegistry := &grpcServers.ServiceRegistry{
|
||||||
PermissionHandler: permissionHandler,
|
// PermissionHandler: permissionHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Buat gRPC server dengan registry yang sudah diisi
|
// 3. Buat gRPC server dengan registry yang sudah diisi
|
||||||
|
|||||||
@@ -1,141 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"service/internal/infrastructure/cache"
|
|
||||||
"service/internal/infrastructure/config"
|
|
||||||
"service/internal/infrastructure/database"
|
|
||||||
httpServer "service/internal/infrastructure/transport/http/servers"
|
|
||||||
satuSehatFactory "service/internal/interfaces/satusehat"
|
|
||||||
"service/pkg/logger"
|
|
||||||
|
|
||||||
satuSehatAuth "service/internal/satusehat/reference/auth"
|
|
||||||
satuSehatKfa "service/internal/satusehat/reference/kfa"
|
|
||||||
satuSehatLocation "service/internal/satusehat/reference/location"
|
|
||||||
satuSehatOrganization "service/internal/satusehat/reference/organization"
|
|
||||||
satuSehatPatient "service/internal/satusehat/reference/patient"
|
|
||||||
satuSehatPractitioner "service/internal/satusehat/reference/practitioner"
|
|
||||||
satuSehatCondition "service/internal/satusehat/usecase/condition"
|
|
||||||
satuSehatEncounter "service/internal/satusehat/usecase/encounter"
|
|
||||||
satuSehatProcedure "service/internal/satusehat/usecase/procedure"
|
|
||||||
|
|
||||||
_ "service/docs/swagger" // Import swagger docs
|
|
||||||
|
|
||||||
"golang.org/x/sync/errgroup"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// 1. Load Config
|
|
||||||
cfg := config.LoadConfig()
|
|
||||||
|
|
||||||
// 2. Init Logger khusus untuk service Satu Sehat
|
|
||||||
loggerConfig := logger.Config{
|
|
||||||
Level: cfg.Logger.Level,
|
|
||||||
Format: cfg.Logger.Format,
|
|
||||||
Output: "both",
|
|
||||||
ServiceName: "service-satusehat", // Penanda log
|
|
||||||
EnableCaller: cfg.Server.Mode != "production",
|
|
||||||
Environment: cfg.Server.Mode,
|
|
||||||
}
|
|
||||||
logger.Init(loggerConfig)
|
|
||||||
|
|
||||||
logger.Default().Info("SatuSehat Microservice starting...",
|
|
||||||
logger.String("environment", cfg.Server.Mode),
|
|
||||||
logger.String("log_level", cfg.Logger.Level),
|
|
||||||
)
|
|
||||||
|
|
||||||
if err := cfg.Validate(); err != nil {
|
|
||||||
logger.Default().Fatal("Config validation failed", logger.ErrorField(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Init Database Manager
|
|
||||||
dbService := database.New(cfg)
|
|
||||||
defer dbService.Close()
|
|
||||||
|
|
||||||
gormDB, err := dbService.GetGormDB("default")
|
|
||||||
if err != nil {
|
|
||||||
logger.Default().Fatal("Failed to get primary database", logger.ErrorField(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Init Cache
|
|
||||||
cacheFactory := cache.NewFactory(cfg.Cache)
|
|
||||||
cacheManager, err := cacheFactory.CreateManager()
|
|
||||||
if err != nil {
|
|
||||||
logger.Default().Fatal("Failed to initialize cache manager", logger.ErrorField(err))
|
|
||||||
}
|
|
||||||
defer cacheManager.Close()
|
|
||||||
|
|
||||||
// 5. Init Layers (Hanya Modul Satu Sehat)
|
|
||||||
satusehatFact := satuSehatFactory.NewSatuSehatFactory(cfg.SatuSehat)
|
|
||||||
satusehatClient := satusehatFact.Client()
|
|
||||||
|
|
||||||
// - Reference Services
|
|
||||||
satuSehatAuthSvc := satuSehatAuth.NewService(satusehatClient, cacheManager)
|
|
||||||
satuSehatPatientSvc := satuSehatPatient.NewService(satuSehatPatient.NewRepository(satusehatClient))
|
|
||||||
satuSehatPractitionerSvc := satuSehatPractitioner.NewService(satuSehatPractitioner.NewRepository(satusehatClient))
|
|
||||||
satuSehatOrganizationSvc := satuSehatOrganization.NewService(satuSehatOrganization.NewRepository(satusehatClient))
|
|
||||||
satuSehatLocationSvc := satuSehatLocation.NewService(satuSehatLocation.NewRepository(satusehatClient))
|
|
||||||
satuSehatKfaSvc := satuSehatKfa.NewService(satuSehatKfa.NewRepository(satusehatClient))
|
|
||||||
|
|
||||||
// - Usecase Services
|
|
||||||
satuSehatEncounterSvc := satuSehatEncounter.NewService(satuSehatEncounter.NewRepository(satusehatClient, dbService))
|
|
||||||
satuSehatProcedureSvc := satuSehatProcedure.NewService(satuSehatProcedure.NewRepository(satusehatClient))
|
|
||||||
satuSehatConditionSvc := satuSehatCondition.NewService(satuSehatCondition.NewRepository(satusehatClient))
|
|
||||||
|
|
||||||
// 6. Server Orchestration
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
g, ctx := errgroup.WithContext(ctx)
|
|
||||||
|
|
||||||
// --- Start REST Server (Hanya me-load endpoint Satu Sehat & Health) ---
|
|
||||||
if cfg.Server.REST.Enabled {
|
|
||||||
registry := &httpServer.ServiceRegistry{
|
|
||||||
Config: cfg,
|
|
||||||
DBManager: dbService,
|
|
||||||
PrimaryDB: gormDB,
|
|
||||||
CacheManager: cacheManager,
|
|
||||||
SatuSehat: &httpServer.SatuSehatServices{
|
|
||||||
Auth: satuSehatAuthSvc,
|
|
||||||
Patient: satuSehatPatientSvc,
|
|
||||||
Practitioner: satuSehatPractitionerSvc,
|
|
||||||
Organization: satuSehatOrganizationSvc,
|
|
||||||
Location: satuSehatLocationSvc,
|
|
||||||
KFA: satuSehatKfaSvc,
|
|
||||||
Encounter: satuSehatEncounterSvc,
|
|
||||||
Procedure: satuSehatProcedureSvc,
|
|
||||||
Condition: satuSehatConditionSvc,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
restSrv := httpServer.NewHTTPServer(&cfg.Server.REST, registry)
|
|
||||||
g.Go(func() error {
|
|
||||||
logger.Default().Info("SatuSehat REST API running", logger.Int("port", cfg.Server.REST.Port))
|
|
||||||
if err := restSrv.Start(&cfg.Server); err != nil && err != http.ErrServerClosed {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Graceful Shutdown Listener ---
|
|
||||||
g.Go(func() error {
|
|
||||||
quit := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
|
||||||
<-quit
|
|
||||||
logger.Default().Warn("Signal received, shutting down SatuSehat service...")
|
|
||||||
cancel()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
if err := g.Wait(); err != nil {
|
|
||||||
logger.Default().Error("SatuSehat service shutdown with error", logger.ErrorField(err))
|
|
||||||
} else {
|
|
||||||
logger.Default().Info("SatuSehat service shutdown successful")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"service/internal/infrastructure/config"
|
|
||||||
"service/internal/infrastructure/database"
|
|
||||||
satuSehatFactory "service/internal/interfaces/satusehat"
|
|
||||||
"service/internal/worker"
|
|
||||||
"service/pkg/logger"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// 1. Load Configuration
|
|
||||||
cfg := config.LoadConfig()
|
|
||||||
|
|
||||||
// 2. Initialize Logger khusus untuk Worker
|
|
||||||
loggerConfig := logger.Config{
|
|
||||||
Level: cfg.Logger.Level,
|
|
||||||
Format: cfg.Logger.Format,
|
|
||||||
Output: "both",
|
|
||||||
ServiceName: "service-worker", // Penanda log khusus worker
|
|
||||||
EnableCaller: cfg.Server.Mode != "production",
|
|
||||||
Environment: cfg.Server.Mode,
|
|
||||||
}
|
|
||||||
logger.Init(loggerConfig)
|
|
||||||
|
|
||||||
logger.Default().Info("Background Worker Microservice starting...",
|
|
||||||
logger.String("environment", cfg.Server.Mode),
|
|
||||||
logger.String("log_level", cfg.Logger.Level),
|
|
||||||
)
|
|
||||||
|
|
||||||
if err := cfg.Validate(); err != nil {
|
|
||||||
logger.Default().Fatal("Config validation failed", logger.ErrorField(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Initialize Database Manager
|
|
||||||
dbService := database.New(cfg)
|
|
||||||
defer dbService.Close()
|
|
||||||
|
|
||||||
// 4. Initialize SatuSehat Client (Dibutuhkan oleh worker manager)
|
|
||||||
satusehatFact := satuSehatFactory.NewSatuSehatFactory(cfg.SatuSehat)
|
|
||||||
satusehatClient := satusehatFact.Client()
|
|
||||||
|
|
||||||
// 5. Setup Context untuk Graceful Shutdown
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
// 6. Initialize dan Jalankan Worker Manager
|
|
||||||
workerManager := worker.NewManager(cfg, dbService, satusehatClient)
|
|
||||||
workerManager.Start(ctx)
|
|
||||||
|
|
||||||
// 7. Listener untuk OS Signals (Ctrl+C / SIGTERM)
|
|
||||||
quit := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
|
||||||
|
|
||||||
<-quit // Block aplikasi sampai signal diterima
|
|
||||||
logger.Default().Warn("Signal received, shutting down worker service...")
|
|
||||||
cancel() // Batalkan context, trigger penghentian semua worker
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package antrol
|
|
||||||
|
|
||||||
// Poli merepresentasikan data referensi poli dari API Antrean RS BPJS
|
|
||||||
type Poli struct {
|
|
||||||
KdPoli string `json:"kdpoli"`
|
|
||||||
NmPoli string `json:"nmpoli"`
|
|
||||||
KdSubSpesialis string `json:"kdsubspesialis"`
|
|
||||||
NmSubSpesialis string `json:"nmsubspesialis"`
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package antrol
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"service/internal/interfaces/bpjs"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Repository interface {
|
|
||||||
GetRefPoli(ctx context.Context) ([]Poli, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type repository struct {
|
|
||||||
client bpjs.BpjsClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRepository(client bpjs.BpjsClient) Repository {
|
|
||||||
return &repository{client: client}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRefPoli fetches referensi poli from BPJS API
|
|
||||||
//
|
|
||||||
// # This function will return an array of Poli and error if any
|
|
||||||
//
|
|
||||||
// Context is used to pass the request context to the underlying
|
|
||||||
// client
|
|
||||||
//
|
|
||||||
// The function will return an error if the request to BPJS API
|
|
||||||
// fails or if the response cannot be unmarshalled into an array
|
|
||||||
// of Poli
|
|
||||||
//
|
|
||||||
// The function will return an empty array and nil error if the request
|
|
||||||
// to BPJS API succeeds but the response is an empty array
|
|
||||||
func (r *repository) GetRefPoli(ctx context.Context) ([]Poli, error) {
|
|
||||||
respBytes, err := r.client.DoRequest(ctx, "GET", "ref/poli", nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var result []Poli
|
|
||||||
if err := json.Unmarshal(respBytes, &result); err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to unmarshal ref poli antrol response: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package antrol
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"service/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service interface {
|
|
||||||
GetRefPoli(ctx context.Context) ([]Poli, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type service struct {
|
|
||||||
repo Repository
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewService(repo Repository) Service {
|
|
||||||
return &service{repo: repo}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) GetRefPoli(ctx context.Context) ([]Poli, error) {
|
|
||||||
res, err := s.repo.GetRefPoli(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.ExternalError().Message("Gagal mengambil referensi poli Antrean RS BPJS").Cause(err).Build()
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package bed
|
|
||||||
|
|
||||||
// BedData merepresentasikan payload untuk membuat, mengubah, atau mengambil data ketersediaan Bed
|
|
||||||
type BedData struct {
|
|
||||||
KodeKelas string `json:"kodekelas"`
|
|
||||||
KodeRuang string `json:"koderuang"`
|
|
||||||
NamaRuang string `json:"namaruang"`
|
|
||||||
Kapasitas int `json:"kapasitas"`
|
|
||||||
Tersedia int `json:"tersedia"`
|
|
||||||
TersediaPria int `json:"tersediapria"`
|
|
||||||
TersediaWanita int `json:"tersediawanita"`
|
|
||||||
TersediaPriaWanita int `json:"tersediapriawanita"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// BedDeletePayload merepresentasikan payload untuk menghapus data Bed
|
|
||||||
type BedDeletePayload struct {
|
|
||||||
KodeKelas string `json:"kodekelas"`
|
|
||||||
KodeRuang string `json:"koderuang"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// BedReadResponse merepresentasikan balikan dari endpoint GET Read Bed
|
|
||||||
type BedReadResponse struct {
|
|
||||||
List []BedData `json:"list"`
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
package bed
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"service/internal/interfaces/bpjs"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Repository interface {
|
|
||||||
Read(ctx context.Context, kdPpk string, start, limit int) ([]BedData, error)
|
|
||||||
Create(ctx context.Context, kdPpk string, payload BedData) error
|
|
||||||
Update(ctx context.Context, kdPpk string, payload BedData) error
|
|
||||||
Delete(ctx context.Context, kdPpk string, payload BedDeletePayload) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type repository struct {
|
|
||||||
client bpjs.BpjsClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRepository(client bpjs.BpjsClient) Repository {
|
|
||||||
return &repository{client: client}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) Read(ctx context.Context, kdPpk string, start, limit int) ([]BedData, error) {
|
|
||||||
endpoint := fmt.Sprintf("rest/bed/read/%s/%d/%d", kdPpk, start, limit)
|
|
||||||
respBytes, err := r.client.DoRequest(ctx, "GET", endpoint, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var result BedReadResponse
|
|
||||||
if err := json.Unmarshal(respBytes, &result); err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to unmarshal applicare read response: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.List, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) Create(ctx context.Context, kdPpk string, payload BedData) error {
|
|
||||||
endpoint := fmt.Sprintf("rest/bed/create/%s", kdPpk)
|
|
||||||
_, err := r.client.DoRequest(ctx, "POST", endpoint, payload)
|
|
||||||
// Aplicares biasanya mengembalikan sukses di metadata yang sudah dihandle oleh client.go
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) Update(ctx context.Context, kdPpk string, payload BedData) error {
|
|
||||||
// Endpoint Update Aplicares menggunakan method POST, bukan PUT
|
|
||||||
endpoint := fmt.Sprintf("rest/bed/update/%s", kdPpk)
|
|
||||||
_, err := r.client.DoRequest(ctx, "POST", endpoint, payload)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) Delete(ctx context.Context, kdPpk string, payload BedDeletePayload) error {
|
|
||||||
// Endpoint Delete Aplicares juga menggunakan method POST
|
|
||||||
endpoint := fmt.Sprintf("rest/bed/delete/%s", kdPpk)
|
|
||||||
_, err := r.client.DoRequest(ctx, "POST", endpoint, payload)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package bed
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"service/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service interface {
|
|
||||||
GetBedList(ctx context.Context, kdPpk string, start, limit int) ([]BedData, error)
|
|
||||||
CreateBed(ctx context.Context, kdPpk string, req BedData) error
|
|
||||||
UpdateBed(ctx context.Context, kdPpk string, req BedData) error
|
|
||||||
DeleteBed(ctx context.Context, kdPpk string, req BedDeletePayload) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type service struct {
|
|
||||||
repo Repository
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewService(repo Repository) Service {
|
|
||||||
return &service{repo: repo}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) GetBedList(ctx context.Context, kdPpk string, start, limit int) ([]BedData, error) {
|
|
||||||
if kdPpk == "" {
|
|
||||||
return nil, errors.NewValidationError().Message("Kode PPK (Kode Faskes) wajib diisi").Build()
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := s.repo.Read(ctx, kdPpk, start, limit)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.ExternalError().Message("Gagal mengambil data ketersediaan tempat tidur (Aplicares)").Cause(err).Build()
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) CreateBed(ctx context.Context, kdPpk string, req BedData) error {
|
|
||||||
err := s.repo.Create(ctx, kdPpk, req)
|
|
||||||
if err != nil {
|
|
||||||
return errors.ExternalError().Message("Gagal membuat data tempat tidur baru (Aplicares)").Cause(err).Build()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) UpdateBed(ctx context.Context, kdPpk string, req BedData) error {
|
|
||||||
err := s.repo.Update(ctx, kdPpk, req)
|
|
||||||
if err != nil {
|
|
||||||
return errors.ExternalError().Message("Gagal memperbarui data tempat tidur (Aplicares)").Cause(err).Build()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) DeleteBed(ctx context.Context, kdPpk string, req BedDeletePayload) error {
|
|
||||||
err := s.repo.Delete(ctx, kdPpk, req)
|
|
||||||
if err != nil {
|
|
||||||
return errors.ExternalError().Message("Gagal menghapus data tempat tidur (Aplicares)").Cause(err).Build()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package dpho
|
|
||||||
|
|
||||||
// DPHOData merepresentasikan detail referensi DPHO dari API Apotek
|
|
||||||
type DPHOData struct {
|
|
||||||
KodeObat string `json:"kodeobat"`
|
|
||||||
NamaObat string `json:"namaobat"`
|
|
||||||
PRB string `json:"prb"`
|
|
||||||
Kronis string `json:"kronis"`
|
|
||||||
Kemo string `json:"kemo"`
|
|
||||||
Harga string `json:"harga"`
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package dpho
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"service/internal/interfaces/bpjs"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Repository interface {
|
|
||||||
GetDPHO(ctx context.Context) ([]DPHOData, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type repository struct {
|
|
||||||
client bpjs.BpjsClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRepository(client bpjs.BpjsClient) Repository {
|
|
||||||
return &repository{client: client}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) GetDPHO(ctx context.Context) ([]DPHOData, error) {
|
|
||||||
respBytes, err := r.client.DoRequest(ctx, "GET", "referensi/dpho", nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Coba parsing ke dalam format object { "list": [...] }
|
|
||||||
var result struct {
|
|
||||||
List []DPHOData `json:"list"`
|
|
||||||
}
|
|
||||||
if err := json.Unmarshal(respBytes, &result); err != nil {
|
|
||||||
// Fallback jika API mengembalikan array langsung [...]
|
|
||||||
var directList []DPHOData
|
|
||||||
if err2 := json.Unmarshal(respBytes, &directList); err2 == nil {
|
|
||||||
return directList, nil
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("failed to unmarshal apotek dpho response: %w", err)
|
|
||||||
}
|
|
||||||
return result.List, nil
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package dpho
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"service/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service interface {
|
|
||||||
GetDPHO(ctx context.Context) ([]DPHOData, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type service struct {
|
|
||||||
repo Repository
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewService(repo Repository) Service {
|
|
||||||
return &service{repo: repo}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) GetDPHO(ctx context.Context) ([]DPHOData, error) {
|
|
||||||
res, err := s.repo.GetDPHO(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.ExternalError().Message("Gagal mengambil referensi DPHO Apotek BPJS").Cause(err).Build()
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package poli
|
|
||||||
|
|
||||||
// PoliData merepresentasikan detail referensi Poli dari API Apotek
|
|
||||||
type PoliData struct {
|
|
||||||
KodePoli string `json:"kodepoli"`
|
|
||||||
NamaPoli string `json:"namapoli"`
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package poli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"service/internal/interfaces/bpjs"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Repository interface {
|
|
||||||
GetPoli(ctx context.Context, param string) ([]PoliData, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type repository struct {
|
|
||||||
client bpjs.BpjsClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRepository(client bpjs.BpjsClient) Repository {
|
|
||||||
return &repository{client: client}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) GetPoli(ctx context.Context, param string) ([]PoliData, error) {
|
|
||||||
endpoint := fmt.Sprintf("referensi/poli/%s", param)
|
|
||||||
respBytes, err := r.client.DoRequest(ctx, "GET", endpoint, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var result struct {
|
|
||||||
List []PoliData `json:"list"`
|
|
||||||
}
|
|
||||||
if err := json.Unmarshal(respBytes, &result); err != nil {
|
|
||||||
var directList []PoliData
|
|
||||||
if err2 := json.Unmarshal(respBytes, &directList); err2 == nil {
|
|
||||||
return directList, nil
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("failed to unmarshal apotek poli response: %w", err)
|
|
||||||
}
|
|
||||||
return result.List, nil
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package poli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"service/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service interface {
|
|
||||||
GetPoli(ctx context.Context, param string) ([]PoliData, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type service struct {
|
|
||||||
repo Repository
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewService(repo Repository) Service {
|
|
||||||
return &service{repo: repo}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) GetPoli(ctx context.Context, param string) ([]PoliData, error) {
|
|
||||||
if param == "" {
|
|
||||||
return nil, errors.NewValidationError().Message("Parameter pencarian Poli wajib diisi").Build()
|
|
||||||
}
|
|
||||||
res, err := s.repo.GetPoli(ctx, param)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.ExternalError().Message("Gagal mengambil referensi Poli Apotek BPJS").Cause(err).Build()
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package peserta
|
|
||||||
|
|
||||||
// PesertaResponse merepresentasikan wrapper data dari API BPJS VClaim
|
|
||||||
type PesertaResponse struct {
|
|
||||||
Peserta PesertaData `json:"peserta"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PesertaData merepresentasikan entitas detail Peserta BPJS
|
|
||||||
type PesertaData struct {
|
|
||||||
NoKartu string `json:"noKartu"`
|
|
||||||
Nik string `json:"nik"`
|
|
||||||
Nama string `json:"nama"`
|
|
||||||
Pisa string `json:"pisa"`
|
|
||||||
Sex string `json:"sex"`
|
|
||||||
Umur Umur `json:"umur"`
|
|
||||||
TglLahir string `json:"tglLahir"`
|
|
||||||
StatusPeserta StatusPeserta `json:"statusPeserta"`
|
|
||||||
ProviderUmum ProviderUmum `json:"provUmum"`
|
|
||||||
JenisPeserta JenisPeserta `json:"jenisPeserta"`
|
|
||||||
HakKelas HakKelas `json:"hakKelas"`
|
|
||||||
Informasi Informasi `json:"informasi"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Umur struct {
|
|
||||||
UmurSaatPelayanan string `json:"umurSaatPelayanan"`
|
|
||||||
UmurSekarang string `json:"umurSekarang"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type StatusPeserta struct {
|
|
||||||
Kode string `json:"kode"`
|
|
||||||
Keterangan string `json:"keterangan"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProviderUmum struct {
|
|
||||||
KdProvider string `json:"kdProvider"`
|
|
||||||
NmProvider string `json:"nmProvider"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type JenisPeserta struct {
|
|
||||||
Kode string `json:"kode"`
|
|
||||||
Keterangan string `json:"keterangan"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type HakKelas struct {
|
|
||||||
Kode string `json:"kode"`
|
|
||||||
Keterangan string `json:"keterangan"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Informasi struct {
|
|
||||||
Dinsos string `json:"dinsos"`
|
|
||||||
ProlanisPRB string `json:"prolanisPRB"`
|
|
||||||
NoSKTM string `json:"noSKTM"`
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package peserta
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"service/internal/interfaces/bpjs"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Repository interface {
|
|
||||||
GetByNoKartu(ctx context.Context, noKartu, tglSEP string) (*PesertaData, error)
|
|
||||||
GetByNIK(ctx context.Context, nik, tglSEP string) (*PesertaData, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type repository struct {
|
|
||||||
client bpjs.BpjsClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRepository(client bpjs.BpjsClient) Repository {
|
|
||||||
return &repository{client: client}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) GetByNoKartu(ctx context.Context, noKartu, tglSEP string) (*PesertaData, error) {
|
|
||||||
endpoint := fmt.Sprintf("Peserta/nokartu/%s/tglSEP/%s", noKartu, tglSEP)
|
|
||||||
respBytes, err := r.client.DoRequest(ctx, "GET", endpoint, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var result PesertaResponse
|
|
||||||
if err := json.Unmarshal(respBytes, &result); err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to unmarshal peserta response: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &result.Peserta, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) GetByNIK(ctx context.Context, nik, tglSEP string) (*PesertaData, error) {
|
|
||||||
endpoint := fmt.Sprintf("Peserta/nik/%s/tglSEP/%s", nik, tglSEP)
|
|
||||||
respBytes, err := r.client.DoRequest(ctx, "GET", endpoint, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var result PesertaResponse
|
|
||||||
if err := json.Unmarshal(respBytes, &result); err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to unmarshal peserta response: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &result.Peserta, nil
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package peserta
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"service/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service interface {
|
|
||||||
GetPesertaByNoKartu(ctx context.Context, noKartu, tglSEP string) (*PesertaData, error)
|
|
||||||
GetPesertaByNIK(ctx context.Context, nik, tglSEP string) (*PesertaData, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type service struct {
|
|
||||||
repo Repository
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewService(repo Repository) Service {
|
|
||||||
return &service{repo: repo}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) GetPesertaByNoKartu(ctx context.Context, noKartu, tglSEP string) (*PesertaData, error) {
|
|
||||||
if noKartu == "" || tglSEP == "" {
|
|
||||||
return nil, errors.NewValidationError().Message("Nomor Kartu dan Tanggal SEP wajib diisi").Build()
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := s.repo.GetByNoKartu(ctx, noKartu, tglSEP)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.ExternalError().Message("Gagal mengambil data peserta BPJS berdasarkan No Kartu").Cause(err).Build()
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) GetPesertaByNIK(ctx context.Context, nik, tglSEP string) (*PesertaData, error) {
|
|
||||||
if nik == "" || tglSEP == "" {
|
|
||||||
return nil, errors.NewValidationError().Message("NIK dan Tanggal SEP wajib diisi").Build()
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := s.repo.GetByNIK(ctx, nik, tglSEP)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.ExternalError().Message("Gagal mengambil data peserta BPJS berdasarkan NIK").Cause(err).Build()
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
package sep
|
|
||||||
|
|
||||||
// CreateSEPRequest adalah data payload untuk insert pembuatan SEP.
|
|
||||||
// Strukturnya mengikuti format yang dibutuhkan oleh API VClaim 2.0.
|
|
||||||
type CreateSEPRequest struct {
|
|
||||||
Request struct {
|
|
||||||
Sep `json:"t_sep"`
|
|
||||||
} `json:"request"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sep adalah detail data untuk pembuatan SEP.
|
|
||||||
type Sep struct {
|
|
||||||
NoKartu string `json:"noKartu"`
|
|
||||||
TglSep string `json:"tglSep"`
|
|
||||||
PpkPelayanan string `json:"ppkPelayanan"`
|
|
||||||
JnsPelayanan string `json:"jnsPelayanan"`
|
|
||||||
KlsRawat KlsRawat `json:"klsRawat"`
|
|
||||||
NoMR string `json:"noMR"`
|
|
||||||
Rujukan Rujukan `json:"rujukan"`
|
|
||||||
Catatan string `json:"catatan"`
|
|
||||||
DiagAwal string `json:"diagAwal"`
|
|
||||||
Poli Poli `json:"poli"`
|
|
||||||
Cob string `json:"cob"`
|
|
||||||
Katarak string `json:"katarak"`
|
|
||||||
Jaminan Jaminan `json:"jaminan"`
|
|
||||||
Tujuan string `json:"tujuan"`
|
|
||||||
FlagProcedure string `json:"flagProcedure"`
|
|
||||||
KdPenunjang string `json:"kdPenunjang"`
|
|
||||||
AssesmentPel string `json:"assesmentPel"`
|
|
||||||
NoSurat string `json:"noSurat"`
|
|
||||||
KodeDPJP string `json:"kodeDPJP"`
|
|
||||||
DpjpLayan string `json:"dpjpLayan"`
|
|
||||||
NoTelp string `json:"noTelp"`
|
|
||||||
User string `json:"user"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type KlsRawat struct {
|
|
||||||
KlsRawatHak string `json:"klsRawatHak"`
|
|
||||||
KlsRawatNaik string `json:"klsRawatNaik,omitempty"`
|
|
||||||
Pembiayaan string `json:"pembiayaan,omitempty"`
|
|
||||||
PenanggungJawab string `json:"penanggungJawab,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Rujukan struct {
|
|
||||||
AsalRujukan string `json:"asalRujukan"`
|
|
||||||
TglRujukan string `json:"tglRujukan"`
|
|
||||||
NoRujukan string `json:"noRujukan"`
|
|
||||||
PpkRujukan string `json:"ppkRujukan"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Poli struct {
|
|
||||||
Tujuan string `json:"tujuan"`
|
|
||||||
Eksekutif string `json:"eksekutif"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Jaminan struct {
|
|
||||||
LakaLantas string `json:"lakaLantas"`
|
|
||||||
NoLP string `json:"noLP,omitempty"`
|
|
||||||
Penjamin Penjamin `json:"penjamin,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Penjamin struct {
|
|
||||||
TglKejadian string `json:"tglKejadian,omitempty"`
|
|
||||||
Keterangan string `json:"keterangan,omitempty"`
|
|
||||||
Suplesi struct {
|
|
||||||
Suplesi string `json:"suplesi"`
|
|
||||||
NoSepSuplesi string `json:"noSepSuplesi,omitempty"`
|
|
||||||
LokasiLaka struct {
|
|
||||||
KdPropinsi string `json:"kdPropinsi"`
|
|
||||||
KdKabupaten string `json:"kdKabupaten"`
|
|
||||||
KdKecamatan string `json:"kdKecamatan"`
|
|
||||||
} `json:"lokasiLaka,omitempty"`
|
|
||||||
} `json:"suplesi,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSEPResponse adalah data balikan setelah SEP berhasil dicreate.
|
|
||||||
type CreateSEPResponse struct {
|
|
||||||
Sep struct {
|
|
||||||
NoSep string `json:"noSep"`
|
|
||||||
TglSep string `json:"tglSep"`
|
|
||||||
Poli string `json:"poli"`
|
|
||||||
Diagnosa string `json:"diagnosa"`
|
|
||||||
Catatan string `json:"catatan"`
|
|
||||||
JnsRawat string `json:"jnsRawat"`
|
|
||||||
KlsRawat string `json:"klsRawat"`
|
|
||||||
Penjamin string `json:"penjamin"`
|
|
||||||
} `json:"sep"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateSEPRequest adalah data payload untuk update SEP.
|
|
||||||
type UpdateSEPRequest struct {
|
|
||||||
Request struct {
|
|
||||||
Sep struct {
|
|
||||||
NoSep string `json:"noSep"`
|
|
||||||
KlsRawat KlsRawat `json:"klsRawat"`
|
|
||||||
NoMR string `json:"noMR"`
|
|
||||||
Catatan string `json:"catatan"`
|
|
||||||
DiagAwal string `json:"diagAwal"`
|
|
||||||
Poli Poli `json:"poli"`
|
|
||||||
Eksekutif string `json:"eksekutif"`
|
|
||||||
Cob string `json:"cob"`
|
|
||||||
Katarak string `json:"katarak"`
|
|
||||||
Jaminan Jaminan `json:"jaminan"`
|
|
||||||
NoTelp string `json:"noTelp"`
|
|
||||||
User string `json:"user"`
|
|
||||||
} `json:"t_sep"`
|
|
||||||
} `json:"request"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteSEPRequest adalah data payload untuk menghapus SEP.
|
|
||||||
type DeleteSEPRequest struct {
|
|
||||||
Request struct {
|
|
||||||
Sep struct {
|
|
||||||
NoSep string `json:"noSep"`
|
|
||||||
User string `json:"user"`
|
|
||||||
} `json:"t_sep"`
|
|
||||||
} `json:"request"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SEPDetailResponse adalah data balikan untuk detail SEP.
|
|
||||||
type SEPDetailResponse struct {
|
|
||||||
Catatan string `json:"catatan"`
|
|
||||||
Diagnosa string `json:"diagnosa"`
|
|
||||||
JnsPelayanan string `json:"jnsPelayanan"`
|
|
||||||
KelasRawat string `json:"kelasRawat"`
|
|
||||||
NoRujukan string `json:"noRujukan"`
|
|
||||||
NoSep string `json:"noSep"`
|
|
||||||
Penjamin string `json:"penjamin"`
|
|
||||||
Peserta struct {
|
|
||||||
Nama string `json:"nama"`
|
|
||||||
NoKartu string `json:"noKartu"`
|
|
||||||
NoMr string `json:"noMr"`
|
|
||||||
} `json:"peserta"`
|
|
||||||
Poli string `json:"poli"`
|
|
||||||
TglSep string `json:"tglSep"`
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
package sep
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"service/internal/interfaces/bpjs"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Repository interface {
|
|
||||||
CreateSEP(ctx context.Context, req CreateSEPRequest) (*CreateSEPResponse, error)
|
|
||||||
UpdateSEP(ctx context.Context, req UpdateSEPRequest) (string, error)
|
|
||||||
DeleteSEP(ctx context.Context, req DeleteSEPRequest) (string, error)
|
|
||||||
GetSEP(ctx context.Context, noSEP string) (*SEPDetailResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type repository struct {
|
|
||||||
client bpjs.BpjsClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRepository(client bpjs.BpjsClient) Repository {
|
|
||||||
return &repository{client: client}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) CreateSEP(ctx context.Context, req CreateSEPRequest) (*CreateSEPResponse, error) {
|
|
||||||
endpoint := "SEP/2.0/insert"
|
|
||||||
decryptedBytes, err := r.client.DoRequest(ctx, "POST", endpoint, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var result CreateSEPResponse
|
|
||||||
return &result, json.Unmarshal(decryptedBytes, &result)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) UpdateSEP(ctx context.Context, req UpdateSEPRequest) (string, error) {
|
|
||||||
endpoint := "SEP/2.0/update"
|
|
||||||
decryptedBytes, err := r.client.DoRequest(ctx, "PUT", endpoint, req)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
// Response dari update SEP biasanya hanya string nomor SEP itu sendiri
|
|
||||||
return string(decryptedBytes), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) DeleteSEP(ctx context.Context, req DeleteSEPRequest) (string, error) {
|
|
||||||
endpoint := "SEP/2.0/delete"
|
|
||||||
// BPJS API untuk delete menggunakan POST method dengan payload spesifik
|
|
||||||
decryptedBytes, err := r.client.DoRequest(ctx, "POST", endpoint, req)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
// Response dari delete SEP biasanya hanya string "OK" atau pesan konfirmasi
|
|
||||||
return string(decryptedBytes), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repository) GetSEP(ctx context.Context, noSEP string) (*SEPDetailResponse, error) {
|
|
||||||
endpoint := fmt.Sprintf("SEP/%s", noSEP)
|
|
||||||
decryptedBytes, err := r.client.DoRequest(ctx, "GET", endpoint, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var result SEPDetailResponse
|
|
||||||
if err := json.Unmarshal(decryptedBytes, &result); err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to unmarshal SEP detail response: %w", err)
|
|
||||||
}
|
|
||||||
return &result, nil
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package sep
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service interface {
|
|
||||||
Create(ctx context.Context, req CreateSEPRequest) (*CreateSEPResponse, error)
|
|
||||||
Update(ctx context.Context, req UpdateSEPRequest) (string, error)
|
|
||||||
Delete(ctx context.Context, req DeleteSEPRequest) (string, error)
|
|
||||||
GetDetail(ctx context.Context, noSEP string) (*SEPDetailResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type service struct {
|
|
||||||
repo Repository
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewService(repo Repository) Service {
|
|
||||||
return &service{repo: repo}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) Create(ctx context.Context, req CreateSEPRequest) (*CreateSEPResponse, error) {
|
|
||||||
// Anda bisa menambahkan validasi atau logika bisnis di sini sebelum memanggil repository.
|
|
||||||
return s.repo.CreateSEP(ctx, req)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) Update(ctx context.Context, req UpdateSEPRequest) (string, error) {
|
|
||||||
// TODO: Tambahkan validasi untuk request update di sini.
|
|
||||||
// Contoh: if req.Request.Sep.NoSep == "" { return "", errors.New("nomor SEP wajib diisi") }
|
|
||||||
return s.repo.UpdateSEP(ctx, req)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) Delete(ctx context.Context, req DeleteSEPRequest) (string, error) {
|
|
||||||
// TODO: Tambahkan validasi untuk request delete di sini.
|
|
||||||
return s.repo.DeleteSEP(ctx, req)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) GetDetail(ctx context.Context, noSEP string) (*SEPDetailResponse, error) {
|
|
||||||
// TODO: Tambahkan validasi untuk noSEP di sini.
|
|
||||||
return s.repo.GetSEP(ctx, noSEP)
|
|
||||||
}
|
|
||||||
@@ -1,484 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.36.11
|
|
||||||
// protoc v3.12.4
|
|
||||||
// source: internal/infrastructure/transport/grpc/proto/permission/v1/permission.proto
|
|
||||||
|
|
||||||
package permissionV1
|
|
||||||
|
|
||||||
import (
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
unsafe "unsafe"
|
|
||||||
|
|
||||||
wrappers "github.com/golang/protobuf/ptypes/wrappers"
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Pesan request untuk RPC GetRolePermissionTree.
|
|
||||||
type GetRolePermissionTreeRequest struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
RoleKeycloak string `protobuf:"bytes,1,opt,name=role_keycloak,json=roleKeycloak,proto3" json:"role_keycloak,omitempty"`
|
|
||||||
GroupKeycloak []string `protobuf:"bytes,2,rep,name=group_keycloak,json=groupKeycloak,proto3" json:"group_keycloak,omitempty"`
|
|
||||||
// Menggunakan wrapper BoolValue untuk membedakan antara 'false' dan 'tidak diset'.
|
|
||||||
ActiveOnly *wrappers.BoolValue `protobuf:"bytes,3,opt,name=active_only,json=activeOnly,proto3" json:"active_only,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetRolePermissionTreeRequest) Reset() {
|
|
||||||
*x = GetRolePermissionTreeRequest{}
|
|
||||||
mi := &file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetRolePermissionTreeRequest) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*GetRolePermissionTreeRequest) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *GetRolePermissionTreeRequest) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[0]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use GetRolePermissionTreeRequest.ProtoReflect.Descriptor instead.
|
|
||||||
func (*GetRolePermissionTreeRequest) Descriptor() ([]byte, []int) {
|
|
||||||
return file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetRolePermissionTreeRequest) GetRoleKeycloak() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.RoleKeycloak
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetRolePermissionTreeRequest) GetGroupKeycloak() []string {
|
|
||||||
if x != nil {
|
|
||||||
return x.GroupKeycloak
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetRolePermissionTreeRequest) GetActiveOnly() *wrappers.BoolValue {
|
|
||||||
if x != nil {
|
|
||||||
return x.ActiveOnly
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pesan response untuk RPC GetRolePermissionTree.
|
|
||||||
type RolePermissionTreeResponse struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
|
||||||
Data *RolePermissionData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RolePermissionTreeResponse) Reset() {
|
|
||||||
*x = RolePermissionTreeResponse{}
|
|
||||||
mi := &file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[1]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RolePermissionTreeResponse) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*RolePermissionTreeResponse) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *RolePermissionTreeResponse) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[1]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use RolePermissionTreeResponse.ProtoReflect.Descriptor instead.
|
|
||||||
func (*RolePermissionTreeResponse) Descriptor() ([]byte, []int) {
|
|
||||||
return file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescGZIP(), []int{1}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RolePermissionTreeResponse) GetSuccess() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Success
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RolePermissionTreeResponse) GetData() *RolePermissionData {
|
|
||||||
if x != nil {
|
|
||||||
return x.Data
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type RolePermissionData struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
|
|
||||||
Group []string `protobuf:"bytes,2,rep,name=group,proto3" json:"group,omitempty"`
|
|
||||||
Access []*AccessTreeItem `protobuf:"bytes,3,rep,name=access,proto3" json:"access,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RolePermissionData) Reset() {
|
|
||||||
*x = RolePermissionData{}
|
|
||||||
mi := &file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[2]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RolePermissionData) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*RolePermissionData) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *RolePermissionData) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[2]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use RolePermissionData.ProtoReflect.Descriptor instead.
|
|
||||||
func (*RolePermissionData) Descriptor() ([]byte, []int) {
|
|
||||||
return file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescGZIP(), []int{2}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RolePermissionData) GetRole() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Role
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RolePermissionData) GetGroup() []string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Group
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RolePermissionData) GetAccess() []*AccessTreeItem {
|
|
||||||
if x != nil {
|
|
||||||
return x.Access
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type AccessTreeItem struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
|
||||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
|
||||||
Icon string `protobuf:"bytes,3,opt,name=icon,proto3" json:"icon,omitempty"`
|
|
||||||
Url string `protobuf:"bytes,4,opt,name=url,proto3" json:"url,omitempty"`
|
|
||||||
Level int32 `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"`
|
|
||||||
Sort int32 `protobuf:"varint,6,opt,name=sort,proto3" json:"sort,omitempty"`
|
|
||||||
Active bool `protobuf:"varint,7,opt,name=active,proto3" json:"active,omitempty"`
|
|
||||||
Permission *Permission `protobuf:"bytes,8,opt,name=permission,proto3,oneof" json:"permission,omitempty"`
|
|
||||||
Children []*AccessTreeItem `protobuf:"bytes,9,rep,name=children,proto3" json:"children,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) Reset() {
|
|
||||||
*x = AccessTreeItem{}
|
|
||||||
mi := &file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[3]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*AccessTreeItem) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[3]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use AccessTreeItem.ProtoReflect.Descriptor instead.
|
|
||||||
func (*AccessTreeItem) Descriptor() ([]byte, []int) {
|
|
||||||
return file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescGZIP(), []int{3}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) GetId() int64 {
|
|
||||||
if x != nil {
|
|
||||||
return x.Id
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) GetName() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Name
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) GetIcon() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Icon
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) GetUrl() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Url
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) GetLevel() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.Level
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) GetSort() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.Sort
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) GetActive() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Active
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) GetPermission() *Permission {
|
|
||||||
if x != nil {
|
|
||||||
return x.Permission
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *AccessTreeItem) GetChildren() []*AccessTreeItem {
|
|
||||||
if x != nil {
|
|
||||||
return x.Children
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type Permission struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
Create bool `protobuf:"varint,1,opt,name=create,proto3" json:"create,omitempty"`
|
|
||||||
Read bool `protobuf:"varint,2,opt,name=read,proto3" json:"read,omitempty"`
|
|
||||||
Update bool `protobuf:"varint,3,opt,name=update,proto3" json:"update,omitempty"`
|
|
||||||
Delete bool `protobuf:"varint,4,opt,name=delete,proto3" json:"delete,omitempty"`
|
|
||||||
Disable bool `protobuf:"varint,5,opt,name=disable,proto3" json:"disable,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Permission) Reset() {
|
|
||||||
*x = Permission{}
|
|
||||||
mi := &file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[4]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Permission) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*Permission) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *Permission) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[4]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use Permission.ProtoReflect.Descriptor instead.
|
|
||||||
func (*Permission) Descriptor() ([]byte, []int) {
|
|
||||||
return file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescGZIP(), []int{4}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Permission) GetCreate() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Create
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Permission) GetRead() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Read
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Permission) GetUpdate() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Update
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Permission) GetDelete() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Delete
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Permission) GetDisable() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Disable
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
const file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDesc = "" +
|
|
||||||
"\n" +
|
|
||||||
"Kinternal/infrastructure/transport/grpc/proto/permission/v1/permission.proto\x12\rpermission.v1\x1a\x1egoogle/protobuf/wrappers.proto\"\xa7\x01\n" +
|
|
||||||
"\x1cGetRolePermissionTreeRequest\x12#\n" +
|
|
||||||
"\rrole_keycloak\x18\x01 \x01(\tR\froleKeycloak\x12%\n" +
|
|
||||||
"\x0egroup_keycloak\x18\x02 \x03(\tR\rgroupKeycloak\x12;\n" +
|
|
||||||
"\vactive_only\x18\x03 \x01(\v2\x1a.google.protobuf.BoolValueR\n" +
|
|
||||||
"activeOnly\"m\n" +
|
|
||||||
"\x1aRolePermissionTreeResponse\x12\x18\n" +
|
|
||||||
"\asuccess\x18\x01 \x01(\bR\asuccess\x125\n" +
|
|
||||||
"\x04data\x18\x02 \x01(\v2!.permission.v1.RolePermissionDataR\x04data\"u\n" +
|
|
||||||
"\x12RolePermissionData\x12\x12\n" +
|
|
||||||
"\x04role\x18\x01 \x01(\tR\x04role\x12\x14\n" +
|
|
||||||
"\x05group\x18\x02 \x03(\tR\x05group\x125\n" +
|
|
||||||
"\x06access\x18\x03 \x03(\v2\x1d.permission.v1.AccessTreeItemR\x06access\"\xa6\x02\n" +
|
|
||||||
"\x0eAccessTreeItem\x12\x0e\n" +
|
|
||||||
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" +
|
|
||||||
"\x04name\x18\x02 \x01(\tR\x04name\x12\x12\n" +
|
|
||||||
"\x04icon\x18\x03 \x01(\tR\x04icon\x12\x10\n" +
|
|
||||||
"\x03url\x18\x04 \x01(\tR\x03url\x12\x14\n" +
|
|
||||||
"\x05level\x18\x05 \x01(\x05R\x05level\x12\x12\n" +
|
|
||||||
"\x04sort\x18\x06 \x01(\x05R\x04sort\x12\x16\n" +
|
|
||||||
"\x06active\x18\a \x01(\bR\x06active\x12>\n" +
|
|
||||||
"\n" +
|
|
||||||
"permission\x18\b \x01(\v2\x19.permission.v1.PermissionH\x00R\n" +
|
|
||||||
"permission\x88\x01\x01\x129\n" +
|
|
||||||
"\bchildren\x18\t \x03(\v2\x1d.permission.v1.AccessTreeItemR\bchildrenB\r\n" +
|
|
||||||
"\v_permission\"\x82\x01\n" +
|
|
||||||
"\n" +
|
|
||||||
"Permission\x12\x16\n" +
|
|
||||||
"\x06create\x18\x01 \x01(\bR\x06create\x12\x12\n" +
|
|
||||||
"\x04read\x18\x02 \x01(\bR\x04read\x12\x16\n" +
|
|
||||||
"\x06update\x18\x03 \x01(\bR\x06update\x12\x16\n" +
|
|
||||||
"\x06delete\x18\x04 \x01(\bR\x06delete\x12\x18\n" +
|
|
||||||
"\adisable\x18\x05 \x01(\bR\adisable2\x87\x01\n" +
|
|
||||||
"\x14RolPermissionService\x12o\n" +
|
|
||||||
"\x15GetRolePermissionTree\x12+.permission.v1.GetRolePermissionTreeRequest\x1a).permission.v1.RolePermissionTreeResponseBGZEinternal/infrastructure/transport/grpc/gen/permission/v1;permissionV1b\x06proto3"
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescOnce sync.Once
|
|
||||||
file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescData []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescGZIP() []byte {
|
|
||||||
file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescOnce.Do(func() {
|
|
||||||
file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDesc), len(file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDesc)))
|
|
||||||
})
|
|
||||||
return file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
|
||||||
var file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_goTypes = []any{
|
|
||||||
(*GetRolePermissionTreeRequest)(nil), // 0: permission.v1.GetRolePermissionTreeRequest
|
|
||||||
(*RolePermissionTreeResponse)(nil), // 1: permission.v1.RolePermissionTreeResponse
|
|
||||||
(*RolePermissionData)(nil), // 2: permission.v1.RolePermissionData
|
|
||||||
(*AccessTreeItem)(nil), // 3: permission.v1.AccessTreeItem
|
|
||||||
(*Permission)(nil), // 4: permission.v1.Permission
|
|
||||||
(*wrappers.BoolValue)(nil), // 5: google.protobuf.BoolValue
|
|
||||||
}
|
|
||||||
var file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_depIdxs = []int32{
|
|
||||||
5, // 0: permission.v1.GetRolePermissionTreeRequest.active_only:type_name -> google.protobuf.BoolValue
|
|
||||||
2, // 1: permission.v1.RolePermissionTreeResponse.data:type_name -> permission.v1.RolePermissionData
|
|
||||||
3, // 2: permission.v1.RolePermissionData.access:type_name -> permission.v1.AccessTreeItem
|
|
||||||
4, // 3: permission.v1.AccessTreeItem.permission:type_name -> permission.v1.Permission
|
|
||||||
3, // 4: permission.v1.AccessTreeItem.children:type_name -> permission.v1.AccessTreeItem
|
|
||||||
0, // 5: permission.v1.RolPermissionService.GetRolePermissionTree:input_type -> permission.v1.GetRolePermissionTreeRequest
|
|
||||||
1, // 6: permission.v1.RolPermissionService.GetRolePermissionTree:output_type -> permission.v1.RolePermissionTreeResponse
|
|
||||||
6, // [6:7] is the sub-list for method output_type
|
|
||||||
5, // [5:6] is the sub-list for method input_type
|
|
||||||
5, // [5:5] is the sub-list for extension type_name
|
|
||||||
5, // [5:5] is the sub-list for extension extendee
|
|
||||||
0, // [0:5] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_init() }
|
|
||||||
func file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_init() {
|
|
||||||
if File_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes[3].OneofWrappers = []any{}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDesc), len(file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_rawDesc)),
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 5,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 1,
|
|
||||||
},
|
|
||||||
GoTypes: file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_goTypes,
|
|
||||||
DependencyIndexes: file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_depIdxs,
|
|
||||||
MessageInfos: file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto = out.File
|
|
||||||
file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_goTypes = nil
|
|
||||||
file_internal_infrastructure_transport_grpc_proto_permission_v1_permission_proto_depIdxs = nil
|
|
||||||
}
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// - protoc-gen-go-grpc v1.6.0
|
|
||||||
// - protoc v3.12.4
|
|
||||||
// source: internal/infrastructure/transport/grpc/proto/permission/v1/permission.proto
|
|
||||||
|
|
||||||
package permissionV1
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
// Requires gRPC-Go v1.64.0 or later.
|
|
||||||
const _ = grpc.SupportPackageIsVersion9
|
|
||||||
|
|
||||||
const (
|
|
||||||
RolPermissionService_GetRolePermissionTree_FullMethodName = "/permission.v1.RolPermissionService/GetRolePermissionTree"
|
|
||||||
)
|
|
||||||
|
|
||||||
// RolPermissionServiceClient is the client API for RolPermissionService service.
|
|
||||||
//
|
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
||||||
//
|
|
||||||
// Definisi service.
|
|
||||||
type RolPermissionServiceClient interface {
|
|
||||||
// Mengambil permission tree untuk role dan/atau group tertentu.
|
|
||||||
GetRolePermissionTree(ctx context.Context, in *GetRolePermissionTreeRequest, opts ...grpc.CallOption) (*RolePermissionTreeResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type rolPermissionServiceClient struct {
|
|
||||||
cc grpc.ClientConnInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRolPermissionServiceClient(cc grpc.ClientConnInterface) RolPermissionServiceClient {
|
|
||||||
return &rolPermissionServiceClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *rolPermissionServiceClient) GetRolePermissionTree(ctx context.Context, in *GetRolePermissionTreeRequest, opts ...grpc.CallOption) (*RolePermissionTreeResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(RolePermissionTreeResponse)
|
|
||||||
err := c.cc.Invoke(ctx, RolPermissionService_GetRolePermissionTree_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RolPermissionServiceServer is the server API for RolPermissionService service.
|
|
||||||
// All implementations must embed UnimplementedRolPermissionServiceServer
|
|
||||||
// for forward compatibility.
|
|
||||||
//
|
|
||||||
// Definisi service.
|
|
||||||
type RolPermissionServiceServer interface {
|
|
||||||
// Mengambil permission tree untuk role dan/atau group tertentu.
|
|
||||||
GetRolePermissionTree(context.Context, *GetRolePermissionTreeRequest) (*RolePermissionTreeResponse, error)
|
|
||||||
mustEmbedUnimplementedRolPermissionServiceServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedRolPermissionServiceServer must be embedded to have
|
|
||||||
// forward compatible implementations.
|
|
||||||
//
|
|
||||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
||||||
// pointer dereference when methods are called.
|
|
||||||
type UnimplementedRolPermissionServiceServer struct{}
|
|
||||||
|
|
||||||
func (UnimplementedRolPermissionServiceServer) GetRolePermissionTree(context.Context, *GetRolePermissionTreeRequest) (*RolePermissionTreeResponse, error) {
|
|
||||||
return nil, status.Error(codes.Unimplemented, "method GetRolePermissionTree not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedRolPermissionServiceServer) mustEmbedUnimplementedRolPermissionServiceServer() {}
|
|
||||||
func (UnimplementedRolPermissionServiceServer) testEmbeddedByValue() {}
|
|
||||||
|
|
||||||
// UnsafeRolPermissionServiceServer may be embedded to opt out of forward compatibility for this service.
|
|
||||||
// Use of this interface is not recommended, as added methods to RolPermissionServiceServer will
|
|
||||||
// result in compilation errors.
|
|
||||||
type UnsafeRolPermissionServiceServer interface {
|
|
||||||
mustEmbedUnimplementedRolPermissionServiceServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterRolPermissionServiceServer(s grpc.ServiceRegistrar, srv RolPermissionServiceServer) {
|
|
||||||
// If the following call panics, it indicates UnimplementedRolPermissionServiceServer was
|
|
||||||
// embedded by pointer and is nil. This will cause panics if an
|
|
||||||
// unimplemented method is ever invoked, so we test this at initialization
|
|
||||||
// time to prevent it from happening at runtime later due to I/O.
|
|
||||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
||||||
t.testEmbeddedByValue()
|
|
||||||
}
|
|
||||||
s.RegisterService(&RolPermissionService_ServiceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _RolPermissionService_GetRolePermissionTree_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(GetRolePermissionTreeRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(RolPermissionServiceServer).GetRolePermissionTree(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: RolPermissionService_GetRolePermissionTree_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(RolPermissionServiceServer).GetRolePermissionTree(ctx, req.(*GetRolePermissionTreeRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RolPermissionService_ServiceDesc is the grpc.ServiceDesc for RolPermissionService service.
|
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
|
||||||
// and not to be introspected or modified (even as a copy)
|
|
||||||
var RolPermissionService_ServiceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "permission.v1.RolPermissionService",
|
|
||||||
HandlerType: (*RolPermissionServiceServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{
|
|
||||||
{
|
|
||||||
MethodName: "GetRolePermissionTree",
|
|
||||||
Handler: _RolPermissionService_GetRolePermissionTree_Handler,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Streams: []grpc.StreamDesc{},
|
|
||||||
Metadata: "internal/infrastructure/transport/grpc/proto/permission/v1/permission.proto",
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package handlers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"service/internal/infrastructure/transport/grpc/mappers"
|
|
||||||
"service/internal/master/role/permission"
|
|
||||||
|
|
||||||
// Asumsi path ke proto-generated file
|
|
||||||
permissionV1 "service/internal/infrastructure/transport/grpc/gen/permission/v1"
|
|
||||||
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PermissionHandler mengimplementasikan gRPC service untuk role permission.
|
|
||||||
type PermissionHandler struct {
|
|
||||||
permissionV1.UnimplementedRolPermissionServiceServer
|
|
||||||
service permission.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewPermissionHandler membuat instance baru dari PermissionHandler.
|
|
||||||
func NewPermissionHandler(service permission.Service) *PermissionHandler {
|
|
||||||
return &PermissionHandler{
|
|
||||||
service: service,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRolePermissionTree adalah implementasi dari RPC.
|
|
||||||
func (h *PermissionHandler) GetRolePermissionTree(ctx context.Context, req *permissionV1.GetRolePermissionTreeRequest) (*permissionV1.RolePermissionTreeResponse, error) {
|
|
||||||
if req == nil {
|
|
||||||
return nil, status.Error(codes.InvalidArgument, "request cannot be nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Konversi wrapper BoolValue ke pointer *bool yang diharapkan oleh service
|
|
||||||
var activeOnly *bool
|
|
||||||
if val := req.GetActiveOnly(); val != nil {
|
|
||||||
b := val.GetValue()
|
|
||||||
activeOnly = &b
|
|
||||||
}
|
|
||||||
|
|
||||||
tree, err := h.service.GetRolePermissionTree(ctx, req.GetRoleKeycloak(), req.GetGroupKeycloak(), activeOnly)
|
|
||||||
if err != nil {
|
|
||||||
return nil, handleServiceError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Menggunakan mapper untuk mengubah hasil dari service ke format proto
|
|
||||||
protoResponse := mappers.MapRolePermissionTreeToProto(tree)
|
|
||||||
|
|
||||||
return protoResponse, nil
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package mappers
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func convertToString(value interface{}) string {
|
|
||||||
if value == nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
switch v := value.(type) {
|
|
||||||
case string:
|
|
||||||
return v
|
|
||||||
case int, int64, float64:
|
|
||||||
return fmt.Sprintf("%v", v)
|
|
||||||
default:
|
|
||||||
return fmt.Sprintf("%v", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package mappers
|
|
||||||
|
|
||||||
import (
|
|
||||||
permissionV1 "service/internal/infrastructure/transport/grpc/gen/permission/v1"
|
|
||||||
"service/internal/master/role/permission"
|
|
||||||
)
|
|
||||||
|
|
||||||
// mapAccessTreeToProto secara rekursif mengubah tree dari service ke format proto.
|
|
||||||
func mapAccessTreeToProto(serviceAccess []*permission.AccessTreeItem) []*permissionV1.AccessTreeItem {
|
|
||||||
if serviceAccess == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
protoAccess := make([]*permissionV1.AccessTreeItem, len(serviceAccess))
|
|
||||||
for i, item := range serviceAccess {
|
|
||||||
protoItem := &permissionV1.AccessTreeItem{
|
|
||||||
Id: item.ID,
|
|
||||||
Name: item.Name,
|
|
||||||
Icon: item.Icon,
|
|
||||||
Url: item.URL,
|
|
||||||
Level: int32(item.Level),
|
|
||||||
Sort: int32(item.Sort),
|
|
||||||
Active: item.Active,
|
|
||||||
Children: mapAccessTreeToProto(item.Children), // Panggilan rekursif
|
|
||||||
}
|
|
||||||
|
|
||||||
if item.Permission != nil {
|
|
||||||
protoItem.Permission = &permissionV1.Permission{
|
|
||||||
Create: item.Permission.Create,
|
|
||||||
Read: item.Permission.Read,
|
|
||||||
Update: item.Permission.Update,
|
|
||||||
Delete: item.Permission.Delete,
|
|
||||||
Disable: item.Permission.Disable,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protoAccess[i] = protoItem
|
|
||||||
}
|
|
||||||
return protoAccess
|
|
||||||
}
|
|
||||||
|
|
||||||
// MapRolePermissionTreeToProto adalah fungsi utama untuk mengubah seluruh respons tree.
|
|
||||||
func MapRolePermissionTreeToProto(serviceResponse *permission.RolePermissionTreeResponse) *permissionV1.RolePermissionTreeResponse {
|
|
||||||
if serviceResponse == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return &permissionV1.RolePermissionTreeResponse{
|
|
||||||
Success: serviceResponse.Success,
|
|
||||||
Data: &permissionV1.RolePermissionData{
|
|
||||||
Role: serviceResponse.Data.Role,
|
|
||||||
// Group: serviceResponse.Data.Group,
|
|
||||||
Access: mapAccessTreeToProto(serviceResponse.Data.Access),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package master.v1;
|
|
||||||
|
|
||||||
// Path should be relative to the module root.
|
|
||||||
// The package name is specified after the semicolon.
|
|
||||||
option go_package = "internal/infrastructure/transport/grpc/gen/master/role/master/v1;masterV1";
|
|
||||||
|
|
||||||
import "google/protobuf/wrappers.proto";
|
|
||||||
import "google/protobuf/timestamp.proto";
|
|
||||||
import "google/protobuf/empty.proto";
|
|
||||||
|
|
||||||
// Service definition for RoleAccessRolMaster.
|
|
||||||
service RoleAccessRolMasterService {
|
|
||||||
// Get a single RoleAccessRolMaster by its ID.
|
|
||||||
rpc GetRoleAccessRolMaster(GetRoleAccessRolMasterRequest) returns (RoleAccessRolMasterResponse);
|
|
||||||
|
|
||||||
// Get a list of RoleAccessRolMasters with pagination and filtering.
|
|
||||||
rpc ListRoleAccessRolMasters(ListRoleAccessRolMastersRequest) returns (ListRoleAccessRolMastersResponse);
|
|
||||||
|
|
||||||
// Create a new RoleAccessRolMaster.
|
|
||||||
rpc CreateRoleAccessRolMaster(CreateRoleAccessRolMasterRequest) returns (RoleAccessRolMasterResponse);
|
|
||||||
|
|
||||||
// Update an existing RoleAccessRolMaster.
|
|
||||||
rpc UpdateRoleAccessRolMaster(UpdateRoleAccessRolMasterRequest) returns (RoleAccessRolMasterResponse);
|
|
||||||
|
|
||||||
// Delete a RoleAccessRolMaster by its ID.
|
|
||||||
rpc DeleteRoleAccessRolMaster(DeleteRoleAccessRolMasterRequest) returns (google.protobuf.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The main message representing a RoleAccessRolMaster.
|
|
||||||
message RoleAccessRolMaster {
|
|
||||||
string id = 1;
|
|
||||||
optional string name = 2;
|
|
||||||
optional bool active = 3;
|
|
||||||
optional google.protobuf.Timestamp created_at = 4;
|
|
||||||
optional google.protobuf.Timestamp updated_at = 5;
|
|
||||||
optional string s_e_l_e_c_t = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Request/Response Messages ---
|
|
||||||
|
|
||||||
message GetRoleAccessRolMasterRequest {
|
|
||||||
int64 id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message RoleAccessRolMasterResponse {
|
|
||||||
RoleAccessRolMaster data = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ListRoleAccessRolMastersRequest {
|
|
||||||
int32 page = 1;
|
|
||||||
int32 page_size = 2;
|
|
||||||
// Add filter fields here if needed
|
|
||||||
}
|
|
||||||
|
|
||||||
message ListRoleAccessRolMastersResponse {
|
|
||||||
repeated RoleAccessRolMaster data = 1;
|
|
||||||
int64 total_items = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message CreateRoleAccessRolMasterRequest {
|
|
||||||
string id = 1;
|
|
||||||
string name = 2;
|
|
||||||
bool active = 3;
|
|
||||||
google.protobuf.Timestamp created_at = 4;
|
|
||||||
google.protobuf.Timestamp updated_at = 5;
|
|
||||||
string s_e_l_e_c_t = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UpdateRoleAccessRolMasterRequest {
|
|
||||||
int64 id = 1;
|
|
||||||
optional string id = 2;
|
|
||||||
optional string name = 3;
|
|
||||||
optional bool active = 4;
|
|
||||||
optional google.protobuf.Timestamp created_at = 5;
|
|
||||||
optional google.protobuf.Timestamp updated_at = 6;
|
|
||||||
optional string s_e_l_e_c_t = 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteRoleAccessRolMasterRequest {
|
|
||||||
int64 id = 1;
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package permission.v1;
|
|
||||||
|
|
||||||
// Opsi go_package ini sangat penting.
|
|
||||||
// Path harus relatif terhadap root modul (tanpa nama modul "service-general").
|
|
||||||
// Nama paket eksplisit (permissionV1) ditambahkan setelah titik koma.
|
|
||||||
option go_package = "internal/infrastructure/transport/grpc/gen/permission/v1;permissionV1";
|
|
||||||
|
|
||||||
import "google/protobuf/wrappers.proto";
|
|
||||||
|
|
||||||
// Definisi service.
|
|
||||||
service RolPermissionService {
|
|
||||||
// Mengambil permission tree untuk role dan/atau group tertentu.
|
|
||||||
rpc GetRolePermissionTree(GetRolePermissionTreeRequest) returns (RolePermissionTreeResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pesan request untuk RPC GetRolePermissionTree.
|
|
||||||
message GetRolePermissionTreeRequest {
|
|
||||||
string role_keycloak = 1;
|
|
||||||
repeated string group_keycloak = 2;
|
|
||||||
// Menggunakan wrapper BoolValue untuk membedakan antara 'false' dan 'tidak diset'.
|
|
||||||
google.protobuf.BoolValue active_only = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pesan response untuk RPC GetRolePermissionTree.
|
|
||||||
message RolePermissionTreeResponse {
|
|
||||||
bool success = 1;
|
|
||||||
RolePermissionData data = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message RolePermissionData {
|
|
||||||
string role = 1;
|
|
||||||
repeated string group = 2;
|
|
||||||
repeated AccessTreeItem access = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AccessTreeItem {
|
|
||||||
int64 id = 1;
|
|
||||||
string name = 2;
|
|
||||||
string icon = 3;
|
|
||||||
string url = 4;
|
|
||||||
int32 level = 5;
|
|
||||||
int32 sort = 6;
|
|
||||||
bool active = 7;
|
|
||||||
optional Permission permission = 8;
|
|
||||||
repeated AccessTreeItem children = 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Permission {
|
|
||||||
bool create = 1;
|
|
||||||
bool read = 2;
|
|
||||||
bool update = 3;
|
|
||||||
bool delete = 4;
|
|
||||||
bool disable = 5;
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package auth;
|
|
||||||
|
|
||||||
// PERBAIKAN: Tambahkan 'transport' dan hapus suffix '/auth' agar sesuai direktori import
|
|
||||||
option go_package = "gen/auth/v1;auth";
|
|
||||||
|
|
||||||
message LoginRequest {
|
|
||||||
string username = 1;
|
|
||||||
string password = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message LoginResponse {
|
|
||||||
string token = 1;
|
|
||||||
string expires_at = 2;
|
|
||||||
User user = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message RegisterRequest {
|
|
||||||
string username = 1;
|
|
||||||
string email = 2;
|
|
||||||
string password = 3;
|
|
||||||
string full_name = 4;
|
|
||||||
string role = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
message RegisterResponse {
|
|
||||||
string id = 1;
|
|
||||||
string username = 2;
|
|
||||||
string email = 3;
|
|
||||||
string full_name = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ValidateTokenRequest {
|
|
||||||
string token = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ValidateTokenResponse {
|
|
||||||
bool valid = 1;
|
|
||||||
User user = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message LogoutRequest {
|
|
||||||
string token = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message LogoutResponse {
|
|
||||||
bool success = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message User {
|
|
||||||
string id = 1;
|
|
||||||
string username = 2;
|
|
||||||
string email = 3;
|
|
||||||
string full_name = 4;
|
|
||||||
string role = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
service AuthService {
|
|
||||||
rpc Register (RegisterRequest) returns (RegisterResponse);
|
|
||||||
rpc Login(LoginRequest) returns (LoginResponse);
|
|
||||||
rpc ValidateToken (ValidateTokenRequest) returns (ValidateTokenResponse);
|
|
||||||
rpc Logout (LogoutRequest) returns (LogoutResponse);
|
|
||||||
}
|
|
||||||
@@ -4,18 +4,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"service/internal/infrastructure/config"
|
"service/internal/infrastructure/config"
|
||||||
"service/internal/infrastructure/transport/grpc/handlers"
|
|
||||||
"service/pkg/logger"
|
|
||||||
|
|
||||||
// Import generated proto files. Asumsi path ini benar.
|
// Import generated proto files. Asumsi path ini benar.
|
||||||
permissionV1 "service/internal/infrastructure/transport/grpc/gen/permission/v1"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/reflection"
|
"google.golang.org/grpc/reflection"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServiceRegistry struct {
|
type ServiceRegistry struct {
|
||||||
PermissionHandler *handlers.PermissionHandler
|
// PermissionHandler *handlers.PermissionHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
// GRPCServer membungkus instance grpc.Server.
|
// GRPCServer membungkus instance grpc.Server.
|
||||||
@@ -30,10 +27,10 @@ func NewGRPCServer(config *config.ServerGRPCConfig, registry *ServiceRegistry) *
|
|||||||
srv := grpc.NewServer()
|
srv := grpc.NewServer()
|
||||||
|
|
||||||
// Daftarkan semua service yang ada di registry
|
// Daftarkan semua service yang ada di registry
|
||||||
if registry.PermissionHandler != nil {
|
// if registry.PermissionHandler != nil {
|
||||||
permissionV1.RegisterRolPermissionServiceServer(srv, registry.PermissionHandler)
|
// permissionV1.RegisterRolPermissionServiceServer(srv, registry.PermissionHandler)
|
||||||
logger.Default().Info("Registered RolPermission gRPC service")
|
// logger.Default().Info("Registered RolPermission gRPC service")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Aktifkan reflection agar bisa di-debug dengan tools seperti grpcurl
|
// Aktifkan reflection agar bisa di-debug dengan tools seperti grpcurl
|
||||||
reflection.Register(srv)
|
reflection.Register(srv)
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
package antrol
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
antrolService "service/internal/bpjs/antrol/reference"
|
|
||||||
"service/pkg/errors"
|
|
||||||
"service/pkg/response"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AntrolHandler struct {
|
|
||||||
service antrolService.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAntrolHandler(service antrolService.Service) *AntrolHandler {
|
|
||||||
return &AntrolHandler{service: service}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *AntrolHandler) RegisterRoutes(router *gin.RouterGroup) {
|
|
||||||
group := router.Group("/bpjs/antrol/reference")
|
|
||||||
{
|
|
||||||
group.GET("/poli", h.GetRefPoli)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *AntrolHandler) GetRefPoli(c *gin.Context) {
|
|
||||||
ctx := c.Request.Context()
|
|
||||||
res, err := h.service.GetRefPoli(ctx)
|
|
||||||
if err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), appErr.Metadata())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusOK, "Successfully retrieved BPJS Antrol Poli reference", res)
|
|
||||||
}
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
package aplicare
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
bedService "service/internal/bpjs/aplicare/bed"
|
|
||||||
"service/pkg/errors"
|
|
||||||
"service/pkg/response"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type BedHandler struct {
|
|
||||||
service bedService.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewBedHandler(service bedService.Service) *BedHandler {
|
|
||||||
return &BedHandler{service: service}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *BedHandler) RegisterRoutes(router *gin.RouterGroup) {
|
|
||||||
group := router.Group("/bpjs/aplicare/bed")
|
|
||||||
{
|
|
||||||
group.GET("/:kdppk/:start/:limit", h.GetBedList)
|
|
||||||
group.POST("/:kdppk", h.CreateBed)
|
|
||||||
group.PUT("/:kdppk", h.UpdateBed)
|
|
||||||
group.DELETE("/:kdppk", h.DeleteBed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *BedHandler) GetBedList(c *gin.Context) {
|
|
||||||
kdPpk := c.Param("kdppk")
|
|
||||||
start, _ := strconv.Atoi(c.Param("start"))
|
|
||||||
limit, _ := strconv.Atoi(c.Param("limit"))
|
|
||||||
|
|
||||||
ctx := c.Request.Context()
|
|
||||||
res, err := h.service.GetBedList(ctx, kdPpk, start, limit)
|
|
||||||
if err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), appErr.Metadata())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusOK, "Successfully retrieved BPJS Aplicares bed list", res)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *BedHandler) CreateBed(c *gin.Context) {
|
|
||||||
kdPpk := c.Param("kdppk")
|
|
||||||
var req bedService.BedData
|
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
|
||||||
response.Error(c, http.StatusBadRequest, "Invalid request body", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := c.Request.Context()
|
|
||||||
if err := h.service.CreateBed(ctx, kdPpk, req); err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), appErr.Metadata())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusCreated, "Successfully created BPJS Aplicares bed data", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *BedHandler) UpdateBed(c *gin.Context) {
|
|
||||||
kdPpk := c.Param("kdppk")
|
|
||||||
var req bedService.BedData
|
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
|
||||||
response.Error(c, http.StatusBadRequest, "Invalid request body", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := c.Request.Context()
|
|
||||||
if err := h.service.UpdateBed(ctx, kdPpk, req); err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), appErr.Metadata())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusOK, "Successfully updated BPJS Aplicares bed data", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *BedHandler) DeleteBed(c *gin.Context) {
|
|
||||||
kdPpk := c.Param("kdppk")
|
|
||||||
var req bedService.BedDeletePayload
|
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
|
||||||
response.Error(c, http.StatusBadRequest, "Invalid request body", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := c.Request.Context()
|
|
||||||
if err := h.service.DeleteBed(ctx, kdPpk, req); err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), appErr.Metadata())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusOK, "Successfully deleted BPJS Aplicares bed data", nil)
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package apotek
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
dphoService "service/internal/bpjs/apotek/reference/dpho"
|
|
||||||
poliService "service/internal/bpjs/apotek/reference/poli"
|
|
||||||
"service/pkg/errors"
|
|
||||||
"service/pkg/response"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ReferenceHandler struct {
|
|
||||||
dphoService dphoService.Service
|
|
||||||
poliService poliService.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewReferenceHandler(dpho dphoService.Service, poli poliService.Service) *ReferenceHandler {
|
|
||||||
return &ReferenceHandler{
|
|
||||||
dphoService: dpho,
|
|
||||||
poliService: poli,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *ReferenceHandler) RegisterRoutes(router *gin.RouterGroup) {
|
|
||||||
group := router.Group("/bpjs/apotek/reference")
|
|
||||||
{
|
|
||||||
group.GET("/dpho", h.GetDPHO)
|
|
||||||
group.GET("/poli/:param", h.GetPoli)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *ReferenceHandler) GetDPHO(c *gin.Context) {
|
|
||||||
res, err := h.dphoService.GetDPHO(c.Request.Context())
|
|
||||||
if err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), appErr.Metadata())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
response.Success(c, http.StatusOK, "Successfully retrieved BPJS Apotek DPHO reference", res)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *ReferenceHandler) GetPoli(c *gin.Context) {
|
|
||||||
param := c.Param("param")
|
|
||||||
res, err := h.poliService.GetPoli(c.Request.Context(), param)
|
|
||||||
if err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), appErr.Metadata())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
response.Success(c, http.StatusOK, "Successfully retrieved BPJS Apotek Poli reference", res)
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package vclaim
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
pesertaService "service/internal/bpjs/vclaim/peserta"
|
|
||||||
"service/pkg/errors"
|
|
||||||
"service/pkg/response"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PesertaHandler struct {
|
|
||||||
service pesertaService.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewPesertaHandler(service pesertaService.Service) *PesertaHandler {
|
|
||||||
return &PesertaHandler{service: service}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *PesertaHandler) RegisterRoutes(router *gin.RouterGroup) {
|
|
||||||
group := router.Group("/bpjs/vclaim/peserta")
|
|
||||||
{
|
|
||||||
group.GET("/nik/:nik", h.GetPesertaByNIK)
|
|
||||||
group.GET("/nokartu/:nokartu", h.GetPesertaByNoKartu)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *PesertaHandler) GetPesertaByNIK(c *gin.Context) {
|
|
||||||
nik := c.Param("nik")
|
|
||||||
tglSEP := c.Query("tgl_sep")
|
|
||||||
if tglSEP == "" {
|
|
||||||
tglSEP = time.Now().Format("2006-01-02")
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := c.Request.Context()
|
|
||||||
res, err := h.service.GetPesertaByNIK(ctx, nik, tglSEP)
|
|
||||||
if err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), appErr.Metadata())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusOK, "Successfully retrieved participant data by NIK", res)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *PesertaHandler) GetPesertaByNoKartu(c *gin.Context) {
|
|
||||||
noKartu := c.Param("nokartu")
|
|
||||||
tglSEP := c.Query("tgl_sep")
|
|
||||||
if tglSEP == "" {
|
|
||||||
tglSEP = time.Now().Format("2006-01-02")
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := c.Request.Context()
|
|
||||||
res, err := h.service.GetPesertaByNoKartu(ctx, noKartu, tglSEP)
|
|
||||||
if err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), appErr.Metadata())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusOK, "Successfully retrieved participant data by card number", res)
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
package vclaim
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
sepService "service/internal/bpjs/vclaim/sep"
|
|
||||||
"service/pkg/errors"
|
|
||||||
"service/pkg/response"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SepHandler menangani semua request HTTP terkait VClaim.
|
|
||||||
type SepHandler struct {
|
|
||||||
sepService sepService.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewSepHandler membuat instance SepHandler baru.
|
|
||||||
func NewSepHandler(sepService sepService.Service) *SepHandler {
|
|
||||||
return &SepHandler{
|
|
||||||
sepService: sepService,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterRoutes mendaftarkan semua rute untuk BPJS VClaim.
|
|
||||||
func (h *SepHandler) RegisterRoutes(router *gin.RouterGroup) {
|
|
||||||
bpjsGroup := router.Group("/bpjs/vclaim")
|
|
||||||
{
|
|
||||||
sepGroup := bpjsGroup.Group("/sep")
|
|
||||||
{
|
|
||||||
sepGroup.POST("", h.CreateSEP)
|
|
||||||
sepGroup.PUT("", h.UpdateSEP)
|
|
||||||
// BPJS API untuk delete menggunakan method POST, tapi kita ekspos sebagai DELETE untuk konsistensi RESTful.
|
|
||||||
sepGroup.DELETE("", h.DeleteSEP)
|
|
||||||
sepGroup.GET("/:nosep", h.GetSEPDetail)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSEP menangani request untuk membuat SEP baru.
|
|
||||||
func (h *SepHandler) CreateSEP(c *gin.Context) {
|
|
||||||
var req sepService.CreateSEPRequest
|
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
|
||||||
response.Error(c, http.StatusBadRequest, "Invalid request body", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := h.sepService.Create(c.Request.Context(), req)
|
|
||||||
if err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusCreated, "Successfully created SEP", result)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateSEP menangani request untuk memperbarui SEP.
|
|
||||||
func (h *SepHandler) UpdateSEP(c *gin.Context) {
|
|
||||||
var req sepService.UpdateSEPRequest
|
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
|
||||||
response.Error(c, http.StatusBadRequest, "Invalid request body", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := h.sepService.Update(c.Request.Context(), req)
|
|
||||||
if err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusOK, "Successfully updated SEP", result)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetSEPDetail menangani request untuk mendapatkan detail SEP.
|
|
||||||
func (h *SepHandler) GetSEPDetail(c *gin.Context) {
|
|
||||||
noSEP := c.Param("no_sep")
|
|
||||||
|
|
||||||
result, err := h.sepService.GetDetail(c.Request.Context(), noSEP)
|
|
||||||
if err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusOK, "Successfully retrieved SEP detail", result)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteSEP menangani request untuk menghapus SEP.
|
|
||||||
func (h *SepHandler) DeleteSEP(c *gin.Context) {
|
|
||||||
var req sepService.DeleteSEPRequest
|
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
|
||||||
response.Error(c, http.StatusBadRequest, "Invalid request body for SEP deletion", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := h.sepService.Delete(c.Request.Context(), req)
|
|
||||||
if err != nil {
|
|
||||||
appErr := errors.FromError(err)
|
|
||||||
response.Error(c, appErr.HTTPStatus(), appErr.Error(), nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Success(c, http.StatusOK, "Successfully deleted SEP", result)
|
|
||||||
}
|
|
||||||
@@ -8,10 +8,6 @@ import (
|
|||||||
"service/internal/infrastructure/config"
|
"service/internal/infrastructure/config"
|
||||||
"service/internal/infrastructure/transport/http/middleware"
|
"service/internal/infrastructure/transport/http/middleware"
|
||||||
|
|
||||||
antrolHttp "service/internal/infrastructure/transport/http/handlers/bpjs/antrol"
|
|
||||||
aplicareHttp "service/internal/infrastructure/transport/http/handlers/bpjs/aplicare"
|
|
||||||
apotekHttp "service/internal/infrastructure/transport/http/handlers/bpjs/apotek"
|
|
||||||
vclaimHttp "service/internal/infrastructure/transport/http/handlers/bpjs/vclaim"
|
|
||||||
authHttp "service/internal/infrastructure/transport/http/handlers/main/auth"
|
authHttp "service/internal/infrastructure/transport/http/handlers/main/auth"
|
||||||
healthHttp "service/internal/infrastructure/transport/http/handlers/main/health"
|
healthHttp "service/internal/infrastructure/transport/http/handlers/main/health"
|
||||||
roleHttp "service/internal/infrastructure/transport/http/handlers/main/master/roles"
|
roleHttp "service/internal/infrastructure/transport/http/handlers/main/master/roles"
|
||||||
@@ -30,11 +26,6 @@ type ModuleHandlers struct {
|
|||||||
RolePages *roleHttp.RolPagesHandler
|
RolePages *roleHttp.RolPagesHandler
|
||||||
RolePermission *roleHttp.RolPermissionHandler
|
RolePermission *roleHttp.RolPermissionHandler
|
||||||
RoleMaster *roleHttp.RoleMasterHandler
|
RoleMaster *roleHttp.RoleMasterHandler
|
||||||
Sep *vclaimHttp.SepHandler
|
|
||||||
Peserta *vclaimHttp.PesertaHandler
|
|
||||||
Antrol *antrolHttp.AntrolHandler
|
|
||||||
AplicareBed *aplicareHttp.BedHandler
|
|
||||||
ApotekReference *apotekHttp.ReferenceHandler
|
|
||||||
SatuSehatAuth *satuSehatRefHttp.AuthHandler
|
SatuSehatAuth *satuSehatRefHttp.AuthHandler
|
||||||
SatuSehatPatient *satuSehatRefHttp.PatientHandler
|
SatuSehatPatient *satuSehatRefHttp.PatientHandler
|
||||||
SatuSehatPractitioner *satuSehatRefHttp.PractitionerHandler
|
SatuSehatPractitioner *satuSehatRefHttp.PractitionerHandler
|
||||||
@@ -154,29 +145,6 @@ func SetupRoutes(
|
|||||||
h.RoleMaster.RegisterRoutes(protected)
|
h.RoleMaster.RegisterRoutes(protected)
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Routes Modul BPJS VClaim ---
|
|
||||||
if h.Sep != nil {
|
|
||||||
h.Sep.RegisterRoutes(protected)
|
|
||||||
}
|
|
||||||
if h.Peserta != nil {
|
|
||||||
h.Peserta.RegisterRoutes(protected)
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Routes Modul BPJS Antrol ---
|
|
||||||
if h.Antrol != nil {
|
|
||||||
h.Antrol.RegisterRoutes(protected)
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Routes Modul BPJS Aplicares ---
|
|
||||||
if h.AplicareBed != nil {
|
|
||||||
h.AplicareBed.RegisterRoutes(protected)
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Routes Modul BPJS Apotek ---
|
|
||||||
if h.ApotekReference != nil {
|
|
||||||
h.ApotekReference.RegisterRoutes(protected)
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Routes Modul Satu Sehat ---
|
// --- Routes Modul Satu Sehat ---
|
||||||
// Buat grup khusus untuk membatasi traffic hit API ke Kemenkes
|
// Buat grup khusus untuk membatasi traffic hit API ke Kemenkes
|
||||||
satuSehatGroup := protected.Group("")
|
satuSehatGroup := protected.Group("")
|
||||||
|
|||||||
@@ -8,12 +8,6 @@ import (
|
|||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"service/internal/auth"
|
"service/internal/auth"
|
||||||
antrol "service/internal/bpjs/antrol/reference"
|
|
||||||
aplicareBed "service/internal/bpjs/aplicare/bed"
|
|
||||||
apotekDpho "service/internal/bpjs/apotek/reference/dpho"
|
|
||||||
apotekPoli "service/internal/bpjs/apotek/reference/poli"
|
|
||||||
peserta "service/internal/bpjs/vclaim/peserta"
|
|
||||||
sep "service/internal/bpjs/vclaim/sep"
|
|
||||||
roleMaster "service/internal/master/role/master"
|
roleMaster "service/internal/master/role/master"
|
||||||
rolePages "service/internal/master/role/pages"
|
rolePages "service/internal/master/role/pages"
|
||||||
rolePermission "service/internal/master/role/permission"
|
rolePermission "service/internal/master/role/permission"
|
||||||
@@ -51,28 +45,6 @@ type MasterServices struct {
|
|||||||
RoleMaster roleMaster.Service
|
RoleMaster roleMaster.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
// VClaimServices menampung kumpulan service untuk integrasi BPJS VClaim
|
|
||||||
type VClaimServices struct {
|
|
||||||
Sep sep.Service
|
|
||||||
Peserta peserta.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
// AntrolServices menampung kumpulan service untuk integrasi BPJS Antrean RS
|
|
||||||
type AntrolServices struct {
|
|
||||||
Reference antrol.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
// AplicaresServices menampung kumpulan service untuk integrasi BPJS Aplicares
|
|
||||||
type AplicaresServices struct {
|
|
||||||
Bed aplicareBed.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
// ApotekServices menampung kumpulan service untuk integrasi BPJS Apotek
|
|
||||||
type ApotekServices struct {
|
|
||||||
DPHO apotekDpho.Service
|
|
||||||
Poli apotekPoli.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
// SatuSehatServices menampung kumpulan service untuk integrasi Kemenkes Satu Sehat
|
// SatuSehatServices menampung kumpulan service untuk integrasi Kemenkes Satu Sehat
|
||||||
type SatuSehatServices struct {
|
type SatuSehatServices struct {
|
||||||
Auth satuSehatAuth.Service
|
Auth satuSehatAuth.Service
|
||||||
@@ -115,9 +87,5 @@ type ServiceRegistry struct {
|
|||||||
// Modul Aplikasi (Pisahkan berdasarkan Bounded Context)
|
// Modul Aplikasi (Pisahkan berdasarkan Bounded Context)
|
||||||
AuthService auth.Service
|
AuthService auth.Service
|
||||||
Master *MasterServices
|
Master *MasterServices
|
||||||
VClaim *VClaimServices
|
|
||||||
Antrol *AntrolServices
|
|
||||||
Aplicare *AplicaresServices
|
|
||||||
Apotek *ApotekServices
|
|
||||||
SatuSehat *SatuSehatServices
|
SatuSehat *SatuSehatServices
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ import (
|
|||||||
"service/internal/infrastructure/transport/http/middleware"
|
"service/internal/infrastructure/transport/http/middleware"
|
||||||
"service/internal/infrastructure/transport/http/routes"
|
"service/internal/infrastructure/transport/http/routes"
|
||||||
|
|
||||||
antrolHttp "service/internal/infrastructure/transport/http/handlers/bpjs/antrol"
|
|
||||||
aplicareHttp "service/internal/infrastructure/transport/http/handlers/bpjs/aplicare"
|
|
||||||
apotekHttp "service/internal/infrastructure/transport/http/handlers/bpjs/apotek"
|
|
||||||
vclaimHttp "service/internal/infrastructure/transport/http/handlers/bpjs/vclaim"
|
|
||||||
authHttp "service/internal/infrastructure/transport/http/handlers/main/auth"
|
authHttp "service/internal/infrastructure/transport/http/handlers/main/auth"
|
||||||
healthHttp "service/internal/infrastructure/transport/http/handlers/main/health"
|
healthHttp "service/internal/infrastructure/transport/http/handlers/main/health"
|
||||||
roleHttp "service/internal/infrastructure/transport/http/handlers/main/master/roles"
|
roleHttp "service/internal/infrastructure/transport/http/handlers/main/master/roles"
|
||||||
@@ -88,37 +84,6 @@ func NewHTTPServer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inisialisasi Handlers Modul VClaim
|
|
||||||
if registry.VClaim != nil {
|
|
||||||
if registry.VClaim.Sep != nil {
|
|
||||||
appHandlers.Sep = vclaimHttp.NewSepHandler(registry.VClaim.Sep)
|
|
||||||
}
|
|
||||||
if registry.VClaim.Peserta != nil {
|
|
||||||
appHandlers.Peserta = vclaimHttp.NewPesertaHandler(registry.VClaim.Peserta)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inisialisasi Handlers Modul Antrol
|
|
||||||
if registry.Antrol != nil {
|
|
||||||
if registry.Antrol.Reference != nil {
|
|
||||||
appHandlers.Antrol = antrolHttp.NewAntrolHandler(registry.Antrol.Reference)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inisialisasi Handlers Modul Aplicares
|
|
||||||
if registry.Aplicare != nil {
|
|
||||||
if registry.Aplicare.Bed != nil {
|
|
||||||
appHandlers.AplicareBed = aplicareHttp.NewBedHandler(registry.Aplicare.Bed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inisialisasi Handlers Modul Apotek
|
|
||||||
if registry.Apotek != nil {
|
|
||||||
if registry.Apotek.DPHO != nil && registry.Apotek.Poli != nil {
|
|
||||||
appHandlers.ApotekReference = apotekHttp.NewReferenceHandler(registry.Apotek.DPHO, registry.Apotek.Poli)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inisialisasi Handlers Modul Satu Sehat
|
// Inisialisasi Handlers Modul Satu Sehat
|
||||||
if registry.SatuSehat != nil {
|
if registry.SatuSehat != nil {
|
||||||
if registry.SatuSehat.Auth != nil {
|
if registry.SatuSehat.Auth != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user