mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
feat: 增加用户反馈接口
This commit is contained in:
parent
032d768f49
commit
43722df0cb
@ -3,6 +3,8 @@ package io.github.xxyopen.novel.controller.front;
|
|||||||
import io.github.xxyopen.novel.core.common.resp.RestResp;
|
import io.github.xxyopen.novel.core.common.resp.RestResp;
|
||||||
import io.github.xxyopen.novel.core.common.util.IpUtils;
|
import io.github.xxyopen.novel.core.common.util.IpUtils;
|
||||||
import io.github.xxyopen.novel.core.constant.ApiRouterConsts;
|
import io.github.xxyopen.novel.core.constant.ApiRouterConsts;
|
||||||
|
import io.github.xxyopen.novel.core.constant.SystemConfigConsts;
|
||||||
|
import io.github.xxyopen.novel.core.util.JwtUtils;
|
||||||
import io.github.xxyopen.novel.dto.req.UserLoginReqDto;
|
import io.github.xxyopen.novel.dto.req.UserLoginReqDto;
|
||||||
import io.github.xxyopen.novel.dto.req.UserRegisterReqDto;
|
import io.github.xxyopen.novel.dto.req.UserRegisterReqDto;
|
||||||
import io.github.xxyopen.novel.dto.resp.UserLoginRespDto;
|
import io.github.xxyopen.novel.dto.resp.UserLoginRespDto;
|
||||||
@ -10,10 +12,7 @@ import io.github.xxyopen.novel.service.UserService;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员模块相关 控制器
|
* 会员模块相关 控制器
|
||||||
@ -28,6 +27,8 @@ public class UserController {
|
|||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
|
private final JwtUtils jwtUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户注册接口
|
* 用户注册接口
|
||||||
*/
|
*/
|
||||||
@ -40,9 +41,17 @@ public class UserController {
|
|||||||
/**
|
/**
|
||||||
* 用户登录接口
|
* 用户登录接口
|
||||||
*/
|
*/
|
||||||
@GetMapping("login")
|
@PostMapping("login")
|
||||||
public RestResp<UserLoginRespDto> login(@Valid UserLoginReqDto dto) {
|
public RestResp<UserLoginRespDto> login(@Valid UserLoginReqDto dto) {
|
||||||
return userService.login(dto);
|
return userService.login(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户反馈
|
||||||
|
*/
|
||||||
|
@PostMapping("feedBack")
|
||||||
|
public RestResp<Void> submitFeedBack(String content,@RequestHeader("Authorization") String token) {
|
||||||
|
return userService.saveFeedBack(jwtUtils.parseToken(token, SystemConfigConsts.NOVEL_FRONT_KEY),content);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,12 @@ public interface UserService {
|
|||||||
* @return JWT + 昵称
|
* @return JWT + 昵称
|
||||||
* */
|
* */
|
||||||
RestResp<UserLoginRespDto> login(UserLoginReqDto dto);
|
RestResp<UserLoginRespDto> login(UserLoginReqDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户反馈
|
||||||
|
* @param userId 反馈用户ID
|
||||||
|
* @param content 反馈内容
|
||||||
|
* @return void
|
||||||
|
* */
|
||||||
|
RestResp<Void> saveFeedBack(Long userId, String content);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ import io.github.xxyopen.novel.core.common.resp.RestResp;
|
|||||||
import io.github.xxyopen.novel.core.constant.DatabaseConsts;
|
import io.github.xxyopen.novel.core.constant.DatabaseConsts;
|
||||||
import io.github.xxyopen.novel.core.constant.SystemConfigConsts;
|
import io.github.xxyopen.novel.core.constant.SystemConfigConsts;
|
||||||
import io.github.xxyopen.novel.core.util.JwtUtils;
|
import io.github.xxyopen.novel.core.util.JwtUtils;
|
||||||
|
import io.github.xxyopen.novel.dao.entity.UserFeedback;
|
||||||
import io.github.xxyopen.novel.dao.entity.UserInfo;
|
import io.github.xxyopen.novel.dao.entity.UserInfo;
|
||||||
|
import io.github.xxyopen.novel.dao.mapper.UserFeedbackMapper;
|
||||||
import io.github.xxyopen.novel.dao.mapper.UserInfoMapper;
|
import io.github.xxyopen.novel.dao.mapper.UserInfoMapper;
|
||||||
import io.github.xxyopen.novel.dto.req.UserLoginReqDto;
|
import io.github.xxyopen.novel.dto.req.UserLoginReqDto;
|
||||||
import io.github.xxyopen.novel.dto.req.UserRegisterReqDto;
|
import io.github.xxyopen.novel.dto.req.UserRegisterReqDto;
|
||||||
@ -36,6 +38,8 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
private final VerifyCodeManager verifyCodeManager;
|
private final VerifyCodeManager verifyCodeManager;
|
||||||
|
|
||||||
|
private final UserFeedbackMapper userFeedbackMapper;
|
||||||
|
|
||||||
private final JwtUtils jwtUtils;
|
private final JwtUtils jwtUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -95,4 +99,15 @@ public class UserServiceImpl implements UserService {
|
|||||||
.jwt(jwtUtils.generateToken(userInfo.getId(), SystemConfigConsts.NOVEL_FRONT_KEY))
|
.jwt(jwtUtils.generateToken(userInfo.getId(), SystemConfigConsts.NOVEL_FRONT_KEY))
|
||||||
.nickName(userInfo.getNickName()).build());
|
.nickName(userInfo.getNickName()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RestResp<Void> saveFeedBack(Long userId, String content) {
|
||||||
|
UserFeedback userFeedback = new UserFeedback();
|
||||||
|
userFeedback.setUserId(userId);
|
||||||
|
userFeedback.setContent(content);
|
||||||
|
userFeedback.setCreateTime(LocalDateTime.now());
|
||||||
|
userFeedback.setUpdateTime(LocalDateTime.now());
|
||||||
|
userFeedbackMapper.insert(userFeedback);
|
||||||
|
return RestResp.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user