Search in sources :

Example 21 with ResponseResult

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

the class VarsqlCommonController method invalidLogin.

/**
 * @Method Name  : invalidLogin
 * @Method 설명 : 로그인 유효하지 않을때.
 * @작성자   : ytkim
 * @작성일   : 2018. 2. 28.
 * @변경이력  :
 * @param req
 * @param res
 * @param mav
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/invalidLogin")
@ResponseBody
public ResponseResult invalidLogin(HttpServletRequest req, HttpServletResponse res, ModelAndView mav) throws Exception {
    ResponseResult result = new ResponseResult();
    result.setStatus(500);
    result.setMessage("invalidLogin");
    result.setResultCode(RequestResultCode.LOGIN_INVALID);
    return result;
}
Also used : ResponseResult(com.vartech.common.app.beans.ResponseResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 22 with ResponseResult

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

the class UserPreferencesServiceImpl method updatePasswordInfo.

/**
 * @Method Name  : updatePasswordInfo
 * @Method 설명 : 비밀번호 변경.
 * @작성자   : ytkim
 * @작성일   : 2017. 11. 29.
 * @변경이력  :
 * @param passwordForm
 * @param resultObject
 * @return
 * @throws EncryptDecryptException
 */
public ResponseResult updatePasswordInfo(PasswordRequestDTO passwordForm) throws EncryptDecryptException {
    UserEntity userInfo = userMgmtRepository.findByViewid(SecurityUtil.userViewId());
    ResponseResult resultObject = new ResponseResult();
    if (passwordEncoder.matches(passwordForm.getCurrPw(), userInfo.getUpw())) {
        userInfo.setUpw(passwordForm.getUpw());
        userMgmtRepository.save(userInfo);
        resultObject.setItemOne(1);
    } else {
        resultObject.setResultCode(VarsqlAppCode.COMM_PASSWORD_NOT_VALID);
    }
    return resultObject;
}
Also used : ResponseResult(com.vartech.common.app.beans.ResponseResult) UserEntity(com.varsql.web.model.entity.user.UserEntity)

Example 23 with ResponseResult

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

the class UserPreferencesServiceImpl method deleteQnaInfo.

/**
 * @Method Name  : deleteQnaInfo
 * @Method 설명 : qna 삭제.
 * @작성자   : ytkim
 * @작성일   : 2019. 1. 3.
 * @변경이력  :
 * @param paramMap
 * @return
 */
@Transactional(value = ResourceConfigConstants.APP_TRANSMANAGER, rollbackFor = Exception.class)
public ResponseResult deleteQnaInfo(String qnaid) {
    QnAEntity entity = qnaEntityRepository.findByQnaid(qnaid);
    if (entity.getAnswerId() == null) {
        qnaEntityRepository.delete(entity);
    }
    ResponseResult result = new ResponseResult();
    result.setMessageCode("answer.msg.notdelete");
    return result;
}
Also used : QnAEntity(com.varsql.web.model.entity.app.QnAEntity) ResponseResult(com.vartech.common.app.beans.ResponseResult) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with ResponseResult

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

the class SqlUpdateExecutor method execute.

@Override
public SQLExecuteResult execute(SqlStatementInfo statementInfo, AbstractSQLExecutorHandler resultHandler) throws SQLException {
    SQLExecuteResult result = new SQLExecuteResult();
    Map sqlParamMap = VartechUtils.jsonStringToObject(statementInfo.getSqlParam(), HashMap.class);
    ResponseResult parseInfo = SqlSourceBuilder.parseResponseResult(statementInfo.getSql(), sqlParamMap, DBType.getDBType(statementInfo.getDbType()));
    List<SqlSource> sqlList = parseInfo.getItems();
    result.setStartTime(System.currentTimeMillis());
    SqlSource tmpSqlSource = null;
    int sqlIdx = 0, sqlSize = sqlList.size();
    int addCount = 0;
    Connection conn = null;
    Statement statement = null;
    try {
        conn = ConnectionFactory.getInstance().getConnection(statementInfo.getVconnid());
        conn.setAutoCommit(false);
        statement = conn.createStatement();
        boolean handleFlag = (resultHandler != null);
        for (sqlIdx = 0; sqlIdx < sqlSize; sqlIdx++) {
            tmpSqlSource = sqlList.get(sqlIdx);
            if (handleFlag) {
                resultHandler.addTotalCount();
                if (!resultHandler.handle(SQLHandlerParameter.builder().sql(tmpSqlSource.getQuery()).parameter(sqlParamMap).build())) {
                    continue;
                }
            }
            ;
            statement.addBatch(tmpSqlSource.getQuery());
            addCount++;
            if (addCount % getBatchCount() == 0) {
                statement.executeBatch();
                statement.clearBatch();
            }
        }
        if (addCount % getBatchCount() != 0) {
            statement.executeBatch();
            statement.clearBatch();
        }
        conn.commit();
    } catch (Throwable e) {
        if (conn != null)
            conn.rollback();
        result.setResultCode(VarsqlAppCode.EC_SQL_EXECUTOR);
        result.setMessage("errorLine : " + sqlIdx + ", error message :  " + e.getMessage());
        logger.error("update : {} ", e.getMessage(), e);
    } finally {
        if (conn != null) {
            conn.setAutoCommit(true);
            JdbcUtils.close(conn, statement);
        }
    }
    result.setTotalCount(resultHandler.getTotalCount());
    result.setEndTime(System.currentTimeMillis());
    result.setExecuteCount(addCount);
    result.setResult(addCount);
    return result;
}
Also used : SqlSource(com.varsql.core.sql.builder.SqlSource) Statement(java.sql.Statement) ResponseResult(com.vartech.common.app.beans.ResponseResult) Connection(java.sql.Connection) HashMap(java.util.HashMap) Map(java.util.Map)

Example 25 with ResponseResult

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

the class VarsqlFormatterUtil method formatResponseResult.

public static ResponseResult formatResponseResult(String sql, DBType dbType, FORMAT_TYPE format_type) {
    ResponseResult result = new ResponseResult();
    String resultSql = "";
    sql = new SQLCommentRemoveConverter().convert(sql, dbType);
    if (format_type.equals(FORMAT_TYPE.VARSQL)) {
        resultSql = new VarsqlFormatterImpl().execute(sql);
    // resultSql = SqlFormatter.format(sql);
    } else {
        try {
            resultSql = com.varsql.core.sql.util.SQLParserUtils.getParserString(sql, dbType);
        } catch (Exception e) {
            resultSql = new VarsqlFormatterImpl().execute(sql);
            result.setMessage(e.getMessage());
        }
    }
    // resultSql = Native2Ascii.asciiToNative(resultSql);
    result.setItemOne(resultSql + BlankConstants.NEW_LINE);
    return result;
}
Also used : ResponseResult(com.vartech.common.app.beans.ResponseResult) SQLCommentRemoveConverter(com.varsql.core.pattern.convert.SQLCommentRemoveConverter)

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