Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
I
Inovasi Daerah Master
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ghitha Dinan
Inovasi Daerah Master
Commits
785624a5
Commit
785624a5
authored
Nov 18, 2021
by
Ghitha Dinan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete add check data application
parent
1856ab60
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
94 additions
and
26 deletions
+94
-26
ValidatorMessageConstant.kt
...novasi/daerah/master/constant/ValidatorMessageConstant.kt
+4
-0
ApplicationCategoryController.kt
...daerah/master/controller/ApplicationCategoryController.kt
+2
-2
ProvinceController.kt
...ng/inovasi/daerah/master/controller/ProvinceController.kt
+3
-2
RegencyController.kt
...ang/inovasi/daerah/master/controller/RegencyController.kt
+3
-2
ApplicationCategoryService.kt
...ovasi/daerah/master/service/ApplicationCategoryService.kt
+1
-1
ProvinceService.kt
...gkuriang/inovasi/daerah/master/service/ProvinceService.kt
+2
-1
RegencyService.kt
...ngkuriang/inovasi/daerah/master/service/RegencyService.kt
+2
-1
ApplicationCategoryServiceImpl.kt
...rah/master/service/impl/ApplicationCategoryServiceImpl.kt
+24
-8
ProvinceServiceImpl.kt
...inovasi/daerah/master/service/impl/ProvinceServiceImpl.kt
+27
-5
RegencyServiceImpl.kt
.../inovasi/daerah/master/service/impl/RegencyServiceImpl.kt
+26
-4
No files found.
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/constant/ValidatorMessageConstant.kt
View file @
785624a5
...
...
@@ -11,3 +11,7 @@ const val VALIDATOR_MSG_NOT_FOUND = "tidak di temukan"
const
val
VALIDATOR_MSG_DUPLICATE
=
"Data sudah ada di database"
const
val
VALIDATOR_MSG_NOT_HAVE_ACCESS
=
"tidak mempunyai hak akses"
const
val
VALIDATOR_MSG_DELETE_RELATION
=
"Data tidak dapat di hapus."
const
val
VALIDATOR_MSG_REQUEST_FAILED
=
"Gagal melakukan request data"
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/controller/ApplicationCategoryController.kt
View file @
785624a5
...
...
@@ -45,7 +45,7 @@ class ApplicationCategoryController {
}
@DeleteMapping
(
value
=
[
""
],
produces
=
[
"application/json"
])
fun
deleteData
(
@Valid
@RequestBody
request
:
DeleteDataRequest
):
ResponseEntity
<*>?
{
return
service
.
deleteData
(
request
)
fun
deleteData
(
@Valid
@RequestBody
request
:
DeleteDataRequest
,
httpServletRequest
:
HttpServletRequest
):
ResponseEntity
<*>?
{
return
service
.
deleteData
(
request
,
httpServletRequest
)
}
}
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/controller/ProvinceController.kt
View file @
785624a5
...
...
@@ -8,6 +8,7 @@ import id.co.sangkuriang.inovasi.daerah.master.service.ProvinceService
import
org.springframework.beans.factory.annotation.Autowired
import
org.springframework.http.ResponseEntity
import
org.springframework.web.bind.annotation.*
import
javax.servlet.http.HttpServletRequest
import
javax.validation.Valid
@RestController
...
...
@@ -43,7 +44,7 @@ class ProvinceController {
}
@DeleteMapping
(
value
=
[
""
],
produces
=
[
"application/json"
])
fun
deleteData
(
@Valid
@RequestBody
request
:
DeleteDataRequest
):
ResponseEntity
<*>?
{
return
service
.
deleteData
(
request
)
fun
deleteData
(
@Valid
@RequestBody
request
:
DeleteDataRequest
,
httpServletRequest
:
HttpServletRequest
):
ResponseEntity
<*>?
{
return
service
.
deleteData
(
request
,
httpServletRequest
)
}
}
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/controller/RegencyController.kt
View file @
785624a5
...
...
@@ -7,6 +7,7 @@ import id.co.sangkuriang.inovasi.daerah.master.service.RegencyService
import
org.springframework.beans.factory.annotation.Autowired
import
org.springframework.http.ResponseEntity
import
org.springframework.web.bind.annotation.*
import
javax.servlet.http.HttpServletRequest
import
javax.validation.Valid
@RestController
...
...
@@ -37,7 +38,7 @@ class RegencyController {
}
@DeleteMapping
(
value
=
[
""
],
produces
=
[
"application/json"
])
fun
deleteData
(
@Valid
@RequestBody
request
:
DeleteDataRequest
):
ResponseEntity
<*>?
{
return
service
.
deleteData
(
request
)
fun
deleteData
(
@Valid
@RequestBody
request
:
DeleteDataRequest
,
httpServletRequest
:
HttpServletRequest
):
ResponseEntity
<*>?
{
return
service
.
deleteData
(
request
,
httpServletRequest
)
}
}
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/service/ApplicationCategoryService.kt
View file @
785624a5
...
...
@@ -20,7 +20,7 @@ interface ApplicationCategoryService {
httpServletRequest
:
HttpServletRequest
):
ResponseEntity
<*>?
fun
deleteData
(
request
:
DeleteDataRequest
):
ResponseEntity
<*>?
fun
deleteData
(
request
:
DeleteDataRequest
,
httpServletRequest
:
HttpServletRequest
):
ResponseEntity
<*>?
fun
count
():
ResponseEntity
<*>?
}
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/service/ProvinceService.kt
View file @
785624a5
...
...
@@ -5,6 +5,7 @@ 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.pojo.Province
import
org.springframework.http.ResponseEntity
import
javax.servlet.http.HttpServletRequest
interface
ProvinceService
{
...
...
@@ -16,7 +17,7 @@ interface ProvinceService {
fun
updateData
(
id
:
String
,
request
:
Province
):
ResponseEntity
<*>?
fun
deleteData
(
request
:
DeleteDataRequest
):
ResponseEntity
<*>?
fun
deleteData
(
request
:
DeleteDataRequest
,
httpServletRequest
:
HttpServletRequest
):
ResponseEntity
<*>?
fun
datatable
(
req
:
Pagination2Request
):
ResponseEntity
<*>?
...
...
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/service/RegencyService.kt
View file @
785624a5
...
...
@@ -4,6 +4,7 @@ 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.pojo.Regency
import
org.springframework.http.ResponseEntity
import
javax.servlet.http.HttpServletRequest
interface
RegencyService
{
...
...
@@ -15,5 +16,5 @@ interface RegencyService {
fun
updateData
(
id
:
String
,
request
:
Regency
):
ResponseEntity
<*>?
fun
deleteData
(
request
:
DeleteDataRequest
):
ResponseEntity
<*>?
fun
deleteData
(
request
:
DeleteDataRequest
,
httpServletRequest
:
HttpServletRequest
):
ResponseEntity
<*>?
}
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/service/impl/ApplicationCategoryServiceImpl.kt
View file @
785624a5
package
id.co.sangkuriang.inovasi.daerah.master.service.impl
import
id.co.sangkuriang.inovasi.daerah.master.constant.UPLOAD_ICON_APPLICATION_CATEGORY_DIR
import
id.co.sangkuriang.inovasi.daerah.master.constant.UPLOAD_IMAGE_APPLICATION_CATEGORY_DIR
import
id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_HAS_USED
import
id.co.sangkuriang.inovasi.daerah.master.constant.*
import
id.co.sangkuriang.inovasi.daerah.master.exception.BadRequestException
import
id.co.sangkuriang.inovasi.daerah.master.helpers.responseCreated
import
id.co.sangkuriang.inovasi.daerah.master.helpers.responseNotFound
import
id.co.sangkuriang.inovasi.daerah.master.helpers.responseSuccess
import
id.co.sangkuriang.inovasi.daerah.master.helpers.*
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.PaginationRequest
import
id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import
id.co.sangkuriang.inovasi.daerah.master.pojo.ApplicationCategory
import
id.co.sangkuriang.inovasi.daerah.master.repository.ApplicationCategoryRepository
import
id.co.sangkuriang.inovasi.daerah.master.service.ApplicationCategoryService
...
...
@@ -29,6 +26,8 @@ import javax.servlet.http.HttpServletRequest
@Service
class
ApplicationCategoryServiceImpl
:
ApplicationCategoryService
{
private
val
title
=
"Kategori Aplikasi"
@Autowired
private
lateinit
var
repo
:
ApplicationCategoryRepository
...
...
@@ -122,10 +121,27 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService {
}
}
override
fun
deleteData
(
request
:
DeleteDataRequest
):
ResponseEntity
<*>?
{
override
fun
deleteData
(
request
:
DeleteDataRequest
,
httpServletRequest
:
HttpServletRequest
):
ResponseEntity
<*>?
{
try
{
val
data
=
repo
.
findByIdAndActive
(
request
.
id
)
if
(
data
.
isPresent
)
{
val
checkApplication
:
ReturnData
=
RequestHelpers
.
applicationCountByParam
(
httpServletRequest
.
getHeader
(
HEADER_STRING
),
"applicationCategoryId"
,
data
.
get
().
id
)
as
ReturnData
if
(
checkApplication
.
success
==
true
)
{
if
(
checkApplication
.
data
!=
null
)
{
val
countUserApplication
:
Long
=
(
checkApplication
.
data
as
Int
).
toLong
()
if
(
countUserApplication
>
0
)
{
return
responseBadRequest
(
"$VALIDATOR_MSG_DELETE_RELATION $title ${data.get().name} mempunyai $countUserApplication data aplikasi"
)
}
}
}
else
{
return
responseBadRequest
(
"$VALIDATOR_MSG_REQUEST_FAILED Aplikasi"
)
}
val
update
=
data
.
get
()
update
.
updatedAt
=
Date
()
update
.
active
=
false
...
...
@@ -141,7 +157,7 @@ class ApplicationCategoryServiceImpl : ApplicationCategoryService {
override
fun
count
():
ResponseEntity
<*>?
{
return
try
{
responseSuccess
(
data
=
repo
.
getCount
())
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
throw
e
}
}
...
...
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/service/impl/ProvinceServiceImpl.kt
View file @
785624a5
package
id.co.sangkuriang.inovasi.daerah.master.service.impl
import
id.co.sangkuriang.inovasi.daerah.master.constant.HEADER_STRING
import
id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_DELETE_RELATION
import
id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_HAS_USED
import
id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_REQUEST_FAILED
import
id.co.sangkuriang.inovasi.daerah.master.exception.BadRequestException
import
id.co.sangkuriang.inovasi.daerah.master.helpers.responseCreated
import
id.co.sangkuriang.inovasi.daerah.master.helpers.responseNotFound
import
id.co.sangkuriang.inovasi.daerah.master.helpers.responseSuccess
import
id.co.sangkuriang.inovasi.daerah.master.helpers.*
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.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.repository.ProvinceRepository
import
id.co.sangkuriang.inovasi.daerah.master.repository.native.ProvinceRepositoryNative
...
...
@@ -20,11 +22,14 @@ import org.springframework.data.domain.Sort
import
org.springframework.http.ResponseEntity
import
org.springframework.stereotype.Service
import
java.util.*
import
javax.servlet.http.HttpServletRequest
@Suppress
(
"NAME_SHADOWING"
)
@Service
class
ProvinceServiceImpl
:
ProvinceService
{
private
val
title
=
"Provinsi"
@Autowired
private
lateinit
var
repo
:
ProvinceRepository
...
...
@@ -77,7 +82,7 @@ class ProvinceServiceImpl : ProvinceService {
override
fun
count
():
ResponseEntity
<*>?
{
return
try
{
responseSuccess
(
data
=
repo
.
getCount
())
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
throw
e
}
}
...
...
@@ -123,10 +128,27 @@ class ProvinceServiceImpl : ProvinceService {
}
}
override
fun
deleteData
(
request
:
DeleteDataRequest
):
ResponseEntity
<*>?
{
override
fun
deleteData
(
request
:
DeleteDataRequest
,
httpServletRequest
:
HttpServletRequest
):
ResponseEntity
<*>?
{
try
{
val
data
=
repo
.
findByIdAndActive
(
request
.
id
)
if
(
data
.
isPresent
)
{
val
checkApplication
:
ReturnData
=
RequestHelpers
.
applicationCountByParam
(
httpServletRequest
.
getHeader
(
HEADER_STRING
),
"provinceId"
,
data
.
get
().
id
)
as
ReturnData
if
(
checkApplication
.
success
==
true
)
{
if
(
checkApplication
.
data
!=
null
)
{
val
countUserApplication
:
Long
=
(
checkApplication
.
data
as
Int
).
toLong
()
if
(
countUserApplication
>
0
)
{
return
responseBadRequest
(
"$VALIDATOR_MSG_DELETE_RELATION $title ${data.get().name} mempunyai $countUserApplication data aplikasi"
)
}
}
}
else
{
return
responseBadRequest
(
"$VALIDATOR_MSG_REQUEST_FAILED Aplikasi"
)
}
val
update
=
data
.
get
()
update
.
active
=
false
update
.
updatedAt
=
Date
()
...
...
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/service/impl/RegencyServiceImpl.kt
View file @
785624a5
package
id.co.sangkuriang.inovasi.daerah.master.service.impl
import
id.co.sangkuriang.inovasi.daerah.master.constant.HEADER_STRING
import
id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_DELETE_RELATION
import
id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_HAS_USED
import
id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_REQUEST_FAILED
import
id.co.sangkuriang.inovasi.daerah.master.exception.BadRequestException
import
id.co.sangkuriang.inovasi.daerah.master.helpers.responseCreated
import
id.co.sangkuriang.inovasi.daerah.master.helpers.responseNotFound
import
id.co.sangkuriang.inovasi.daerah.master.helpers.responseSuccess
import
id.co.sangkuriang.inovasi.daerah.master.helpers.*
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.response.ReturnData
import
id.co.sangkuriang.inovasi.daerah.master.pojo.Regency
import
id.co.sangkuriang.inovasi.daerah.master.repository.RegencyRepository
import
id.co.sangkuriang.inovasi.daerah.master.service.RegencyService
...
...
@@ -18,11 +20,14 @@ import org.springframework.data.domain.Sort
import
org.springframework.http.ResponseEntity
import
org.springframework.stereotype.Service
import
java.util.*
import
javax.servlet.http.HttpServletRequest
@Suppress
(
"NAME_SHADOWING"
)
@Service
class
RegencyServiceImpl
:
RegencyService
{
private
val
title
=
"Kabupaten/Kota"
@Autowired
private
lateinit
var
repo
:
RegencyRepository
...
...
@@ -91,10 +96,27 @@ class RegencyServiceImpl : RegencyService {
}
}
override
fun
deleteData
(
request
:
DeleteDataRequest
):
ResponseEntity
<*>?
{
override
fun
deleteData
(
request
:
DeleteDataRequest
,
httpServletRequest
:
HttpServletRequest
):
ResponseEntity
<*>?
{
try
{
val
data
=
repo
.
findByIdAndActive
(
request
.
id
)
if
(
data
.
isPresent
)
{
val
checkApplication
:
ReturnData
=
RequestHelpers
.
applicationCountByParam
(
httpServletRequest
.
getHeader
(
HEADER_STRING
),
"regencyId"
,
data
.
get
().
id
)
as
ReturnData
if
(
checkApplication
.
success
==
true
)
{
if
(
checkApplication
.
data
!=
null
)
{
val
countUserApplication
:
Long
=
(
checkApplication
.
data
as
Int
).
toLong
()
if
(
countUserApplication
>
0
)
{
return
responseBadRequest
(
"$VALIDATOR_MSG_DELETE_RELATION $title ${data.get().name} mempunyai $countUserApplication data aplikasi"
)
}
}
}
else
{
return
responseBadRequest
(
"$VALIDATOR_MSG_REQUEST_FAILED Aplikasi"
)
}
val
update
=
data
.
get
()
update
.
active
=
false
update
.
updatedAt
=
Date
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment