添加用户反馈
This commit is contained in:
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"enabled": true,
|
|
||||||
"name": "Java代码风格检查",
|
|
||||||
"description": "写 Java 代码前,提醒严格遵守 Java 端代码开发风格文档中的规范",
|
|
||||||
"version": "1",
|
|
||||||
"when": {
|
|
||||||
"type": "preToolUse",
|
|
||||||
"toolTypes": [
|
|
||||||
"write"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"type": "askAgent",
|
|
||||||
"prompt": "写 Java 代码前请严格遵守 back-end/.kiro/steering/代码开发风格文档.md 中的所有规范。特别注意:紧凑风格(流式语句和链式调用尽量一行)、Service 用 @Autowired 字段注入、Controller 用 @AllArgsConstructor 构造器注入、写操作加 @Transactional、Service 类注释需包含功能说明/依赖/使用表。"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.jiayunet.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.jiayunet.pojo.po.UserFeedback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户反馈Mapper
|
||||||
|
*
|
||||||
|
* @author zk
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface UserFeedbackMapper extends CommonMapper<UserFeedback> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.jiayunet.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户反馈表
|
||||||
|
*
|
||||||
|
* @author zk
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName(value = "bg_user_feedback")
|
||||||
|
public class UserFeedback {
|
||||||
|
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 用户ID */
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/** 反馈类型 1=Bug反馈 2=功能建议 3=使用体验 4=订阅及会员权益相关问题 5=其它 */
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/** 反馈内容,最多2000字 */
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/** 创建时间 */
|
||||||
|
private Instant createTime;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user