fix: dashboard 현황 조회 대상 심의전으로 fix

dev
minuk926 2 years ago
parent 15bc59f3d9
commit cdfa528f01

@ -72,6 +72,12 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jdbc' implementation 'org.springframework.boot:spring-boot-starter-jdbc'
// mybatis
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
//implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter'
// config
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.3' implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.3'
// spring-boot 2.3 - spring-boot-starter-web // spring-boot 2.3 - spring-boot-starter-web
@ -103,7 +109,7 @@ dependencies {
// Mybatis // Mybatis
//-----------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------//
implementation 'org.mybatis:mybatis:3.5.9' implementation 'org.mybatis:mybatis:3.5.9'
implementation 'org.mybatis:mybatis-typehandlers-jsr310:1.0.2' //implementation 'org.mybatis:mybatis-typehandlers-jsr310:1.0.2'
implementation 'org.mybatis:mybatis-spring:2.0.6' implementation 'org.mybatis:mybatis-spring:2.0.6'
//-----------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------//

@ -48,35 +48,34 @@ public class BoardController {
final BoardDto dto, final BoardDto dto,
@Parameter(hidden = true) @Parameter(hidden = true)
final Pageable pageable) { final Pageable pageable) {
//return RestResponse.of(service.findAll(dto, pageable)); return RestResponse.of(service.findAll(dto, pageable));
return RestResponse.of(service.findAllTest(dto));
} }
@Secured(policy = SecurityPolicy.TOKEN) // @Secured(policy = SecurityPolicy.TOKEN)
@Operation(summary = "게시글 조회수 증가" , description = "게시글 조회수 증가") // @Operation(summary = "게시글 조회수 증가" , description = "게시글 조회수 증가")
@Parameters({ // @Parameters({
@Parameter(in = ParameterIn.PATH, name = "ciCode", description = "게시글번호", required = true, example = "18"), // @Parameter(in = ParameterIn.PATH, name = "ciCode", description = "게시글번호", required = true, example = "18"),
}) // })
@PutMapping(value = "/hit/{ciCode}", produces = MediaType.APPLICATION_JSON_VALUE) // @PutMapping(value = "/hit/{ciCode}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<? extends IRestResponse> modifyByCiCode(@PathVariable final Long ciCode) { // public ResponseEntity<? extends IRestResponse> modifyByCiCode(@PathVariable final Long ciCode) {
return RestResponse.of(service.modifyByCiCode(ciCode)); // return RestResponse.of(service.modifyByCiCode(ciCode));
} // }
//
@Secured(policy = SecurityPolicy.TOKEN) // @Secured(policy = SecurityPolicy.TOKEN)
@Operation(summary = "게시글 등록" , description = "게시글 등록") // @Operation(summary = "게시글 등록" , description = "게시글 등록")
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) // @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<? extends IRestResponse> saveBoard(BoardDto dto) { // public ResponseEntity<? extends IRestResponse> saveBoard(BoardDto dto) {
service.saveBoard(dto); // service.saveBoard(dto);
return RestResponse.of(HttpStatus.OK); // return RestResponse.of(HttpStatus.OK);
} // }
//
@Secured(policy = SecurityPolicy.TOKEN) // @Secured(policy = SecurityPolicy.TOKEN)
@Operation(summary = "게시글 삭제", description = "게시글 삭제") // @Operation(summary = "게시글 삭제", description = "게시글 삭제")
@PostMapping(value = "/{ciCode}") // @PostMapping(value = "/{ciCode}")
public ResponseEntity<? extends IRestResponse> removeBoard(@PathVariable @Nonnull final Long ciCode) { // public ResponseEntity<? extends IRestResponse> removeBoard(@PathVariable @Nonnull final Long ciCode) {
AssertUtils.isTrue(!Checks.isEmpty(ciCode), "게시글이 선택되지 않았습니다."); // AssertUtils.isTrue(!Checks.isEmpty(ciCode), "게시글이 선택되지 않았습니다.");
service.removeBoard(ciCode); // service.removeBoard(ciCode);
//
return RestResponse.of(HttpStatus.OK); // return RestResponse.of(HttpStatus.OK);
} // }
} }

@ -6,17 +6,17 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
import java.util.List;
public interface IBoardService { public interface IBoardService {
Page<BoardDto> findAll(final BoardDto dto, Pageable pageable); List<Map<String, Object>> findAll(final BoardDto dto, Pageable pageable);
Map<String, Object> findAllTest(final BoardDto dto); // Page<MinCivBoard680> findAll2(final MinCivBoard680 entity, Pageable pageable);
Page<MinCivBoard680> findAll2(final MinCivBoard680 entity, Pageable pageable); //
// int modifyByCiCode(Long ciCode);
int modifyByCiCode(Long ciCode); //
// void saveBoard(BoardDto dto);
void saveBoard(BoardDto dto); //
// void removeBoard(Long ciCode);
void removeBoard(Long ciCode);
} }

@ -14,6 +14,7 @@ import com.xit.core.util.Checks;
import com.xit.core.util.CommUtil; import com.xit.core.util.CommUtil;
import com.xit.core.util.mpower.MpowerUtil; import com.xit.core.util.mpower.MpowerUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import org.springframework.data.domain.Example; import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher; import org.springframework.data.domain.ExampleMatcher;
@ -30,19 +31,13 @@ import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatc
@Service @Service
@AllArgsConstructor @AllArgsConstructor
@Slf4j
public class BoardService implements IBoardService { public class BoardService implements IBoardService {
private final IBoardRepository repository;
private final PasswordEncoder passwordEncoder; private final PasswordEncoder passwordEncoder;
private final MinCivBoard680Mapstruct mapstruct = Mappers.getMapper(MinCivBoard680Mapstruct.class);
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Page<BoardDto> findAll(final BoardDto dto, Pageable pageable) { public List<Map<String, Object>> findAll(final BoardDto dto, Pageable pageable) {
pageable = JpaUtil.getPagingInfo(pageable);
return repository.findAll(dto, pageable);
}
@Transactional(readOnly = true)
public Map<String, Object> findAllTest(final BoardDto dto){
MpowerUtil sendXml = new MpowerUtil(); MpowerUtil sendXml = new MpowerUtil();
String query = "SELECT ci_code ciCode,\n" + String query = "SELECT ci_code ciCode,\n" +
" name ciName,\n" + " name ciName,\n" +
@ -80,63 +75,95 @@ public class BoardService implements IBoardService {
" 2)"; " 2)";
sendXml.setFeilds("ciCode, ciName, ciContentno, ciTitle, ciContents, ciNalja, ciStep, ciRevel, ciRef, ciHit, ciPass, ciId"); sendXml.setFeilds("ciCode, ciName, ciContentno, ciTitle, ciContents, ciNalja, ciStep, ciRevel, ciRef, ciHit, ciPass, ciId");
sendXml.setQuery(query); sendXml.setQuery(query);
Map<String,Object> eMap = sendXml.selectCustomQuery();
return eMap;
}
@Transactional(readOnly = true)
public Page<MinCivBoard680> findAll2(final MinCivBoard680 entity, Pageable pageable) {
pageable = JpaUtil.getPagingInfo(pageable);
ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll()
.withMatcher("ciTitle", contains())
.withMatcher("ciName", contains());
Example<MinCivBoard680> example = Example.of(entity, exampleMatcher);
return repository.findAll(example, pageable);
}
@Override
@Transactional
public int modifyByCiCode(Long ciCode) {
return repository.updateInHitForMinCivBoard680(ciCode);
}
@Override
@Transactional
public void saveBoard(BoardDto dto) {
MinCivBoard680 entity = null;
// update 인 경우 // SqlMapClientImpl sqlMapClientImpl;
if(Checks.isNotEmpty(dto.getCiCode())) { // MappedStatement mappedStatement;
entity = repository.findById(dto.getCiCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.DATA_NOT_FOUND)); // StatementScope statementScope;
if(!entity.getCiPass().equals(passwordEncoder.encode(dto.getCiPass()))){ // SessionScope sessionScope;
throw new CustomBaseException(ErrorCode.MISMATCH_PASSWORD); // Sql sql ;
} //
entity.setCiTitle(dto.getCiTitle()); // //ibatis에서 sqlMapClient인터페이스 구현체는 sqlMapClientImpl 밖에 없습니다. doc 참조
entity.setCiContents(dto.getCiContents()); // //다운캐스팅 합니다.
}else { // sqlMapClientImpl = (SqlMapClientImpl)this.sqlMapClientTemplate.getSqlMapClient();
dto.setCiCode(repository.getCiCode()); // //sqlmap statement 객체를 구합니다.
dto.setCiContentno(dto.getCiCode()); // mappedStatement = sqlMapClientImpl.getMappedStatement("selectMember");
if (Checks.isEmpty(dto.getCiRef()) || dto.getCiRef() == 0L) { //
dto.setCiRef(dto.getCiCode()); // //iBatis에서는 ThreadLocal를 통해서 세션을 정의합니다.
dto.setCiStep(0L); // sessionScope = new SessionScope();
dto.setCiRevel(0L); // statementScope = new StatementScope(sessionScope);
} // //이부분 매우 중요합니다. 이부분을 생략 하면 다이나믹 쿼리가 적용되지 않습니다.
dto.setCiPass(passwordEncoder.encode(dto.getCiPass())); // mappedStatement.initRequest(statementScope);
dto.setCiIp(CommUtil.getDeviceInfo().getIp()); // //sql을 추출 합니다.
entity = mapstruct.toEntity(dto); // sql = mappedStatement.getSql();
} //
repository.save(entity); // if(logger.isDebugEnabled()){
} // logger.debug("======================="+
// sql.getSql(statementScope,parameterMap);
// }
@Override
@Transactional
public void removeBoard(Long ciCode) {
MinCivBoard680 savedEntity = repository.findById(ciCode).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND));
if(!Objects.equal(HeaderUtil.getUserId(), savedEntity.getCiId())) throw new CustomBaseException("삭제 권한(게시글 소유자)이 없는 사용자 입니다");
// 댓글 존재 여부 조회 return sendXml.selectCustomQuery();
List<MinCivBoard680> list = repository.findByCiRef(ciCode); //log.debug("{}", map);
if(list.size() > 1) throw new CustomBaseException("삭제 할 수 없는 게시글 입니다[댓글 존재]"); //return map.get("resultList");
repository.deleteById(ciCode);
} }
// @Transactional(readOnly = true)
// public Page<MinCivBoard680> findAll2(final MinCivBoard680 entity, Pageable pageable) {
// pageable = JpaUtil.getPagingInfo(pageable);
// ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll()
// .withMatcher("ciTitle", contains())
// .withMatcher("ciName", contains());
// Example<MinCivBoard680> example = Example.of(entity, exampleMatcher);
// return repository.findAll(example, pageable);
// }
//
// @Override
// @Transactional
// public int modifyByCiCode(Long ciCode) {
// return repository.updateInHitForMinCivBoard680(ciCode);
// }
//
// @Override
// @Transactional
// public void saveBoard(BoardDto dto) {
// MinCivBoard680 entity = null;
//
// // update 인 경우
// if(Checks.isNotEmpty(dto.getCiCode())) {
// entity = repository.findById(dto.getCiCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.DATA_NOT_FOUND));
// if(!entity.getCiPass().equals(passwordEncoder.encode(dto.getCiPass()))){
// throw new CustomBaseException(ErrorCode.MISMATCH_PASSWORD);
// }
// entity.setCiTitle(dto.getCiTitle());
// entity.setCiContents(dto.getCiContents());
// }else {
// dto.setCiCode(repository.getCiCode());
// dto.setCiContentno(dto.getCiCode());
// if (Checks.isEmpty(dto.getCiRef()) || dto.getCiRef() == 0L) {
// dto.setCiRef(dto.getCiCode());
// dto.setCiStep(0L);
// dto.setCiRevel(0L);
// }
// dto.setCiPass(passwordEncoder.encode(dto.getCiPass()));
// dto.setCiIp(CommUtil.getDeviceInfo().getIp());
// entity = mapstruct.toEntity(dto);
// }
// repository.save(entity);
// }
//
// @Override
// @Transactional
// public void removeBoard(Long ciCode) {
//
// MinCivBoard680 savedEntity = repository.findById(ciCode).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND));
// if(!Objects.equal(HeaderUtil.getUserId(), savedEntity.getCiId())) throw new CustomBaseException("삭제 권한(게시글 소유자)이 없는 사용자 입니다");
//
// // 댓글 존재 여부 조회
// List<MinCivBoard680> list = repository.findByCiRef(ciCode);
// if(list.size() > 1) throw new CustomBaseException("삭제 할 수 없는 게시글 입니다[댓글 존재]");
// repository.deleteById(ciCode);
// }
} }

@ -10,13 +10,10 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.*; import java.util.*;
//import org.apache.log4j.Logger;
//import com.gpki.util.Base64;
import com.plf.client.Client; import com.plf.client.Client;
import lombok.extern.slf4j.Slf4j;
//import egovframework.rte.psl.dataaccess.util.EgovMap; @Slf4j
public class MpowerUtil { public class MpowerUtil {
//DBName Properties //DBName Properties
// static String DbName2 = PropertiesUtil.getValue("Globals.DBName"); // static String DbName2 = PropertiesUtil.getValue("Globals.DBName");
@ -210,6 +207,8 @@ public class MpowerUtil {
mpower.setInput("SQLXML", query); mpower.setInput("SQLXML", query);
mpower.Request(); mpower.Request();
String result = mpower.getString("result", 0, 0); String result = mpower.getString("result", 0, 0);
System.out.println("#######$$$$$$$$$$$$$$$$$$"+result);
int row; int row;
if (result.equals("true")){ if (result.equals("true")){
row = mpower.getMaxRow("list1"); row = mpower.getMaxRow("list1");
@ -634,7 +633,7 @@ public class MpowerUtil {
* @ SELECT * @ SELECT
* @return * @return
*/ */
public Map<String,Object> selectCustomQuery() { public List<Map<String,Object>> selectCustomQuery() {
//EgovMap mListMap = new EgovMap(); //EgovMap mListMap = new EgovMap();
Map<String,Object> mListMap = new HashMap<>(); Map<String,Object> mListMap = new HashMap<>();
//배열로 넘어온 필드를 String 오브젝트로 변형 //배열로 넘어온 필드를 String 오브젝트로 변형
@ -652,7 +651,7 @@ public class MpowerUtil {
System.out.println("======"+query); System.out.println("======"+query);
//List<EgovMap> mList = new ArrayList<EgovMap>(); //List<EgovMap> mList = new ArrayList<EgovMap>();
List<Map> mList = new ArrayList<>(); List<Map<String,Object>> mList = new ArrayList<>();
int mListCount = 0; int mListCount = 0;
try { try {
mpower = new Client(hostip,port); mpower = new Client(hostip,port);
@ -660,6 +659,33 @@ public class MpowerUtil {
mpower.setInput("SQLXML", query); mpower.setInput("SQLXML", query);
mpower.Request(); mpower.Request();
String result = mpower.getString("result", 0, 0); String result = mpower.getString("result", 0, 0);
System.out.println("#######message = "+mpower.getMessage());
String s = mpower.getMessage();
// System.out.println(new String(s.getBytes("unicode"), "unicode"));
// System.out.println(new String(s.getBytes("utf-8"), "utf-8"));
// System.out.println(new String(s.getBytes("utf-16"), "utf-16"));
// System.out.println(new String(s.getBytes("euc-kr"), "euc-kr"));
// System.out.println(new String(s.getBytes("ksc5601"), "ksc5601"));
// System.out.println(new String(s.getBytes("ms949"), "ms949"));
// System.out.println(new String(s.getBytes("iso-8859-1"), "iso-8859-1"));
System.out.println(new String(s.getBytes("unicode"), "unicode"));
System.out.println(new String(s.getBytes("utf-8"), "utf-8"));
System.out.println(new String(s.getBytes("utf-16"), "utf-16"));
System.out.println(new String(s.getBytes("euc-kr"), "euc-kr"));
System.out.println(new String(s.getBytes("ksc5601"), "ksc5601"));
System.out.println(new String(s.getBytes("ms949"), "ms949"));
System.out.println(new String(s.getBytes("iso-8859-1"), "iso-8859-1"));
System.out.println("#######data:::result = "+mpower.getData("result"));
System.out.println("#######data:::result = "+mpower.getData("list1"));
System.out.println("#######$$$$$$$$$$$$$$$$$$"+result);
log.debug("#######$$$$$$$$$$$$$$$$$$====>>>>>>"+result);
int row; int row;
if (result.equals("true")){ if (result.equals("true")){
row = mpower.getMaxRow("list1"); row = mpower.getMaxRow("list1");
@ -676,7 +702,8 @@ public class MpowerUtil {
} }
mList.add(m); mList.add(m);
} }
mListMap.put("resultList", mList); //mListMap.put("resultList", mList);
//mList;
} }
} }
mpower.disconnect(); mpower.disconnect();
@ -688,7 +715,7 @@ public class MpowerUtil {
} }
String s = String.valueOf(mList); String s = String.valueOf(mList);
byte[] b = s.getBytes(StandardCharsets.UTF_8); byte[] b = s.getBytes(StandardCharsets.UTF_8);
return mListMap; return mList;
} }

Loading…
Cancel
Save