@@ -1,7 +1,5 @@
|
|||||||
package com.sb.web.admin.controller;
|
package com.sb.web.admin.controller;
|
||||||
|
|
||||||
import com.sb.web.board.dto.BoardSettingRequest;
|
|
||||||
import com.sb.web.board.dto.BoardSettingResponse;
|
|
||||||
import com.sb.web.board.dto.TagCategoryRequest;
|
import com.sb.web.board.dto.TagCategoryRequest;
|
||||||
import com.sb.web.board.dto.TagCategoryResponse;
|
import com.sb.web.board.dto.TagCategoryResponse;
|
||||||
import com.sb.web.board.dto.TagRequest;
|
import com.sb.web.board.dto.TagRequest;
|
||||||
@@ -68,16 +66,4 @@ public class AdminTagController {
|
|||||||
tagService.deleteTag(id);
|
tagService.deleteTag(id);
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.noContent().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== 게시판 설정 (사용할 태그 카테고리) ===== */
|
|
||||||
|
|
||||||
@GetMapping("/board-setting")
|
|
||||||
public BoardSettingResponse boardSetting() {
|
|
||||||
return tagService.getBoardSetting();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/board-setting")
|
|
||||||
public BoardSettingResponse updateBoardSetting(@RequestBody BoardSettingRequest req) {
|
|
||||||
return tagService.setBoardSetting(req.getTagCategoryId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.sb.web.board.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 게시판 설정 변경 요청 — 사용할 태그 카테고리(null 이면 제한 없음).
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class BoardSettingRequest {
|
|
||||||
private Long tagCategoryId;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.sb.web.board.dto;
|
|
||||||
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 게시판 설정 응답.
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
public class BoardSettingResponse {
|
|
||||||
private Long tagCategoryId;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.sb.web.board.mapper;
|
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface BoardSettingMapper {
|
|
||||||
|
|
||||||
/** 게시판에서 사용할 태그 카테고리 ID (없으면 null) */
|
|
||||||
Long findTagCategoryId();
|
|
||||||
|
|
||||||
int updateTagCategoryId(@Param("categoryId") Long categoryId);
|
|
||||||
}
|
|
||||||
@@ -4,10 +4,8 @@ import com.sb.web.board.domain.Tag;
|
|||||||
import com.sb.web.board.domain.TagCategory;
|
import com.sb.web.board.domain.TagCategory;
|
||||||
import com.sb.web.board.dto.TagCategoryRequest;
|
import com.sb.web.board.dto.TagCategoryRequest;
|
||||||
import com.sb.web.board.dto.TagCategoryResponse;
|
import com.sb.web.board.dto.TagCategoryResponse;
|
||||||
import com.sb.web.board.dto.BoardSettingResponse;
|
|
||||||
import com.sb.web.board.dto.TagRequest;
|
import com.sb.web.board.dto.TagRequest;
|
||||||
import com.sb.web.board.dto.TagResponse;
|
import com.sb.web.board.dto.TagResponse;
|
||||||
import com.sb.web.board.mapper.BoardSettingMapper;
|
|
||||||
import com.sb.web.board.mapper.TagCategoryBoardMapper;
|
import com.sb.web.board.mapper.TagCategoryBoardMapper;
|
||||||
import com.sb.web.board.mapper.TagCategoryMapper;
|
import com.sb.web.board.mapper.TagCategoryMapper;
|
||||||
import com.sb.web.board.mapper.TagMapper;
|
import com.sb.web.board.mapper.TagMapper;
|
||||||
@@ -30,7 +28,6 @@ public class TagService {
|
|||||||
|
|
||||||
private final TagCategoryMapper categoryMapper;
|
private final TagCategoryMapper categoryMapper;
|
||||||
private final TagMapper tagMapper;
|
private final TagMapper tagMapper;
|
||||||
private final BoardSettingMapper boardSettingMapper;
|
|
||||||
private final TagCategoryBoardMapper categoryBoardMapper;
|
private final TagCategoryBoardMapper categoryBoardMapper;
|
||||||
|
|
||||||
/** 게시판 매핑에 허용되는 값 */
|
/** 게시판 매핑에 허용되는 값 */
|
||||||
@@ -50,6 +47,10 @@ public class TagService {
|
|||||||
* 매핑이 하나도 없는 그룹은 전체 게시판에서 노출(하위호환).
|
* 매핑이 하나도 없는 그룹은 전체 게시판에서 노출(하위호환).
|
||||||
*/
|
*/
|
||||||
public List<TagCategoryResponse> listWritableGroups(String boardCategory) {
|
public List<TagCategoryResponse> listWritableGroups(String boardCategory) {
|
||||||
|
// 게시판 미지정(수정 화면 등) → 전체 그룹 (기존 글 태그 유실 방지)
|
||||||
|
if (boardCategory == null || boardCategory.isBlank()) {
|
||||||
|
return listGrouped();
|
||||||
|
}
|
||||||
List<TagCategoryResponse> result = new ArrayList<>();
|
List<TagCategoryResponse> result = new ArrayList<>();
|
||||||
for (TagCategory c : categoryMapper.findAll()) {
|
for (TagCategory c : categoryMapper.findAll()) {
|
||||||
TagCategoryResponse g = toGroup(c);
|
TagCategoryResponse g = toGroup(c);
|
||||||
@@ -80,23 +81,6 @@ public class TagService {
|
|||||||
.forEach(b -> categoryBoardMapper.insert(categoryId, b));
|
.forEach(b -> categoryBoardMapper.insert(categoryId, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== 게시판 설정 ===================== */
|
|
||||||
|
|
||||||
public BoardSettingResponse getBoardSetting() {
|
|
||||||
return BoardSettingResponse.builder()
|
|
||||||
.tagCategoryId(boardSettingMapper.findTagCategoryId())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public BoardSettingResponse setBoardSetting(Long tagCategoryId) {
|
|
||||||
if (tagCategoryId != null && categoryMapper.findById(tagCategoryId) == null) {
|
|
||||||
throw new ApiException(HttpStatus.NOT_FOUND, "카테고리를 찾을 수 없습니다.");
|
|
||||||
}
|
|
||||||
boardSettingMapper.updateTagCategoryId(tagCategoryId);
|
|
||||||
return BoardSettingResponse.builder().tagCategoryId(tagCategoryId).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===================== 카테고리 ===================== */
|
/* ===================== 카테고리 ===================== */
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -71,16 +71,6 @@ CREATE TABLE IF NOT EXISTS post_tag (
|
|||||||
KEY idx_post_tag_tag (tag_id)
|
KEY idx_post_tag_tag (tag_id)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
-- 게시판 설정 (단일 행) — 게시판에서 사용할 태그 카테고리 지정
|
|
||||||
CREATE TABLE IF NOT EXISTS board_setting (
|
|
||||||
id BIGINT NOT NULL,
|
|
||||||
tag_category_id BIGINT NULL COMMENT '이 게시판에서 사용 가능한 태그 카테고리',
|
|
||||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (id)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
||||||
|
|
||||||
INSERT IGNORE INTO board_setting (id, tag_category_id) VALUES (1, NULL);
|
|
||||||
|
|
||||||
-- 게시글 인라인 이미지 (DB 저장). 본문에는 /api/images/{id} URL 만 포함(base64 미사용).
|
-- 게시글 인라인 이미지 (DB 저장). 본문에는 /api/images/{id} URL 만 포함(base64 미사용).
|
||||||
CREATE TABLE IF NOT EXISTS board_image (
|
CREATE TABLE IF NOT EXISTS board_image (
|
||||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.sb.web.board.mapper.BoardSettingMapper">
|
|
||||||
|
|
||||||
<select id="findTagCategoryId" resultType="java.lang.Long">
|
|
||||||
SELECT tag_category_id FROM board_setting WHERE id = 1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<update id="updateTagCategoryId">
|
|
||||||
UPDATE board_setting SET tag_category_id = #{categoryId} WHERE id = 1
|
|
||||||
</update>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
Reference in New Issue
Block a user