Commit bbe15047 authored by Ghitha Dinan's avatar Ghitha Dinan

add api count

parent ef2901c2
...@@ -2,8 +2,8 @@ package id.co.sangkuriang.inovasi.daerah.master.constant ...@@ -2,8 +2,8 @@ package id.co.sangkuriang.inovasi.daerah.master.constant
import java.io.File import java.io.File
//const val ROOT_DIR = "D:\\app-files\\inovasi_daerah_master\\files\\" const val ROOT_DIR = "D:\\app-files\\inovasi_daerah_master\\files\\"
const val ROOT_DIR = "/home/inovasi-daerah/data/files/inovasi_daerah_master/" //const val ROOT_DIR = "/home/inovasi-daerah/data/files/inovasi_daerah_master/"
val UPLOAD_DIR = "${ROOT_DIR}uploads${File.separator}" val UPLOAD_DIR = "${ROOT_DIR}uploads${File.separator}"
val UPLOAD_ICON_APPLICATION_CATEGORY_DIR = "${UPLOAD_DIR}apllication_category/icon" val UPLOAD_ICON_APPLICATION_CATEGORY_DIR = "${UPLOAD_DIR}apllication_category/icon"
......
...@@ -2,9 +2,9 @@ package id.co.sangkuriang.inovasi.daerah.master.constant ...@@ -2,9 +2,9 @@ package id.co.sangkuriang.inovasi.daerah.master.constant
const val TOKEN_PREFIX = "Bearer " const val TOKEN_PREFIX = "Bearer "
const val HEADER_STRING = "Authorization" const val HEADER_STRING = "Authorization"
//const val AUTH_URL = "http://localhost:8081/auth" const val AUTH_URL = "http://localhost:8081/auth"
//const val AUTH_URL = "https://auth.inovasi-daerah.dev.layanan.go.id/auth" //const val AUTH_URL = "https://auth.inovasi-daerah.dev.layanan.go.id/auth"
const val AUTH_URL = "http://inovasi-daerah-auth.inovasi-daerah.svc.cluster.local:8081/auth" //const val AUTH_URL = "http://inovasi-daerah-auth.inovasi-daerah.svc.cluster.local:8081/auth"
val USER_ALLOWED_PATH = emptyList<String>() val USER_ALLOWED_PATH = emptyList<String>()
......
...@@ -53,4 +53,14 @@ class PublicController { ...@@ -53,4 +53,14 @@ class PublicController {
return regencyService.getAll(page) return regencyService.getAll(page)
} }
@GetMapping(value = ["application-category/count"], produces = ["application/json"])
fun applicationCategoryCount(): ResponseEntity<*>? {
return applicationCategoryService.count()
}
@GetMapping(value = ["province/count"], produces = ["application/json"])
fun provinceCount(): ResponseEntity<*>? {
return provinceService.count()
}
} }
...@@ -100,7 +100,6 @@ class LogInterceptor : Filter { ...@@ -100,7 +100,6 @@ class LogInterceptor : Filter {
getLogDescription(success, requestUri, httpServletRequest.method), getLogDescription(success, requestUri, httpServletRequest.method),
res.replace("\\\"", "\"") res.replace("\\\"", "\"")
) )
println("requestInfo => $res")
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
......
...@@ -21,4 +21,7 @@ interface ApplicationCategoryRepository : JpaRepository<ApplicationCategory, Str ...@@ -21,4 +21,7 @@ interface ApplicationCategoryRepository : JpaRepository<ApplicationCategory, Str
@Query("FROM ApplicationCategory WHERE LOWER(name) = LOWER(:name) AND active = true") @Query("FROM ApplicationCategory WHERE LOWER(name) = LOWER(:name) AND active = true")
fun findByName(name: String?): Optional<ApplicationCategory> fun findByName(name: String?): Optional<ApplicationCategory>
@Query("SELECT COUNT(u) FROM ApplicationCategory u WHERE u.active = true")
fun getCount(): Long?
} }
...@@ -21,4 +21,7 @@ interface ProvinceRepository : JpaRepository<Province, String> { ...@@ -21,4 +21,7 @@ interface ProvinceRepository : JpaRepository<Province, String> {
@Query("FROM Province WHERE LOWER(name) = LOWER(:name) AND active = true") @Query("FROM Province WHERE LOWER(name) = LOWER(:name) AND active = true")
fun findByName(name: String?): Optional<Province> fun findByName(name: String?): Optional<Province>
@Query("SELECT COUNT(u) FROM Province u WHERE u.active = true")
fun getCount(): Long?
} }
...@@ -21,4 +21,6 @@ interface ApplicationCategoryService { ...@@ -21,4 +21,6 @@ interface ApplicationCategoryService {
): ResponseEntity<*>? ): ResponseEntity<*>?
fun deleteData(request: DeleteDataRequest): ResponseEntity<*>? fun deleteData(request: DeleteDataRequest): ResponseEntity<*>?
fun count(): ResponseEntity<*>?
} }
...@@ -21,4 +21,6 @@ interface ProvinceService { ...@@ -21,4 +21,6 @@ interface ProvinceService {
fun datatable(req: Pagination2Request): ResponseEntity<*>? fun datatable(req: Pagination2Request): ResponseEntity<*>?
fun getByName(name: String): ResponseEntity<*>? fun getByName(name: String): ResponseEntity<*>?
fun count(): ResponseEntity<*>?
} }
...@@ -138,6 +138,14 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService { ...@@ -138,6 +138,14 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService {
} }
} }
override fun count(): ResponseEntity<*>? {
return try {
responseSuccess(data = repo.getCount())
} catch (e : Exception) {
throw e
}
}
private fun validateRequest(request: ApplicationCategoryRequest, id: String? = null) { private fun validateRequest(request: ApplicationCategoryRequest, id: String? = null) {
try { try {
val listMessage = mutableListOf<Map<String, String>>() val listMessage = mutableListOf<Map<String, String>>()
......
...@@ -74,6 +74,14 @@ class ProvinceServiceImpl : ProvinceService { ...@@ -74,6 +74,14 @@ class ProvinceServiceImpl : ProvinceService {
} }
} }
override fun count(): ResponseEntity<*>? {
return try {
responseSuccess(data = repo.getCount())
} catch (e : Exception) {
throw e
}
}
override fun getDetail(id: String): ResponseEntity<*>? { override fun getDetail(id: String): ResponseEntity<*>? {
try { try {
val data = repo.findByIdAndActive(id) val data = repo.findByIdAndActive(id)
......
...@@ -4,13 +4,13 @@ spring.profiles.active=development ...@@ -4,13 +4,13 @@ spring.profiles.active=development
server.port=8080 server.port=8080
# DATABASE CONFIG # DATABASE CONFIG
#spring.datasource.url=jdbc:postgresql://localhost:5432/inovasi_daerah_backup spring.datasource.url=jdbc:postgresql://localhost:5432/inovasi_daerah_backup
#spring.datasource.username=postgres spring.datasource.username=postgres
#spring.datasource.password=root spring.datasource.password=root
spring.datasource.url=jdbc:postgresql://pg-dev.spbe.sangkuriang.co.id:5432/inovasi_daerah_db #spring.datasource.url=jdbc:postgresql://pg-dev.spbe.sangkuriang.co.id:5432/inovasi_daerah_db
spring.datasource.username=u_inovasi_daerah #spring.datasource.username=u_inovasi_daerah
spring.datasource.password=wV9Tnx6S8TmmUYXdgkmN4pzreSD3RE #spring.datasource.password=wV9Tnx6S8TmmUYXdgkmN4pzreSD3RE
spring.jpa.hibernate.ddl-auto=none spring.jpa.hibernate.ddl-auto=none
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<!-- configuration file for LogBack (slf4J implementation) <!-- configuration file for LogBack (slf4J implementation)
See here for more details: http://gordondickens.com/wordpress/2013/03/27/sawing-through-the-java-loggers/ --> See here for more details: http://gordondickens.com/wordpress/2013/03/27/sawing-through-the-java-loggers/ -->
<configuration scan="true" scanPeriod="30 seconds"> <configuration scan="true" scanPeriod="30 seconds">
<!-- <property name="DEV_HOME" value="D://app-files//inovasi_daerah_master//log"/>--> <property name="DEV_HOME" value="D://app-files//inovasi_daerah_master//log"/>
<property name="DEV_HOME" value="/home/inovasi-daerah/data/log/inovasi_daerah_master"/> <!-- <property name="DEV_HOME" value="/home/inovasi-daerah/data/log/inovasi_daerah_master"/>-->
<appender name="ACCESS-LOG" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="ACCESS-LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${DEV_HOME}/access.log</file> <file>${DEV_HOME}/access.log</file>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment