원천데이터 insert 샘플 커밋
This commit is contained in:
parent
f49f9b503f
commit
3a98060078
@ -36,6 +36,17 @@ public interface ComtsrcdataMapper {
|
|||||||
public int insertComtTabledataInfo(ComtTableVO vo) throws Exception;
|
public int insertComtTabledataInfo(ComtTableVO vo) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 원천데이터 테이블을 [comtsrcdatameta]테이블에 저장
|
||||||
|
*
|
||||||
|
* @param vo
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public int insertComtSrcdata(ComtsrcdataVO vo) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
// 원천데이터 jsonb type 테스트 용 샘플
|
||||||
public int updateDatasrc(ComtsrcdataVO vo) throws Exception;
|
public int updateDatasrc(ComtsrcdataVO vo) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public interface ComtsrcdataService {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public int insertComtSrcdataInfo(ComtsrcdataVO vo) throws Exception;
|
public int insertComtSrcdata(ComtsrcdataVO vo) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,6 +36,7 @@ public interface ComtsrcdataService {
|
|||||||
public int insertComtTabledataInfo(ComtTableVO vo) throws Exception;
|
public int insertComtTabledataInfo(ComtTableVO vo) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test
|
* test
|
||||||
*
|
*
|
||||||
@ -49,38 +50,4 @@ public interface ComtsrcdataService {
|
|||||||
ComtsrcdataDTO selectComtSrcData(ComtsrcdataVO vo) throws Exception;
|
ComtsrcdataDTO selectComtSrcData(ComtsrcdataVO vo) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Yaml 파일을 업데이트하기 위해 목록을 조회한다(pg_chameleon yaml용이나 차후 다른 용도로 쓰임이 있다 판단되면 수정)
|
|
||||||
// *
|
|
||||||
// * @param vo
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// List<DatabaseInfoVO> selectSysDbConnList(DatabaseInfoVO vo);
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * DB 연결 정보 검증(중복확인)
|
|
||||||
// *
|
|
||||||
// * @param vo
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// int checkDbConnInfo(DatabaseInfoVO vo);
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 스키마 내 테이블정보를 [inst_db_tbl_info] 테이블에 저장한다.
|
|
||||||
// *
|
|
||||||
// * @param tbVo
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// int insertDbTblInfo(TableInfoVO tbVo) throws Exception;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 컬럼 정보를 [inst_tbl_col_info] 테이블에 저장한다.
|
|
||||||
// *
|
|
||||||
// * @param colVo
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// public int insertTblColInfo(ColumnInfoVO colVo) throws Exception;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,15 +25,14 @@ public class ComtsrcdataServiceImpl extends EgovAbstractServiceImpl implements C
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertComtSrcdataInfo(ComtsrcdataVO vo) throws Exception {
|
public int insertComtSrcdata(ComtsrcdataVO vo) throws Exception {
|
||||||
return comtsrcdataMapper.insertComtSrcdataInfo(vo);
|
return comtsrcdataMapper.insertComtSrcdata(vo);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int insertComtTabledataInfo(ComtTableVO vo) throws Exception {
|
public int insertComtTabledataInfo(ComtTableVO vo) throws Exception {
|
||||||
return comtsrcdataMapper.insertComtTabledataInfo(vo);
|
return comtsrcdataMapper.insertComtTabledataInfo(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateDatasrc(ComtsrcdataVO vo) throws Exception {
|
public int updateDatasrc(ComtsrcdataVO vo) throws Exception {
|
||||||
return comtsrcdataMapper.updateDatasrc(vo);
|
return comtsrcdataMapper.updateDatasrc(vo);
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import egovframework.com.mtdata.comtsrcdata.dto.ComtsrcdataDTO;
|
|||||||
import egovframework.com.mtdata.comtsrcdata.service.ComtsrcdataService;
|
import egovframework.com.mtdata.comtsrcdata.service.ComtsrcdataService;
|
||||||
import egovframework.com.mtdata.comtsrcdata.vo.ComtsrcdataVO;
|
import egovframework.com.mtdata.comtsrcdata.vo.ComtsrcdataVO;
|
||||||
import egovframework.com.mtdata.database.vo.DatabaseInfoVO;
|
import egovframework.com.mtdata.database.vo.DatabaseInfoVO;
|
||||||
//import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api")
|
@RequestMapping("/api")
|
||||||
@ -26,12 +28,12 @@ public class ComtsrcdataController {
|
|||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(ComtsrcdataController.class);
|
private static final Logger log = LoggerFactory.getLogger(ComtsrcdataController.class);
|
||||||
|
|
||||||
|
// jsonb 데이터 업데이트 테스트 샘플
|
||||||
@RequestMapping("/comtsrcdataTest.do")
|
@RequestMapping("/comtsrcdataTest.do")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String insertDbConn(@ModelAttribute DatabaseInfoVO vo) throws Exception {
|
public String insertDbConn(@ModelAttribute DatabaseInfoVO vo) throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// jsonb 데이터 업데이트 테스트
|
|
||||||
ComtsrcdataVO comtvo = new ComtsrcdataVO();
|
ComtsrcdataVO comtvo = new ComtsrcdataVO();
|
||||||
comtvo.setSrcDataVl("{\"id\":\"1\", \"field1\":\"ccc\"}");
|
comtvo.setSrcDataVl("{\"id\":\"1\", \"field1\":\"ccc\"}");
|
||||||
int test = service.updateDatasrc(comtvo);
|
int test = service.updateDatasrc(comtvo);
|
||||||
@ -44,8 +46,8 @@ public class ComtsrcdataController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// jsonb 데이터 insert 테스트 샘플
|
||||||
@RequestMapping("/selectComtsrcdata.do")
|
@RequestMapping("/insertComtsrcdata.do")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String selectComtsrcdata( ) throws Exception {
|
public String selectComtsrcdata( ) throws Exception {
|
||||||
|
|
||||||
@ -55,19 +57,22 @@ public class ComtsrcdataController {
|
|||||||
String selectTableSql = "SELECT * FROM smku.test_table1";
|
String selectTableSql = "SELECT * FROM smku.test_table1";
|
||||||
Statement stmt = conn.createStatement();
|
Statement stmt = conn.createStatement();
|
||||||
ResultSet datas = stmt.executeQuery(selectTableSql);
|
ResultSet datas = stmt.executeQuery(selectTableSql);
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
while (datas.next()){
|
while (datas.next()){
|
||||||
|
Map<String, String> resultMap = new HashMap<>();
|
||||||
// JSONObject obj = new JSONObject();
|
ResultSetMetaData rsmd = datas.getMetaData();
|
||||||
// ResultSetMetaData rsmd = datas.getMetaData();
|
int colCnt = rsmd.getColumnCount();
|
||||||
// int coCnt = rsmd.getColumnCount();
|
for (int i=0; i<colCnt; i++) {
|
||||||
// for (int i=0; i<coCnt; i++) {
|
String columnName = rsmd.getColumnLabel(i+1);
|
||||||
// String columnName = rsmd.getColumnLabel(i+1);
|
String value = datas.getString(i+1);
|
||||||
// Object columnValue = datas.getObject(i+1);
|
resultMap.put(columnName, value);
|
||||||
// obj.put(columnName, columnValue);
|
}
|
||||||
// System.out.println(obj.toString());
|
obj.putAll(resultMap);
|
||||||
// }
|
ComtsrcdataVO vo = new ComtsrcdataVO();
|
||||||
|
vo.setExtrId(6);
|
||||||
|
vo.setSrcDataVl(obj.toString());
|
||||||
|
service.insertComtSrcdata(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "원천데이터 컨트롤러 ::";
|
return "원천데이터 컨트롤러 ::";
|
||||||
|
|||||||
@ -46,6 +46,15 @@
|
|||||||
values (#{srcDataMetaId}, #{srcDataId}, #{srcDataTblNm})
|
values (#{srcDataMetaId}, #{srcDataId}, #{srcDataTblNm})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertComtSrcdata" parameterType="ComtsrcdataVO">
|
||||||
|
<selectKey resultType="int" keyProperty="srcDataId" order="BEFORE">
|
||||||
|
SELECT nextval('comtsrcdata_extr_tbl_id_seq') as srcDataId
|
||||||
|
</selectKey>
|
||||||
|
insert into comtsrcdata (src_data_id, extr_id, src_data_vl)
|
||||||
|
values (#{srcDataId}, #{extrId}, ( (#{srcDataVl})::jsonb ) )
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
<update id="updateDatasrc" parameterType="ComtsrcdataVO">
|
<update id="updateDatasrc" parameterType="ComtsrcdataVO">
|
||||||
update comtsrcdata
|
update comtsrcdata
|
||||||
set src_data_vl= ( (#{srcDataVl})::jsonb )
|
set src_data_vl= ( (#{srcDataVl})::jsonb )
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user