Search in sources :

Example 11 with ResponseResult

use of com.vartech.common.app.beans.ResponseResult in project varsql by varsqlinfo.

the class ExportServiceImpl method selectExportDbObjectInfo.

/**
 * @Method Name  : selectExportDbObjectInfo
 * @Method 설명 : db object info
 * @작성자   : ytkim
 * @작성일   : 2018. 8. 29.
 * @변경이력  :
 * @param preferencesInfo
 * @param mode
 * @param model
 * @return
 * @throws Exception
 */
public ResponseResult selectExportDbObjectInfo(DatabaseParamInfo databaseParam) throws Exception {
    MetaControlBean dbMetaEnum = MetaControlFactory.getDbInstanceFactory(databaseParam.getDbType());
    Map customParam = databaseParam.getCustom();
    String ddlObjInfo = String.valueOf(customParam.get("ddlObjInfo"));
    String[] objArr = ddlObjInfo.split(",");
    ResponseResult result = new ResponseResult();
    for (int i = 0; i < objArr.length; i++) {
        String mode = objArr[i];
        result.addCustoms(mode, dbMetaEnum.getDBObjectList(ObjectType.getDBObjectType(mode).getObjectTypeId(), databaseParam));
    }
    return result;
}
Also used : ResponseResult(com.vartech.common.app.beans.ResponseResult) MetaControlBean(com.varsql.core.db.MetaControlBean) ModelMap(org.springframework.ui.ModelMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 12 with ResponseResult

use of com.vartech.common.app.beans.ResponseResult in project varsql by varsqlinfo.

the class BoardService method commentSave.

/**
 * @Method Name  : commentSave
 * @Method 설명 : 코멘트 저장.
 * @작성자   : ytkim
 * @작성일   : 2021. 7. 8.
 * @변경이력  :
 * @param articleId
 * @param boardCommentRequestDTO
 * @return
 */
@Transactional(transactionManager = ResourceConfigConstants.APP_TRANSMANAGER, rollbackFor = Throwable.class)
public ResponseResult commentSave(long articleId, BoardCommentRequestDTO boardCommentRequestDTO) {
    BoardCommentEntity boardCommentEntity;
    boolean isNew = NumberUtils.isNullOrZero(boardCommentRequestDTO.getCommentId());
    boolean isReComment = false;
    if (isNew) {
        boardCommentEntity = boardCommentRequestDTO.toEntity();
        boardCommentEntity.setArticleId(articleId);
        boardCommentEntity.setAuthorName(SecurityUtil.loginInfo().getFullname());
        boardCommentEntity.setFileList(new ArrayList<BoardFileEntity>());
        // 대댓글
        isReComment = !NumberUtils.isNullOrZero(boardCommentRequestDTO.getParentCommentId());
        if (isReComment) {
            BoardCommentEntity parentBoardCommentEntity = boardCommentEntityRepository.findByArticleIdAndCommentId(articleId, boardCommentRequestDTO.getParentCommentId());
            if (parentBoardCommentEntity == null) {
                throw new BoardNotFoundException("parent comments not found : " + boardCommentRequestDTO.getParentCommentId());
            }
            boardCommentEntity.setIndent(parentBoardCommentEntity.getIndent() + 1);
            boardCommentEntity.setGrpCommentId(parentBoardCommentEntity.getGrpCommentId());
            boardCommentEntity.setGrpSeq(boardCommentEntityRepository.findByGrpSeqMaxQuery(parentBoardCommentEntity.getGrpCommentId()));
        } else {
        }
    } else {
        boardCommentEntity = boardCommentEntityRepository.findByArticleIdAndCommentId(articleId, boardCommentRequestDTO.getCommentId());
        if (!isCommentModify(boardCommentEntity)) {
            throw new BoardPermissionException("no permission");
        }
        boardCommentEntity.setContents(boardCommentRequestDTO.getContents());
        String fileIds = boardCommentRequestDTO.getRemoveFileIds();
        if (!StringUtils.isBlank(fileIds)) {
            boardFileEntityRepository.deleteByIdInQuery(Arrays.asList(fileIds.split(",")).stream().map(item -> {
                return Long.parseLong(item);
            }).collect(Collectors.toList()));
        }
    }
    if (boardCommentRequestDTO.getFile().size() > 0) {
        List<BoardFileEntity> boardFileList = boardCommentEntity.getFileList();
        fileUploadService.uploadFiles(UploadFileType.BOARD, boardCommentRequestDTO.getFile(), boardCommentRequestDTO.getCommentId() + "", boardCommentRequestDTO.getBoardCode(), "file", false, false).forEach(item -> {
            BoardFileEntity entity = BoardFileEntity.toBoardFileEntity(item);
            entity.setComment(boardCommentEntity);
            entity.setContType(COMMENT_CONT_TYPE);
            boardFileList.add(entity);
        });
        boardCommentEntity.setFileList(boardFileList);
    }
    BoardCommentEntity saveEntity = boardCommentEntityRepository.save(boardCommentEntity);
    if (isNew) {
        if (!isReComment) {
            saveEntity.setGrpCommentId(saveEntity.getCommentId());
            boardCommentEntityRepository.save(saveEntity);
        } else {
            boardCommentEntityRepository.updateGrpSeqQuery(saveEntity.getArticleId(), saveEntity.getGrpCommentId(), saveEntity.getCommentId(), saveEntity.getGrpSeq());
        }
    }
    ResponseResult result = VarsqlUtils.getResponseResultItemList(new ArrayList());
    result.setItemOne(1);
    return result;
}
Also used : BoardCommentEntity(com.varsql.web.model.entity.board.BoardCommentEntity) BoardPermissionException(com.varsql.web.exception.BoardPermissionException) BoardFileEntity(com.varsql.web.model.entity.board.BoardFileEntity) ResponseResult(com.vartech.common.app.beans.ResponseResult) ArrayList(java.util.ArrayList) BoardNotFoundException(com.varsql.web.exception.BoardNotFoundException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with ResponseResult

use of com.vartech.common.app.beans.ResponseResult in project varsql by varsqlinfo.

the class BoardService method saveBoardInfo.

/**
 * @Method Name  : saveBoardInfo
 * @Method 설명 : 게시물 정보 저장.
 * @작성자   : ytkim
 * @작성일   : 2021. 7. 1.
 * @변경이력  :
 * @param boardRequestDTO
 * @return
 */
@Transactional(transactionManager = ResourceConfigConstants.APP_TRANSMANAGER, rollbackFor = Throwable.class)
public ResponseResult saveBoardInfo(BoardRequestDTO boardRequestDTO) {
    BoardEntity boardEntity;
    if (NumberUtils.isNullOrZero(boardRequestDTO.getArticleId())) {
        boardEntity = boardRequestDTO.toEntity();
        boardEntity.setAuthorName(SecurityUtil.loginInfo().getFullname());
        boardEntity.setFileList(new ArrayList<BoardFileEntity>());
    } else {
        boardEntity = boardEntityRepository.findByArticleId(boardRequestDTO.getArticleId());
        if (!isModify(boardEntity)) {
            throw new BoardPermissionException("no permission");
        }
        boardEntity.setTitle(boardRequestDTO.getTitle());
        boardEntity.setContents(boardRequestDTO.getContents());
        String fileIds = boardRequestDTO.getRemoveFileIds();
        if (!StringUtils.isBlank(fileIds)) {
            boardFileEntityRepository.deleteByIdInQuery(Arrays.asList(fileIds.split(",")).stream().map(item -> {
                return Long.parseLong(item);
            }).collect(Collectors.toList()));
        }
    }
    if (boardRequestDTO.getFile() != null && boardRequestDTO.getFile().size() > 0) {
        List<BoardFileEntity> boardFileList = boardEntity.getFileList();
        fileUploadService.uploadFiles(UploadFileType.BOARD, boardRequestDTO.getFile(), boardRequestDTO.getArticleId() + "", boardRequestDTO.getBoardCode(), "file", false, false).forEach(item -> {
            BoardFileEntity entity = BoardFileEntity.toBoardFileEntity(item);
            entity.setArticle(boardEntity);
            entity.setContType(BOARD_CONT_TYPE);
            boardFileList.add(entity);
        });
        boardEntity.setFileList(boardFileList);
    }
    boardEntityRepository.save(boardEntity);
    ResponseResult result = VarsqlUtils.getResponseResultItemList(new ArrayList());
    result.setItemOne(1);
    return result;
}
Also used : BoardPermissionException(com.varsql.web.exception.BoardPermissionException) BoardFileEntity(com.varsql.web.model.entity.board.BoardFileEntity) ResponseResult(com.vartech.common.app.beans.ResponseResult) ArrayList(java.util.ArrayList) BoardEntity(com.varsql.web.model.entity.board.BoardEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with ResponseResult

use of com.vartech.common.app.beans.ResponseResult in project varsql by varsqlinfo.

the class DbDiffServiceImpl method objectTypeList.

/**
 * @Method Name  : objectTypeList
 * @Method 설명 : db object type list (table , view 등등)
 * @작성자   : ytkim
 * @작성일   : 2019. 1. 2.
 * @변경이력  :
 * @param vconnid
 * @return
 * @throws SQLException
 */
public ResponseResult objectTypeList(String vconnid) throws SQLException {
    ResponseResult resultObject = new ResponseResult();
    DBConnectionEntity vtConnRVO = dbConnectionEntityRepository.findByVconnid(vconnid);
    if (vtConnRVO == null) {
        resultObject.setResultCode(RequestResultCode.ERROR);
        resultObject.setItemList(null);
    } else {
        MetaControlBean dbMetaEnum = MetaControlFactory.getDbInstanceFactory(vtConnRVO.getDbTypeDriverProvider().getDbType());
        resultObject.setItemList(dbMetaEnum.getServiceMenu());
        resultObject.addCustoms("schemaInfo", dbMetaEnum.getSchemas(getDatabaseParamInfo(vtConnRVO)));
    }
    return resultObject;
}
Also used : ResponseResult(com.vartech.common.app.beans.ResponseResult) DBConnectionEntity(com.varsql.web.model.entity.db.DBConnectionEntity) MetaControlBean(com.varsql.core.db.MetaControlBean)

Example 15 with ResponseResult

use of com.vartech.common.app.beans.ResponseResult in project varsql by varsqlinfo.

the class UserMgmtServiceImpl method updateAccept.

/**
 * @Method Name  : updateAccept
 * @Method 설명 : 사용자 수락 거부 .
 * @작성자   : ytkim
 * @작성일   : 2017. 12. 1.
 * @변경이력  :
 * @param paramMap
 * @return
 */
@Transactional(value = ResourceConfigConstants.APP_TRANSMANAGER, rollbackFor = Exception.class)
public ResponseResult updateAccept(String acceptyn, String selectItem) {
    String[] viewidArr = StringUtils.split(selectItem, ",");
    AuthorityType role = "Y".equals(acceptyn) ? AuthorityType.USER : AuthorityType.GUEST;
    List<UserEntity> users = userMgmtRepository.findByViewidIn(Arrays.asList(viewidArr)).stream().map(item -> {
        item.setUserRole(role.name());
        item.setAcceptYn("Y".equals(acceptyn) ? true : false);
        return item;
    }).collect(Collectors.toList());
    userMgmtRepository.saveAll(users);
    return VarsqlUtils.getResponseResultItemOne(1);
}
Also used : Arrays(java.util.Arrays) UserEntity(com.varsql.web.model.entity.user.UserEntity) Configuration(com.varsql.core.configuration.Configuration) ResourceConfigConstants(com.varsql.web.constants.ResourceConfigConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) UUIDUtil(com.varsql.core.common.util.UUIDUtil) ResponseResult(com.vartech.common.app.beans.ResponseResult) DBGroupEntityRepository(com.varsql.web.repository.db.DBGroupEntityRepository) VarsqlUtils(com.varsql.web.util.VarsqlUtils) ParamMap(com.vartech.common.app.beans.ParamMap) SecurityUtil(com.varsql.core.common.util.SecurityUtil) DBBlockingUserEntity(com.varsql.web.model.entity.db.DBBlockingUserEntity) Service(org.springframework.stereotype.Service) MessageDTO(com.varsql.web.dto.websocket.MessageDTO) Qualifier(org.springframework.beans.factory.annotation.Qualifier) UserMgmtRepository(com.varsql.web.repository.user.UserMgmtRepository) EncryptDecryptException(com.vartech.common.crypto.EncryptDecryptException) DBManagerSpec(com.varsql.web.repository.spec.DBManagerSpec) SearchParameter(com.vartech.common.app.beans.SearchParameter) DBGroupMappingUserEntityRepository(com.varsql.web.repository.db.DBGroupMappingUserEntityRepository) PasswordUtil(com.vartech.common.crypto.password.PasswordUtil) AbstractService(com.varsql.web.common.service.AbstractService) UserDBConnectionEntityRepository(com.varsql.web.repository.user.UserDBConnectionEntityRepository) MessageType(com.varsql.web.constants.MessageType) StringUtils(com.vartech.common.utils.StringUtils) RequestResultCode(com.vartech.common.constants.RequestResultCode) Page(org.springframework.data.domain.Page) DBGroupSpec(com.varsql.web.repository.spec.DBGroupSpec) Collectors(java.util.stream.Collectors) WebSocketServiceImpl(com.varsql.web.app.websocket.service.WebSocketServiceImpl) UserSpec(com.varsql.web.repository.spec.UserSpec) List(java.util.List) PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) DBManagerEntityRepository(com.varsql.web.repository.db.DBManagerEntityRepository) DBBlockingUserEntityRepository(com.varsql.web.repository.db.DBBlockingUserEntityRepository) AuthorityType(com.varsql.core.auth.AuthorityType) Transactional(org.springframework.transaction.annotation.Transactional) UserMapper(com.varsql.web.model.mapper.user.UserMapper) AuthorityType(com.varsql.core.auth.AuthorityType) UserEntity(com.varsql.web.model.entity.user.UserEntity) DBBlockingUserEntity(com.varsql.web.model.entity.db.DBBlockingUserEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ResponseResult (com.vartech.common.app.beans.ResponseResult)75 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)15 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 Transactional (org.springframework.transaction.annotation.Transactional)12 MetaControlBean (com.varsql.core.db.MetaControlBean)10 DBTypeDriverProviderEntity (com.varsql.web.model.entity.db.DBTypeDriverProviderEntity)8 HashMap (java.util.HashMap)8 DBConnectionEntity (com.varsql.web.model.entity.db.DBConnectionEntity)6 EncryptDecryptException (com.vartech.common.crypto.EncryptDecryptException)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 ObjectError (org.springframework.validation.ObjectError)6 FileInfoEntity (com.varsql.web.model.entity.app.FileInfoEntity)5 SQLException (java.sql.SQLException)5 FileInfo (com.varsql.core.common.beans.FileInfo)4 JDBCDriverInfo (com.varsql.core.connection.beans.JDBCDriverInfo)4 DBMetadataException (com.varsql.core.exception.DBMetadataException)4 DBTypeDriverEntity (com.varsql.web.model.entity.db.DBTypeDriverEntity)4