feat: user
This commit is contained in:
parent
f6e601c9f9
commit
ff9dad72f4
@ -2,6 +2,8 @@ package com.edufocus.edufocus.qna.controller;
|
||||
|
||||
import com.edufocus.edufocus.qna.entity.Qna;
|
||||
import com.edufocus.edufocus.qna.service.QnaService;
|
||||
import com.edufocus.edufocus.user.util.JWTUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.Response;
|
||||
@ -18,12 +20,17 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class QnaController {
|
||||
private final QnaService qnaService;
|
||||
|
||||
private final JWTUtil jwtUtil;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Qna> createQna(@RequestBody Qna qna) {
|
||||
public ResponseEntity<Qna> createQna(@RequestBody Qna qna , HttpServletRequest request) {
|
||||
|
||||
|
||||
try{
|
||||
qnaService.createQna(qna);
|
||||
String token = request.getHeader("Authorization");
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||
|
||||
qnaService.createQna(userId,qna);
|
||||
return new ResponseEntity<>(qna, HttpStatus.CREATED);
|
||||
|
||||
}catch (Exception e){
|
||||
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||
@Service
|
||||
public interface QnaService {
|
||||
|
||||
void createQna(Qna qna) throws SQLException;
|
||||
void createQna(Long id,Qna qna) throws SQLException;
|
||||
void updateQna(Long id,Qna qna) throws SQLException;
|
||||
void deleteQna(Long id) throws SQLException;
|
||||
Qna getQna(Long id) throws SQLException;
|
||||
|
@ -20,9 +20,10 @@ public class QnaServiceImpl implements QnaService{
|
||||
|
||||
|
||||
@Override
|
||||
public void createQna(Qna qna) {
|
||||
public void createQna(Long id,Qna qna) {
|
||||
|
||||
|
||||
qna.setId(id);
|
||||
qnaRepository.save(qna);
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ public class User {
|
||||
private UserRole role;
|
||||
private String refreshToken;
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user