添加用户反馈
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package org.jiayunet.controller;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.jiayunet.pojo.param.feedback.UserFeedbackParam;
|
||||
import org.jiayunet.service.UserFeedbackService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 用户反馈接口
|
||||
*
|
||||
* @author zk
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/feedback")
|
||||
@AllArgsConstructor
|
||||
public class UserFeedbackController {
|
||||
|
||||
private final UserFeedbackService userFeedbackService;
|
||||
|
||||
/**
|
||||
* 提交反馈
|
||||
*/
|
||||
@PostMapping
|
||||
public void submit(@Validated @RequestBody UserFeedbackParam param) {
|
||||
userFeedbackService.submit(param.getType(), param.getContent());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.jiayunet.pojo.param.feedback;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 用户反馈提交入参
|
||||
*
|
||||
* @author zk
|
||||
*/
|
||||
@Data
|
||||
public class UserFeedbackParam {
|
||||
|
||||
/** 反馈类型 1=Bug反馈 2=功能建议 3=使用体验 4=订阅及会员权益相关问题 5=其它 */
|
||||
@NotNull(message = "反馈类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
/** 反馈内容 */
|
||||
@NotBlank(message = "反馈内容不能为空")
|
||||
@Size(max = 2000, message = "反馈内容最多2000字")
|
||||
private String content;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.jiayunet.service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jiayunet.mapper.UserFeedbackMapper;
|
||||
import org.jiayunet.pojo.po.UserFeedback;
|
||||
import org.jiayunet.tool.UserSecurityTool;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 用户反馈服务
|
||||
* <p>主要功能:提交用户反馈</p>
|
||||
* <p>使用表:bg_user_feedback(插入反馈记录)</p>
|
||||
*
|
||||
* @author zk
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class UserFeedbackService {
|
||||
|
||||
@Autowired
|
||||
private UserFeedbackMapper userFeedbackMapper;
|
||||
|
||||
/**
|
||||
* 提交反馈
|
||||
* <p>获取当前用户ID,构建反馈记录并插入</p>
|
||||
*/
|
||||
public void submit(Integer type, String content) {
|
||||
Long userId = UserSecurityTool.getUserId();
|
||||
|
||||
UserFeedback feedback = new UserFeedback();
|
||||
feedback.setUserId(userId);
|
||||
feedback.setType(type);
|
||||
feedback.setContent(content);
|
||||
|
||||
userFeedbackMapper.insert(feedback);
|
||||
log.info("用户反馈提交成功 userId:{} type:{}", userId, type);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user