Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
d09ff45c
Commit
d09ff45c
authored
Feb 14, 2020
by
胡学良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加意见反馈和投诉举报功能
parent
dbc0e054
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
150 additions
and
9 deletions
+150
-9
src/main/java/cn/meteor/beyondclouds/modules/feedback/api/FeedbackApi.java
+30
-7
src/main/java/cn/meteor/beyondclouds/modules/feedback/entity/Feedback.java
+1
-1
src/main/java/cn/meteor/beyondclouds/modules/feedback/enums/FeedBackErrorCode.java
+29
-0
src/main/java/cn/meteor/beyondclouds/modules/feedback/exception/FeedbackServiceException.java
+19
-0
src/main/java/cn/meteor/beyondclouds/modules/feedback/form/ComplaintForm.java
+6
-0
src/main/java/cn/meteor/beyondclouds/modules/feedback/form/FeedbackForm.java
+10
-0
src/main/java/cn/meteor/beyondclouds/modules/feedback/service/IFeedbackService.java
+14
-0
src/main/java/cn/meteor/beyondclouds/modules/feedback/service/impl/FeedbackServiceImpl.java
+40
-0
src/main/resources/application.yml
+1
-1
No files found.
src/main/java/cn/meteor/beyondclouds/modules/feedback/api/FeedbackApi.java
View file @
d09ff45c
package
cn
.
meteor
.
beyondclouds
.
modules
.
feedback
.
api
;
import
cn.meteor.beyondclouds.core.annotation.Anonymous
;
import
cn.meteor.beyondclouds.core.api.Response
;
import
cn.meteor.beyondclouds.modules.feedback.entity.Feedback
;
import
cn.meteor.beyondclouds.modules.feedback.exception.FeedbackServiceException
;
import
cn.meteor.beyondclouds.modules.feedback.form.ComplaintForm
;
import
cn.meteor.beyondclouds.modules.feedback.form.FeedbackForm
;
import
cn.meteor.beyondclouds.modules.feedback.service.IFeedbackService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
...
...
@@ -25,42 +31,59 @@ import javax.validation.Valid;
*/
@Api
(
tags
=
"反馈API"
)
@RestController
@RequestMapping
(
"/api
/
"
)
@RequestMapping
(
"/api"
)
public
class
FeedbackApi
{
private
IFeedbackService
feedbackService
;
@Autowired
public
FeedbackApi
(
IFeedbackService
feedbackService
)
{
this
.
feedbackService
=
feedbackService
;
}
/**
* 意见反馈
* @param feedbackForm
* @param bindingResult
* @return
*/
@Anonymous
@PostMapping
(
"/feedback"
)
@ApiOperation
(
"意见反馈"
)
p
rivate
Response
feedback
(
@Valid
FeedbackForm
feedbackForm
,
BindingResult
bindingResult
)
{
p
ublic
Response
feedback
(
@RequestBody
@Valid
FeedbackForm
feedbackForm
,
BindingResult
bindingResult
)
{
if
(
bindingResult
.
hasErrors
())
{
return
Response
.
fieldError
(
bindingResult
.
getFieldError
());
}
// TODO 实现反馈功能
Feedback
feedback
=
new
Feedback
();
BeanUtils
.
copyProperties
(
feedbackForm
,
feedback
);
try
{
feedbackService
.
feedback
(
feedback
,
feedbackForm
.
getVerifyCode
());
return
Response
.
success
();
}
catch
(
FeedbackServiceException
e
)
{
return
Response
.
error
(
e
);
}
}
/**
*
意见反馈
*
投诉举报
* @param complaintForm
* @param bindingResult
* @return
*/
@Anonymous
@PostMapping
(
"/complaint"
)
@ApiOperation
(
"投诉举报"
)
p
rivate
Response
feedback
(
@Valid
ComplaintForm
complaintForm
,
BindingResult
bindingResult
)
{
p
ublic
Response
complaint
(
@RequestBody
@Valid
ComplaintForm
complaintForm
,
BindingResult
bindingResult
)
{
if
(
bindingResult
.
hasErrors
())
{
return
Response
.
fieldError
(
bindingResult
.
getFieldError
());
}
// TODO 实现投诉举报功能
Feedback
complaint
=
new
Feedback
();
BeanUtils
.
copyProperties
(
complaintForm
,
complaint
);
feedbackService
.
complaint
(
complaint
);
return
Response
.
success
();
}
...
...
src/main/java/cn/meteor/beyondclouds/modules/feedback/entity/Feedback.java
View file @
d09ff45c
...
...
@@ -30,7 +30,7 @@ public class Feedback implements Serializable {
private
Integer
feedbackId
;
@ApiModelProperty
(
value
=
"反馈类型,1-反馈,2-举报"
)
private
Boolean
feedbackType
;
private
Integer
feedbackType
;
private
String
feedbackReason
;
...
...
src/main/java/cn/meteor/beyondclouds/modules/feedback/enums/FeedBackErrorCode.java
0 → 100644
View file @
d09ff45c
package
cn
.
meteor
.
beyondclouds
.
modules
.
feedback
.
enums
;
import
cn.meteor.beyondclouds.core.IErrorCode
;
/**
* @author 胡学良
* @since 2020/2/14
*/
public
enum
FeedBackErrorCode
implements
IErrorCode
{
;
private
long
code
;
private
String
msg
;
FeedBackErrorCode
(
long
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
@Override
public
long
code
()
{
return
0
;
}
@Override
public
String
msg
()
{
return
null
;
}
}
src/main/java/cn/meteor/beyondclouds/modules/feedback/exception/FeedbackServiceException.java
0 → 100644
View file @
d09ff45c
package
cn
.
meteor
.
beyondclouds
.
modules
.
feedback
.
exception
;
import
cn.meteor.beyondclouds.core.IErrorCode
;
import
cn.meteor.beyondclouds.core.exception.ServiceException
;
/**
* @author 胡学良
* @since 2020/2/14
*/
public
class
FeedbackServiceException
extends
ServiceException
{
public
FeedbackServiceException
(
long
errorCode
,
String
errorMsg
)
{
super
(
errorCode
,
errorMsg
);
}
public
FeedbackServiceException
(
IErrorCode
errorCode
)
{
super
(
errorCode
);
}
}
src/main/java/cn/meteor/beyondclouds/modules/feedback/form/ComplaintForm.java
View file @
d09ff45c
package
cn
.
meteor
.
beyondclouds
.
modules
.
feedback
.
form
;
import
cn.meteor.beyondclouds.core.constant.RegexPatterns
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.Pattern
;
/**
* 投诉举报
* @author meteor
...
...
@@ -19,6 +23,7 @@ public class ComplaintForm {
* 内容侵权
* 其它
*/
@NotEmpty
(
message
=
"举报原因不能为空"
)
private
String
feedbackReason
;
/**
...
...
@@ -29,6 +34,7 @@ public class ComplaintForm {
/**
* 要举报的链接(必填)
*/
@NotEmpty
(
message
=
"举报链接不能为空"
)
private
String
link
;
/**
...
...
src/main/java/cn/meteor/beyondclouds/modules/feedback/form/FeedbackForm.java
View file @
d09ff45c
package
cn
.
meteor
.
beyondclouds
.
modules
.
feedback
.
form
;
import
cn.meteor.beyondclouds.core.constant.RegexPatterns
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Pattern
;
/**
* 意见反馈
* @author meteor
...
...
@@ -16,11 +21,13 @@ public class FeedbackForm {
* 功能提议
* 其它
*/
@NotEmpty
(
message
=
"反馈类型不能为空"
)
private
String
feedbackReason
;
/**
* 反馈描述
*/
@NotEmpty
(
message
=
"反馈信息不能为空"
)
private
String
content
;
/**
...
...
@@ -31,11 +38,14 @@ public class FeedbackForm {
/**
* 反馈人手机号(必填,还得通过验证码验证才行)
*/
@NotEmpty
(
message
=
"手机号不能为空"
)
@Pattern
(
regexp
=
RegexPatterns
.
MOBILE
,
message
=
"手机号格式不正确"
)
private
String
mobile
;
/**
* 验证码
*/
@NotEmpty
(
message
=
"验证码不能为空"
)
private
String
verifyCode
;
}
src/main/java/cn/meteor/beyondclouds/modules/feedback/service/IFeedbackService.java
View file @
d09ff45c
package
cn
.
meteor
.
beyondclouds
.
modules
.
feedback
.
service
;
import
cn.meteor.beyondclouds.modules.feedback.entity.Feedback
;
import
cn.meteor.beyondclouds.modules.feedback.exception.FeedbackServiceException
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
...
...
@@ -13,4 +14,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public
interface
IFeedbackService
extends
IService
<
Feedback
>
{
/**
*意见反馈
* @param feedback
* @param verifyCode
* @throws FeedbackServiceException
*/
void
feedback
(
Feedback
feedback
,
String
verifyCode
)
throws
FeedbackServiceException
;
/**
* 投诉举报
* @param complaint
*/
void
complaint
(
Feedback
complaint
);
}
src/main/java/cn/meteor/beyondclouds/modules/feedback/service/impl/FeedbackServiceImpl.java
View file @
d09ff45c
package
cn
.
meteor
.
beyondclouds
.
modules
.
feedback
.
service
.
impl
;
import
cn.meteor.beyondclouds.common.helper.IRedisHelper
;
import
cn.meteor.beyondclouds.core.redis.RedisKey
;
import
cn.meteor.beyondclouds.modules.feedback.entity.Feedback
;
import
cn.meteor.beyondclouds.modules.feedback.exception.FeedbackServiceException
;
import
cn.meteor.beyondclouds.modules.feedback.mapper.FeedbackMapper
;
import
cn.meteor.beyondclouds.modules.feedback.service.IFeedbackService
;
import
cn.meteor.beyondclouds.modules.user.enums.UserErrorCode
;
import
cn.meteor.beyondclouds.modules.user.exception.UserServiceException
;
import
com.aliyuncs.utils.StringUtils
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
...
...
@@ -17,4 +24,37 @@ import org.springframework.stereotype.Service;
@Service
public
class
FeedbackServiceImpl
extends
ServiceImpl
<
FeedbackMapper
,
Feedback
>
implements
IFeedbackService
{
private
IRedisHelper
redisHelper
;
@Autowired
public
FeedbackServiceImpl
(
IRedisHelper
redisHelper
)
{
this
.
redisHelper
=
redisHelper
;
}
@Override
public
void
feedback
(
Feedback
feedback
,
String
verifyCode
)
throws
FeedbackServiceException
{
//1.检查验证码是否正确
String
realVerifyCode
=
redisHelper
.
get
(
RedisKey
.
MOBILE_VERIFY_CODE
(
feedback
.
getMobile
()));
if
(
StringUtils
.
isEmpty
(
realVerifyCode
)
||
!
realVerifyCode
.
equals
(
verifyCode
))
{
throw
new
FeedbackServiceException
(
UserErrorCode
.
REG_VERIFY_CODE_ERROR
);
}
// 删除验证码
redisHelper
.
del
(
RedisKey
.
MOBILE_VERIFY_CODE
(
feedback
.
getMobile
()));
//2.设置反馈类型,1-反馈,2-举报
feedback
.
setFeedbackType
(
1
);
//3.保存意见反馈信息
save
(
feedback
);
}
@Override
public
void
complaint
(
Feedback
complaint
)
{
//1.设置反馈类型,1-反馈,2-举报
complaint
.
setFeedbackType
(
2
);
//2.保存投诉举报信息
save
(
complaint
);
}
}
src/main/resources/application.yml
View file @
d09ff45c
...
...
@@ -4,7 +4,7 @@ spring:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
username
:
root
password
:
1
00Centa30821%mysql
password
:
1
97442
# 邮箱
mail
:
...
...
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