This commit is contained in:
2025-05-19 15:34:12 +07:00
parent 1f30f3e10d
commit cd880e3854
3 changed files with 8 additions and 21 deletions

8
.env
View File

@@ -1,4 +1,4 @@
PORT=8086
PORT=8080
SATUDATA_HOST=10.10.123.165
SATUDATA_USERNAME=stim
@@ -6,12 +6,6 @@ SATUDATA_PASSWORD=stim*RS54
SATUDATA_NAME=satu_db
SATUDATA_PORT=5000
SIMRS_HOST=10.10.123.160
SIMRS_USERNAME=simrs
SIMRS_PASSWORD=simrs.rssa
SIMRS_NAME=simrs
SIMRS_PORT=5000
SIMRS_STAG_HOST=10.10.123.223
SIMRS_STAG_USER=simtest
SIMRS_STAG_PASS=12345

View File

@@ -6,7 +6,7 @@ services:
container_name: api-retribusi
restart: always
ports:
- 8086:8086
- 8080:8080
volumes:
- .:/app
- /etc/localtime:/etc/localtime:ro
@@ -14,6 +14,12 @@ services:
environment:
# TIMEZONE
- TZ=Asia/Jakarta
# DATABASE SIMRS V3.0
- SIMRS_STAG_HOST=10.10.123.223
- SIMRS_STAG_PORT=5432
- SIMRS_STAG_NAME=simrsbackup
- SIMRS_STAG_USER=simtest
- SIMRS_STAG_PASS=12345
# DATABASE SATU DATA
- SATUDATA_HOST=10.10.123.165
- SATUDATA_USER=stim

View File

@@ -27,11 +27,6 @@ type service struct {
}
var (
hostSimrs = os.Getenv("SIMRS_STAG_HOST")
userNameSimrs = os.Getenv("SIMRS_STAG_USER")
passwordSimrs = os.Getenv("SIMRS_STAG_PASS")
dbNameSimrs = os.Getenv("SIMRS_STAG_NAME")
portSimrs = os.Getenv("SIMRS_STAG_PORT")
hostSatudata = os.Getenv("SATUDATA_HOST")
userNameSatudata = os.Getenv("SATUDATA_USER")
passwordSatudata = os.Getenv("SATUDATA_PASS")
@@ -45,14 +40,7 @@ func New() Service {
if dbInstance != nil {
return dbInstance
}
simrs := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Jakarta", hostSimrs, userNameSimrs, passwordSimrs, dbNameSimrs, portSimrs)
SimrsDB, err := gorm.Open(postgres.Open(simrs), &gorm.Config{})
if err != nil {
log.Fatal("Failed to connect to SIM database: ", err)
} else {
log.Println("Successfully connected to the database")
}
satudata := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Jakarta", hostSatudata, userNameSatudata, passwordSatudata, dbNameSatudata, portSatudata)
SatudataDB, err := gorm.Open(postgres.Open(satudata), &gorm.Config{})
@@ -62,7 +50,6 @@ func New() Service {
log.Println("Successfully connected to the database")
}
dbInstance = &service{
simrsDB: SimrsDB,
satuDataDB: SatudataDB,
}
return dbInstance