261021_01_ENH: 2차 마이그레이션 완료
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
package com.kri.kart.server.common.consts;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public final class KartConstant {
|
||||
private KartConstant() {}
|
||||
|
||||
public static final int REPORT_MEMBER_ROLE = 9001;
|
||||
public static final int EXTERNAL_URL_COPY_ROLE = 9002;
|
||||
public static final int EXTERNAL_PAGE_COPY_ROLE = 9003;
|
||||
|
||||
// CustomProgressService
|
||||
public static final String LEGACY_APPEND_PREFIX = "../report_append/";
|
||||
|
||||
// ExportService
|
||||
public static final String QUESTION_FORM_FILE_NAME = "KON 문항 등록 양식.xlsx";
|
||||
public static final List<String> EXPORT_FIXED_HEADERS =
|
||||
List.of(
|
||||
"IDKEY",
|
||||
"Status",
|
||||
"start_date",
|
||||
"end_date",
|
||||
"interval_min",
|
||||
"INTERVIEWER_INFO",
|
||||
"INTERVIEWER_CODE");
|
||||
|
||||
// ShareLinkService
|
||||
public static final String EXTERNAL_TEAM = "KART_EXTERNAL";
|
||||
public static final String EXTERNAL_USER_PREFIX = "EXTERNAL:";
|
||||
public static final String REQUEST_LINK_ATTRIBUTE =
|
||||
"com.kri.kart.server.service.ShareLinkService.link";
|
||||
public static final Set<String> REPORT_PATHS =
|
||||
Set.of("/Report/Current", "/Report/Quota", "/Report/Tabulation", "/Report/Crosstab");
|
||||
|
||||
// StatisticsService
|
||||
public static final String STANDARD_MODE = "STANDARD";
|
||||
// TABULATION requests have no single index; their rows are stored under the INDEX root.
|
||||
public static final String TABULATION_STORAGE_ROOT = "INDEX";
|
||||
public static final String ATTRIBUTE_PROJECTION_SUFFIX = "#A";
|
||||
public static final int PROFILE_QUESTION_ROLE = 1001;
|
||||
public static final List<String> PROFILE_ID_PREFIXES = List.of("PF", "PS");
|
||||
public static final String REPORT_AUDIT_EVENT = "Get Report Data";
|
||||
public static final String CALCULATION_FAILED_CODE = "REPORT_CALCULATION_FAILED";
|
||||
public static final String CALCULATION_FAILED_MESSAGE = "문항 집계 처리에 실패했습니다.";
|
||||
|
||||
// LegacyFilterService
|
||||
public static final int LEGACY_FILTER_MAX_TOKENS = 2048;
|
||||
public static final int LEGACY_FILTER_MAX_DEPTH = 32;
|
||||
public static final Map<String, String> LEGACY_FILTER_COMPARISON_OPERATORS =
|
||||
Map.of("=", "EQ", "!=", "NE", "<>", "NE", ">", "GT", ">=", "GE", "<", "LT", "<=", "LE");
|
||||
|
||||
// StatisticsAggregationService
|
||||
public static final String TOTAL_COLUMN_ID = "i";
|
||||
public static final String CASE_COUNT_LABEL = "사례수";
|
||||
// TABULATION_0 divides each banner column by the total of its sibling columns.
|
||||
public static final String SIBLING_BASE_MODE = "TABULATION_0";
|
||||
// TABULATION_1 crosses every banner column with every other banner column.
|
||||
public static final String BANNER_CROSS_MODE = "TABULATION_1";
|
||||
public static final Set<String> OPEN_QUESTION_TYPES = Set.of("num", "text");
|
||||
public static final String MEAN = "Mean";
|
||||
public static final String SUM = "Sum";
|
||||
public static final List<String> NUMERIC_STATISTICS =
|
||||
List.of("Median", "SD", "Max", "Min", "Mode");
|
||||
public static final int NPS_SCALE_SIZE = 11;
|
||||
public static final int EXCEL_DECIMALS = 14;
|
||||
|
||||
// StatisticsDimensionService
|
||||
public static final Set<String> UNSUPPORTED_QUESTION_TYPES = Set.of("com", "come");
|
||||
|
||||
// StatisticsFilterService
|
||||
public static final int STATISTICS_FILTER_MAX_DEPTH = 32;
|
||||
public static final int STATISTICS_FILTER_MAX_GROUP_CHILDREN = 128;
|
||||
public static final Set<String> FILTER_GROUP_OPERATORS = Set.of("AND", "OR", "NOT");
|
||||
public static final Set<String> FILTER_CONDITION_OPERATORS =
|
||||
Set.of(
|
||||
"EQ",
|
||||
"NE",
|
||||
"GT",
|
||||
"GE",
|
||||
"LT",
|
||||
"LE",
|
||||
"IN",
|
||||
"NOT_IN",
|
||||
"BETWEEN",
|
||||
"IS_ANSWERED",
|
||||
"IS_UNANSWERED");
|
||||
public static final Set<String> FILTER_NEGATED_OPERATORS = Set.of("NE", "NOT_IN", "IS_UNANSWERED");
|
||||
// Returned by order() when a numeric operand cannot be compared with a non-numeric answer.
|
||||
public static final int FILTER_NOT_COMPARABLE = Integer.MIN_VALUE;
|
||||
|
||||
// StatisticsStreamService
|
||||
public static final long STREAM_TIMEOUT_MILLIS = 600_000L;
|
||||
|
||||
// StatisticsTableService
|
||||
public static final String NO_HEADER_MODE = "NONE";
|
||||
public static final String FLAT_HEADER_MODE = "FLAT";
|
||||
|
||||
// StatisticsTextService
|
||||
public static final int TOP_WORD_LIMIT = 100;
|
||||
public static final String FOREIGN_WORD_TAG = "SL";
|
||||
|
||||
// StatisticsController
|
||||
public static final String CROSSTAB_PAGE = "/Report/Crosstab";
|
||||
}
|
||||
@@ -18,7 +18,9 @@ public class ExternalController {
|
||||
private final ShareLinkService shareLinkService;
|
||||
|
||||
@PostMapping("/api/v1/external/{urlKey}/login")
|
||||
@Operation(summary = "공유 링크 전용 인증 발급", description = "검증된 링크의 프로젝트·페이지 범위에 제한되는 24시간 인증")
|
||||
@Operation(
|
||||
summary = "공유 링크 전용 인증 발급",
|
||||
description = "accessToken/user/link 반환. user는 토큰과 동일한 인증 정보이며 URL Copy=9002, Page Copy=9003. 검증된 링크 범위의 24시간 인증")
|
||||
public ResponseEntity<ExternalLoginResponseDto> login(
|
||||
@PathVariable String urlKey, RequestUserContext ctx) {
|
||||
return ResponseEntity.ok()
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.log.VisitLogRequestDto;
|
||||
import com.kri.kart.server.dto.share.ShareLinkDto;
|
||||
import com.kri.kart.server.service.LogService;
|
||||
import com.kri.kart.server.service.ShareLinkService;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -30,7 +30,7 @@ public class LogController {
|
||||
@Parameter(hidden = true) RequestUserContext ctx,
|
||||
HttpServletRequest servletRequest) {
|
||||
ShareLinkDto link =
|
||||
(ShareLinkDto) servletRequest.getAttribute(ShareLinkService.REQUEST_LINK_ATTRIBUTE);
|
||||
(ShareLinkDto) servletRequest.getAttribute(KartConstant.REQUEST_LINK_ATTRIBUTE);
|
||||
if (link != null
|
||||
&& (link.getProjectType() != request.getProjectType()
|
||||
|| !link.getPkey().equals(request.getPkey()))) {
|
||||
|
||||
@@ -2,13 +2,13 @@ package com.kri.kart.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.share.ShareLinkDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsBatchDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsBatchRequestDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsStreamEventDto;
|
||||
import com.kri.kart.server.service.ShareLinkService;
|
||||
import com.kri.kart.server.service.StatisticsService;
|
||||
import com.kri.kart.server.service.statistics.StatisticsStreamService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -38,8 +38,6 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class StatisticsController {
|
||||
private static final String STANDARD_MODE = "STANDARD";
|
||||
private static final String CROSSTAB_PAGE = "/Report/Crosstab";
|
||||
|
||||
private final StatisticsService statisticsService;
|
||||
private final StatisticsStreamService statisticsStreamService;
|
||||
@@ -63,7 +61,7 @@ public class StatisticsController {
|
||||
@Parameter(hidden = true) RequestUserContext ctx,
|
||||
HttpServletRequest servletRequest,
|
||||
HttpServletResponse servletResponse) {
|
||||
if (isCrosstabPageLink(servletRequest) && !STANDARD_MODE.equals(request.getMode())) {
|
||||
if (isCrosstabPageLink(servletRequest) && !KartConstant.STANDARD_MODE.equals(request.getMode())) {
|
||||
throw BusinessException.forbidden(
|
||||
"EXTERNAL_SCOPE_DENIED", "Cross Tab 공유 링크에서는 Cross Tab 집계만 허용됩니다.");
|
||||
}
|
||||
@@ -85,9 +83,9 @@ public class StatisticsController {
|
||||
/** A page-only Cross Tab share link may request Cross Tab (STANDARD) results only. */
|
||||
private boolean isCrosstabPageLink(HttpServletRequest servletRequest) {
|
||||
ShareLinkDto link =
|
||||
(ShareLinkDto) servletRequest.getAttribute(ShareLinkService.REQUEST_LINK_ATTRIBUTE);
|
||||
(ShareLinkDto) servletRequest.getAttribute(KartConstant.REQUEST_LINK_ATTRIBUTE);
|
||||
return link != null
|
||||
&& link.isPageOnly()
|
||||
&& URI.create(link.getRealUrl()).getPath().equals(CROSSTAB_PAGE);
|
||||
&& URI.create(link.getRealUrl()).getPath().equals(KartConstant.CROSSTAB_PAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.Setter;
|
||||
@Setter
|
||||
public class DerivedDefinitionDto {
|
||||
private String qid;
|
||||
private String gkey;
|
||||
private String questionJson;
|
||||
private String derivedJson;
|
||||
private Integer qOrder;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class DerivedSaveRequestDto {
|
||||
private String variableTitle;
|
||||
|
||||
@NotNull
|
||||
@Pattern(regexp = "single|multi|num")
|
||||
@Pattern(regexp = "single|multi|scale|num")
|
||||
private String variableType;
|
||||
|
||||
@NotNull private JsonNode variableInfo;
|
||||
|
||||
@@ -9,6 +9,7 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DerivedVariableDto {
|
||||
private String variableId;
|
||||
private String qid;
|
||||
|
||||
@Getter(onMethod_ = @JsonProperty("qOrder"))
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.kri.kart.server.dto.share;
|
||||
|
||||
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class ExternalLoginResponseDto {
|
||||
String accessToken;
|
||||
JwtUserClaimsDto user;
|
||||
ShareLinkDto link;
|
||||
}
|
||||
|
||||
@@ -15,10 +15,16 @@ public class StatisticsCellDto {
|
||||
private Long count;
|
||||
private Double percent;
|
||||
|
||||
@Schema(description = "Excel용 백분율: 요청 표시 자릿수 대신 기존 기본 자릿수 14 적용, 분모 0이면 null")
|
||||
private Double percentExact;
|
||||
|
||||
@Schema(description = "해당 셀의 백분율 분모")
|
||||
private Long base;
|
||||
|
||||
private Double statisticValue;
|
||||
|
||||
@Schema(description = "Excel용 통계량: 요청 표시 자릿수 대신 기존 기본 자릿수 14 적용, 계산 불가 시 null")
|
||||
private Double statisticExact;
|
||||
private String measurement;
|
||||
private String countDisplayText;
|
||||
private String percentDisplayText;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kri.kart.server.persistence;
|
||||
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import java.util.Objects;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -20,6 +21,14 @@ public class SurveySessionProvider {
|
||||
this.konkiwiSqlSessionTemplate = konkiwiSqlSessionTemplate;
|
||||
}
|
||||
|
||||
public <T> T mapper(ProjectRefDto project, Class<T> mapperType) {
|
||||
return mapper(project.getProjectType(), mapperType);
|
||||
}
|
||||
|
||||
public <T> T mapper(ProjectType type, Class<T> mapperType) {
|
||||
return forProject(type).getMapper(mapperType);
|
||||
}
|
||||
|
||||
public SqlSessionTemplate forProject(ProjectType type) {
|
||||
return switch (Objects.requireNonNull(type, "Project type is required")) {
|
||||
case KON -> konSqlSessionTemplate;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.bookmark.BookmarkDto;
|
||||
import com.kri.kart.server.dto.bookmark.BookmarkSaveRequestDto;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface BookmarkMapper {
|
||||
List<BookmarkDto> list(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("page") String page,
|
||||
@Param("userId") String userId);
|
||||
|
||||
BookmarkDto find(@Param("pkey") String pkey, @Param("bookmarkId") String bookmarkId);
|
||||
|
||||
int create(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("bookmarkId") String bookmarkId,
|
||||
@Param("request") BookmarkSaveRequestDto request,
|
||||
@Param("userTeam") String userTeam,
|
||||
@Param("userId") String userId);
|
||||
|
||||
int update(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("bookmarkId") String bookmarkId,
|
||||
@Param("request") BookmarkSaveRequestDto request,
|
||||
@Param("userId") String userId);
|
||||
|
||||
int shiftOrderAfterDelete(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("bookmarkId") String bookmarkId,
|
||||
@Param("userId") String userId);
|
||||
|
||||
int delete(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("bookmarkId") String bookmarkId,
|
||||
@Param("userId") String userId);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.derived.DerivedDataDto;
|
||||
import com.kri.kart.server.dto.derived.DerivedDefinitionDto;
|
||||
import com.kri.kart.server.dto.question.QuestionDto;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface DerivedMapper {
|
||||
List<QuestionDto> list(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("userRole") Integer userRole,
|
||||
@Param("userTeam") String userTeam);
|
||||
|
||||
String lockProject(@Param("pkey") String pkey);
|
||||
|
||||
List<DerivedDefinitionDto> definitions(@Param("pkey") String pkey);
|
||||
|
||||
DerivedDefinitionDto find(@Param("pkey") String pkey, @Param("qid") String qid);
|
||||
|
||||
Integer duplicate(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("qid") String qid,
|
||||
@Param("originId") String originId);
|
||||
|
||||
int create(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("qid") String qid,
|
||||
@Param("questionJson") String questionJson,
|
||||
@Param("derivedJson") String derivedJson,
|
||||
@Param("userTeam") String userTeam,
|
||||
@Param("userId") String userId);
|
||||
|
||||
int update(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("qid") String qid,
|
||||
@Param("questionJson") String questionJson,
|
||||
@Param("derivedJson") String derivedJson,
|
||||
@Param("originId") String originId,
|
||||
@Param("userTeam") String userTeam,
|
||||
@Param("userId") String userId);
|
||||
|
||||
int shiftOrder(@Param("pkey") String pkey, @Param("qid") String qid);
|
||||
|
||||
int delete(@Param("pkey") String pkey, @Param("qid") String qid);
|
||||
|
||||
int clearData(@Param("pkey") String pkey, @Param("jsonPath") String jsonPath);
|
||||
|
||||
List<DerivedDataDto> responses(@Param("pkey") String pkey);
|
||||
|
||||
int saveData(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("jsonPath") String jsonPath,
|
||||
@Param("idkey") String idkey,
|
||||
@Param("groupJson") String groupJson);
|
||||
|
||||
int ensureRespondent(@Param("pkey") String pkey, @Param("idkey") String idkey);
|
||||
|
||||
int clearRespondentData(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("jsonPath") String jsonPath,
|
||||
@Param("idkey") String idkey);
|
||||
|
||||
List<DerivedDataDto> respondentResponses(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("idkey") String idkey);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.export.ExportDataDto;
|
||||
import com.kri.kart.server.dto.export.ExportDerivedHeaderDto;
|
||||
import com.kri.kart.server.dto.export.ExportHeaderDto;
|
||||
import com.kri.kart.server.dto.export.ExportTitleDto;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ExportMapper {
|
||||
String additionalColumns(@Param("pkey") String pkey);
|
||||
|
||||
List<ExportDerivedHeaderDto> derivedHeaders(@Param("pkey") String pkey);
|
||||
|
||||
List<ExportHeaderDto> questionHeaders(@Param("pkey") String pkey);
|
||||
|
||||
List<ExportTitleDto> titles(@Param("pkey") String pkey);
|
||||
|
||||
String surveyType(@Param("pkey") String pkey);
|
||||
|
||||
List<ExportDataDto> data(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("type") String type,
|
||||
@Param("startDate") LocalDate startDate,
|
||||
@Param("endDate") LocalDate endDate,
|
||||
@Param("includeInterviewer") Boolean includeInterviewer);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.upload.ImportQuestionDto;
|
||||
import com.kri.kart.server.dto.upload.ImportResponseDto;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ImportMapper {
|
||||
String lockProject(@Param("pkey") String pkey);
|
||||
|
||||
int resetTitles(@Param("pkey") String pkey);
|
||||
|
||||
int title(@Param("pkey") String pkey, @Param("qid") String qid, @Param("explain") String explain);
|
||||
|
||||
int deleteQuestions(@Param("pkey") String pkey);
|
||||
|
||||
int deleteOptions(@Param("pkey") String pkey);
|
||||
|
||||
int deleteQuotaSets(@Param("pkey") String pkey);
|
||||
|
||||
int deleteQuotas(@Param("pkey") String pkey);
|
||||
|
||||
int resetStructure(@Param("pkey") String pkey);
|
||||
|
||||
int question(@Param("pkey") String pkey, @Param("question") ImportQuestionDto question);
|
||||
|
||||
int structure(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("question") ImportQuestionDto question,
|
||||
@Param("jsonPath") String jsonPath);
|
||||
|
||||
int deleteUploaded(@Param("pkey") String pkey);
|
||||
|
||||
int archiveCompleted(@Param("pkey") String pkey);
|
||||
|
||||
int response(@Param("pkey") String pkey, @Param("response") ImportResponseDto response);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface LogMapper {
|
||||
int loginLog(@Param("userId") String userId, @Param("clientIp") String clientIp);
|
||||
|
||||
int visitLog(
|
||||
@Param("userId") String userId,
|
||||
@Param("pkey") String pkey,
|
||||
@Param("pageInfo") String pageInfo,
|
||||
@Param("clientIp") String clientIp);
|
||||
|
||||
int siteLog(
|
||||
@Param("userId") String userId,
|
||||
@Param("pageInfo") String pageInfo,
|
||||
@Param("clientIp") String clientIp);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.statistics.NlpDictionaryWordDto;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface NlpMapper {
|
||||
List<String> tags(@Param("pkey") String pkey, @Param("qid") String qid);
|
||||
|
||||
List<NlpDictionaryWordDto> words(@Param("pkey") String pkey, @Param("qid") String qid);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.project.CustomProgressDto;
|
||||
import com.kri.kart.server.dto.project.LoiDto;
|
||||
import com.kri.kart.server.dto.project.ProgressDayDto;
|
||||
import com.kri.kart.server.dto.project.ProgressScreenDto;
|
||||
import com.kri.kart.server.dto.project.ProgressTypeDto;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ProgressMapper {
|
||||
List<ProgressDayDto> daily(@Param("pkey") String pkey);
|
||||
|
||||
List<ProgressTypeDto> type(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("startDate") LocalDate startDate,
|
||||
@Param("endDate") LocalDate endDate);
|
||||
|
||||
List<LoiDto> loi(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("startDate") LocalDate startDate,
|
||||
@Param("endDate") LocalDate endDate);
|
||||
|
||||
List<ProgressScreenDto> screen(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("startDate") LocalDate startDate,
|
||||
@Param("endDate") LocalDate endDate);
|
||||
|
||||
List<CustomProgressDto> reportUrls(@Param("pkey") String pkey);
|
||||
|
||||
List<CustomProgressDto> appendFiles(@Param("pkey") String pkey);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.project.ProjectListDto;
|
||||
import com.kri.kart.server.dto.project.ProjectSummaryDto;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ProjectMapper {
|
||||
List<ProjectListDto> list(
|
||||
@Param("userRole") Integer userRole,
|
||||
@Param("authenticatedUserTeam") String authenticatedUserTeam,
|
||||
@Param("assignedPkeys") List<String> assignedPkeys,
|
||||
@Param("projectType") Integer projectType,
|
||||
@Param("excludedOwnerIds") List<String> excludedOwnerIds,
|
||||
@Param("mustViewPkeys") List<String> mustViewPkeys);
|
||||
|
||||
List<ProjectSummaryDto> summary(
|
||||
@Param("userRole") Integer userRole,
|
||||
@Param("authenticatedUserTeam") String authenticatedUserTeam,
|
||||
@Param("assignedPkeys") List<String> assignedPkeys,
|
||||
@Param("excludedOwnerIds") List<String> excludedOwnerIds);
|
||||
|
||||
List<String> mustViewPkeys(@Param("projectType") Integer projectType);
|
||||
|
||||
List<String> assignedPkeys(@Param("userId") String userId);
|
||||
|
||||
List<ProjectListDto> linkedList(
|
||||
@Param("userRole") Integer userRole,
|
||||
@Param("authenticatedUserTeam") String authenticatedUserTeam,
|
||||
@Param("assignedPkeys") List<String> assignedPkeys,
|
||||
@Param("intranetCode") String intranetCode,
|
||||
@Param("userTeam") String userTeam,
|
||||
@Param("keyword") String keyword);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.question.QuestionDto;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface QuestionMapper {
|
||||
List<QuestionDto> list(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("includeProfiles") Boolean includeProfiles);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.quota.QuotaEntryDto;
|
||||
import com.kri.kart.server.dto.quota.QuotaSetDto;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface QuotaMapper {
|
||||
List<QuotaSetDto> quotaSets(@Param("pkey") String pkey);
|
||||
|
||||
QuotaSetDto quotaSet(@Param("pkey") String pkey, @Param("quotaOrder") Integer quotaOrder);
|
||||
|
||||
List<QuotaEntryDto> quotaEntries(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("quotaOrder") Integer quotaOrder);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.share.ShareLinkRecordDto;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ShareLinkMapper {
|
||||
ShareLinkRecordDto find(@Param("urlKey") String urlKey);
|
||||
|
||||
ShareLinkRecordDto reusable(ShareLinkRecordDto link);
|
||||
|
||||
Integer keyExists(@Param("urlKey") String urlKey);
|
||||
|
||||
int create(ShareLinkRecordDto link);
|
||||
|
||||
int incrementLanding(@Param("id") Long id, @Param("urlKey") String urlKey);
|
||||
|
||||
String projectTitle(@Param("pkey") String pkey);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.statistics.StatisticsDataDto;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface StatisticsMapper {
|
||||
List<StatisticsDataDto> data(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("dataScope") String dataScope,
|
||||
@Param("startDate") LocalDate startDate,
|
||||
@Param("endDate") LocalDate endDate,
|
||||
@Param("includeProfiles") Boolean includeProfiles,
|
||||
@Param("selectedRoots") List<String> selectedRoots,
|
||||
@Param("hasFilter") Boolean hasFilter);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.kri.kart.server.persistence.mapper;
|
||||
|
||||
import com.kri.kart.server.dto.auth.LoginRequestDto;
|
||||
import com.kri.kart.server.dto.auth.ReportMemberDto;
|
||||
import java.util.List;
|
||||
|
||||
public interface UserMapper {
|
||||
List<ReportMemberDto> findMember(LoginRequestDto request);
|
||||
}
|
||||
@@ -3,9 +3,8 @@ package com.kri.kart.server.persistence.repository;
|
||||
import com.kri.kart.server.dto.bookmark.BookmarkDto;
|
||||
import com.kri.kart.server.dto.bookmark.BookmarkSaveRequestDto;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import java.util.HashMap;
|
||||
import com.kri.kart.server.persistence.mapper.BookmarkMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -22,15 +21,13 @@ public class BookmarkRepository {
|
||||
}
|
||||
|
||||
public List<BookmarkDto> list(ProjectRefDto project, String page, String userId) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("pkey", project.getPkey());
|
||||
params.put("page", page);
|
||||
params.put("userId", userId);
|
||||
return kartSqlSessionTemplate.selectList("kart.Bookmark.list", params);
|
||||
return kartSqlSessionTemplate.getMapper(BookmarkMapper.class)
|
||||
.list(project.getPkey(), page, userId);
|
||||
}
|
||||
|
||||
public BookmarkDto find(ProjectRefDto project, String bookmarkId) {
|
||||
return kartSqlSessionTemplate.selectOne("kart.Bookmark.find", keys(project, bookmarkId));
|
||||
return kartSqlSessionTemplate.getMapper(BookmarkMapper.class)
|
||||
.find(project.getPkey(), bookmarkId);
|
||||
}
|
||||
|
||||
public int create(
|
||||
@@ -39,32 +36,23 @@ public class BookmarkRepository {
|
||||
BookmarkSaveRequestDto request,
|
||||
String userTeam,
|
||||
String userId) {
|
||||
Map<String, Object> params = keys(project, bookmarkId);
|
||||
params.put("request", request);
|
||||
params.put("userTeam", userTeam);
|
||||
params.put("userId", userId);
|
||||
return kartSqlSessionTemplate.insert("kart.Bookmark.create", params);
|
||||
return kartSqlSessionTemplate.getMapper(BookmarkMapper.class)
|
||||
.create(project.getPkey(), bookmarkId, request, userTeam, userId);
|
||||
}
|
||||
|
||||
public int update(ProjectRefDto project, String bookmarkId, BookmarkSaveRequestDto request) {
|
||||
Map<String, Object> params = keys(project, bookmarkId);
|
||||
params.put("request", request);
|
||||
return kartSqlSessionTemplate.update("kart.Bookmark.update", params);
|
||||
public int update(
|
||||
ProjectRefDto project, String bookmarkId, BookmarkSaveRequestDto request, String userId) {
|
||||
return kartSqlSessionTemplate.getMapper(BookmarkMapper.class)
|
||||
.update(project.getPkey(), bookmarkId, request, userId);
|
||||
}
|
||||
|
||||
public int shiftOrderAfterDelete(ProjectRefDto project, String bookmarkId) {
|
||||
return kartSqlSessionTemplate.update(
|
||||
"kart.Bookmark.shiftOrderAfterDelete", keys(project, bookmarkId));
|
||||
public int shiftOrderAfterDelete(ProjectRefDto project, String bookmarkId, String userId) {
|
||||
return kartSqlSessionTemplate.getMapper(BookmarkMapper.class)
|
||||
.shiftOrderAfterDelete(project.getPkey(), bookmarkId, userId);
|
||||
}
|
||||
|
||||
public int delete(ProjectRefDto project, String bookmarkId) {
|
||||
return kartSqlSessionTemplate.delete("kart.Bookmark.delete", keys(project, bookmarkId));
|
||||
}
|
||||
|
||||
private Map<String, Object> keys(ProjectRefDto project, String bookmarkId) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("pkey", project.getPkey());
|
||||
params.put("bookmarkId", bookmarkId);
|
||||
return params;
|
||||
public int delete(ProjectRefDto project, String bookmarkId, String userId) {
|
||||
return kartSqlSessionTemplate.getMapper(BookmarkMapper.class)
|
||||
.delete(project.getPkey(), bookmarkId, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,8 @@ import com.kri.kart.server.dto.derived.DerivedDefinitionDto;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.question.QuestionDto;
|
||||
import com.kri.kart.server.persistence.SurveySessionProvider;
|
||||
import java.util.HashMap;
|
||||
import com.kri.kart.server.persistence.mapper.DerivedMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -19,39 +18,28 @@ public class DerivedRepository {
|
||||
private final SurveySessionProvider surveySessionProvider;
|
||||
|
||||
public List<QuestionDto> list(ProjectRefDto project, Integer userRole, String userTeam) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("pkey", project.getPkey());
|
||||
params.put("userRole", userRole);
|
||||
params.put("userTeam", userTeam);
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Derived.list", params);
|
||||
return surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.list(project.getPkey(), userRole, userTeam);
|
||||
}
|
||||
|
||||
public String lockProject(ProjectRefDto project) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectOne("kart.Derived.lockProject", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.lockProject(project.getPkey());
|
||||
}
|
||||
|
||||
public List<DerivedDefinitionDto> definitions(ProjectRefDto project) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Derived.definitions", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.definitions(project.getPkey());
|
||||
}
|
||||
|
||||
public DerivedDefinitionDto find(ProjectRefDto project, String qid) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectOne("kart.Derived.find", keys(project, qid));
|
||||
return surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.find(project.getPkey(), qid);
|
||||
}
|
||||
|
||||
public boolean duplicate(ProjectRefDto project, String qid, String originId) {
|
||||
var params = keys(project, qid);
|
||||
params.put("originId", originId == null ? "" : originId);
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.<Integer>selectOne("kart.Derived.duplicate", params)
|
||||
return surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.duplicate(project.getPkey(), qid, originId == null ? "" : originId)
|
||||
> 0;
|
||||
}
|
||||
|
||||
@@ -61,77 +49,62 @@ public class DerivedRepository {
|
||||
String originId,
|
||||
String userTeam,
|
||||
String userId) {
|
||||
var params = keys(project, definition.getQid());
|
||||
params.put("questionJson", definition.getQuestionJson());
|
||||
params.put("derivedJson", definition.getDerivedJson());
|
||||
params.put("originId", originId);
|
||||
params.put("userTeam", userTeam);
|
||||
params.put("userId", userId);
|
||||
var session = surveySessionProvider.forProject(project.getProjectType());
|
||||
var derivedMapper = surveySessionProvider.mapper(project, DerivedMapper.class);
|
||||
return originId == null
|
||||
? session.insert("kart.Derived.create", params)
|
||||
: session.update("kart.Derived.update", params);
|
||||
? derivedMapper.create(
|
||||
project.getPkey(),
|
||||
definition.getQid(),
|
||||
definition.getQuestionJson(),
|
||||
definition.getDerivedJson(),
|
||||
userTeam,
|
||||
userId)
|
||||
: derivedMapper.update(
|
||||
project.getPkey(),
|
||||
definition.getQid(),
|
||||
definition.getQuestionJson(),
|
||||
definition.getDerivedJson(),
|
||||
originId,
|
||||
userTeam,
|
||||
userId);
|
||||
}
|
||||
|
||||
public void shiftOrder(ProjectRefDto project, String qid) {
|
||||
surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.update("kart.Derived.shiftOrder", keys(project, qid));
|
||||
surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.shiftOrder(project.getPkey(), qid);
|
||||
}
|
||||
|
||||
public int delete(ProjectRefDto project, String qid) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.delete("kart.Derived.delete", keys(project, qid));
|
||||
return surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.delete(project.getPkey(), qid);
|
||||
}
|
||||
|
||||
public void clearData(ProjectRefDto project, String qid) {
|
||||
surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.update("kart.Derived.clearData", keys(project, qid));
|
||||
surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.clearData(project.getPkey(), "$.\"" + qid + "\"");
|
||||
}
|
||||
|
||||
public List<DerivedDataDto> responses(ProjectRefDto project) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Derived.responses", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.responses(project.getPkey());
|
||||
}
|
||||
|
||||
public void ensureRespondent(ProjectRefDto project, String idkey) {
|
||||
surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.update("kart.Derived.ensureRespondent", Map.of("pkey", project.getPkey(), "idkey", idkey));
|
||||
surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.ensureRespondent(project.getPkey(), idkey);
|
||||
}
|
||||
|
||||
public void clearRespondentData(ProjectRefDto project, String qid, String idkey) {
|
||||
var params = keys(project, qid);
|
||||
params.put("idkey", idkey);
|
||||
surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.update("kart.Derived.clearRespondentData", params);
|
||||
surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.clearRespondentData(project.getPkey(), "$.\"" + qid + "\"", idkey);
|
||||
}
|
||||
|
||||
public List<DerivedDataDto> respondentResponses(ProjectRefDto project, String idkey) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList(
|
||||
"kart.Derived.respondentResponses", Map.of("pkey", project.getPkey(), "idkey", idkey));
|
||||
return surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.respondentResponses(project.getPkey(), idkey);
|
||||
}
|
||||
|
||||
public void saveData(ProjectRefDto project, String qid, String idkey, String groupJson) {
|
||||
var params = keys(project, qid);
|
||||
params.put("idkey", idkey);
|
||||
params.put("groupJson", groupJson);
|
||||
surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.update("kart.Derived.saveData", params);
|
||||
}
|
||||
|
||||
private Map<String, Object> keys(ProjectRefDto project, String qid) {
|
||||
var params = new HashMap<String, Object>();
|
||||
params.put("pkey", project.getPkey());
|
||||
params.put("qid", qid);
|
||||
params.put("jsonPath", "$.\"" + qid + "\"");
|
||||
return params;
|
||||
surveySessionProvider.mapper(project, DerivedMapper.class)
|
||||
.saveData(project.getPkey(), "$.\"" + qid + "\"", idkey, groupJson);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,9 @@ import com.kri.kart.server.dto.export.ExportTitleDto;
|
||||
import com.kri.kart.server.dto.export.RawDataExportRequestDto;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.persistence.SurveySessionProvider;
|
||||
import java.util.HashMap;
|
||||
import com.kri.kart.server.persistence.mapper.ExportMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -22,41 +20,36 @@ public class ExportRepository {
|
||||
private final SurveySessionProvider surveySessionProvider;
|
||||
|
||||
public String additionalColumns(ProjectRefDto project) {
|
||||
return session(project)
|
||||
.selectOne("kart.Export.additionalColumns", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, ExportMapper.class)
|
||||
.additionalColumns(project.getPkey());
|
||||
}
|
||||
|
||||
public List<ExportDerivedHeaderDto> derivedHeaders(ProjectRefDto project) {
|
||||
return session(project)
|
||||
.selectList("kart.Export.derivedHeaders", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, ExportMapper.class)
|
||||
.derivedHeaders(project.getPkey());
|
||||
}
|
||||
|
||||
public List<ExportHeaderDto> questionHeaders(ProjectRefDto project) {
|
||||
return session(project)
|
||||
.selectList("kart.Export.questionHeaders", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, ExportMapper.class)
|
||||
.questionHeaders(project.getPkey());
|
||||
}
|
||||
|
||||
public List<ExportTitleDto> titles(ProjectRefDto project) {
|
||||
return session(project).selectList("kart.Export.titles", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, ExportMapper.class).titles(project.getPkey());
|
||||
}
|
||||
|
||||
public String surveyType(ProjectRefDto project) {
|
||||
return session(project).selectOne("kart.Export.surveyType", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, ExportMapper.class).surveyType(project.getPkey());
|
||||
}
|
||||
|
||||
public List<ExportDataDto> data(
|
||||
ProjectRefDto project, RawDataExportRequestDto request, boolean includeInterviewer) {
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("pkey", project.getPkey());
|
||||
parameters.put("type", request.getType());
|
||||
parameters.put("startDate", request.getStartDate());
|
||||
parameters.put(
|
||||
"endDate", request.getEndDate() == null ? request.getStartDate() : request.getEndDate());
|
||||
parameters.put("includeInterviewer", includeInterviewer);
|
||||
return session(project).selectList("kart.Export.data", parameters);
|
||||
}
|
||||
|
||||
private SqlSessionTemplate session(ProjectRefDto project) {
|
||||
return surveySessionProvider.forProject(project.getProjectType());
|
||||
return surveySessionProvider.mapper(project, ExportMapper.class)
|
||||
.data(
|
||||
project.getPkey(),
|
||||
request.getType(),
|
||||
request.getStartDate(),
|
||||
request.getEndDate() == null ? request.getStartDate() : request.getEndDate(),
|
||||
includeInterviewer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.upload.ImportQuestionDto;
|
||||
import com.kri.kart.server.dto.upload.ImportResponseDto;
|
||||
import com.kri.kart.server.persistence.SurveySessionProvider;
|
||||
import java.util.Map;
|
||||
import com.kri.kart.server.persistence.mapper.ImportMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -17,43 +16,65 @@ public class ImportRepository {
|
||||
private final SurveySessionProvider surveySessionProvider;
|
||||
|
||||
public String lockProject(ProjectRefDto project) {
|
||||
return session(project).selectOne("kart.Import.lockProject", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class).lockProject(project.getPkey());
|
||||
}
|
||||
|
||||
public int command(ProjectRefDto project, String statement) {
|
||||
return session(project).update("kart.Import." + statement, Map.of("pkey", project.getPkey()));
|
||||
public int resetTitles(ProjectRefDto project) {
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class).resetTitles(project.getPkey());
|
||||
}
|
||||
|
||||
public int deleteQuestions(ProjectRefDto project) {
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.deleteQuestions(project.getPkey());
|
||||
}
|
||||
|
||||
public int deleteOptions(ProjectRefDto project) {
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.deleteOptions(project.getPkey());
|
||||
}
|
||||
|
||||
public int deleteQuotaSets(ProjectRefDto project) {
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.deleteQuotaSets(project.getPkey());
|
||||
}
|
||||
|
||||
public int deleteQuotas(ProjectRefDto project) {
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.deleteQuotas(project.getPkey());
|
||||
}
|
||||
|
||||
public int resetStructure(ProjectRefDto project) {
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.resetStructure(project.getPkey());
|
||||
}
|
||||
|
||||
public int deleteUploaded(ProjectRefDto project) {
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.deleteUploaded(project.getPkey());
|
||||
}
|
||||
|
||||
public int archiveCompleted(ProjectRefDto project) {
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.archiveCompleted(project.getPkey());
|
||||
}
|
||||
|
||||
public int title(ProjectRefDto project, String qid, String explain) {
|
||||
return session(project)
|
||||
.update(
|
||||
"kart.Import.title", Map.of("pkey", project.getPkey(), "qid", qid, "explain", explain));
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.title(project.getPkey(), qid, explain);
|
||||
}
|
||||
|
||||
public int question(ProjectRefDto project, ImportQuestionDto question) {
|
||||
return session(project)
|
||||
.insert("kart.Import.question", Map.of("pkey", project.getPkey(), "question", question));
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.question(project.getPkey(), question);
|
||||
}
|
||||
|
||||
public int structure(ProjectRefDto project, ImportQuestionDto question) {
|
||||
return session(project)
|
||||
.update(
|
||||
"kart.Import.structure",
|
||||
Map.of(
|
||||
"pkey",
|
||||
project.getPkey(),
|
||||
"question",
|
||||
question,
|
||||
"jsonPath",
|
||||
"$." + question.getQid()));
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.structure(project.getPkey(), question, "$." + question.getQid());
|
||||
}
|
||||
|
||||
public int response(ProjectRefDto project, ImportResponseDto response) {
|
||||
return session(project)
|
||||
.insert("kart.Import.response", Map.of("pkey", project.getPkey(), "response", response));
|
||||
}
|
||||
|
||||
private SqlSessionTemplate session(ProjectRefDto project) {
|
||||
return surveySessionProvider.forProject(project.getProjectType());
|
||||
return surveySessionProvider.mapper(project, ImportMapper.class)
|
||||
.response(project.getPkey(), response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.kri.kart.server.persistence.repository;
|
||||
|
||||
import java.util.Map;
|
||||
import com.kri.kart.server.persistence.mapper.LogMapper;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -20,33 +20,21 @@ public class LogRepository {
|
||||
|
||||
@Transactional(transactionManager = "kartTransactionManager")
|
||||
public void writeLoginLog(String userId, String clientIp) {
|
||||
kartSqlSessionTemplate.insert(
|
||||
"kart.Log.loginLog",
|
||||
Map.of("userId", userId, "clientIp", clientIp == null ? "" : clientIp));
|
||||
kartSqlSessionTemplate.getMapper(LogMapper.class)
|
||||
.loginLog(userId, clientIp == null ? "" : clientIp);
|
||||
}
|
||||
|
||||
@Transactional(transactionManager = "kartTransactionManager")
|
||||
public void writeVisitLog(String userId, String pkey, String pageInfo, String clientIp) {
|
||||
kartSqlSessionTemplate.insert(
|
||||
"kart.Log.visitLog",
|
||||
Map.of(
|
||||
"userId",
|
||||
userId,
|
||||
"pkey",
|
||||
pkey,
|
||||
"pageInfo",
|
||||
pageInfo,
|
||||
"clientIp",
|
||||
clientIp == null ? "" : clientIp));
|
||||
kartSqlSessionTemplate.getMapper(LogMapper.class)
|
||||
.visitLog(userId, pkey, pageInfo, clientIp == null ? "" : clientIp);
|
||||
}
|
||||
|
||||
@Transactional(
|
||||
transactionManager = "kartTransactionManager",
|
||||
propagation = Propagation.REQUIRES_NEW)
|
||||
public void writeSiteLog(String userId, String pageInfo, String clientIp) {
|
||||
kartSqlSessionTemplate.insert(
|
||||
"kart.Log.siteLog",
|
||||
Map.of(
|
||||
"userId", userId, "pageInfo", pageInfo, "clientIp", clientIp == null ? "" : clientIp));
|
||||
kartSqlSessionTemplate.getMapper(LogMapper.class)
|
||||
.siteLog(userId, pageInfo, clientIp == null ? "" : clientIp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.kri.kart.server.persistence.repository;
|
||||
|
||||
import com.kri.kart.server.dto.statistics.NlpDictionaryWordDto;
|
||||
import com.kri.kart.server.persistence.mapper.NlpMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -19,10 +19,10 @@ public class NlpRepository {
|
||||
}
|
||||
|
||||
public List<String> tags(String pkey, String qid) {
|
||||
return kartSqlSessionTemplate.selectList("kart.Nlp.tags", Map.of("pkey", pkey, "qid", qid));
|
||||
return kartSqlSessionTemplate.getMapper(NlpMapper.class).tags(pkey, qid);
|
||||
}
|
||||
|
||||
public List<NlpDictionaryWordDto> words(String pkey, String qid) {
|
||||
return kartSqlSessionTemplate.selectList("kart.Nlp.words", Map.of("pkey", pkey, "qid", qid));
|
||||
return kartSqlSessionTemplate.getMapper(NlpMapper.class).words(pkey, qid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ import com.kri.kart.server.dto.project.ProgressSearchDto;
|
||||
import com.kri.kart.server.dto.project.ProgressTypeDto;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.persistence.SurveySessionProvider;
|
||||
import java.util.HashMap;
|
||||
import com.kri.kart.server.persistence.mapper.ProgressMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -22,46 +21,32 @@ public class ProgressRepository {
|
||||
private final SurveySessionProvider surveySessionProvider;
|
||||
|
||||
public List<ProgressDayDto> daily(ProjectRefDto project) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Progress.daily", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, ProgressMapper.class)
|
||||
.daily(project.getPkey());
|
||||
}
|
||||
|
||||
public List<ProgressTypeDto> type(ProjectRefDto project, ProgressSearchDto search) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Progress.type", params(project, search));
|
||||
return surveySessionProvider.mapper(project, ProgressMapper.class)
|
||||
.type(project.getPkey(), search.getStartDate(), search.getEndDate());
|
||||
}
|
||||
|
||||
public List<LoiDto> loi(ProjectRefDto project, ProgressSearchDto search) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Progress.loi", params(project, search));
|
||||
return surveySessionProvider.mapper(project, ProgressMapper.class)
|
||||
.loi(project.getPkey(), search.getStartDate(), search.getEndDate());
|
||||
}
|
||||
|
||||
public List<ProgressScreenDto> screen(ProjectRefDto project, ProgressSearchDto search) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Progress.screen", params(project, search));
|
||||
return surveySessionProvider.mapper(project, ProgressMapper.class)
|
||||
.screen(project.getPkey(), search.getStartDate(), search.getEndDate());
|
||||
}
|
||||
|
||||
public List<CustomProgressDto> reportUrls(ProjectRefDto project) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Progress.reportUrls", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, ProgressMapper.class)
|
||||
.reportUrls(project.getPkey());
|
||||
}
|
||||
|
||||
public List<CustomProgressDto> appendFiles(ProjectRefDto project) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Progress.appendFiles", Map.of("pkey", project.getPkey()));
|
||||
}
|
||||
|
||||
private Map<String, Object> params(ProjectRefDto project, ProgressSearchDto search) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("pkey", project.getPkey());
|
||||
result.put("startDate", search.getStartDate());
|
||||
result.put("endDate", search.getEndDate());
|
||||
return result;
|
||||
return surveySessionProvider.mapper(project, ProgressMapper.class)
|
||||
.appendFiles(project.getPkey());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.project.ProjectListDto;
|
||||
import com.kri.kart.server.dto.project.ProjectSummaryDto;
|
||||
import com.kri.kart.server.persistence.SurveySessionProvider;
|
||||
import java.util.HashMap;
|
||||
import com.kri.kart.server.persistence.mapper.ProjectMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -26,13 +25,11 @@ public class ProjectRepository {
|
||||
}
|
||||
|
||||
public List<String> findMustViewPkeys(ProjectType type) {
|
||||
return kartSqlSessionTemplate.selectList(
|
||||
"kart.Project.mustViewPkeys", Map.of("projectType", type.getCode()));
|
||||
return kartSqlSessionTemplate.getMapper(ProjectMapper.class).mustViewPkeys(type.getCode());
|
||||
}
|
||||
|
||||
public List<String> findAssignedPkeys(String userId) {
|
||||
return kartSqlSessionTemplate.selectList(
|
||||
"kart.Project.assignedPkeys", Map.of("userId", userId));
|
||||
return kartSqlSessionTemplate.getMapper(ProjectMapper.class).assignedPkeys(userId);
|
||||
}
|
||||
|
||||
public List<ProjectListDto> list(
|
||||
@@ -42,11 +39,8 @@ public class ProjectRepository {
|
||||
Integer userRole,
|
||||
String userTeam,
|
||||
List<String> assignedPkeys) {
|
||||
var params = visibility(userRole, userTeam, assignedPkeys);
|
||||
params.put("projectType", type.getCode());
|
||||
params.put("excludedOwnerIds", excluded);
|
||||
params.put("mustViewPkeys", mustView);
|
||||
return surveySessionProvider.forProject(type).selectList("kart.Project.list", params);
|
||||
return surveySessionProvider.mapper(type, ProjectMapper.class)
|
||||
.list(userRole, userTeam, assignedPkeys, type.getCode(), excluded, mustView);
|
||||
}
|
||||
|
||||
public List<ProjectListDto> linkedList(
|
||||
@@ -57,11 +51,14 @@ public class ProjectRepository {
|
||||
Integer userRole,
|
||||
String authenticatedUserTeam,
|
||||
List<String> assignedPkeys) {
|
||||
var params = visibility(userRole, authenticatedUserTeam, assignedPkeys);
|
||||
params.put("intranetCode", intranetCode);
|
||||
params.put("userTeam", userTeam);
|
||||
params.put("keyword", keyword);
|
||||
return surveySessionProvider.forProject(type).selectList("kart.Project.linkedList", params);
|
||||
return surveySessionProvider.mapper(type, ProjectMapper.class)
|
||||
.linkedList(
|
||||
userRole,
|
||||
authenticatedUserTeam,
|
||||
assignedPkeys,
|
||||
intranetCode,
|
||||
userTeam,
|
||||
keyword);
|
||||
}
|
||||
|
||||
public List<ProjectSummaryDto> summary(
|
||||
@@ -70,17 +67,7 @@ public class ProjectRepository {
|
||||
Integer userRole,
|
||||
String userTeam,
|
||||
List<String> assignedPkeys) {
|
||||
var params = visibility(userRole, userTeam, assignedPkeys);
|
||||
params.put("excludedOwnerIds", excluded);
|
||||
return surveySessionProvider.forProject(type).selectList("kart.Project.summary", params);
|
||||
}
|
||||
|
||||
private Map<String, Object> visibility(
|
||||
Integer userRole, String userTeam, List<String> assignedPkeys) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("userRole", userRole);
|
||||
params.put("authenticatedUserTeam", userTeam);
|
||||
params.put("assignedPkeys", assignedPkeys);
|
||||
return params;
|
||||
return surveySessionProvider.mapper(type, ProjectMapper.class)
|
||||
.summary(userRole, userTeam, assignedPkeys, excluded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.kri.kart.server.persistence.repository;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.question.QuestionDto;
|
||||
import com.kri.kart.server.persistence.SurveySessionProvider;
|
||||
import com.kri.kart.server.persistence.mapper.QuestionMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -16,10 +16,7 @@ public class QuestionRepository {
|
||||
private final SurveySessionProvider surveySessionProvider;
|
||||
|
||||
public List<QuestionDto> list(ProjectRefDto project, boolean includeProfiles) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList(
|
||||
"kart.Question.list",
|
||||
Map.of("pkey", project.getPkey(), "includeProfiles", includeProfiles));
|
||||
return surveySessionProvider.mapper(project, QuestionMapper.class)
|
||||
.list(project.getPkey(), includeProfiles);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.quota.QuotaEntryDto;
|
||||
import com.kri.kart.server.dto.quota.QuotaSetDto;
|
||||
import com.kri.kart.server.persistence.SurveySessionProvider;
|
||||
import com.kri.kart.server.persistence.mapper.QuotaMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -17,22 +17,17 @@ public class QuotaRepository {
|
||||
private final SurveySessionProvider surveySessionProvider;
|
||||
|
||||
public List<QuotaSetDto> quotaSets(ProjectRefDto project) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Quota.quotaSets", Map.of("pkey", project.getPkey()));
|
||||
return surveySessionProvider.mapper(project, QuotaMapper.class)
|
||||
.quotaSets(project.getPkey());
|
||||
}
|
||||
|
||||
public QuotaSetDto quotaSet(ProjectRefDto project, int quotaOrder) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectOne(
|
||||
"kart.Quota.quotaSet", Map.of("pkey", project.getPkey(), "quotaOrder", quotaOrder));
|
||||
return surveySessionProvider.mapper(project, QuotaMapper.class)
|
||||
.quotaSet(project.getPkey(), quotaOrder);
|
||||
}
|
||||
|
||||
public List<QuotaEntryDto> quotaEntries(ProjectRefDto project, int quotaOrder) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList(
|
||||
"kart.Quota.quotaEntries", Map.of("pkey", project.getPkey(), "quotaOrder", quotaOrder));
|
||||
return surveySessionProvider.mapper(project, QuotaMapper.class)
|
||||
.quotaEntries(project.getPkey(), quotaOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.kri.kart.server.persistence.repository;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.share.ShareLinkRecordDto;
|
||||
import com.kri.kart.server.persistence.SurveySessionProvider;
|
||||
import java.util.Map;
|
||||
import com.kri.kart.server.persistence.mapper.ShareLinkMapper;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -23,29 +23,28 @@ public class ShareLinkRepository {
|
||||
}
|
||||
|
||||
public ShareLinkRecordDto find(String urlKey) {
|
||||
return kartSqlSessionTemplate.selectOne("kart.ShareLink.find", urlKey);
|
||||
return kartSqlSessionTemplate.getMapper(ShareLinkMapper.class).find(urlKey);
|
||||
}
|
||||
|
||||
public String projectTitle(ProjectRefDto project) {
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectOne("kart.ShareLink.projectTitle", project.getPkey());
|
||||
return surveySessionProvider.mapper(project, ShareLinkMapper.class)
|
||||
.projectTitle(project.getPkey());
|
||||
}
|
||||
|
||||
public ShareLinkRecordDto reusable(ShareLinkRecordDto link) {
|
||||
return kartSqlSessionTemplate.selectOne("kart.ShareLink.reusable", link);
|
||||
return kartSqlSessionTemplate.getMapper(ShareLinkMapper.class).reusable(link);
|
||||
}
|
||||
|
||||
public boolean keyExists(String urlKey) {
|
||||
return kartSqlSessionTemplate.<Integer>selectOne("kart.ShareLink.keyExists", urlKey) > 0;
|
||||
return kartSqlSessionTemplate.getMapper(ShareLinkMapper.class).keyExists(urlKey) > 0;
|
||||
}
|
||||
|
||||
public int create(ShareLinkRecordDto link) {
|
||||
return kartSqlSessionTemplate.insert("kart.ShareLink.create", link);
|
||||
return kartSqlSessionTemplate.getMapper(ShareLinkMapper.class).create(link);
|
||||
}
|
||||
|
||||
public int incrementLanding(ShareLinkRecordDto link) {
|
||||
return kartSqlSessionTemplate.update(
|
||||
"kart.ShareLink.incrementLanding", Map.of("id", link.getId(), "urlKey", link.getUrlKey()));
|
||||
return kartSqlSessionTemplate.getMapper(ShareLinkMapper.class)
|
||||
.incrementLanding(link.getId(), link.getUrlKey());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsDataDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsRequestDto;
|
||||
import com.kri.kart.server.persistence.SurveySessionProvider;
|
||||
import java.util.HashMap;
|
||||
import com.kri.kart.server.persistence.mapper.StatisticsMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -22,17 +21,14 @@ public class StatisticsRepository {
|
||||
StatisticsRequestDto request,
|
||||
boolean includeProfiles,
|
||||
List<String> selectedRoots) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("pkey", project.getPkey());
|
||||
params.put("dataScope", request.getDataScope());
|
||||
params.put("startDate", request.getStartDate());
|
||||
params.put(
|
||||
"endDate", request.getEndDate() == null ? request.getStartDate() : request.getEndDate());
|
||||
params.put("includeProfiles", includeProfiles);
|
||||
params.put("selectedRoots", selectedRoots);
|
||||
params.put("hasFilter", request.getFilter() != null);
|
||||
return surveySessionProvider
|
||||
.forProject(project.getProjectType())
|
||||
.selectList("kart.Statistics.data", params);
|
||||
return surveySessionProvider.mapper(project, StatisticsMapper.class)
|
||||
.data(
|
||||
project.getPkey(),
|
||||
request.getDataScope(),
|
||||
request.getStartDate(),
|
||||
request.getEndDate() == null ? request.getStartDate() : request.getEndDate(),
|
||||
includeProfiles,
|
||||
selectedRoots,
|
||||
request.getFilter() != null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kri.kart.server.persistence.repository;
|
||||
|
||||
import com.kri.kart.server.dto.auth.LoginRequestDto;
|
||||
import com.kri.kart.server.dto.auth.ReportMemberDto;
|
||||
import com.kri.kart.server.persistence.mapper.UserMapper;
|
||||
import java.util.List;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -20,7 +21,7 @@ public class UserRepository {
|
||||
|
||||
public ReportMemberDto findMember(LoginRequestDto request) {
|
||||
List<ReportMemberDto> users =
|
||||
kartSqlSessionTemplate.selectList("kart.User.findMember", request);
|
||||
kartSqlSessionTemplate.getMapper(UserMapper.class).findMember(request);
|
||||
return users.isEmpty() ? null : users.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +119,7 @@ public class AggregateExcelService {
|
||||
var link = cell(contents, i + 5, 2);
|
||||
link.setCellValue("Go");
|
||||
var hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
|
||||
hyperlink.setAddress(
|
||||
java.net.URI.create("#'테이블'!A" + nextRow).toASCIIString().substring(1));
|
||||
hyperlink.setAddress("'테이블'!A" + nextRow);
|
||||
link.setHyperlink(hyperlink);
|
||||
var font = workbook.createFont();
|
||||
font.setFontName("맑은 고딕");
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kri.kart.server.service;
|
||||
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
|
||||
import com.kri.common.feature.auth.jwt.JwtService;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.common.external.intranet.IntranetExtensionApiClient;
|
||||
import com.kri.kart.server.common.external.intranet.IntranetUserDto;
|
||||
import com.kri.kart.server.dto.auth.LoginRequestDto;
|
||||
@@ -47,7 +48,7 @@ public class AuthService {
|
||||
.userName(reportMember.getUserName())
|
||||
.userCmpn("")
|
||||
.userTeam("CLIENT")
|
||||
.userRole(9001)
|
||||
.userRole(KartConstant.REPORT_MEMBER_ROLE)
|
||||
.build();
|
||||
}
|
||||
String token = jwtService.generateAccessToken(claims);
|
||||
|
||||
@@ -59,8 +59,8 @@ public class BookmarkService {
|
||||
String bookmarkId,
|
||||
BookmarkSaveRequestDto request,
|
||||
RequestUserContext ctx) {
|
||||
BookmarkDto origin = find(project, bookmarkId);
|
||||
if (bookmarkRepository.update(project, bookmarkId, request) != 1) {
|
||||
BookmarkDto origin = findOwned(project, bookmarkId, ctx);
|
||||
if (bookmarkRepository.update(project, bookmarkId, request, ctx.getUserId()) != 1) {
|
||||
throw BusinessException.conflict("북마크가 변경되었습니다. 다시 조회해 주세요.");
|
||||
}
|
||||
ObjectNode content = objectMapper.createObjectNode();
|
||||
@@ -72,23 +72,28 @@ public class BookmarkService {
|
||||
|
||||
@Transactional(transactionManager = "kartTransactionManager")
|
||||
public boolean delete(ProjectRefDto project, String bookmarkId, RequestUserContext ctx) {
|
||||
BookmarkDto origin = find(project, bookmarkId);
|
||||
BookmarkDto origin = findOwned(project, bookmarkId, ctx);
|
||||
ObjectNode content = objectMapper.createObjectNode();
|
||||
content.set("ORIGIN", snapshot(origin));
|
||||
// Legacy deletion logs the original values before reordering/deleting.
|
||||
logService.writeSiteLog(project, "Delete Bookmark", content, ctx);
|
||||
bookmarkRepository.shiftOrderAfterDelete(project, bookmarkId);
|
||||
if (bookmarkRepository.delete(project, bookmarkId) != 1) {
|
||||
bookmarkRepository.shiftOrderAfterDelete(project, bookmarkId, ctx.getUserId());
|
||||
if (bookmarkRepository.delete(project, bookmarkId, ctx.getUserId()) != 1) {
|
||||
throw BusinessException.conflict("북마크가 변경되었습니다. 다시 조회해 주세요.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private BookmarkDto find(ProjectRefDto project, String bookmarkId) {
|
||||
private BookmarkDto findOwned(
|
||||
ProjectRefDto project, String bookmarkId, RequestUserContext ctx) {
|
||||
BookmarkDto bookmark = bookmarkRepository.find(project, bookmarkId);
|
||||
if (bookmark == null) {
|
||||
throw BusinessException.notFound("북마크를 찾을 수 없습니다.");
|
||||
}
|
||||
if (ctx.getUserId() == null || !ctx.getUserId().equals(bookmark.getMkey())) {
|
||||
throw BusinessException.forbidden(
|
||||
"BOOKMARK_OWNER_REQUIRED", "북마크 생성자만 수정하거나 삭제할 수 있습니다.");
|
||||
}
|
||||
return bookmark;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kri.kart.server.service;
|
||||
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.project.CustomProgressDto;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.persistence.repository.ProgressRepository;
|
||||
@@ -15,7 +16,6 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class CustomProgressService {
|
||||
private static final String LEGACY_APPEND_PREFIX = "../report_append/";
|
||||
private final ProgressRepository progressRepository;
|
||||
private final Path appendDirectory;
|
||||
|
||||
@@ -45,12 +45,12 @@ public class CustomProgressService {
|
||||
}
|
||||
|
||||
private boolean localFileExists(String fileName) {
|
||||
if (fileName == null || !fileName.startsWith(LEGACY_APPEND_PREFIX)) {
|
||||
if (fileName == null || !fileName.startsWith(KartConstant.LEGACY_APPEND_PREFIX)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Path path =
|
||||
appendDirectory.resolve(fileName.substring(LEGACY_APPEND_PREFIX.length())).normalize();
|
||||
appendDirectory.resolve(fileName.substring(KartConstant.LEGACY_APPEND_PREFIX.length())).normalize();
|
||||
return path.startsWith(appendDirectory) && Files.isRegularFile(path);
|
||||
} catch (InvalidPathException ignored) {
|
||||
return false;
|
||||
|
||||
@@ -54,6 +54,7 @@ public class DerivedManagementService {
|
||||
String originId,
|
||||
DerivedSaveRequestDto request,
|
||||
RequestUserContext ctx) {
|
||||
requireRole(ctx);
|
||||
validateId(request.getVariableId());
|
||||
if (originId != null) {
|
||||
validateId(originId);
|
||||
@@ -64,6 +65,9 @@ public class DerivedManagementService {
|
||||
() -> {
|
||||
requireProject(project);
|
||||
var original = originId == null ? null : requireDefinition(project, originId);
|
||||
if (original != null) {
|
||||
requireTeam(original, ctx);
|
||||
}
|
||||
if (derivedRepository.duplicate(project, definition.getQid(), originId)) {
|
||||
throw BusinessException.conflict("DERIVED_ID_DUPLICATE", "이미 사용 중인 변수 ID입니다.");
|
||||
}
|
||||
@@ -91,12 +95,14 @@ public class DerivedManagementService {
|
||||
}
|
||||
|
||||
public boolean delete(ProjectRefDto project, String qid, RequestUserContext ctx) {
|
||||
requireRole(ctx);
|
||||
validateId(qid);
|
||||
return transaction(
|
||||
project,
|
||||
() -> {
|
||||
requireProject(project);
|
||||
var original = requireDefinition(project, qid);
|
||||
requireTeam(original, ctx);
|
||||
var content =
|
||||
objectMapper.createObjectNode().set("ORIGIN", objectMapper.valueToTree(original));
|
||||
logService.writeSiteLog(project, "Delete Derived Variable", content, ctx);
|
||||
@@ -111,6 +117,7 @@ public class DerivedManagementService {
|
||||
|
||||
public DerivedCalculationDto recalculate(
|
||||
ProjectRefDto project, String qid, RequestUserContext ctx) {
|
||||
requireRole(ctx);
|
||||
if (qid != null) {
|
||||
validateId(qid);
|
||||
}
|
||||
@@ -205,6 +212,20 @@ public class DerivedManagementService {
|
||||
return definition;
|
||||
}
|
||||
|
||||
private void requireRole(RequestUserContext ctx) {
|
||||
if (ctx.getUserRole() == null || ctx.getUserRole() >= 9001) {
|
||||
throw BusinessException.forbidden("DERIVED_ROLE_REQUIRED", "파생변수 관리 권한이 필요합니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private void requireTeam(DerivedDefinitionDto definition, RequestUserContext ctx) {
|
||||
if (!Integer.valueOf(1001).equals(ctx.getUserRole())
|
||||
&& (ctx.getUserTeam() == null || ctx.getUserTeam().isBlank()
|
||||
|| !ctx.getUserTeam().equals(definition.getGkey()))) {
|
||||
throw BusinessException.forbidden("DERIVED_TEAM_REQUIRED", "본인 팀의 파생변수만 수정·삭제할 수 있습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateId(String qid) {
|
||||
if (qid == null || !qid.matches("[A-Za-z][A-Za-z0-9_]{0,127}")) {
|
||||
throw BusinessException.badRequest("파생변수 ID 형식을 확인해 주세요.");
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kri.kart.server.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kri.common.feature.json.JsonUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.dto.derived.DerivedVariableDto;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
@@ -20,10 +21,18 @@ public class DerivedService {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public List<DerivedVariableDto> list(ProjectRefDto project, RequestUserContext ctx) {
|
||||
return questionService
|
||||
.organize(derivedRepository.list(project, ctx.getUserRole(), ctx.getUserTeam()))
|
||||
.stream()
|
||||
.map(question -> JsonUtil.convert(objectMapper, question, DerivedVariableDto.class))
|
||||
if (ctx.getUserRole() == null || ctx.getUserRole() >= 9001) {
|
||||
throw BusinessException.forbidden("DERIVED_ROLE_REQUIRED", "파생변수 관리 권한이 필요합니다.");
|
||||
}
|
||||
return derivedRepository.list(project, ctx.getUserRole(), ctx.getUserTeam()).stream()
|
||||
.flatMap(
|
||||
original -> questionService.organize(List.of(original)).stream()
|
||||
.map(
|
||||
question -> {
|
||||
var variable = JsonUtil.convert(objectMapper, question, DerivedVariableDto.class);
|
||||
variable.setVariableId(original.getQid());
|
||||
return variable;
|
||||
}))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.excel.ExcelMapper;
|
||||
import com.kri.common.feature.json.JsonUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.export.ExportDataDto;
|
||||
import com.kri.kart.server.dto.export.ExportDerivedHeaderDto;
|
||||
import com.kri.kart.server.dto.export.ExportFileDto;
|
||||
@@ -41,16 +42,6 @@ import org.springframework.web.util.HtmlUtils;
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class ExportService {
|
||||
private static final String QUESTION_FORM = "KON 문항 등록 양식.xlsx";
|
||||
private static final List<String> FIXED_HEADERS =
|
||||
List.of(
|
||||
"IDKEY",
|
||||
"Status",
|
||||
"start_date",
|
||||
"end_date",
|
||||
"interval_min",
|
||||
"INTERVIEWER_INFO",
|
||||
"INTERVIEWER_CODE");
|
||||
private static final DateTimeFormatter FILE_TIMESTAMP =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HHmmss");
|
||||
private static final Pattern HTML_TAG = Pattern.compile("<[a-zA-Z/][^\\n]*?>");
|
||||
@@ -60,8 +51,8 @@ public class ExportService {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public ExportFileDto questionForm() {
|
||||
try (var input = new ClassPathResource("file_forms/" + QUESTION_FORM).getInputStream()) {
|
||||
return new ExportFileDto(QUESTION_FORM, input.readAllBytes());
|
||||
try (var input = new ClassPathResource("file_forms/" + KartConstant.QUESTION_FORM_FILE_NAME).getInputStream()) {
|
||||
return new ExportFileDto(KartConstant.QUESTION_FORM_FILE_NAME, input.readAllBytes());
|
||||
} catch (IOException exception) {
|
||||
throw new IllegalStateException("문항 등록 양식을 읽을 수 없습니다.", exception);
|
||||
}
|
||||
@@ -77,7 +68,7 @@ public class ExportService {
|
||||
private Map<String, String> headers(ProjectRefDto project, Integer userRole) {
|
||||
// This ordered map is the dynamic Excel column boundary, not an untyped database result.
|
||||
Map<String, String> headers = new LinkedHashMap<>();
|
||||
FIXED_HEADERS.forEach(value -> headers.put(value, value));
|
||||
KartConstant.EXPORT_FIXED_HEADERS.forEach(value -> headers.put(value, value));
|
||||
String additionalColumns = exportRepository.additionalColumns(project);
|
||||
if (additionalColumns != null) {
|
||||
if (!"[]".equals(additionalColumns)) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ImportService {
|
||||
project,
|
||||
() -> {
|
||||
requireProject(project);
|
||||
importRepository.command(project, "resetTitles");
|
||||
importRepository.resetTitles(project);
|
||||
int affected = 0;
|
||||
for (var row : table.getRows()) {
|
||||
affected += importRepository.title(project, row.get(0), row.get(3));
|
||||
@@ -90,11 +90,11 @@ public class ImportService {
|
||||
project,
|
||||
() -> {
|
||||
requireProject(project);
|
||||
int removed = importRepository.command(project, "deleteQuestions");
|
||||
importRepository.command(project, "deleteOptions");
|
||||
importRepository.command(project, "deleteQuotaSets");
|
||||
importRepository.command(project, "deleteQuotas");
|
||||
if (importRepository.command(project, "resetStructure") != 1) {
|
||||
int removed = importRepository.deleteQuestions(project);
|
||||
importRepository.deleteOptions(project);
|
||||
importRepository.deleteQuotaSets(project);
|
||||
importRepository.deleteQuotas(project);
|
||||
if (importRepository.resetStructure(project) != 1) {
|
||||
throw BusinessException.conflict("STRUCTURE_NOT_FOUND", "프로젝트 STRUCTURE를 확인해 주세요.");
|
||||
}
|
||||
for (var question : questions) {
|
||||
@@ -119,8 +119,8 @@ public class ImportService {
|
||||
.map(question -> question.getQid().split("_", -1)[0])
|
||||
.collect(Collectors.toSet());
|
||||
var responses = responseImportService.prepare(table, multi);
|
||||
int removed = importRepository.command(project, "deleteUploaded");
|
||||
int archived = importRepository.command(project, "archiveCompleted");
|
||||
int removed = importRepository.deleteUploaded(project);
|
||||
int archived = importRepository.archiveCompleted(project);
|
||||
for (var response : responses) {
|
||||
requireOne(importRepository.response(project, response));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kri.kart.server.service;
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.common.external.intranet.IntranetExtensionApiClient;
|
||||
import com.kri.kart.server.dto.project.ProjectLinkSearchDto;
|
||||
@@ -115,14 +116,14 @@ public class ProjectService {
|
||||
if (ctx.getUserRole() == null
|
||||
|| (!Integer.valueOf(1001).equals(ctx.getUserRole())
|
||||
&& StringUtil.normalizeBlank(ctx.getUserTeam()) == null)
|
||||
|| (Integer.valueOf(9001).equals(ctx.getUserRole())
|
||||
|| (Integer.valueOf(KartConstant.REPORT_MEMBER_ROLE).equals(ctx.getUserRole())
|
||||
&& StringUtil.normalizeBlank(ctx.getUserId()) == null)) {
|
||||
throw BusinessException.unauthorized("PROJECT_IDENTITY_REQUIRED", "프로젝트 조회 인증 정보가 부족합니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> assignedPkeys(RequestUserContext ctx) {
|
||||
return Integer.valueOf(9001).equals(ctx.getUserRole())
|
||||
return Integer.valueOf(KartConstant.REPORT_MEMBER_ROLE).equals(ctx.getUserRole())
|
||||
? projectRepository.findAssignedPkeys(ctx.getUserId())
|
||||
: List.of();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.kri.common.feature.auth.jwt.JwtService;
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.config.ShareLinkProperties;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
@@ -28,11 +29,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class ShareLinkService {
|
||||
public static final String EXTERNAL_TEAM = "KART_EXTERNAL";
|
||||
public static final String EXTERNAL_USER_PREFIX = "EXTERNAL:";
|
||||
public static final String REQUEST_LINK_ATTRIBUTE = ShareLinkService.class.getName() + ".link";
|
||||
private static final Set<String> REPORT_PATHS =
|
||||
Set.of("/Report/Current", "/Report/Quota", "/Report/Tabulation", "/Report/Crosstab");
|
||||
private final ShareLinkRepository shareLinkRepository;
|
||||
private final LegacyProjectKeyService legacyProjectKeyService;
|
||||
private final ShareLinkProperties shareLinkProperties;
|
||||
@@ -94,21 +90,24 @@ public class ShareLinkService {
|
||||
public ExternalLoginResponseDto login(String urlKey, String clientIp) {
|
||||
ShareLinkRecordDto stored = record(urlKey);
|
||||
ShareLinkDto link = resolve(stored);
|
||||
String userId = EXTERNAL_USER_PREFIX + link.getUrlKey();
|
||||
String token =
|
||||
jwtService.generateAccessToken(
|
||||
JwtUserClaimsDto.builder()
|
||||
.userId(userId)
|
||||
.userName("CLIENT")
|
||||
.userTeam(EXTERNAL_TEAM)
|
||||
.userCmpn("")
|
||||
.userRole(9001)
|
||||
.build());
|
||||
String userId = KartConstant.EXTERNAL_USER_PREFIX + link.getUrlKey();
|
||||
JwtUserClaimsDto user =
|
||||
JwtUserClaimsDto.builder()
|
||||
.userId(userId)
|
||||
.userName("CLIENT")
|
||||
.userTeam(KartConstant.EXTERNAL_TEAM)
|
||||
.userCmpn("")
|
||||
.userRole(
|
||||
link.isPageOnly()
|
||||
? KartConstant.EXTERNAL_PAGE_COPY_ROLE
|
||||
: KartConstant.EXTERNAL_URL_COPY_ROLE)
|
||||
.build();
|
||||
String token = jwtService.generateAccessToken(user);
|
||||
if (shareLinkRepository.incrementLanding(stored) != 1) {
|
||||
throw BusinessException.conflict("SHARE_LINK_CHANGED", "공유 링크를 다시 열어 주세요.");
|
||||
}
|
||||
logService.writeLoginLog(userId, clientIp);
|
||||
return new ExternalLoginResponseDto(token, link);
|
||||
return new ExternalLoginResponseDto(token, user, link);
|
||||
}
|
||||
|
||||
private ShareLinkRecordDto record(String urlKey) {
|
||||
@@ -197,7 +196,7 @@ public class ShareLinkService {
|
||||
// Query/fragment are retained as navigation state, not an authorization source.
|
||||
String path = uri.getRawPath().replaceFirst("/+$", "");
|
||||
String canonical =
|
||||
REPORT_PATHS.stream()
|
||||
KartConstant.REPORT_PATHS.stream()
|
||||
.filter(allowed -> allowed.equalsIgnoreCase(path))
|
||||
.findFirst()
|
||||
.orElseThrow(IllegalArgumentException::new);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.common.enums.ProjectType;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.question.QuestionDto;
|
||||
@@ -37,15 +38,6 @@ import org.springframework.stereotype.Service;
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class StatisticsService {
|
||||
private static final String STANDARD_MODE = "STANDARD";
|
||||
// TABULATION requests have no single index; their rows are stored under the INDEX root.
|
||||
private static final String TABULATION_STORAGE_ROOT = "INDEX";
|
||||
private static final String ATTRIBUTE_PROJECTION_SUFFIX = "#A";
|
||||
private static final int PROFILE_QUESTION_ROLE = 1001;
|
||||
private static final List<String> PROFILE_ID_PREFIXES = List.of("PF", "PS");
|
||||
private static final String AUDIT_EVENT = "Get Report Data";
|
||||
private static final String CALCULATION_FAILED_CODE = "REPORT_CALCULATION_FAILED";
|
||||
private static final String CALCULATION_FAILED_MESSAGE = "문항 집계 처리에 실패했습니다.";
|
||||
|
||||
private final StatisticsRepository statisticsRepository;
|
||||
private final QuestionRepository questionRepository;
|
||||
@@ -80,7 +72,7 @@ public class StatisticsService {
|
||||
List<StatisticsRequestDto> requests,
|
||||
RequestUserContext ctx) {
|
||||
StatisticsBatchDto statisticsBatch = prepare(project, requests, ctx, false);
|
||||
logService.writeSiteLog(project, AUDIT_EVENT, objectMapper.valueToTree(requests), ctx);
|
||||
logService.writeSiteLog(project, KartConstant.REPORT_AUDIT_EVENT, objectMapper.valueToTree(requests), ctx);
|
||||
return statisticsBatch;
|
||||
}
|
||||
|
||||
@@ -117,7 +109,7 @@ public class StatisticsService {
|
||||
} catch (RuntimeException error) {
|
||||
event =
|
||||
errorEvent(
|
||||
position, request, 500, CALCULATION_FAILED_CODE, CALCULATION_FAILED_MESSAGE);
|
||||
position, request, 500, KartConstant.CALCULATION_FAILED_CODE, KartConstant.CALCULATION_FAILED_MESSAGE);
|
||||
failed++;
|
||||
}
|
||||
// A calculation can take a while; never write to a stream cancelled in the meantime.
|
||||
@@ -167,7 +159,7 @@ public class StatisticsService {
|
||||
private List<QuestionDto> loadQuestions(ProjectRefDto project, RequestUserContext ctx) {
|
||||
boolean includeProfileQuestions =
|
||||
project.getProjectType() == ProjectType.KIWI
|
||||
&& Integer.valueOf(PROFILE_QUESTION_ROLE).equals(ctx.getUserRole());
|
||||
&& Integer.valueOf(KartConstant.PROFILE_QUESTION_ROLE).equals(ctx.getUserRole());
|
||||
return questionService.organize(questionRepository.list(project, includeProfileQuestions));
|
||||
}
|
||||
|
||||
@@ -233,7 +225,7 @@ public class StatisticsService {
|
||||
return false;
|
||||
}
|
||||
String upperCaseId = normalized.toUpperCase(Locale.ROOT);
|
||||
return PROFILE_ID_PREFIXES.stream().anyMatch(upperCaseId::startsWith);
|
||||
return KartConstant.PROFILE_ID_PREFIXES.stream().anyMatch(upperCaseId::startsWith);
|
||||
}
|
||||
|
||||
private StatisticsResponseDto calculate(
|
||||
@@ -263,7 +255,7 @@ public class StatisticsService {
|
||||
/** Storage root keys selected by the original single-index query: index plus banners. */
|
||||
private List<String> storageRoots(StatisticsRequestDto request) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
ids.add(isStandard(request) ? request.getIndex() : TABULATION_STORAGE_ROOT);
|
||||
ids.add(isStandard(request) ? request.getIndex() : KartConstant.TABULATION_STORAGE_ROOT);
|
||||
request.getBanners().forEach(ids::addAll);
|
||||
return ids.stream().map(this::toStorageRoot).distinct().toList();
|
||||
}
|
||||
@@ -272,7 +264,7 @@ public class StatisticsService {
|
||||
private String toStorageRoot(String id) {
|
||||
return Objects.toString(StringUtil.normalizeBlank(id), "")
|
||||
.toUpperCase(Locale.ROOT)
|
||||
.replace(ATTRIBUTE_PROJECTION_SUFFIX, "")
|
||||
.replace(KartConstant.ATTRIBUTE_PROJECTION_SUFFIX, "")
|
||||
.split("_")[0];
|
||||
}
|
||||
|
||||
@@ -298,7 +290,7 @@ public class StatisticsService {
|
||||
}
|
||||
|
||||
private boolean isStandard(StatisticsRequestDto request) {
|
||||
return STANDARD_MODE.equals(request.getMode());
|
||||
return KartConstant.STANDARD_MODE.equals(request.getMode());
|
||||
}
|
||||
|
||||
private boolean isCancelled(BooleanSupplier cancelled) {
|
||||
@@ -307,7 +299,7 @@ public class StatisticsService {
|
||||
|
||||
/** Server-side failures must not expose internal details to the client. */
|
||||
private String clientMessage(BusinessException error) {
|
||||
return error.getStatus().is5xxServerError() ? CALCULATION_FAILED_MESSAGE : error.getMessage();
|
||||
return error.getStatus().is5xxServerError() ? KartConstant.CALCULATION_FAILED_MESSAGE : error.getMessage();
|
||||
}
|
||||
|
||||
private StatisticsStreamEventDto resultEvent(
|
||||
|
||||
@@ -74,7 +74,7 @@ public class QuotaComputationService {
|
||||
.findFirst()
|
||||
.orElseThrow());
|
||||
List<StatisticsRowDto> headers =
|
||||
statisticsTableService.headers(quotaSet.getQsTitle(), columns, "MERGED");
|
||||
statisticsTableService.headers("", columns, "MERGED");
|
||||
List<QuotaRowDto> rows = new ArrayList<>();
|
||||
for (StatisticsRowDto row : table.getRows()) {
|
||||
List<QuotaCellDto> cells = new ArrayList<>();
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kri.kart.server.service.share;
|
||||
|
||||
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.share.ShareLinkDto;
|
||||
import com.kri.kart.server.service.ShareLinkService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -33,22 +34,34 @@ public class ExternalAccessInterceptor implements HandlerInterceptor {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null
|
||||
|| !authentication.isAuthenticated()
|
||||
|| !(authentication.getDetails() instanceof JwtUserClaimsDto claims)
|
||||
|| !ShareLinkService.EXTERNAL_TEAM.equals(claims.getUserTeam())) {
|
||||
|| !(authentication.getDetails() instanceof JwtUserClaimsDto claims)) {
|
||||
return true;
|
||||
}
|
||||
String userId = claims.getUserId();
|
||||
if (!Integer.valueOf(9001).equals(claims.getUserRole())
|
||||
|| userId == null
|
||||
|| !userId.startsWith(ShareLinkService.EXTERNAL_USER_PREFIX)) {
|
||||
boolean externalRole =
|
||||
Integer.valueOf(KartConstant.EXTERNAL_URL_COPY_ROLE).equals(claims.getUserRole())
|
||||
|| Integer.valueOf(KartConstant.EXTERNAL_PAGE_COPY_ROLE).equals(claims.getUserRole());
|
||||
boolean externalTeam = KartConstant.EXTERNAL_TEAM.equals(claims.getUserTeam());
|
||||
boolean externalId = userId != null && userId.startsWith(KartConstant.EXTERNAL_USER_PREFIX);
|
||||
if (!externalRole && !externalTeam && !externalId) {
|
||||
return true;
|
||||
}
|
||||
if (!externalRole || !externalTeam || !externalId) {
|
||||
throw denied();
|
||||
}
|
||||
String urlKey = userId.substring(ShareLinkService.EXTERNAL_USER_PREFIX.length());
|
||||
String urlKey = userId.substring(KartConstant.EXTERNAL_USER_PREFIX.length());
|
||||
ShareLinkDto link =
|
||||
(ShareLinkDto) request.getAttribute(ShareLinkService.REQUEST_LINK_ATTRIBUTE);
|
||||
(ShareLinkDto) request.getAttribute(KartConstant.REQUEST_LINK_ATTRIBUTE);
|
||||
if (link == null || !urlKey.equals(link.getUrlKey())) {
|
||||
link = shareLinkService.lookup(urlKey);
|
||||
}
|
||||
int expectedRole =
|
||||
link.isPageOnly()
|
||||
? KartConstant.EXTERNAL_PAGE_COPY_ROLE
|
||||
: KartConstant.EXTERNAL_URL_COPY_ROLE;
|
||||
if (!Integer.valueOf(expectedRole).equals(claims.getUserRole())) {
|
||||
throw denied();
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> variables =
|
||||
(Map<String, String>) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
|
||||
@@ -104,7 +117,7 @@ public class ExternalAccessInterceptor implements HandlerInterceptor {
|
||||
if (!allowed) {
|
||||
throw denied();
|
||||
}
|
||||
request.setAttribute(ShareLinkService.REQUEST_LINK_ATTRIBUTE, link);
|
||||
request.setAttribute(KartConstant.REQUEST_LINK_ATTRIBUTE, link);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import com.fasterxml.jackson.databind.node.DecimalNode;
|
||||
import com.fasterxml.jackson.databind.node.TextNode;
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsFilterDto;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -25,10 +25,6 @@ public class LegacyFilterService {
|
||||
private static final Pattern TOKEN =
|
||||
Pattern.compile(
|
||||
"\\G\\s*('(?:[^']|'')*'|[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)|[A-Z][A-Z0-9_]*|>=|<=|<>|!=|[=><(),])");
|
||||
private static final int MAX_TOKENS = 2048;
|
||||
private static final int MAX_DEPTH = 32;
|
||||
private static final Map<String, String> COMPARISON_OPERATORS =
|
||||
Map.of("=", "EQ", "!=", "NE", "<>", "NE", ">", "GT", ">=", "GE", "<", "LT", "<=", "LE");
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@@ -71,7 +67,9 @@ public class LegacyFilterService {
|
||||
Matcher matcher = TOKEN.matcher(expression);
|
||||
int position = 0;
|
||||
while (position < expression.length()) {
|
||||
if (!matcher.find(position) || matcher.start() != position || tokens.size() >= MAX_TOKENS) {
|
||||
if (!matcher.find(position)
|
||||
|| matcher.start() != position
|
||||
|| tokens.size() >= KartConstant.LEGACY_FILTER_MAX_TOKENS) {
|
||||
throw invalid();
|
||||
}
|
||||
tokens.add(matcher.group(1));
|
||||
@@ -114,7 +112,7 @@ public class LegacyFilterService {
|
||||
}
|
||||
|
||||
private StatisticsFilterDto condition(int depth) {
|
||||
if (depth > MAX_DEPTH) {
|
||||
if (depth > KartConstant.LEGACY_FILTER_MAX_DEPTH) {
|
||||
throw invalid();
|
||||
}
|
||||
if (take("(")) {
|
||||
@@ -146,7 +144,7 @@ public class LegacyFilterService {
|
||||
filter.setOperator("IN");
|
||||
filter.setValues(values());
|
||||
} else {
|
||||
String operator = COMPARISON_OPERATORS.get(next());
|
||||
String operator = KartConstant.LEGACY_FILTER_COMPARISON_OPERATORS.get(next());
|
||||
if (operator == null) {
|
||||
throw invalid();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kri.kart.server.service.statistics;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.question.QuestionDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsCellDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsColumnDto;
|
||||
@@ -18,7 +19,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -26,20 +26,8 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StatisticsAggregationService {
|
||||
private static final String TOTAL_COLUMN_ID = "i";
|
||||
private static final String CASE_COUNT_LABEL = "사례수";
|
||||
// TABULATION_0 divides each banner column by the total of its sibling columns.
|
||||
private static final String SIBLING_BASE_MODE = "TABULATION_0";
|
||||
// TABULATION_1 crosses every banner column with every other banner column.
|
||||
private static final String BANNER_CROSS_MODE = "TABULATION_1";
|
||||
private static final Set<String> OPEN_QUESTION_TYPES = Set.of("num", "text");
|
||||
private static final String MEAN = "Mean";
|
||||
private static final String SUM = "Sum";
|
||||
private static final List<String> NUMERIC_STATISTICS =
|
||||
List.of("Median", "SD", "Max", "Min", "Mode");
|
||||
private static final String[] SCALE_GROUP_LABELS = {"Top", "Mid", "Bottom"};
|
||||
private static final String[] NPS_GROUP_LABELS = {"Promoters", "Passives", "Detractors"};
|
||||
private static final int NPS_SCALE_SIZE = 11;
|
||||
|
||||
private final StatisticsDimensionService statisticsDimensionService;
|
||||
private final StatisticsSelectionService statisticsSelectionService;
|
||||
@@ -68,7 +56,7 @@ public class StatisticsAggregationService {
|
||||
StatisticsDimension index =
|
||||
statisticsDimensionService.resolve(request.getIndex(), questions, responses);
|
||||
List<Column> columns = columns(index, request, questions, responses);
|
||||
if (BANNER_CROSS_MODE.equals(request.getMode())) {
|
||||
if (KartConstant.BANNER_CROSS_MODE.equals(request.getMode())) {
|
||||
return bannerCrossTable(index, columns, request);
|
||||
}
|
||||
List<StatisticsRowDto> rows = new ArrayList<>();
|
||||
@@ -95,7 +83,7 @@ public class StatisticsAggregationService {
|
||||
.map(choice -> statisticsSelectionService.cases(responses, index, choice.value()))
|
||||
.toList();
|
||||
List<Column> columns = new ArrayList<>();
|
||||
columns.add(new Column(TOTAL_COLUMN_ID, List.of("Total"), total, cases, false));
|
||||
columns.add(new Column(KartConstant.TOTAL_COLUMN_ID, List.of("Total"), total, cases, false));
|
||||
List<List<String>> banners = request.getBanners();
|
||||
if (!index.getAttributes().isEmpty()) {
|
||||
// The old matrix summary replaces supplied banners with its own attribute projection.
|
||||
@@ -173,13 +161,13 @@ public class StatisticsAggregationService {
|
||||
}
|
||||
|
||||
private boolean isOpenAnswer(StatisticsDimension dimension) {
|
||||
return OPEN_QUESTION_TYPES.contains(dimension.getQuestion().getQtype())
|
||||
return KartConstant.OPEN_QUESTION_TYPES.contains(dimension.getQuestion().getQtype())
|
||||
&& !dimension.isAttributeProjection();
|
||||
}
|
||||
|
||||
private StatisticsRowDto totalRow(List<Column> columns, StatisticsRequestDto request) {
|
||||
List<StatisticsCellDto> cells = new ArrayList<>();
|
||||
cells.add(StatisticsTableService.text(0, CASE_COUNT_LABEL));
|
||||
cells.add(StatisticsTableService.text(0, KartConstant.CASE_COUNT_LABEL));
|
||||
for (int column = 0; column < columns.size(); column++) {
|
||||
Column source = columns.get(column);
|
||||
long base = percentBase(columns, column, request);
|
||||
@@ -193,6 +181,7 @@ public class StatisticsAggregationService {
|
||||
column + 1,
|
||||
source.total().size(),
|
||||
StatisticsArithmetic.round(totalPercent, request.getPercentageDecimals()),
|
||||
base == 0 ? null : totalPercent,
|
||||
source.total().size(),
|
||||
request));
|
||||
}
|
||||
@@ -207,6 +196,11 @@ public class StatisticsAggregationService {
|
||||
for (int choice = 0; choice < index.getChoices().size(); choice++) {
|
||||
String value = index.getChoices().get(choice).value();
|
||||
String label = request.isShowValueCodes() ? value : index.label(value);
|
||||
if (KartConstant.SIBLING_BASE_MODE.equals(request.getMode())
|
||||
&& index.getDimensionId().isEmpty()
|
||||
&& !request.isShowValueCodes()) {
|
||||
label = "%";
|
||||
}
|
||||
List<StatisticsCellDto> cells = new ArrayList<>();
|
||||
cells.add(StatisticsTableService.text(0, label));
|
||||
for (int column = 0; column < columns.size(); column++) {
|
||||
@@ -229,12 +223,12 @@ public class StatisticsAggregationService {
|
||||
StatisticsRequestDto request) {
|
||||
String type = index.getQuestion().getQtype();
|
||||
if ("num".equals(type)) {
|
||||
addStatistic(rows, columns, index, MEAN, request);
|
||||
for (String statistic : NUMERIC_STATISTICS) {
|
||||
addStatistic(rows, columns, index, KartConstant.MEAN, request);
|
||||
for (String statistic : KartConstant.NUMERIC_STATISTICS) {
|
||||
addStatistic(rows, columns, index, statistic, request);
|
||||
}
|
||||
if (request.isShowNumericSum()) {
|
||||
addStatistic(rows, columns, index, SUM, request);
|
||||
addStatistic(rows, columns, index, KartConstant.SUM, request);
|
||||
}
|
||||
}
|
||||
if ("scale".equals(type)) {
|
||||
@@ -244,7 +238,7 @@ public class StatisticsAggregationService {
|
||||
addGroup(rows, columns, index, group.getLabel(), group.getValues(), request);
|
||||
}
|
||||
if ("scale".equals(type) && !isNps(index)) {
|
||||
addStatistic(rows, columns, index, MEAN, request);
|
||||
addStatistic(rows, columns, index, KartConstant.MEAN, request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +247,7 @@ public class StatisticsAggregationService {
|
||||
* its sibling columns: ids equal except for a last character that is a digit.
|
||||
*/
|
||||
private long percentBase(List<Column> columns, int column, StatisticsRequestDto request) {
|
||||
if (!SIBLING_BASE_MODE.equals(request.getMode()) || column == 0) {
|
||||
if (!KartConstant.SIBLING_BASE_MODE.equals(request.getMode()) || column == 0) {
|
||||
return columns.get(column).total().size();
|
||||
}
|
||||
String id = columns.get(column).id();
|
||||
@@ -271,7 +265,7 @@ public class StatisticsAggregationService {
|
||||
StatisticsDimension index, List<Column> columns, StatisticsRequestDto request) {
|
||||
List<StatisticsRowDto> rows = new ArrayList<>();
|
||||
List<StatisticsCellDto> totalCells = new ArrayList<>();
|
||||
totalCells.add(StatisticsTableService.text(0, CASE_COUNT_LABEL));
|
||||
totalCells.add(StatisticsTableService.text(0, KartConstant.CASE_COUNT_LABEL));
|
||||
for (int column = 0; column < columns.size(); column++) {
|
||||
double totalPercent = 0;
|
||||
for (int row = 1; row < columns.size(); row++) {
|
||||
@@ -283,6 +277,7 @@ public class StatisticsAggregationService {
|
||||
column + 1,
|
||||
columns.get(column).total().size(),
|
||||
StatisticsArithmetic.round(totalPercent, request.getPercentageDecimals()),
|
||||
columns.get(column).total().isEmpty() ? null : totalPercent,
|
||||
columns.get(column).total().size(),
|
||||
request));
|
||||
}
|
||||
@@ -345,7 +340,7 @@ public class StatisticsAggregationService {
|
||||
StatisticsDimension index,
|
||||
String statistic,
|
||||
StatisticsRequestDto request) {
|
||||
boolean mean = MEAN.equals(statistic);
|
||||
boolean mean = KartConstant.MEAN.equals(statistic);
|
||||
int decimals = mean ? request.getStatisticDecimals() : request.getPercentageDecimals();
|
||||
List<StatisticsCellDto> cells = new ArrayList<>();
|
||||
cells.add(StatisticsTableService.text(0, statistic));
|
||||
@@ -361,6 +356,7 @@ public class StatisticsAggregationService {
|
||||
.kind(rounded == null ? "MISSING" : "STATISTIC")
|
||||
.measurement(statistic.toUpperCase(Locale.ROOT))
|
||||
.statisticValue(rounded)
|
||||
.statisticExact(value == null ? null : StatisticsArithmetic.round(value, KartConstant.EXCEL_DECIMALS))
|
||||
.statisticDisplayText(StatisticsArithmetic.display(rounded, decimals))
|
||||
.build());
|
||||
}
|
||||
@@ -422,7 +418,7 @@ public class StatisticsAggregationService {
|
||||
/** Statistic over ascending values. */
|
||||
private Double calculate(List<Double> values, String statistic) {
|
||||
if (values.isEmpty()) {
|
||||
return SUM.equals(statistic) ? 0.0 : null;
|
||||
return KartConstant.SUM.equals(statistic) ? 0.0 : null;
|
||||
}
|
||||
int middle = values.size() / 2;
|
||||
return switch (statistic) {
|
||||
@@ -444,7 +440,7 @@ public class StatisticsAggregationService {
|
||||
values.forEach(value -> counts.merge(value, 1, Integer::sum));
|
||||
yield counts.entrySet().stream().max(Map.Entry.comparingByValue()).orElseThrow().getKey();
|
||||
}
|
||||
case SUM -> values.stream().mapToDouble(Double::doubleValue).sum();
|
||||
case KartConstant.SUM -> values.stream().mapToDouble(Double::doubleValue).sum();
|
||||
default -> throw new IllegalArgumentException("Unknown statistic");
|
||||
};
|
||||
}
|
||||
@@ -471,7 +467,7 @@ public class StatisticsAggregationService {
|
||||
}
|
||||
boolean nps = isNps(index);
|
||||
int[] groupSizes = scaleGroupSizes(values.size(), nps);
|
||||
if (nps && values.size() != NPS_SCALE_SIZE) {
|
||||
if (nps && values.size() != KartConstant.NPS_SCALE_SIZE) {
|
||||
throw BusinessException.badRequest("NPS 문항은 결측을 제외한 11개 척도 값이 필요합니다.");
|
||||
}
|
||||
String[] labels = nps ? NPS_GROUP_LABELS : SCALE_GROUP_LABELS;
|
||||
@@ -538,12 +534,18 @@ public class StatisticsAggregationService {
|
||||
: StatisticsArithmetic.round(
|
||||
promoters.getPercent() - detractors.getPercent(),
|
||||
request.getPercentageDecimals());
|
||||
long base = columns.get(column - 1).total().size();
|
||||
Double exact =
|
||||
base == 0
|
||||
? null
|
||||
: promoters.getCount() * 100.0 / base - detractors.getCount() * 100.0 / base;
|
||||
cells.add(
|
||||
cell(
|
||||
column,
|
||||
promoters.getCount() - detractors.getCount(),
|
||||
percent,
|
||||
columns.get(column - 1).total().size(),
|
||||
exact,
|
||||
base,
|
||||
request)
|
||||
.toBuilder()
|
||||
.measurement("NPS")
|
||||
@@ -590,7 +592,14 @@ public class StatisticsAggregationService {
|
||||
? null
|
||||
: StatisticsArithmetic.round(
|
||||
count * 100.0 / source.total().size(), request.getPercentageDecimals());
|
||||
cells.add(cell(column + 1, count, percent, source.total().size(), request));
|
||||
cells.add(
|
||||
cell(
|
||||
column + 1,
|
||||
count,
|
||||
percent,
|
||||
source.total().isEmpty() ? null : count * 100.0 / source.total().size(),
|
||||
source.total().size(),
|
||||
request));
|
||||
}
|
||||
rows.add(new StatisticsRowDto(rows.size(), label, "GROUP", cells));
|
||||
}
|
||||
@@ -614,7 +623,7 @@ public class StatisticsAggregationService {
|
||||
}
|
||||
|
||||
private String columnKind(Column column) {
|
||||
if (column.id().equals(TOTAL_COLUMN_ID)) {
|
||||
if (column.id().equals(KartConstant.TOTAL_COLUMN_ID)) {
|
||||
return "TOTAL";
|
||||
}
|
||||
return column.subtotal() ? "SUBTOTAL" : "VALUE";
|
||||
@@ -626,17 +635,23 @@ public class StatisticsAggregationService {
|
||||
base == 0
|
||||
? 0.0
|
||||
: StatisticsArithmetic.round(count * 100.0 / base, request.getPercentageDecimals());
|
||||
return cell(column, count, percent, base, request);
|
||||
return cell(column, count, percent, base == 0 ? null : count * 100.0 / base, base, request);
|
||||
}
|
||||
|
||||
private StatisticsCellDto cell(
|
||||
int column, long count, Double percent, long base, StatisticsRequestDto request) {
|
||||
int column,
|
||||
long count,
|
||||
Double percent,
|
||||
Double exact,
|
||||
long base,
|
||||
StatisticsRequestDto request) {
|
||||
// TODO(weighting): keep the legacy non-weighted count location for a separately approved phase.
|
||||
return StatisticsCellDto.builder()
|
||||
.columnIndex(column)
|
||||
.kind("VALUE")
|
||||
.count(count)
|
||||
.percent(percent)
|
||||
.percentExact(exact == null ? null : StatisticsArithmetic.round(exact, KartConstant.EXCEL_DECIMALS))
|
||||
.base(base)
|
||||
.countDisplayText(Long.toString(count))
|
||||
.percentDisplayText(StatisticsArithmetic.display(percent, request.getPercentageDecimals()))
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kri.common.feature.json.JsonUtil;
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.question.QuestionDto;
|
||||
import com.kri.kart.server.dto.statistics.SurveyResponseDto;
|
||||
import java.util.ArrayList;
|
||||
@@ -12,16 +13,12 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StatisticsDimensionService {
|
||||
private static final String ATTRIBUTE_PROJECTION_SUFFIX = "#A";
|
||||
private static final Set<String> OPEN_QUESTION_TYPES = Set.of("num", "text");
|
||||
private static final Set<String> UNSUPPORTED_QUESTION_TYPES = Set.of("com", "come");
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@@ -36,15 +33,15 @@ public class StatisticsDimensionService {
|
||||
return wholeSample();
|
||||
}
|
||||
id = id.toUpperCase(Locale.ROOT);
|
||||
boolean projection = id.endsWith(ATTRIBUTE_PROJECTION_SUFFIX);
|
||||
boolean projection = id.endsWith(KartConstant.ATTRIBUTE_PROJECTION_SUFFIX);
|
||||
String qid =
|
||||
projection ? id.substring(0, id.length() - ATTRIBUTE_PROJECTION_SUFFIX.length()) : id;
|
||||
projection ? id.substring(0, id.length() - KartConstant.ATTRIBUTE_PROJECTION_SUFFIX.length()) : id;
|
||||
QuestionDto question =
|
||||
questions.stream()
|
||||
.filter(row -> qid.equalsIgnoreCase(row.getQid()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> BusinessException.badRequest("집계 문항을 찾을 수 없습니다: " + qid));
|
||||
if (UNSUPPORTED_QUESTION_TYPES.contains(question.getQtype())) {
|
||||
if (KartConstant.UNSUPPORTED_QUESTION_TYPES.contains(question.getQtype())) {
|
||||
throw BusinessException.badRequest("com 문항은 기존 집계에서도 지원하지 않습니다.");
|
||||
}
|
||||
JsonNode attributeInfo = metadata(question.getAttrInfo());
|
||||
@@ -62,7 +59,7 @@ public class StatisticsDimensionService {
|
||||
rankCount = metadata(question.getRankInfo()).path("val").asInt(0);
|
||||
} else if (attributeQuestion) {
|
||||
// Q1 (or open Q1_2) covers every attribute; Q1_A (or open Q1_2_A) selects attribute A.
|
||||
boolean open = OPEN_QUESTION_TYPES.contains(question.getQtype());
|
||||
boolean open = KartConstant.OPEN_QUESTION_TYPES.contains(question.getQtype());
|
||||
String[] parts = qid.split("_");
|
||||
if (!qid.contains("_") || (open && parts.length < 3)) {
|
||||
attributeInfo
|
||||
@@ -110,7 +107,7 @@ public class StatisticsDimensionService {
|
||||
|
||||
private List<StatisticsDimension.Choice> choices(
|
||||
QuestionDto question, String qid, boolean projection, List<SurveyResponseDto> responses) {
|
||||
if (!projection && OPEN_QUESTION_TYPES.contains(question.getQtype())) {
|
||||
if (!projection && KartConstant.OPEN_QUESTION_TYPES.contains(question.getQtype())) {
|
||||
return answeredChoices(question, qid, responses);
|
||||
}
|
||||
List<StatisticsDimension.Choice> choices = new ArrayList<>();
|
||||
@@ -170,12 +167,14 @@ public class StatisticsDimensionService {
|
||||
return;
|
||||
}
|
||||
for (JsonNode step : logic) {
|
||||
String condition = step.path("condition").asText();
|
||||
JsonNode conditionNode = step.path("condition");
|
||||
String condition =
|
||||
conditionNode.isTextual() ? conditionNode.asText() : conditionNode.toString();
|
||||
if (!"screen".equalsIgnoreCase(step.path("nextpage").asText())
|
||||
|| condition.toLowerCase(Locale.ROOT).contains("and")) {
|
||||
continue;
|
||||
}
|
||||
JsonNode conditions = parseJson(condition);
|
||||
JsonNode conditions = conditionNode.isArray() ? conditionNode : parseJson(condition);
|
||||
if (conditions == null || !conditions.isArray()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kri.kart.server.service.statistics;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.question.QuestionDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsFilterDto;
|
||||
import com.kri.kart.server.dto.statistics.SurveyResponseDto;
|
||||
@@ -17,25 +18,6 @@ import org.springframework.web.util.HtmlUtils;
|
||||
/** Compiles a filter AST into a respondent predicate. User input is never turned into SQL. */
|
||||
@Service
|
||||
public class StatisticsFilterService {
|
||||
private static final int MAX_DEPTH = 32;
|
||||
private static final int MAX_GROUP_CHILDREN = 128;
|
||||
private static final Set<String> GROUP_OPERATORS = Set.of("AND", "OR", "NOT");
|
||||
private static final Set<String> CONDITION_OPERATORS =
|
||||
Set.of(
|
||||
"EQ",
|
||||
"NE",
|
||||
"GT",
|
||||
"GE",
|
||||
"LT",
|
||||
"LE",
|
||||
"IN",
|
||||
"NOT_IN",
|
||||
"BETWEEN",
|
||||
"IS_ANSWERED",
|
||||
"IS_UNANSWERED");
|
||||
private static final Set<String> NEGATED_OPERATORS = Set.of("NE", "NOT_IN", "IS_UNANSWERED");
|
||||
// Returned by order() when a numeric operand cannot be compared with a non-numeric answer.
|
||||
private static final int NOT_COMPARABLE = Integer.MIN_VALUE;
|
||||
|
||||
public Predicate<SurveyResponseDto> compile(
|
||||
StatisticsFilterDto filter, List<QuestionDto> questions) {
|
||||
@@ -71,12 +53,12 @@ public class StatisticsFilterService {
|
||||
private Predicate<SurveyResponseDto> compile(
|
||||
StatisticsFilterDto filter, List<QuestionDto> questions, int depth) {
|
||||
if (filter == null
|
||||
|| depth > MAX_DEPTH
|
||||
|| depth > KartConstant.STATISTICS_FILTER_MAX_DEPTH
|
||||
|| filter.getChildren() == null
|
||||
|| filter.getValues() == null) {
|
||||
throw BusinessException.badRequest("필터 구조가 올바르지 않습니다.");
|
||||
}
|
||||
if (GROUP_OPERATORS.contains(Objects.toString(filter.getOperator(), ""))) {
|
||||
if (KartConstant.FILTER_GROUP_OPERATORS.contains(Objects.toString(filter.getOperator(), ""))) {
|
||||
return compileGroup(filter, questions, depth);
|
||||
}
|
||||
return compileCondition(filter, questions);
|
||||
@@ -88,7 +70,7 @@ public class StatisticsFilterService {
|
||||
List<StatisticsFilterDto> children = filter.getChildren();
|
||||
if (children.isEmpty()
|
||||
|| ("NOT".equals(operator) && children.size() != 1)
|
||||
|| children.size() > MAX_GROUP_CHILDREN
|
||||
|| children.size() > KartConstant.STATISTICS_FILTER_MAX_GROUP_CHILDREN
|
||||
|| !filter.getValues().isEmpty()
|
||||
|| StringUtil.hasText(filter.getDimensionId())) {
|
||||
throw BusinessException.badRequest("필터 그룹의 조건 개수가 올바르지 않습니다.");
|
||||
@@ -105,7 +87,7 @@ public class StatisticsFilterService {
|
||||
private Predicate<SurveyResponseDto> compileCondition(
|
||||
StatisticsFilterDto filter, List<QuestionDto> questions) {
|
||||
String operator = filter.getOperator();
|
||||
if (!CONDITION_OPERATORS.contains(Objects.toString(operator, ""))
|
||||
if (!KartConstant.FILTER_CONDITION_OPERATORS.contains(Objects.toString(operator, ""))
|
||||
|| !filter.getChildren().isEmpty()) {
|
||||
throw BusinessException.badRequest("지원하지 않는 필터 연산자입니다.");
|
||||
}
|
||||
@@ -119,7 +101,7 @@ public class StatisticsFilterService {
|
||||
.filter(entry -> matchingKey(qid, entry.getKey()))
|
||||
.anyMatch(entry -> compare(entry.getValue(), operator, filter.getValues()));
|
||||
// Legacy negative multi conditions are NOT EXISTS of a matching value, including missing keys.
|
||||
return NEGATED_OPERATORS.contains(operator) ? predicate.negate() : predicate;
|
||||
return KartConstant.FILTER_NEGATED_OPERATORS.contains(operator) ? predicate.negate() : predicate;
|
||||
}
|
||||
|
||||
private boolean hasValidValues(String operator, List<JsonNode> values) {
|
||||
@@ -171,7 +153,7 @@ public class StatisticsFilterService {
|
||||
return order(actual, operands.get(0)) >= 0 && order(actual, operands.get(1)) <= 0;
|
||||
}
|
||||
int comparison = order(actual, operands.get(0));
|
||||
if (comparison == NOT_COMPARABLE) {
|
||||
if (comparison == KartConstant.FILTER_NOT_COMPARABLE) {
|
||||
return false;
|
||||
}
|
||||
return switch (operator) {
|
||||
@@ -187,7 +169,7 @@ public class StatisticsFilterService {
|
||||
private int order(String actual, JsonNode expected) {
|
||||
if (expected.isNumber()) {
|
||||
Double number = StatisticsArithmetic.number(actual);
|
||||
return number == null ? NOT_COMPARABLE : Double.compare(number, expected.asDouble());
|
||||
return number == null ? KartConstant.FILTER_NOT_COMPARABLE : Double.compare(number, expected.asDouble());
|
||||
}
|
||||
// SQL Server's existing collation is case-insensitive; DAT also contains FOR XML escaping.
|
||||
return HtmlUtils.htmlUnescape(actual)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kri.kart.server.service.statistics;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.kri.common.feature.json.JsonUtil;
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsBatchDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsStreamEventDto;
|
||||
import com.kri.kart.server.service.StatisticsService;
|
||||
@@ -20,7 +21,6 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter
|
||||
@Service
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class StatisticsStreamService {
|
||||
private static final long STREAM_TIMEOUT_MILLIS = 600_000L;
|
||||
|
||||
private final StatisticsService statisticsService;
|
||||
private final ObjectMapper objectMapper;
|
||||
@@ -36,7 +36,7 @@ public class StatisticsStreamService {
|
||||
}
|
||||
|
||||
public ResponseBodyEmitter stream(StatisticsBatchDto statisticsBatch) {
|
||||
ResponseBodyEmitter emitter = new ResponseBodyEmitter(STREAM_TIMEOUT_MILLIS);
|
||||
ResponseBodyEmitter emitter = new ResponseBodyEmitter(KartConstant.STREAM_TIMEOUT_MILLIS);
|
||||
AtomicBoolean cancelled = new AtomicBoolean();
|
||||
AtomicReference<Future<?>> task = new AtomicReference<>();
|
||||
Runnable cancel =
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kri.kart.server.service.statistics;
|
||||
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsCellDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsColumnDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsRequestDto;
|
||||
@@ -13,8 +14,6 @@ import org.springframework.stereotype.Service;
|
||||
/** Adds header rows to calculated rows and optionally transposes the whole table. */
|
||||
@Service
|
||||
public class StatisticsTableService {
|
||||
private static final String NO_HEADER_MODE = "NONE";
|
||||
private static final String FLAT_HEADER_MODE = "FLAT";
|
||||
|
||||
private record Layout(
|
||||
List<StatisticsColumnDto> columns,
|
||||
@@ -27,7 +26,7 @@ public class StatisticsTableService {
|
||||
List<StatisticsColumnDto> columns,
|
||||
List<StatisticsRowDto> body,
|
||||
StatisticsRequestDto request) {
|
||||
List<StatisticsRowDto> headers = headers(title, columns, request.getHeaderMode());
|
||||
List<StatisticsRowDto> headers = headers("", columns, request.getHeaderMode());
|
||||
Layout layout = new Layout(columns, headers, placeBelowHeaders(body, headers.size()));
|
||||
if (request.isTranspose()) {
|
||||
layout = transpose(layout);
|
||||
@@ -50,10 +49,10 @@ public class StatisticsTableService {
|
||||
*/
|
||||
public List<StatisticsRowDto> headers(
|
||||
String title, List<StatisticsColumnDto> columns, String mode) {
|
||||
if (NO_HEADER_MODE.equals(mode)) {
|
||||
if (KartConstant.NO_HEADER_MODE.equals(mode)) {
|
||||
return List.of();
|
||||
}
|
||||
boolean flat = FLAT_HEADER_MODE.equals(mode);
|
||||
boolean flat = KartConstant.FLAT_HEADER_MODE.equals(mode);
|
||||
int height =
|
||||
flat
|
||||
? 1
|
||||
@@ -75,7 +74,7 @@ public class StatisticsTableService {
|
||||
String label = row < labels.size() ? labels.get(row) : "";
|
||||
List<StatisticsCellDto> rowCells = cells.get(row);
|
||||
StatisticsCellDto previous = rowCells.isEmpty() ? null : rowCells.get(rowCells.size() - 1);
|
||||
if (canMergeWithPrevious(previous, columns, column, row)) {
|
||||
if (canMergeWithPrevious(previous, columns, column, row, height)) {
|
||||
rowCells.set(
|
||||
rowCells.size() - 1, previous.toBuilder().colSpan(previous.getColSpan() + 1).build());
|
||||
} else {
|
||||
@@ -102,15 +101,18 @@ public class StatisticsTableService {
|
||||
|
||||
/** Merge adjacent anchors only when every parent label is also the same. */
|
||||
private boolean canMergeWithPrevious(
|
||||
StatisticsCellDto previous, List<StatisticsColumnDto> columns, int column, int row) {
|
||||
StatisticsCellDto previous, List<StatisticsColumnDto> columns, int column, int row, int height) {
|
||||
if (previous == null || column <= 1) {
|
||||
return false;
|
||||
}
|
||||
List<String> labels = columns.get(column).getLabels();
|
||||
List<String> previousLabels = columns.get(column - 1).getLabels();
|
||||
boolean stretches = row == Math.max(1, labels.size()) - 1 && height - row > 1;
|
||||
return previous.getRowSpan() == 1
|
||||
&& !stretches
|
||||
&& previous.getColumnIndex() + previous.getColSpan() == column
|
||||
&& labels.size() == previousLabels.size()
|
||||
&& row < labels.size()
|
||||
&& row < previousLabels.size()
|
||||
&& labels.subList(0, row + 1).equals(previousLabels.subList(0, row + 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kri.kart.server.service.statistics;
|
||||
|
||||
import com.kri.kart.server.common.consts.KartConstant;
|
||||
import com.kri.kart.server.dto.project.ProjectRefDto;
|
||||
import com.kri.kart.server.dto.statistics.NlpTokenDto;
|
||||
import com.kri.kart.server.dto.statistics.StatisticsWordDto;
|
||||
@@ -22,8 +23,6 @@ import org.springframework.web.util.HtmlUtils;
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
|
||||
public class StatisticsTextService {
|
||||
private static final int TOP_WORD_LIMIT = 100;
|
||||
private static final String FOREIGN_WORD_TAG = "SL";
|
||||
|
||||
private final NlpRepository nlpRepository;
|
||||
private final KiwiNlpService kiwiNlpService;
|
||||
@@ -44,7 +43,7 @@ public class StatisticsTextService {
|
||||
// Stable sort: equal counts keep their first-appearance order.
|
||||
return counts.entrySet().stream()
|
||||
.sorted(Map.Entry.<NlpTokenDto, Long>comparingByValue().reversed())
|
||||
.limit(TOP_WORD_LIMIT)
|
||||
.limit(KartConstant.TOP_WORD_LIMIT)
|
||||
.map(entry -> toWord(entry.getKey(), entry.getValue()))
|
||||
.toList();
|
||||
}
|
||||
@@ -78,6 +77,6 @@ public class StatisticsTextService {
|
||||
selectedTags.contains(token.tag())
|
||||
&& (token.tag().startsWith("N") || token.text().length() > 1);
|
||||
// Preserve SL inclusion regardless of the configured tags and its one-character allowance.
|
||||
return selected || FOREIGN_WORD_TAG.equals(token.tag());
|
||||
return selected || KartConstant.FOREIGN_WORD_TAG.equals(token.tag());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,9 +88,18 @@ public class QuestionImportService {
|
||||
qtype = "attr";
|
||||
stype = "AM1";
|
||||
}
|
||||
// Preserve uppercase-only max capture and the original nested option.option shape.
|
||||
String max = row.get(2).equals("R") || row.get(2).equals("M") ? row.get(4) : "";
|
||||
// Rank metadata and structure must use the same count for both R and r.
|
||||
String max = type.equals("r") || row.get(2).equals("M") ? row.get(4) : "";
|
||||
int rankCount = 0;
|
||||
if (type.equals("r")) {
|
||||
try {
|
||||
rankCount = Integer.parseInt(max.trim());
|
||||
} catch (NumberFormatException exception) {
|
||||
throw BusinessException.badRequest("순위 문항의 최대 순위는 양의 정수로 입력해 주세요.");
|
||||
}
|
||||
if (rankCount < 1 || rankCount > labels.size()) {
|
||||
throw BusinessException.badRequest("순위 문항의 최대 순위는 1부터 보기 수까지 입력해 주세요.");
|
||||
}
|
||||
dataset.set("rank", objectMapper.createObjectNode().put("val", max).put("max", max));
|
||||
}
|
||||
ObjectNode option = objectMapper.createObjectNode();
|
||||
@@ -125,7 +134,7 @@ public class QuestionImportService {
|
||||
question.set("option", objectMapper.createObjectNode().set("option", option));
|
||||
}
|
||||
String qid = "Q" + (result.size() + 1);
|
||||
var structure = structure(qid, itemType, labels, attrs);
|
||||
var structure = structure(qid, type.equals("r") ? "rank" : itemType, labels, attrs, rankCount);
|
||||
result.add(
|
||||
new ImportQuestionDto(
|
||||
qid, result.size() + 1, legacyJson(question), structure.get(0), structure.get(1)));
|
||||
@@ -146,7 +155,8 @@ public class QuestionImportService {
|
||||
return json;
|
||||
}
|
||||
|
||||
private List<String> structure(String qid, String itemType, ObjectNode labels, ObjectNode attrs) {
|
||||
private List<String> structure(
|
||||
String qid, String itemType, ObjectNode labels, ObjectNode attrs, int rankCount) {
|
||||
var keys = objectMapper.createArrayNode();
|
||||
var info = objectMapper.createObjectNode();
|
||||
int attrCount = Math.max(1, attrs.size());
|
||||
@@ -156,9 +166,12 @@ public class QuestionImportService {
|
||||
for (int attr = 1; attr <= attrCount; attr++) {
|
||||
String suffix =
|
||||
attrs.isEmpty() ? "" : "_" + attrs.get(Integer.toString(attr)).get("value").asText();
|
||||
int count = itemType.equals("single") || itemType.equals("scale") ? 1 : labels.size();
|
||||
int count =
|
||||
itemType.equals("rank")
|
||||
? rankCount
|
||||
: itemType.equals("single") || itemType.equals("scale") ? 1 : labels.size();
|
||||
ObjectNode allLabels = objectMapper.createObjectNode();
|
||||
if (itemType.equals("single") || itemType.equals("scale")) {
|
||||
if (itemType.equals("single") || itemType.equals("scale") || itemType.equals("rank")) {
|
||||
labels.forEach(
|
||||
label -> allLabels.put(label.get("value").asText(), label.get("label").asText()));
|
||||
}
|
||||
@@ -167,7 +180,7 @@ public class QuestionImportService {
|
||||
String itemSuffix =
|
||||
itemType.equals("multi")
|
||||
? "_" + label.get("value").asText()
|
||||
: itemType.equals("open") ? "_" + item : "";
|
||||
: itemType.equals("open") || itemType.equals("rank") ? "_" + item : "";
|
||||
String key = qid + itemSuffix + suffix;
|
||||
if (info.has(key)) {
|
||||
throw BusinessException.badRequest("중복된 보기 값 또는 속성 값을 확인해 주세요.");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Bookmark">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.BookmarkMapper">
|
||||
<select id="list" databaseId="kart" resultType="com.kri.kart.server.dto.bookmark.BookmarkDto">
|
||||
SELECT BOOKMARK_ID, BOOKMARK_TITLE, BOOKMARK_INFO, BOOKMARK_JSON,
|
||||
GKEY, MKEY, IS_OPEN, CASE WHEN MKEY = #{userId} THEN '1' ELSE '0' END AS IS_MINE
|
||||
@@ -10,7 +10,7 @@
|
||||
ORDER BY BOOKMARK_ORDER
|
||||
</select>
|
||||
<select id="find" databaseId="kart" resultType="com.kri.kart.server.dto.bookmark.BookmarkDto">
|
||||
SELECT BOOKMARK_ID, BOOKMARK_TITLE, BOOKMARK_INFO, BOOKMARK_JSON, IS_OPEN
|
||||
SELECT BOOKMARK_ID, BOOKMARK_TITLE, BOOKMARK_INFO, BOOKMARK_JSON, IS_OPEN, MKEY
|
||||
FROM REPORT_BOOKMARK WHERE PKEY = #{pkey} AND BOOKMARK_ID = #{bookmarkId}
|
||||
</select>
|
||||
<insert id="create" databaseId="kart">
|
||||
@@ -27,16 +27,19 @@
|
||||
UPDATE REPORT_BOOKMARK SET BOOKMARK_TITLE = #{request.bookmarkTitle},
|
||||
BOOKMARK_INFO = #{request.bookmarkInfo}, BOOKMARK_JSON = #{request.bookmarkJson},
|
||||
IS_OPEN = #{request.isOpen}
|
||||
WHERE PKEY = #{pkey} AND BOOKMARK_ID = #{bookmarkId}
|
||||
WHERE PKEY = #{pkey} AND BOOKMARK_ID = #{bookmarkId} AND MKEY = #{userId}
|
||||
</update>
|
||||
<update id="shiftOrderAfterDelete" databaseId="kart">
|
||||
<![CDATA[
|
||||
UPDATE REPORT_BOOKMARK SET BOOKMARK_ORDER = BOOKMARK_ORDER - 1
|
||||
WHERE PKEY = #{pkey} AND BOOKMARK_ORDER >
|
||||
(SELECT BOOKMARK_ORDER FROM REPORT_BOOKMARK WHERE PKEY = #{pkey} AND BOOKMARK_ID = #{bookmarkId})
|
||||
WHERE PKEY = #{pkey}
|
||||
AND BOOKMARK_PAGE = (SELECT BOOKMARK_PAGE FROM REPORT_BOOKMARK
|
||||
WHERE PKEY = #{pkey} AND BOOKMARK_ID = #{bookmarkId} AND MKEY = #{userId})
|
||||
AND BOOKMARK_ORDER >
|
||||
(SELECT BOOKMARK_ORDER FROM REPORT_BOOKMARK WHERE PKEY = #{pkey} AND BOOKMARK_ID = #{bookmarkId} AND MKEY = #{userId})
|
||||
]]>
|
||||
</update>
|
||||
<delete id="delete" databaseId="kart">
|
||||
DELETE FROM REPORT_BOOKMARK WHERE PKEY = #{pkey} AND BOOKMARK_ID = #{bookmarkId}
|
||||
DELETE FROM REPORT_BOOKMARK WHERE PKEY = #{pkey} AND BOOKMARK_ID = #{bookmarkId} AND MKEY = #{userId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Derived">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.DerivedMapper">
|
||||
<select id="list" databaseId="survey" resultType="com.kri.kart.server.dto.question.QuestionDto">
|
||||
<![CDATA[
|
||||
SELECT QID, Qorder AS q_order, VARIABLE, TITLE,
|
||||
@@ -41,8 +41,8 @@
|
||||
FROM DERIVED_VARIABLE WHERE PKEY = #{pkey} ORDER BY Qorder
|
||||
</select>
|
||||
<select id="find" databaseId="survey" resultType="com.kri.kart.server.dto.derived.DerivedDefinitionDto">
|
||||
SELECT QID, QUESTIONJSON AS question_json, DERIVEDJSON AS derived_json, Qorder AS q_order
|
||||
FROM DERIVED_VARIABLE WHERE PKEY = #{pkey} AND QID = #{qid}
|
||||
SELECT QID, GKEY, QUESTIONJSON AS question_json, DERIVEDJSON AS derived_json, Qorder AS q_order
|
||||
FROM DERIVED_VARIABLE WITH(UPDLOCK, HOLDLOCK) WHERE PKEY = #{pkey} AND QID = #{qid}
|
||||
</select>
|
||||
<select id="duplicate" databaseId="survey" resultType="int">
|
||||
<![CDATA[
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Export">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.ExportMapper">
|
||||
<select id="additionalColumns" databaseId="survey" resultType="string">
|
||||
SELECT ISNULL(JSON_QUERY(PROJECTJSON, '$.add_column'), '[]')
|
||||
FROM PROJECT WHERE PKEY = #{pkey}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Import">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.ImportMapper">
|
||||
<select id="lockProject" databaseId="survey" resultType="string">
|
||||
SELECT PKEY FROM PROJECT WITH(UPDLOCK,HOLDLOCK) WHERE PKEY = #{pkey}
|
||||
</select>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Log">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.LogMapper">
|
||||
<insert id="loginLog" databaseId="kart">
|
||||
INSERT INTO dbo.TB_LOGIN_LOG(M_USER, L_IP) VALUES(#{userId}, #{clientIp})
|
||||
</insert>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Nlp">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.NlpMapper">
|
||||
<select id="tags" databaseId="kart" resultType="string">
|
||||
SELECT DISTINCT WORD_TAG FROM (
|
||||
SELECT WORD_TAG FROM dbo.REPORT_NLP_TAG WHERE PKEY = 'ALL'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Progress">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.ProgressMapper">
|
||||
<sql id="dateRange">
|
||||
<if test="startDate != null">
|
||||
<![CDATA[
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Project">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.ProjectMapper">
|
||||
<sql id="dinOwnerExclusion">
|
||||
<if test="excludedOwnerIds != null and !excludedOwnerIds.isEmpty()">
|
||||
AND MKEY NOT IN
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Question">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.QuestionMapper">
|
||||
<select id="list" databaseId="survey" resultType="com.kri.kart.server.dto.question.QuestionDto">
|
||||
<![CDATA[
|
||||
SELECT QID, Qorder AS q_order, VARIABLE, TITLE,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Quota">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.QuotaMapper">
|
||||
<select id="quotaSets" databaseId="survey" resultType="com.kri.kart.server.dto.quota.QuotaSetDto">
|
||||
<![CDATA[
|
||||
SELECT ID, QSORDER AS qs_order,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.ShareLink">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.ShareLinkMapper">
|
||||
<sql id="columns">ID, URL_KEY, REAL_URL, IS_PAGE_ONLY, SKEY, PKEY, PROJECT_TYPE, PROJECT_TITLE, URL_OWNER</sql>
|
||||
<select id="find" databaseId="kart" resultType="com.kri.kart.server.dto.share.ShareLinkRecordDto">
|
||||
SELECT <include refid="columns"/> FROM dbo.REPORT_URL
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.Statistics">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.StatisticsMapper">
|
||||
<select id="data" databaseId="survey" resultType="com.kri.kart.server.dto.statistics.StatisticsDataDto">
|
||||
<![CDATA[
|
||||
SELECT IA.IDKEY, DAT.DAT, DAT.filter_dat
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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="kart.User">
|
||||
<mapper namespace="com.kri.kart.server.persistence.mapper.UserMapper">
|
||||
<select id="findMember" databaseId="kart" resultType="com.kri.kart.server.dto.auth.ReportMemberDto">
|
||||
SELECT member_mail AS user_id, member_name AS user_name, member_redirect
|
||||
FROM REPORT_MEMBER
|
||||
|
||||
Reference in New Issue
Block a user