게시물 저장 사원id 임시 추가
This commit is contained in:
parent
a3ce5ade18
commit
5ad352da9b
@ -21,6 +21,8 @@ import java.sql.Blob;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -30,7 +32,9 @@ import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.github.pagehelper.PageSerializable;
|
||||
|
||||
import io.company.localhost.common.annotation.Member;
|
||||
import io.company.localhost.common.annotation.ParameterCheck;
|
||||
@ -146,23 +150,34 @@ public class BoardController {
|
||||
*/
|
||||
@Member
|
||||
@ParameterCheck
|
||||
@PostMapping
|
||||
public ApiResponse<?> createBoard(@ReqMap MapDto map) {
|
||||
// 비밀번호 암호화 (익명 게시판 등 비밀번호가 필요한 경우)
|
||||
if (map.containsKey("LOCBRDPWD")) {
|
||||
String rawPassword = map.getString("LOCBRDPWD");
|
||||
String encodedPassword = passwordEncoder.encode(rawPassword);
|
||||
map.put("LOCBRDPWD", encodedPassword);
|
||||
}
|
||||
@PostMapping
|
||||
public ApiResponse<?> createBoard(@ReqMap MapDto map) {
|
||||
// 비밀번호 암호화
|
||||
if (map.containsKey("LOCBRDPWD")) {
|
||||
String rawPassword = map.getString("LOCBRDPWD");
|
||||
String encodedPassword = passwordEncoder.encode(rawPassword);
|
||||
map.put("LOCBRDPWD", encodedPassword);
|
||||
}
|
||||
|
||||
BigInteger createdIdx = boardService.createBoard(map); // 작성된 게시물의 idx를 반환
|
||||
Map<String, Object> responseData = new HashMap<>();
|
||||
responseData.put("CMNBRDSEQ", createdIdx);
|
||||
//로그인 미개발 ->임시
|
||||
map.put("MEMBERSEQ", 1);
|
||||
responseData.put("message", "게시물이 작성되었습니다.");
|
||||
return ApiResponse.ok(responseData);
|
||||
}
|
||||
// LOCBRDCON 필드를 JSON 문자열로 변환
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
if (map.containsKey("LOCBRDCON")) {
|
||||
try {
|
||||
String jsonContent = objectMapper.writeValueAsString(map.get("LOCBRDCON"));
|
||||
map.put("LOCBRDCON", jsonContent); // JSON 문자열로 변환된 값 설정
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error serializing LOCBRDCON field", e);
|
||||
}
|
||||
}
|
||||
//로그인 미개발 ->임시
|
||||
map.put("MEMBERSEQ", 1);
|
||||
|
||||
BigInteger createdIdx = boardService.createBoard(map); // 작성된 게시물의 idx를 반환
|
||||
Map<String, Object> responseData = new HashMap<>();
|
||||
responseData.put("CMNBRDSEQ", createdIdx);
|
||||
responseData.put("message", "게시물이 작성되었습니다.");
|
||||
return ApiResponse.ok(responseData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 첨부파일 추가
|
||||
@ -173,6 +188,9 @@ public class BoardController {
|
||||
@ParameterCheck
|
||||
@PostMapping("/{CMNBRDSEQ}/attachments")
|
||||
public ApiResponse<String> uploadAttachment(@ReqMap MapDto map) {
|
||||
String filename = UUID.randomUUID().toString();
|
||||
map.put("CMNFLENAM", filename);
|
||||
map.put("CMNFLEREG", 1);
|
||||
// 파일 데이터 저장
|
||||
boardService.addAttachment(map);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user