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