fix: cors Sesurity 적용

dev
minuk926 2 years ago
parent a8a62ebd06
commit fbcfb02931

@ -17,6 +17,7 @@ import com.xit.core.oauth2.oauth.JwtTokenProvider;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.BeanIds; import org.springframework.security.config.BeanIds;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
@ -183,6 +184,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
// GET, POST 요청시 : OPTIONS preflight 요청 - 실제 서버가 살아있는지를 사전에 확인하는 요청 // GET, POST 요청시 : OPTIONS preflight 요청 - 실제 서버가 살아있는지를 사전에 확인하는 요청
// Spring에서 OPTIONS에 대한 요청을 막고 있어 OPTIONS 요청이 왔을 때도 오류를 리턴하지 않도록 설정 // Spring에서 OPTIONS에 대한 요청을 막고 있어 OPTIONS 요청이 왔을 때도 오류를 리턴하지 않도록 설정
.requestMatchers(CorsUtils::isPreFlightRequest).permitAll() .requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
.mvcMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.antMatchers( .antMatchers(
"/", "/",
"/favicon.ico", "/favicon.ico",

@ -1,113 +0,0 @@
package com.xit.biz.ctgy.repository;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.xit.core.util.DateUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import java.time.LocalDate;
import java.util.List;
import static com.xit.biz.ctgy.entity.QMinSimsa680.minSimsa680;
import static com.xit.biz.ctgy.entity.QMinSimsaUser680.minSimsaUser680;
import static com.xit.biz.ctgy.entity.QMinUserinfo.minUserinfo;
@SpringBootTest
@Transactional
@ActiveProfiles({"dev"})
class IMinJudge680RepositoryTest {
@Autowired
EntityManager em;
private JPAQueryFactory queryFactory;
@BeforeEach
void beforeEach(){
queryFactory = new JPAQueryFactory(em);
}
@AfterEach
void afterEach(){
}
@Test
@DisplayName("sim_result:심사목록에서 기간 클릭시")
void sim_result() {
//LocalDate now = LocalDate.now();
LocalDate now = LocalDate.of(2021, 12, 11);
LocalDate now2 = LocalDate.of(2021, 12, 12);
queryFactory
.select(minSimsa680.msSeq,
minSimsa680.msCarnum,
minSimsa680.msMaincode)
.from(minSimsaUser680)
.join(minSimsa680)
.on(minSimsa680.msMaincode.eq(minSimsaUser680.msuMaincode))
.join(minUserinfo)
.on(minSimsaUser680.msuUserid.eq(minUserinfo.userid))
.where(minSimsaUser680.msuTeam.eq(""),
minSimsa680.msChasu.eq(1L),
minSimsa680.msSdate.eq(now),
minSimsa680.msEdate.eq(now2))
.groupBy(minSimsa680.msCarnum,
minSimsa680.msSeq,
minSimsa680.msMaincode)
.orderBy(minSimsa680.msSeq.asc())
.offset(0L)
.limit(10L)
//, minSimsa680.msSdate.eq(java.sql.Date.valueOf(now)))
.fetchResults();
}
@Test
void judgeDetailsTest() {
BooleanBuilder builder = new BooleanBuilder();
builder.and(minSimsa680.msSdate.gt(DateUtil.parseLocalDate("2021-09-10")).or(minSimsa680.msSdate.eq(DateUtil.parseLocalDate("2021-09-10"))));
builder.and(minSimsa680.msEdate.lt(DateUtil.parseLocalDate("2021-09-11")).or(minSimsa680.msEdate.eq(DateUtil.parseLocalDate("2021-09-11"))));
// builder.and(minSimsaUser680.msuTeam.eq(dto.getMsuTeam()));
List<MinSimsa680> rslt =
queryFactory
.select(Projections.fields(MinSimsa680.class,
minSimsa680.msSeq,
minSimsa680.msCarnum,
minSimsa680.msMaincode))
.from(minSimsaUser680)
.join(minSimsa680)
.on(minSimsa680.msMaincode.eq(minSimsaUser680.msuMaincode))
.join(minUserinfo)
.on(minSimsaUser680.msuUserid.eq(minUserinfo.userid))
.where(builder)
.groupBy(minSimsa680.msCarnum,
minSimsa680.msSeq,
minSimsa680.msMaincode)
.orderBy(minSimsa680.msSeq.asc())
.fetch();
}
// @BeforeAll
// void beforeAll(){
// log.debug("initializing...");
// }
// @AfterAll
// void afterAll(){
// log.debug("...shutdown");
// }
}

@ -1,236 +0,0 @@
package com.xit.biz.ctgy.repository;
import com.querydsl.core.types.Expression;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.xit.biz.ctgy.entity.QGnRecallSc;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import java.lang.reflect.Modifier;
import java.sql.Date;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static com.xit.biz.ctgy.entity.QMinSimsa680.minSimsa680;
import static com.xit.biz.ctgy.entity.QMinSimsaUser680.minSimsaUser680;
import static com.xit.biz.ctgy.entity.QMinUserinfo.minUserinfo;
@SpringBootTest
@Transactional
@ActiveProfiles({"dev"})
@Slf4j
class RecallRepositoryTest {
@Autowired
EntityManager em;
private JPAQueryFactory queryFactory;
@BeforeEach
void beforeEach(){
queryFactory = new JPAQueryFactory(em);
}
@AfterEach
void afterEach(){
}
@Test
void dddd(){
QGnRecallSc qGnRecallSc = QGnRecallSc.gnRecallSc;
final List<Expression<?>> columns = Arrays.stream(QGnRecallSc.class.getDeclaredFields())
.filter(field -> !Modifier.isStatic(field.getModifiers()))
.map(field -> {
try {
return (Expression<?>) field.get(qGnRecallSc);
}
catch (final Exception e) {
log.trace("should never happen", e);
return null;
}
})
.collect(Collectors.toList());
log.debug("{}", qGnRecallSc);
// Adding transient fields
// CollectionUtils.addAll(columns, new Expression[] { qOtherBean, qStupidJoinBean });
}
@Test
@DisplayName("sim_result:심사목록에서 기간 클릭시")
void sim_reg() {
/*
"SELECT COUNT(*) CNT FROM TF680_MAIN INNER JOIN TF680_RECALL ON (MM_CODE=RC_MAINCODE)
WHERE MM_DBGB = '11' AND MM_LSTATE != '75' AND RC_GB = '1' AND RC_STATE = '0'
AND RC_SEQ >= '""& rtxtsNum &""' AND RC_SEQ <= '""& rtxteNum &""' AND RC_IR_TRANSFER = '""& rstTrans &""'"""
*/
/*
SELECTROWNUM, RC_SEQ, MM_OCARNO, MM_NCARNO, RC_NAME, GET_RECALL_CONTID(RC_CONT_DOC) CONTDOC,
RC_DATE, Get_Recall_Ingb_Str(RC_INGB) INGB
FROM TF680_MAIN INNER JOIN TF680_RECALL ON (MM_CODE=RC_MAINCODE)
WHERE MM_DBGB = '11' AND MM_LSTATE != '75'
AND RC_GB = '1' AND RC_STATE = '0' AND RC_SEQ >= '"& rtxtsNum &"' AND RC_SEQ <= '"& rtxteNum &"' "
AND RC_IR_TRANSFER = '"& rstTrans &"' ORDER BY RC_SEQ
*/
//LocalDate now = LocalDate.now();
LocalDate now = LocalDate.of(2021, 12, 11);
LocalDate now2 = LocalDate.of(2021, 12, 12);
queryFactory
.select(minSimsa680.msSeq,
minSimsa680.msCarnum,
minSimsa680.msMaincode)
.from(minSimsaUser680)
.join(minSimsa680)
.on(minSimsa680.msMaincode.eq(minSimsaUser680.msuMaincode))
.join(minUserinfo)
.on(minSimsaUser680.msuUserid.eq(minUserinfo.userid))
.where(minSimsaUser680.msuTeam.eq(""),
minSimsa680.msChasu.eq(1L),
minSimsa680.msSdate.eq(now),
minSimsa680.msEdate.eq(now2))
.groupBy(minSimsa680.msCarnum,
minSimsa680.msSeq,
minSimsa680.msMaincode)
.orderBy(minSimsa680.msSeq.asc())
.offset(0L)
.limit(10L)
//, minSimsa680.msSdate.eq(java.sql.Date.valueOf(now)))
.fetchResults();
// jpaQueryFactory.selectFrom(minSimsa680)
// .leftJoin(minSimsa680.msMaincode, minSimsaUser680).fetchJoin()
// .groupBy(minSimsa680.msEdate, minSimsaUser680.msuTeam, qMinUserinfo.name)
// .orderBy(minSimsa680.msChasu.desc())
// //.where(minSimsa680.name.eq(name))
// .fetch();
}
@Test
void resultMapReturn(){
/*
SELECT TM.MM_CODE,
TR.RC_CODE,
TR.RC_SEQ,
TM.MM_OCARNO,
TM.MM_NCARNO,
TR.RC_NAME,
TR.RC_CONT_DOC,
-- (1:, 2:, 3:, 4:, 5:, 6:, 7:, 8:, 9:, 10:, 11:, 12:, 13:, 14:)
CASE WHEN TR.RC_CONT_DOC = '1' THEN ''
WHEN TR.RC_CONT_DOC = '2' THEN ''
WHEN TR.RC_CONT_DOC = '3' THEN ''
WHEN TR.RC_CONT_DOC = '4' THEN ''
WHEN TR.RC_CONT_DOC = '5' THEN ''
WHEN TR.RC_CONT_DOC = '6' THEN ''
WHEN TR.RC_CONT_DOC = '7' THEN ''
WHEN TR.RC_CONT_DOC = '8' THEN ''
WHEN TR.RC_CONT_DOC = '9' THEN ''
WHEN TR.RC_CONT_DOC = '10' THEN ''
WHEN TR.RC_CONT_DOC = '11' THEN ''
WHEN TR.RC_CONT_DOC = '12' THEN ''
WHEN TR.RC_CONT_DOC = '13' THEN ''
WHEN TR.RC_CONT_DOC = '14' THEN ''
ELSE ''
END AS RC_COND_DOC_STR,
TCCS2.CODE_NM,
TR.RC_DATE,
-- (1:, 2:, 3:, 4:, 5:, 6:, 7:ARS, 8:, 9:)
TR.RC_INGB,
CASE WHEN TR.RC_INGB = '1' THEN ''
WHEN TR.RC_INGB = '2' THEN ''
WHEN TR.RC_INGB = '3' THEN ''
WHEN TR.RC_INGB = '4' THEN ''
WHEN TR.RC_INGB = '5' THEN ''
WHEN TR.RC_INGB = '6' THEN ''
WHEN TR.RC_INGB = '7' THEN 'ARS'
WHEN TR.RC_INGB = '8' THEN ''
WHEN TR.RC_INGB = '9' THEN ''
ELSE ''
END AS RC_INGB_STR,
TCCS1.CODE_NM
FROM TF680_MAIN TM
JOIN TF680_RECALL TR ON TM.MM_CODE = TR.RC_MAINCODE
LEFT JOIN TB_CMM_CODE_S TCCS1 ON TR.RC_INGB = TCCS1.CODE_CD
AND TCCS1.CODE_GRP_ID = 'TRAFFIC'
AND TCCS1.CODE_LCD = 'GANGNAM_SIMSA'
AND TCCS1.CODE_MCD = 'RC_INGB'
LEFT JOIN TB_CMM_CODE_S TCCS2 ON TR.RC_CONT_DOC = TCCS2.CODE_CD
AND TCCS2.CODE_GRP_ID = 'TRAFFIC'
AND TCCS2.CODE_LCD = 'GANGNAM_SIMSA'
AND TCCS2.CODE_MCD = 'RC_CONT_DOC'
WHERE MM_DBGB = '11' -- : 11-' 12-
AND MM_LSTATE != '75' -- 10:,11:,12:,13:,21:,49:,51:,52:,53:,54:,55:,61:,62:,65:,71:,72:,73:,74:,75:,81:,82:,91:,92:,98:,99:)
AND RC_GB = '1' -- : 1- 2-
AND RC_STATE = '0' -- (0:, 1:, 2:, 3:-OCR , 5:, 7:, 8:, 9:)
-- AND RC_SEQ >= '"& rtxtsNum &"'
-- AND RC_SEQ <= '"& rtxteNum &"'
AND RC_IR_TRANSFER = '1' -- : 1- 2-
order by RC_SEQ;
*/
// Map<String, Object> rsltMap = em.createQuery("SELECT new map(TM.MM_CODE as mmCode," +
// " TR.RC_CODE as rcCode, " +
// " TR.RC_SEQ as rcSeq, " +
// " TM.MM_OCARNO as mmOcarno, " +
// " TM.MM_NCARNO as mmNcarno " +
// " FROM TF680_MAIN TM " +
// " JOIN TF680_RECALL TR ON TM.MM_CODE = TR.RC_MAINCODE " +
// " LEFT JOIN TB_CMM_CODE_S TCCS1 ON TR.RC_INGB = TCCS1.CODE_CD " +
// " AND TCCS1.CODE_GRP_ID = 'TRAFFIC' " +
// " AND TCCS1.CODE_LCD = 'GANGNAM_SIMSA' " +
// " AND TCCS1.CODE_MCD = 'RC_INGB' " +
// " LEFT JOIN TB_CMM_CODE_S TCCS2 ON TR.RC_CONT_DOC = TCCS2.CODE_CD " +
// " AND TCCS2.CODE_GRP_ID = 'TRAFFIC' " +
// " AND TCCS2.CODE_LCD = 'GANGNAM_SIMSA' " +
// " AND TCCS2.CODE_MCD = 'RC_CONT_DOC' " +
// " WHERE MM_DBGB = '11' " +
// " AND MM_LSTATE != '75' " +
// " AND RC_GB = '1' " +
// " AND RC_STATE = '0' " +
// " AND RC_IR_TRANSFER = '1' " +
// " order by RC_SEQ "
// , Tuple.class
// ).getResultList()
// .stream()
// .collect(
// Collectors.toMap(
// tuple -> ((Long) tuple.get("MM_CODE")).,
// tuple -> ((Long) tuple.get("RC_CODE"),
// )
// )
//
// }
// @BeforeAll
// void beforeAll(){
// log.debug("initializing...");
// }
// @AfterAll
// void afterAll(){
// log.debug("...shutdown");
}
}

@ -1,55 +0,0 @@
package com.xit.biz.ctgy.repository;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import static com.xit.biz.ctgy.entity.QMinSimsa680.minSimsa680;
@SpringBootTest
@Transactional
@ActiveProfiles({"dev"})
@Slf4j
public class RepositoryTest {
@Autowired
EntityManager em;
private JPAQueryFactory queryFactory;
// @BeforeAll
// void beforeAll(){
// log.debug("initializing...");
// }
// @AfterAll
// void afterAll(){
// log.debug("...shutdown");
// }
@BeforeEach
void beforeEach(){
log.debug("biz start...");
queryFactory = new JPAQueryFactory(em);
}
@AfterEach
void afterEach(){
log.debug("... biz end");
}
@Test
void querydslTest() {
//QMinSimsa680 qMinSimsa680 = new QMinSimsa680("minSimsa680");
MinSimsa680 simsa680 = queryFactory.selectFrom(minSimsa680)
.where(minSimsa680.msMaincode.eq(300297013L))
.fetchOne();
System.out.println("##################################"+simsa680);
}
}
Loading…
Cancel
Save