df9a539017
Build & Deploy to K8s / build-and-deploy (push) Successful in 4m26s
템플릿 목록 카드의 정적 📋 아이콘을 실제 view 구조 기반의 미니 와이어프레임으로 교체. 사용자가 카드만 보고도 템플릿이 어떤 화면인지(테이블 위주 / 폼 위주 / 단순 버튼 등) 파악 가능. - backend: getTemplateList SQL 에 VIEWS 컬럼 추가, list 응답 각 row 의 views jsonb 를 객체로 파싱 - frontend: TemplateThumbnail 컴포넌트 신설 — v2(BlockV2.xPct/yPct /wPct/hPct) 정규화 좌표 우선, v1(order/row) 폴백, 컴포넌트 종류별 색상(table=primary, form=cyan, button=pink) - TemplateLibraryModal 카드 아이콘 자리 교체 - dashboard.css 에 .dash-lib-card-thumb / -block 스타일 추가 (v5 토큰 준수 — solid + glow, blur 없음) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
133 lines
5.7 KiB
Java
133 lines
5.7 KiB
Java
package com.erp.service;
|
|
|
|
import com.erp.common.BaseService;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import java.util.*;
|
|
|
|
@Service
|
|
@Slf4j
|
|
public class TemplateService extends BaseService {
|
|
|
|
@Autowired
|
|
private CommonService commonService;
|
|
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
|
|
private static final String NS = "template.";
|
|
|
|
// ──────────────────────────────────────────────────
|
|
// 목록
|
|
// ──────────────────────────────────────────────────
|
|
|
|
public Map<String, Object> getTemplateList(Map<String, Object> params) {
|
|
commonService.applyPagination(params);
|
|
int totalCount = sqlSession.selectOne(NS + "getTemplateListCnt", params);
|
|
List<Map<String, Object>> list = sqlSession.selectList(NS + "getTemplateList", params);
|
|
for (Map<String, Object> row : list) {
|
|
parseJsonField(row, "views");
|
|
}
|
|
return commonService.buildListResponse(list, totalCount, params);
|
|
}
|
|
|
|
// ──────────────────────────────────────────────────
|
|
// 단건
|
|
// ──────────────────────────────────────────────────
|
|
|
|
public Map<String, Object> getTemplateInfo(Map<String, Object> params) {
|
|
Map<String, Object> row = sqlSession.selectOne(NS + "getTemplateInfo", params);
|
|
if (row == null) return null;
|
|
|
|
// JSONB 문자열 → 객체 변환
|
|
parseJsonField(row, "fields");
|
|
parseJsonField(row, "views");
|
|
parseJsonField(row, "connections");
|
|
|
|
return row;
|
|
}
|
|
|
|
// ──────────────────────────────────────────────────
|
|
// 등록
|
|
// ──────────────────────────────────────────────────
|
|
|
|
@Transactional
|
|
public Map<String, Object> insertTemplate(Map<String, Object> params) {
|
|
String templateId = "tpl_" + UUID.randomUUID().toString().replace("-", "").substring(0, 12);
|
|
params.put("template_id", templateId);
|
|
|
|
// 객체 → JSON 문자열 변환
|
|
stringifyJsonField(params, "fields");
|
|
stringifyJsonField(params, "views");
|
|
stringifyJsonField(params, "connections");
|
|
|
|
sqlSession.insert(NS + "insertTemplate", params);
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
result.put("template_id", templateId);
|
|
return result;
|
|
}
|
|
|
|
// ──────────────────────────────────────────────────
|
|
// 수정
|
|
// ──────────────────────────────────────────────────
|
|
|
|
@Transactional
|
|
public void updateTemplate(Map<String, Object> params) {
|
|
stringifyJsonField(params, "fields");
|
|
stringifyJsonField(params, "views");
|
|
stringifyJsonField(params, "connections");
|
|
|
|
sqlSession.update(NS + "updateTemplate", params);
|
|
}
|
|
|
|
// ──────────────────────────────────────────────────
|
|
// 게시
|
|
// ──────────────────────────────────────────────────
|
|
|
|
@Transactional
|
|
public void publishTemplate(Map<String, Object> params) {
|
|
sqlSession.update(NS + "publishTemplate", params);
|
|
}
|
|
|
|
// ──────────────────────────────────────────────────
|
|
// 삭제 (소프트)
|
|
// ──────────────────────────────────────────────────
|
|
|
|
@Transactional
|
|
public int deleteTemplate(Map<String, Object> params) {
|
|
return sqlSession.update(NS + "deleteTemplate", params);
|
|
}
|
|
|
|
// ──────────────────────────────────────────────────
|
|
// JSON 유틸
|
|
// ──────────────────────────────────────────────────
|
|
|
|
private void parseJsonField(Map<String, Object> row, String key) {
|
|
Object val = row.get(key);
|
|
if (val instanceof String) {
|
|
try {
|
|
row.put(key, objectMapper.readValue((String) val, Object.class));
|
|
} catch (Exception e) {
|
|
log.warn("JSON 파싱 실패: key={}, value={}", key, val, e);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void stringifyJsonField(Map<String, Object> params, String key) {
|
|
Object val = params.get(key);
|
|
if (val != null && !(val instanceof String)) {
|
|
try {
|
|
params.put(key, objectMapper.writeValueAsString(val));
|
|
} catch (Exception e) {
|
|
log.warn("JSON 직렬화 실패: key={}", key, e);
|
|
params.put(key, "[]");
|
|
}
|
|
}
|
|
}
|
|
}
|