Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
feedback-admin
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ninh Hoang Cuong
feedback-admin
Commits
7a3cbfcc
Commit
7a3cbfcc
authored
Nov 16, 2020
by
Ninh Hoang Cuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get feedback and get feedback by id
parent
e3bc6200
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
223 additions
and
62 deletions
+223
-62
FeedBackController.java
...ava/com/feedback/demo/controllers/FeedBackController.java
+52
-0
FeedBackOptionsController.java
.../feedback/demo/controllers/FeedBackOptionsController.java
+0
-11
FeedBackSettingsController.java
...feedback/demo/controllers/FeedBackSettingsController.java
+11
-5
UserController.java
...in/java/com/feedback/demo/controllers/UserController.java
+30
-8
ChangePasswordRequest.java
...va/com/feedback/demo/dto/login/ChangePasswordRequest.java
+1
-1
LoginRequest.java
src/main/java/com/feedback/demo/dto/login/LoginRequest.java
+1
-1
LoginResponse.java
src/main/java/com/feedback/demo/dto/login/LoginResponse.java
+1
-1
SignupRequest.java
src/main/java/com/feedback/demo/dto/login/SignupRequest.java
+1
-1
FeedBackNotFoundException.java
...dback/demo/exceptionhandle/FeedBackNotFoundException.java
+9
-0
PageNotFoundException.java
.../feedback/demo/exceptionhandle/PageNotFoundException.java
+9
-0
FeedBackMapper.java
src/main/java/com/feedback/demo/mappers/FeedBackMapper.java
+38
-0
FeedBackOptionsService.java
...ava/com/feedback/demo/service/FeedBackOptionsService.java
+0
-29
FeedBackService.java
src/main/java/com/feedback/demo/service/FeedBackService.java
+63
-0
UserService.java
src/main/java/com/feedback/demo/service/UserService.java
+3
-5
application.properties
src/main/resources/application.properties
+4
-0
No files found.
src/main/java/com/feedback/demo/controllers/FeedBackController.java
0 → 100644
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
controllers
;
import
com.feedback.demo.dto.FeedBackDTO
;
import
com.feedback.demo.service.FeedBackService
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.media.ArraySchema
;
import
io.swagger.v3.oas.annotations.media.Content
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
io.swagger.v3.oas.annotations.responses.ApiResponse
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/feedback"
)
@Tag
(
name
=
"Feed Back"
)
public
class
FeedBackController
{
@Autowired
private
FeedBackService
feedBackService
;
@RequestMapping
(
value
=
{
"/show/"
,
"/show"
})
public
void
redirect
(
HttpServletResponse
response
)
throws
IOException
{
response
.
sendRedirect
(
"/feedback/show/1"
);
}
@Operation
(
description
=
"Get feed back"
,
responses
=
{
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
FeedBackDTO
.
class
))),
responseCode
=
"200"
)
})
@GetMapping
(
"/list"
)
public
ResponseEntity
<
List
<
FeedBackDTO
>>
getFeedBack
(
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"0"
)
String
pageIndex
)
{
return
ResponseEntity
.
ok
(
feedBackService
.
getFeedback
(
pageIndex
));
}
@Operation
(
description
=
"Get feed back by id"
,
responses
=
{
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
FeedBackDTO
.
class
))),
responseCode
=
"200"
)
})
@GetMapping
(
"/show/{id}"
)
public
FeedBackDTO
getFeedbackById
(
@PathVariable
(
name
=
"id"
,
required
=
false
)
String
id
)
{
return
feedBackService
.
getFeedBackById
(
id
);
}
}
src/main/java/com/feedback/demo/controllers/FeedBackOptionsController.java
deleted
100644 → 0
View file @
e3bc6200
package
com
.
feedback
.
demo
.
controllers
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@Tag
(
name
=
"Feed Back Options"
)
@RequestMapping
(
"/feedback-options"
)
public
class
FeedBackOptionsController
{
}
src/main/java/com/feedback/demo/controllers/FeedBackSettingsController.java
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
controllers
;
import
com.feedback.demo.dto.FeedBackSettingsDTO
;
import
com.feedback.demo.dto.FeedBackSettingsRequest
;
import
com.feedback.demo.entities.FeedBackSettings
;
import
com.feedback.demo.service.FeedBackSettingsService
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.media.ArraySchema
;
...
...
@@ -25,7 +23,10 @@ public class FeedBackSettingsController {
private
FeedBackSettingsService
feedBackSettingsService
;
@Operation
(
description
=
"Update FeedBack settings"
,
responses
=
{
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
FeedBackSettingsRequest
.
class
))),
responseCode
=
"200"
)
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
FeedBackSettingsRequest
.
class
))),
responseCode
=
"200"
)
})
@ApiResponses
(
value
=
{
@ApiResponse
(
responseCode
=
"200"
,
description
=
"Thành công"
),
...
...
@@ -34,11 +35,16 @@ public class FeedBackSettingsController {
@ApiResponse
(
responseCode
=
"403"
,
description
=
"Truy cập bị cấm"
),
})
@PostMapping
(
"/update"
)
public
ResponseEntity
<
FeedBackSettingsRequest
>
addFeedbackSettings
(
@Valid
@RequestBody
FeedBackSettingsRequest
fsRequest
){
public
ResponseEntity
<
FeedBackSettingsRequest
>
addFeedbackSettings
(
@Valid
@RequestBody
FeedBackSettingsRequest
fsRequest
){
return
ResponseEntity
.
ok
(
feedBackSettingsService
.
updateSettings
(
fsRequest
));
}
@Operation
(
description
=
"Get FeedBack settings"
,
responses
=
{
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
FeedBackSettings
.
class
))),
responseCode
=
"200"
)
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
FeedBackSettingsRequest
.
class
))),
responseCode
=
"200"
)
})
@GetMapping
(
"/"
)
public
ResponseEntity
<
FeedBackSettingsRequest
>
getFeedbackSettings
(){
...
...
src/main/java/com/feedback/demo/controllers/UserController.java
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
controllers
;
import
com.feedback.demo.dto.ChangePasswordRequest
;
import
com.feedback.demo.dto.LoginRequest
;
import
com.feedback.demo.dto.LoginResponse
;
import
com.feedback.demo.dto.SignupRequest
;
import
com.feedback.demo.entities.FeedBackSettings
;
import
com.feedback.demo.dto.login.ChangePasswordRequest
;
import
com.feedback.demo.dto.login.LoginRequest
;
import
com.feedback.demo.dto.login.LoginResponse
;
import
com.feedback.demo.dto.login.SignupRequest
;
import
com.feedback.demo.repositories.UserRepository
;
import
com.feedback.demo.service.JwtService
;
import
com.feedback.demo.service.UserService
;
...
...
@@ -32,8 +31,11 @@ public class UserController {
@Autowired
JwtService
jwtService
;
@Operation
(
description
=
"Update FeedBack settings"
,
responses
=
{
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
FeedBackSettings
.
class
))),
responseCode
=
"200"
)
@Operation
(
description
=
"Login"
,
responses
=
{
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
LoginRequest
.
class
))),
responseCode
=
"200"
)
})
@ApiResponses
(
value
=
{
@ApiResponse
(
responseCode
=
"200"
,
description
=
"Thành công"
),
...
...
@@ -46,17 +48,37 @@ public class UserController {
return
userService
.
getLoginResponse
(
loginRequest
.
getUsername
(),
loginRequest
.
getPassword
());
}
@Operation
(
description
=
"Change Password"
,
responses
=
{
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
ChangePasswordRequest
.
class
))),
responseCode
=
"200"
)
})
@PostMapping
(
"/auth/changepass"
)
public
LoginResponse
changePassword
(
@Valid
@RequestBody
ChangePasswordRequest
changePasswordRequest
)
{
public
LoginResponse
changePassword
(
@Valid
@RequestBody
ChangePasswordRequest
changePasswordRequest
)
{
return
userService
.
changePassword
(
changePasswordRequest
);
}
@Operation
(
description
=
"Sign up"
,
responses
=
{
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
SignupRequest
.
class
))),
responseCode
=
"200"
)
})
@PostMapping
(
"/auth/signup"
)
public
LoginResponse
signup
(
@Valid
@RequestBody
SignupRequest
signupRequest
)
throws
Exception
{
System
.
out
.
println
(
signupRequest
);
return
userService
.
signUp
(
signupRequest
);
}
@Operation
(
description
=
"Validate token"
,
responses
=
{
@ApiResponse
(
content
=
@Content
(
array
=
@ArraySchema
(
schema
=
@Schema
(
implementation
=
String
.
class
))),
responseCode
=
"200"
)
})
@GetMapping
(
"/auth/verify/{token}"
)
public
LoginResponse
checkToken
(
@PathVariable
String
token
)
throws
IOException
{
return
userService
.
checkToken
(
token
);
...
...
src/main/java/com/feedback/demo/dto/ChangePasswordRequest.java
→
src/main/java/com/feedback/demo/dto/
login/
ChangePasswordRequest.java
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
dto
;
package
com
.
feedback
.
demo
.
dto
.
login
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
...
...
src/main/java/com/feedback/demo/dto/LoginRequest.java
→
src/main/java/com/feedback/demo/dto/
login/
LoginRequest.java
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
dto
;
package
com
.
feedback
.
demo
.
dto
.
login
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
...
...
src/main/java/com/feedback/demo/dto/LoginResponse.java
→
src/main/java/com/feedback/demo/dto/
login/
LoginResponse.java
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
dto
;
package
com
.
feedback
.
demo
.
dto
.
login
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
...
...
src/main/java/com/feedback/demo/dto/SignupRequest.java
→
src/main/java/com/feedback/demo/dto/
login/
SignupRequest.java
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
dto
;
package
com
.
feedback
.
demo
.
dto
.
login
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
...
...
src/main/java/com/feedback/demo/exceptionhandle/FeedBackNotFoundException.java
0 → 100644
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
exceptionhandle
;
public
class
FeedBackNotFoundException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
1L
;
public
FeedBackNotFoundException
()
{
super
(
"Feed Back Not Found ! FeedBack id not exits !"
);
}
}
src/main/java/com/feedback/demo/exceptionhandle/PageNotFoundException.java
0 → 100644
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
exceptionhandle
;
public
class
PageNotFoundException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
1L
;
public
PageNotFoundException
()
{
super
(
"Page Not Found !"
);
}
}
src/main/java/com/feedback/demo/mappers/FeedBackMapper.java
0 → 100644
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
mappers
;
import
com.feedback.demo.dto.FeedBackDTO
;
import
com.feedback.demo.entities.FeedBack
;
public
class
FeedBackMapper
{
public
static
FeedBackDTO
toDTO
(
FeedBack
feedBack
){
return
FeedBackDTO
.
builder
()
.
id
(
feedBack
.
getId
())
.
fullName
(
feedBack
.
getFullName
())
.
appName
(
feedBack
.
getAppName
())
.
email
(
feedBack
.
getEmail
())
.
phone
(
feedBack
.
getPhone
())
.
type
(
feedBack
.
getType
())
.
content
(
feedBack
.
getContent
())
.
imageUrl
(
feedBack
.
getImageUrl
())
.
url
(
feedBack
.
getUrl
())
.
createDate
(
feedBack
.
getCreateDate
())
.
updateDate
(
feedBack
.
getUpdateDate
())
.
build
();
}
public
static
FeedBack
toEntity
(
FeedBackDTO
feedBackDTO
){
return
FeedBack
.
builder
()
.
id
(
feedBackDTO
.
getId
())
.
fullName
(
feedBackDTO
.
getFullName
())
.
appName
(
feedBackDTO
.
getAppName
())
.
email
(
feedBackDTO
.
getEmail
())
.
phone
(
feedBackDTO
.
getPhone
())
.
type
(
feedBackDTO
.
getType
())
.
content
(
feedBackDTO
.
getContent
())
.
imageUrl
(
feedBackDTO
.
getImageUrl
())
.
url
(
feedBackDTO
.
getUrl
())
.
createDate
(
feedBackDTO
.
getCreateDate
())
.
updateDate
(
feedBackDTO
.
getUpdateDate
())
.
build
();
}
}
src/main/java/com/feedback/demo/service/FeedBackOptionsService.java
deleted
100644 → 0
View file @
e3bc6200
package
com
.
feedback
.
demo
.
service
;
import
com.feedback.demo.dto.FeedBackOptionsDTO
;
import
com.feedback.demo.entities.FeedBackOptions
;
import
com.feedback.demo.entities.User
;
import
com.feedback.demo.repositories.FeedBackOptionsRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
FeedBackOptionsService
{
@Autowired
private
FeedBackOptionsRepository
feedBackOptionsRepository
;
@Autowired
private
UserService
userService
;
// public FeedBackOptionsDTO updateAllFeedbackOptions(FeedBackOptionsDTO feedBackOptionsDTO){
// User currentUser = userService.getCurrentUser();
// List<FeedBackOptions> allOptions = feedBackOptionsRepository.findAllByUser(currentUser.getId());
// if (allOptions!=null){
//
// }
// }
}
src/main/java/com/feedback/demo/service/FeedBackService.java
0 → 100644
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
service
;
import
com.feedback.demo.dto.FeedBackDTO
;
import
com.feedback.demo.entities.FeedBack
;
import
com.feedback.demo.exceptionhandle.FeedBackNotFoundException
;
import
com.feedback.demo.exceptionhandle.PageNotFoundException
;
import
com.feedback.demo.mappers.FeedBackMapper
;
import
com.feedback.demo.repositories.FeedBackRepository
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Slf4j
public
class
FeedBackService
{
@Autowired
private
FeedBackRepository
feedBackRepository
;
@Value
(
"${page.size:10}"
)
private
Integer
pageSize
;
@Value
(
"${sort.default:createDate}"
)
private
String
sortBy
;
public
List
<
FeedBackDTO
>
getFeedback
(
String
pageIndex
)
{
try
{
int
page
=
Integer
.
parseInt
(
pageIndex
);
Page
<
FeedBack
>
feedBackPage
=
feedBackRepository
.
findAll
(
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
sortBy
)));
if
(
page
>
feedBackPage
.
getTotalPages
())
{
throw
new
PageNotFoundException
();
}
return
feedBackPage
.
stream
()
.
map
(
FeedBackMapper:
:
toDTO
)
.
collect
(
Collectors
.
toList
());
}
catch
(
NumberFormatException
e
)
{
log
.
error
(
e
.
getMessage
());
throw
new
FeedBackNotFoundException
();
}
}
public
FeedBackDTO
getFeedBackById
(
String
id
)
{
try
{
Long
feedBackId
=
Long
.
parseLong
(
id
);
return
feedBackRepository
.
findById
(
feedBackId
)
.
map
(
FeedBackMapper:
:
toDTO
)
.
orElseThrow
(
FeedBackNotFoundException:
:
new
);
}
catch
(
NumberFormatException
e
)
{
log
.
error
(
e
.
getMessage
());
throw
new
FeedBackNotFoundException
();
}
}
}
src/main/java/com/feedback/demo/service/UserService.java
View file @
7a3cbfcc
package
com
.
feedback
.
demo
.
service
;
import
com.feedback.demo.config.CustomUserDetail
;
import
com.feedback.demo.dto.ChangePasswordRequest
;
import
com.feedback.demo.dto.LoginResponse
;
import
com.feedback.demo.dto.SignupRequest
;
import
com.feedback.demo.dto.
login.
ChangePasswordRequest
;
import
com.feedback.demo.dto.
login.
LoginResponse
;
import
com.feedback.demo.dto.
login.
SignupRequest
;
import
com.feedback.demo.entities.FeedBackOptions
;
import
com.feedback.demo.entities.FeedBackSettings
;
import
com.feedback.demo.entities.User
;
...
...
@@ -22,9 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.stream.Stream
;
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
...
src/main/resources/application.properties
View file @
7a3cbfcc
...
...
@@ -7,3 +7,7 @@ spring.datasource.password=123456
spring.jpa.show-sql
=
true
spring.jpa.hibernate.ddl-auto
=
update
spring.jackson.serialization.fail-on-empty-beans
=
false
#------
page.size
=
10
sort.default
=
createDate
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