Commit 13516436 authored by Ghitha Dinan's avatar Ghitha Dinan

add swagger

parent 790e31b3
...@@ -3,6 +3,7 @@ package id.co.sangkuriang.inovasi.daerah.master.controller ...@@ -3,6 +3,7 @@ package id.co.sangkuriang.inovasi.daerah.master.controller
import id.co.sangkuriang.inovasi.daerah.master.model.request.ApplicationCategoryRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.ApplicationCategoryRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.service.ApplicationCategoryService import id.co.sangkuriang.inovasi.daerah.master.service.ApplicationCategoryService
import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity
...@@ -18,12 +19,12 @@ class ApplicationCategoryController { ...@@ -18,12 +19,12 @@ class ApplicationCategoryController {
private lateinit var service: ApplicationCategoryService private lateinit var service: ApplicationCategoryService
@GetMapping(value = [""], produces = ["application/json"]) @GetMapping(value = [""], produces = ["application/json"])
fun getAll(page: PaginationRequest): ResponseEntity<*>? { fun getAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return service.getAll(page) return service.getAll(page)
} }
@GetMapping(value = ["{id}"], produces = ["application/json"]) @GetMapping(value = ["{id}"], produces = ["application/json"])
fun getDetail(@PathVariable id: String): ResponseEntity<*>? { fun getDetail(@PathVariable id: String): ResponseEntity<ReturnData> {
return service.getDetail(id) return service.getDetail(id)
} }
...@@ -31,7 +32,7 @@ class ApplicationCategoryController { ...@@ -31,7 +32,7 @@ class ApplicationCategoryController {
fun saveData( fun saveData(
@Valid @ModelAttribute request: ApplicationCategoryRequest, @Valid @ModelAttribute request: ApplicationCategoryRequest,
httpServletRequest: HttpServletRequest httpServletRequest: HttpServletRequest
): ResponseEntity<*>? { ): ResponseEntity<ReturnData> {
return service.saveData(request, httpServletRequest) return service.saveData(request, httpServletRequest)
} }
...@@ -40,12 +41,12 @@ class ApplicationCategoryController { ...@@ -40,12 +41,12 @@ class ApplicationCategoryController {
@PathVariable id: String, @PathVariable id: String,
@Valid @ModelAttribute request: ApplicationCategoryRequest, @Valid @ModelAttribute request: ApplicationCategoryRequest,
httpServletRequest: HttpServletRequest httpServletRequest: HttpServletRequest
): ResponseEntity<*>? { ): ResponseEntity<ReturnData> {
return service.updateData(id, request, httpServletRequest) return service.updateData(id, request, httpServletRequest)
} }
@DeleteMapping(value = [""], produces = ["application/json"]) @DeleteMapping(value = [""], produces = ["application/json"])
fun deleteData(@Valid @RequestBody request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? { fun deleteData(@Valid @RequestBody request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData> {
return service.deleteData(request, httpServletRequest) return service.deleteData(request, httpServletRequest)
} }
} }
...@@ -3,6 +3,7 @@ package id.co.sangkuriang.inovasi.daerah.master.controller ...@@ -3,6 +3,7 @@ package id.co.sangkuriang.inovasi.daerah.master.controller
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.Pagination2Request import id.co.sangkuriang.inovasi.daerah.master.model.request.Pagination2Request
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.pojo.Province import id.co.sangkuriang.inovasi.daerah.master.pojo.Province
import id.co.sangkuriang.inovasi.daerah.master.service.ProvinceService import id.co.sangkuriang.inovasi.daerah.master.service.ProvinceService
import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired
...@@ -19,32 +20,32 @@ class ProvinceController { ...@@ -19,32 +20,32 @@ class ProvinceController {
private lateinit var service: ProvinceService private lateinit var service: ProvinceService
@GetMapping(value = [""], produces = ["application/json"]) @GetMapping(value = [""], produces = ["application/json"])
fun getAll(page: PaginationRequest): ResponseEntity<*>? { fun getAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return service.getAll(page) return service.getAll(page)
} }
@PostMapping(value = ["datatable"], produces = ["application/json"]) @PostMapping(value = ["datatable"], produces = ["application/json"])
fun datatable(@RequestBody req: Pagination2Request): ResponseEntity<*>? { fun datatable(@RequestBody req: Pagination2Request): ResponseEntity<ReturnData> {
return service.datatable(req) return service.datatable(req)
} }
@GetMapping(value = ["{id}"], produces = ["application/json"]) @GetMapping(value = ["{id}"], produces = ["application/json"])
fun getDetail(@PathVariable id: String): ResponseEntity<*>? { fun getDetail(@PathVariable id: String): ResponseEntity<ReturnData> {
return service.getDetail(id) return service.getDetail(id)
} }
@PostMapping(value = [""], produces = ["application/json"]) @PostMapping(value = [""], produces = ["application/json"])
fun saveData(@Valid @RequestBody request: Province): ResponseEntity<*>? { fun saveData(@Valid @RequestBody request: Province): ResponseEntity<ReturnData> {
return service.saveData(request) return service.saveData(request)
} }
@PutMapping(value = ["{id}"], produces = ["application/json"]) @PutMapping(value = ["{id}"], produces = ["application/json"])
fun updateData(@PathVariable id: String, @Valid @RequestBody request: Province): ResponseEntity<*>? { fun updateData(@PathVariable id: String, @Valid @RequestBody request: Province): ResponseEntity<ReturnData> {
return service.updateData(id, request) return service.updateData(id, request)
} }
@DeleteMapping(value = [""], produces = ["application/json"]) @DeleteMapping(value = [""], produces = ["application/json"])
fun deleteData(@Valid @RequestBody request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? { fun deleteData(@Valid @RequestBody request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData> {
return service.deleteData(request, httpServletRequest) return service.deleteData(request, httpServletRequest)
} }
} }
package id.co.sangkuriang.inovasi.daerah.master.controller package id.co.sangkuriang.inovasi.daerah.master.controller
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.service.ApplicationCategoryService import id.co.sangkuriang.inovasi.daerah.master.service.ApplicationCategoryService
import id.co.sangkuriang.inovasi.daerah.master.service.ProvinceService import id.co.sangkuriang.inovasi.daerah.master.service.ProvinceService
import id.co.sangkuriang.inovasi.daerah.master.service.RegencyService import id.co.sangkuriang.inovasi.daerah.master.service.RegencyService
...@@ -29,37 +30,37 @@ class PublicController { ...@@ -29,37 +30,37 @@ class PublicController {
private lateinit var regencyService: RegencyService private lateinit var regencyService: RegencyService
@GetMapping(value = ["application-category/all"], produces = ["application/json"]) @GetMapping(value = ["application-category/all"], produces = ["application/json"])
fun applicationCategoryAll(page: PaginationRequest): ResponseEntity<*>? { fun applicationCategoryAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return applicationCategoryService.getAll(page) return applicationCategoryService.getAll(page)
} }
@GetMapping(value = ["tag/all"], produces = ["application/json"]) @GetMapping(value = ["tag/all"], produces = ["application/json"])
fun tagAll(page: PaginationRequest): ResponseEntity<*>? { fun tagAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return tagService.getAll(page) return tagService.getAll(page)
} }
@GetMapping(value = ["province/all"], produces = ["application/json"]) @GetMapping(value = ["province/all"], produces = ["application/json"])
fun provinceAll(page: PaginationRequest): ResponseEntity<*>? { fun provinceAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return provinceService.getAll(page) return provinceService.getAll(page)
} }
@GetMapping(value = ["province/get-by-name"], produces = ["application/json"]) @GetMapping(value = ["province/get-by-name"], produces = ["application/json"])
fun provinceGetByName(@RequestParam("name") name: String): ResponseEntity<*>? { fun provinceGetByName(@RequestParam("name") name: String): ResponseEntity<ReturnData> {
return provinceService.getByName(name) return provinceService.getByName(name)
} }
@GetMapping(value = ["regency/all"], produces = ["application/json"]) @GetMapping(value = ["regency/all"], produces = ["application/json"])
fun regencyAll(page: PaginationRequest): ResponseEntity<*>? { fun regencyAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return regencyService.getAll(page) return regencyService.getAll(page)
} }
@GetMapping(value = ["application-category/count"], produces = ["application/json"]) @GetMapping(value = ["application-category/count"], produces = ["application/json"])
fun applicationCategoryCount(): ResponseEntity<*>? { fun applicationCategoryCount(): ResponseEntity<ReturnData> {
return applicationCategoryService.count() return applicationCategoryService.count()
} }
@GetMapping(value = ["province/count"], produces = ["application/json"]) @GetMapping(value = ["province/count"], produces = ["application/json"])
fun provinceCount(): ResponseEntity<*>? { fun provinceCount(): ResponseEntity<ReturnData> {
return provinceService.count() return provinceService.count()
} }
......
...@@ -2,6 +2,7 @@ package id.co.sangkuriang.inovasi.daerah.master.controller ...@@ -2,6 +2,7 @@ package id.co.sangkuriang.inovasi.daerah.master.controller
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.pojo.Regency import id.co.sangkuriang.inovasi.daerah.master.pojo.Regency
import id.co.sangkuriang.inovasi.daerah.master.service.RegencyService import id.co.sangkuriang.inovasi.daerah.master.service.RegencyService
import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired
...@@ -18,27 +19,27 @@ class RegencyController { ...@@ -18,27 +19,27 @@ class RegencyController {
private lateinit var service: RegencyService private lateinit var service: RegencyService
@GetMapping(value = [""], produces = ["application/json"]) @GetMapping(value = [""], produces = ["application/json"])
fun getAll(page: PaginationRequest): ResponseEntity<*>? { fun getAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return service.getAll(page) return service.getAll(page)
} }
@GetMapping(value = ["{id}"], produces = ["application/json"]) @GetMapping(value = ["{id}"], produces = ["application/json"])
fun getDetail(@PathVariable id: String): ResponseEntity<*>? { fun getDetail(@PathVariable id: String): ResponseEntity<ReturnData> {
return service.getDetail(id) return service.getDetail(id)
} }
@PostMapping(value = [""], produces = ["application/json"]) @PostMapping(value = [""], produces = ["application/json"])
fun saveData(@Valid @RequestBody request: Regency): ResponseEntity<*>? { fun saveData(@Valid @RequestBody request: Regency): ResponseEntity<ReturnData> {
return service.saveData(request) return service.saveData(request)
} }
@PutMapping(value = ["{id}"], produces = ["application/json"]) @PutMapping(value = ["{id}"], produces = ["application/json"])
fun updateData(@PathVariable id: String, @Valid @RequestBody request: Regency): ResponseEntity<*>? { fun updateData(@PathVariable id: String, @Valid @RequestBody request: Regency): ResponseEntity<ReturnData> {
return service.updateData(id, request) return service.updateData(id, request)
} }
@DeleteMapping(value = [""], produces = ["application/json"]) @DeleteMapping(value = [""], produces = ["application/json"])
fun deleteData(@Valid @RequestBody request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? { fun deleteData(@Valid @RequestBody request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData> {
return service.deleteData(request, httpServletRequest) return service.deleteData(request, httpServletRequest)
} }
} }
...@@ -2,6 +2,7 @@ package id.co.sangkuriang.inovasi.daerah.master.controller ...@@ -2,6 +2,7 @@ package id.co.sangkuriang.inovasi.daerah.master.controller
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.pojo.Tag import id.co.sangkuriang.inovasi.daerah.master.pojo.Tag
import id.co.sangkuriang.inovasi.daerah.master.service.TagService import id.co.sangkuriang.inovasi.daerah.master.service.TagService
import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired
...@@ -18,22 +19,22 @@ class TagController { ...@@ -18,22 +19,22 @@ class TagController {
private lateinit var service: TagService private lateinit var service: TagService
@GetMapping(value = [""], produces = ["application/json"]) @GetMapping(value = [""], produces = ["application/json"])
fun getAll(page: PaginationRequest): ResponseEntity<*>? { fun getAll(page: PaginationRequest): ResponseEntity<ReturnData>? {
return service.getAll(page) return service.getAll(page)
} }
@GetMapping(value = ["{id}"], produces = ["application/json"]) @GetMapping(value = ["{id}"], produces = ["application/json"])
fun getDetail(@PathVariable id: String): ResponseEntity<*>? { fun getDetail(@PathVariable id: String): ResponseEntity<ReturnData>? {
return service.getDetail(id) return service.getDetail(id)
} }
@PostMapping(value = [""], produces = ["application/json"]) @PostMapping(value = [""], produces = ["application/json"])
fun saveData(@Valid @RequestBody request: Tag): ResponseEntity<*>? { fun saveData(@Valid @RequestBody request: Tag): ResponseEntity<ReturnData>? {
return service.saveData(request) return service.saveData(request)
} }
@PutMapping(value = ["{id}"], produces = ["application/json"]) @PutMapping(value = ["{id}"], produces = ["application/json"])
fun updateData(@PathVariable id: String, @Valid @RequestBody request: Tag): ResponseEntity<*>? { fun updateData(@PathVariable id: String, @Valid @RequestBody request: Tag): ResponseEntity<ReturnData>? {
return service.updateData(id, request) return service.updateData(id, request)
} }
...@@ -41,7 +42,7 @@ class TagController { ...@@ -41,7 +42,7 @@ class TagController {
fun deleteData( fun deleteData(
@Valid @RequestBody request: DeleteDataRequest, @Valid @RequestBody request: DeleteDataRequest,
httpServletRequest: HttpServletRequest httpServletRequest: HttpServletRequest
): ResponseEntity<*>? { ): ResponseEntity<ReturnData>? {
return service.deleteData(request, httpServletRequest) return service.deleteData(request, httpServletRequest)
} }
} }
...@@ -4,8 +4,8 @@ import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData ...@@ -4,8 +4,8 @@ import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import org.springframework.http.HttpStatus import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity
fun responseSuccess(message: String = "Success", data: Any? = null): ResponseEntity<*> { fun responseSuccess(message: String = "Success", data: Any? = null): ResponseEntity<ReturnData> {
return ResponseEntity<Any?>( return ResponseEntity<ReturnData>(
ReturnData( ReturnData(
success = true, success = true,
message = message, message = message,
...@@ -15,8 +15,8 @@ fun responseSuccess(message: String = "Success", data: Any? = null): ResponseEnt ...@@ -15,8 +15,8 @@ fun responseSuccess(message: String = "Success", data: Any? = null): ResponseEnt
) )
} }
fun responseCreated(message: String = "Created", data: Any? = null): ResponseEntity<*> { fun responseCreated(message: String = "Created", data: Any? = null): ResponseEntity<ReturnData> {
return ResponseEntity<Any?>( return ResponseEntity<ReturnData>(
ReturnData( ReturnData(
success = true, success = true,
message = message, message = message,
...@@ -26,8 +26,11 @@ fun responseCreated(message: String = "Created", data: Any? = null): ResponseEnt ...@@ -26,8 +26,11 @@ fun responseCreated(message: String = "Created", data: Any? = null): ResponseEnt
) )
} }
fun responseInternalServerError(message: String = "Internal Server Error", data: Any? = null): ResponseEntity<*> { fun responseInternalServerError(
return ResponseEntity<Any?>( message: String = "Internal Server Error",
data: Any? = null
): ResponseEntity<ReturnData> {
return ResponseEntity<ReturnData>(
ReturnData( ReturnData(
success = false, success = false,
message = message, message = message,
...@@ -37,8 +40,8 @@ fun responseInternalServerError(message: String = "Internal Server Error", data: ...@@ -37,8 +40,8 @@ fun responseInternalServerError(message: String = "Internal Server Error", data:
) )
} }
fun responseNotFound(message: String = "Not Found", data: Any? = null): ResponseEntity<*> { fun responseNotFound(message: String = "Not Found", data: Any? = null): ResponseEntity<ReturnData> {
return ResponseEntity<Any?>( return ResponseEntity<ReturnData>(
ReturnData( ReturnData(
success = false, success = false,
message = message, message = message,
...@@ -48,8 +51,11 @@ fun responseNotFound(message: String = "Not Found", data: Any? = null): Response ...@@ -48,8 +51,11 @@ fun responseNotFound(message: String = "Not Found", data: Any? = null): Response
) )
} }
fun responseUnprocessableEntity(message: String = "Unprocessable Entity", data: Any? = null): ResponseEntity<*> { fun responseUnprocessableEntity(
return ResponseEntity<Any?>( message: String = "Unprocessable Entity",
data: Any? = null
): ResponseEntity<ReturnData> {
return ResponseEntity<ReturnData>(
ReturnData( ReturnData(
success = false, success = false,
message = message, message = message,
...@@ -59,8 +65,8 @@ fun responseUnprocessableEntity(message: String = "Unprocessable Entity", data: ...@@ -59,8 +65,8 @@ fun responseUnprocessableEntity(message: String = "Unprocessable Entity", data:
) )
} }
fun responseBadRequest(message: String = "Bad Request", data: Any? = null): ResponseEntity<*> { fun responseBadRequest(message: String = "Bad Request", data: Any? = null): ResponseEntity<ReturnData> {
return ResponseEntity<Any?>( return ResponseEntity<ReturnData>(
ReturnData( ReturnData(
success = false, success = false,
message = message, message = message,
......
...@@ -3,24 +3,26 @@ package id.co.sangkuriang.inovasi.daerah.master.service ...@@ -3,24 +3,26 @@ package id.co.sangkuriang.inovasi.daerah.master.service
import id.co.sangkuriang.inovasi.daerah.master.model.request.ApplicationCategoryRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.ApplicationCategoryRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import org.hibernate.validator.internal.metadata.aggregated.ReturnValueMetaData
import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity
import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletRequest
interface ApplicationCategoryService { interface ApplicationCategoryService {
fun getAll(page: PaginationRequest): ResponseEntity<*>? fun getAll(page: PaginationRequest): ResponseEntity<ReturnData>
fun getDetail(id: String): ResponseEntity<*>? fun getDetail(id: String): ResponseEntity<ReturnData>
fun saveData(request: ApplicationCategoryRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? fun saveData(request: ApplicationCategoryRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData>
fun updateData( fun updateData(
id: String, id: String,
request: ApplicationCategoryRequest, request: ApplicationCategoryRequest,
httpServletRequest: HttpServletRequest httpServletRequest: HttpServletRequest
): ResponseEntity<*>? ): ResponseEntity<ReturnData>
fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData>
fun count(): ResponseEntity<*>? fun count(): ResponseEntity<ReturnData>
} }
...@@ -3,25 +3,26 @@ package id.co.sangkuriang.inovasi.daerah.master.service ...@@ -3,25 +3,26 @@ package id.co.sangkuriang.inovasi.daerah.master.service
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.Pagination2Request import id.co.sangkuriang.inovasi.daerah.master.model.request.Pagination2Request
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.pojo.Province import id.co.sangkuriang.inovasi.daerah.master.pojo.Province
import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity
import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletRequest
interface ProvinceService { interface ProvinceService {
fun getAll(page: PaginationRequest): ResponseEntity<*>? fun getAll(page: PaginationRequest): ResponseEntity<ReturnData>
fun getDetail(id: String): ResponseEntity<*>? fun getDetail(id: String): ResponseEntity<ReturnData>
fun saveData(request: Province): ResponseEntity<*>? fun saveData(request: Province): ResponseEntity<ReturnData>
fun updateData(id: String, request: Province): ResponseEntity<*>? fun updateData(id: String, request: Province): ResponseEntity<ReturnData>
fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData>
fun datatable(req: Pagination2Request): ResponseEntity<*>? fun datatable(req: Pagination2Request): ResponseEntity<ReturnData>
fun getByName(name: String): ResponseEntity<*>? fun getByName(name: String): ResponseEntity<ReturnData>
fun count(): ResponseEntity<*>? fun count(): ResponseEntity<ReturnData>
} }
...@@ -2,19 +2,20 @@ package id.co.sangkuriang.inovasi.daerah.master.service ...@@ -2,19 +2,20 @@ package id.co.sangkuriang.inovasi.daerah.master.service
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.pojo.Regency import id.co.sangkuriang.inovasi.daerah.master.pojo.Regency
import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity
import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletRequest
interface RegencyService { interface RegencyService {
fun getAll(page: PaginationRequest): ResponseEntity<*>? fun getAll(page: PaginationRequest): ResponseEntity<ReturnData>
fun getDetail(id: String): ResponseEntity<*>? fun getDetail(id: String): ResponseEntity<ReturnData>
fun saveData(request: Regency): ResponseEntity<*>? fun saveData(request: Regency): ResponseEntity<ReturnData>
fun updateData(id: String, request: Regency): ResponseEntity<*>? fun updateData(id: String, request: Regency): ResponseEntity<ReturnData>
fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData>
} }
...@@ -2,19 +2,20 @@ package id.co.sangkuriang.inovasi.daerah.master.service ...@@ -2,19 +2,20 @@ package id.co.sangkuriang.inovasi.daerah.master.service
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.pojo.Tag import id.co.sangkuriang.inovasi.daerah.master.pojo.Tag
import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity
import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletRequest
interface TagService { interface TagService {
fun getAll(page: PaginationRequest): ResponseEntity<*>? fun getAll(page: PaginationRequest): ResponseEntity<ReturnData>
fun getDetail(id: String): ResponseEntity<*>? fun getDetail(id: String): ResponseEntity<ReturnData>
fun saveData(request: Tag): ResponseEntity<*>? fun saveData(request: Tag): ResponseEntity<ReturnData>
fun updateData(id: String, request: Tag): ResponseEntity<*>? fun updateData(id: String, request: Tag): ResponseEntity<ReturnData>
fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData>
} }
...@@ -31,7 +31,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService { ...@@ -31,7 +31,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService {
@Autowired @Autowired
private lateinit var repo: ApplicationCategoryRepository private lateinit var repo: ApplicationCategoryRepository
override fun getAll(page: PaginationRequest): ResponseEntity<*>? { override fun getAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return try { return try {
val page: Page<ApplicationCategory?>? = if (page.enablePage!! == 1) { val page: Page<ApplicationCategory?>? = if (page.enablePage!! == 1) {
var direction: Sort.Direction = Sort.Direction.ASC var direction: Sort.Direction = Sort.Direction.ASC
...@@ -54,7 +54,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService { ...@@ -54,7 +54,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService {
} }
} }
override fun getDetail(id: String): ResponseEntity<*>? { override fun getDetail(id: String): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(id) val data = repo.findByIdAndActive(id)
if (data.isPresent) { if (data.isPresent) {
...@@ -69,7 +69,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService { ...@@ -69,7 +69,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService {
override fun saveData( override fun saveData(
request: ApplicationCategoryRequest, request: ApplicationCategoryRequest,
httpServletRequest: HttpServletRequest httpServletRequest: HttpServletRequest
): ResponseEntity<*>? { ): ResponseEntity<ReturnData> {
return try { return try {
validateRequest(request) validateRequest(request)
val save = ApplicationCategory() val save = ApplicationCategory()
...@@ -92,7 +92,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService { ...@@ -92,7 +92,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService {
id: String, id: String,
request: ApplicationCategoryRequest, request: ApplicationCategoryRequest,
httpServletRequest: HttpServletRequest httpServletRequest: HttpServletRequest
): ResponseEntity<*>? { ): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(id) val data = repo.findByIdAndActive(id)
if (data.isPresent) { if (data.isPresent) {
...@@ -121,7 +121,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService { ...@@ -121,7 +121,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService {
} }
} }
override fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? { override fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(request.id) val data = repo.findByIdAndActive(request.id)
if (data.isPresent) { if (data.isPresent) {
...@@ -154,7 +154,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService { ...@@ -154,7 +154,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService {
} }
} }
override fun count(): ResponseEntity<*>? { override fun count(): ResponseEntity<ReturnData> {
return try { return try {
responseSuccess(data = repo.getCount()) responseSuccess(data = repo.getCount())
} catch (e: Exception) { } catch (e: Exception) {
......
...@@ -40,7 +40,7 @@ class ProvinceServiceImpl : ProvinceService { ...@@ -40,7 +40,7 @@ class ProvinceServiceImpl : ProvinceService {
@Autowired @Autowired
private lateinit var repoNative: ProvinceRepositoryNative private lateinit var repoNative: ProvinceRepositoryNative
override fun getAll(page: PaginationRequest): ResponseEntity<*>? { override fun getAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return try { return try {
val page: Page<Province?>? = if (page.enablePage!! == 1) { val page: Page<Province?>? = if (page.enablePage!! == 1) {
var direction: Sort.Direction = Sort.Direction.ASC var direction: Sort.Direction = Sort.Direction.ASC
...@@ -63,7 +63,7 @@ class ProvinceServiceImpl : ProvinceService { ...@@ -63,7 +63,7 @@ class ProvinceServiceImpl : ProvinceService {
} }
} }
override fun datatable(req: Pagination2Request): ResponseEntity<*>? { override fun datatable(req: Pagination2Request): ResponseEntity<ReturnData> {
return try { return try {
responseSuccess(data = repoNative.getPage(req)) responseSuccess(data = repoNative.getPage(req))
} catch (e: Exception) { } catch (e: Exception) {
...@@ -71,7 +71,7 @@ class ProvinceServiceImpl : ProvinceService { ...@@ -71,7 +71,7 @@ class ProvinceServiceImpl : ProvinceService {
} }
} }
override fun getByName(name: String): ResponseEntity<*>? { override fun getByName(name: String): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByName(name.trim()) val data = repo.findByName(name.trim())
if (data.isPresent) { if (data.isPresent) {
...@@ -83,7 +83,7 @@ class ProvinceServiceImpl : ProvinceService { ...@@ -83,7 +83,7 @@ class ProvinceServiceImpl : ProvinceService {
} }
} }
override fun count(): ResponseEntity<*>? { override fun count(): ResponseEntity<ReturnData> {
return try { return try {
responseSuccess(data = repo.getCount()) responseSuccess(data = repo.getCount())
} catch (e: Exception) { } catch (e: Exception) {
...@@ -91,7 +91,7 @@ class ProvinceServiceImpl : ProvinceService { ...@@ -91,7 +91,7 @@ class ProvinceServiceImpl : ProvinceService {
} }
} }
override fun getDetail(id: String): ResponseEntity<*>? { override fun getDetail(id: String): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(id) val data = repo.findByIdAndActive(id)
if (data.isPresent) { if (data.isPresent) {
...@@ -103,7 +103,7 @@ class ProvinceServiceImpl : ProvinceService { ...@@ -103,7 +103,7 @@ class ProvinceServiceImpl : ProvinceService {
} }
} }
override fun saveData(request: Province): ResponseEntity<*>? { override fun saveData(request: Province): ResponseEntity<ReturnData> {
return try { return try {
validateRequest(request) validateRequest(request)
val save = Province() val save = Province()
...@@ -115,7 +115,7 @@ class ProvinceServiceImpl : ProvinceService { ...@@ -115,7 +115,7 @@ class ProvinceServiceImpl : ProvinceService {
} }
} }
override fun updateData(id: String, request: Province): ResponseEntity<*>? { override fun updateData(id: String, request: Province): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(id) val data = repo.findByIdAndActive(id)
if (data.isPresent) { if (data.isPresent) {
...@@ -132,7 +132,10 @@ class ProvinceServiceImpl : ProvinceService { ...@@ -132,7 +132,10 @@ class ProvinceServiceImpl : ProvinceService {
} }
} }
override fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? { override fun deleteData(
request: DeleteDataRequest,
httpServletRequest: HttpServletRequest
): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(request.id) val data = repo.findByIdAndActive(request.id)
if (data.isPresent) { if (data.isPresent) {
......
...@@ -31,7 +31,7 @@ class RegencyServiceImpl : RegencyService { ...@@ -31,7 +31,7 @@ class RegencyServiceImpl : RegencyService {
@Autowired @Autowired
private lateinit var repo: RegencyRepository private lateinit var repo: RegencyRepository
override fun getAll(page: PaginationRequest): ResponseEntity<*>? { override fun getAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return try { return try {
val page: Page<Regency?>? = if (page.enablePage!! == 1) { val page: Page<Regency?>? = if (page.enablePage!! == 1) {
var direction: Sort.Direction = Sort.Direction.ASC var direction: Sort.Direction = Sort.Direction.ASC
...@@ -54,7 +54,7 @@ class RegencyServiceImpl : RegencyService { ...@@ -54,7 +54,7 @@ class RegencyServiceImpl : RegencyService {
} }
} }
override fun getDetail(id: String): ResponseEntity<*>? { override fun getDetail(id: String): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(id) val data = repo.findByIdAndActive(id)
if (data.isPresent) { if (data.isPresent) {
...@@ -66,7 +66,7 @@ class RegencyServiceImpl : RegencyService { ...@@ -66,7 +66,7 @@ class RegencyServiceImpl : RegencyService {
} }
} }
override fun saveData(request: Regency): ResponseEntity<*>? { override fun saveData(request: Regency): ResponseEntity<ReturnData> {
return try { return try {
validateRequest(request) validateRequest(request)
val save = Regency() val save = Regency()
...@@ -79,7 +79,7 @@ class RegencyServiceImpl : RegencyService { ...@@ -79,7 +79,7 @@ class RegencyServiceImpl : RegencyService {
} }
} }
override fun updateData(id: String, request: Regency): ResponseEntity<*>? { override fun updateData(id: String, request: Regency): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(id) val data = repo.findByIdAndActive(id)
if (data.isPresent) { if (data.isPresent) {
...@@ -96,7 +96,7 @@ class RegencyServiceImpl : RegencyService { ...@@ -96,7 +96,7 @@ class RegencyServiceImpl : RegencyService {
} }
} }
override fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? { override fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(request.id) val data = repo.findByIdAndActive(request.id)
if (data.isPresent) { if (data.isPresent) {
......
...@@ -31,7 +31,7 @@ class TagServiceImpl : TagService { ...@@ -31,7 +31,7 @@ class TagServiceImpl : TagService {
@Autowired @Autowired
private lateinit var repo: TagRepository private lateinit var repo: TagRepository
override fun getAll(page: PaginationRequest): ResponseEntity<*>? { override fun getAll(page: PaginationRequest): ResponseEntity<ReturnData> {
return try { return try {
val page: Page<Tag?>? = if (page.enablePage!! == 1) { val page: Page<Tag?>? = if (page.enablePage!! == 1) {
var direction: Sort.Direction = Sort.Direction.ASC var direction: Sort.Direction = Sort.Direction.ASC
...@@ -54,7 +54,7 @@ class TagServiceImpl : TagService { ...@@ -54,7 +54,7 @@ class TagServiceImpl : TagService {
} }
} }
override fun getDetail(id: String): ResponseEntity<*>? { override fun getDetail(id: String): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(id) val data = repo.findByIdAndActive(id)
if (data.isPresent) { if (data.isPresent) {
...@@ -66,7 +66,7 @@ class TagServiceImpl : TagService { ...@@ -66,7 +66,7 @@ class TagServiceImpl : TagService {
} }
} }
override fun saveData(request: Tag): ResponseEntity<*>? { override fun saveData(request: Tag): ResponseEntity<ReturnData> {
return try { return try {
validateRequest(request) validateRequest(request)
val save = Tag() val save = Tag()
...@@ -78,7 +78,7 @@ class TagServiceImpl : TagService { ...@@ -78,7 +78,7 @@ class TagServiceImpl : TagService {
} }
} }
override fun updateData(id: String, request: Tag): ResponseEntity<*>? { override fun updateData(id: String, request: Tag): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(id) val data = repo.findByIdAndActive(id)
if (data.isPresent) { if (data.isPresent) {
...@@ -95,7 +95,7 @@ class TagServiceImpl : TagService { ...@@ -95,7 +95,7 @@ class TagServiceImpl : TagService {
} }
} }
override fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>? { override fun deleteData(request: DeleteDataRequest, httpServletRequest: HttpServletRequest): ResponseEntity<ReturnData> {
try { try {
val data = repo.findByIdAndActive(request.id) val data = repo.findByIdAndActive(request.id)
if (data.isPresent) { if (data.isPresent) {
......
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