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