Search in sources :

Example 71 with ResponseResult

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

the class PluginServiceImpl method historySearch.

/**
 * @Method Name  : historySearch
 * @Method 설명 : user sql history search
 * @작성자   : ytkim
 * @작성일   : 2018. 7. 24.
 * @변경이력  :
 * @param param
 * @return
 */
public ResponseResult historySearch(SearchParameter searchParameter) {
    Page<SqlHistoryEntity> result = sqlHistoryEntityRepository.findAll(SqlHistorySpec.userHisotryearch(String.valueOf(searchParameter.getCustomParam().get("conuid")), searchParameter), VarsqlUtils.convertSearchInfoToPage(searchParameter, SqlHistoryEntity.START_TIME));
    ResponseResult responseResult = new ResponseResult();
    responseResult.setItemList(result.getContent().stream().map(item -> {
        SqlHistoryResponseDTO sqlUserHistoryInfo = SqlHistoryMapper.INSTANCE.toDto(item);
        sqlUserHistoryInfo.setErrorLog(null);
        sqlUserHistoryInfo.setUsrIp(null);
        return sqlUserHistoryInfo;
    }).collect(Collectors.toList()));
    responseResult.setPage(PagingUtil.getPageObject(result.getTotalElements(), searchParameter));
    return responseResult;
}
Also used : ResponseResult(com.vartech.common.app.beans.ResponseResult) SqlHistoryResponseDTO(com.varsql.web.dto.sql.SqlHistoryResponseDTO) SqlHistoryEntity(com.varsql.web.model.entity.sql.SqlHistoryEntity)

Example 72 with ResponseResult

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

the class BoardController method save.

@RequestMapping(value = "{" + VarsqlParamConstants.BOARD_CODE + "}/save", method = RequestMethod.POST)
@ResponseBody
public ResponseResult save(@PathVariable(required = true, name = VarsqlParamConstants.BOARD_CODE) String boardCode, @Valid BoardRequestDTO boardRequestDTO, BindingResult result, HttpServletRequest req) throws Exception {
    boardCode = VarsqlUtils.getVonnid(req);
    ResponseResult resultObject = new ResponseResult();
    if (result.hasErrors()) {
        for (ObjectError errorVal : result.getAllErrors()) {
            logger.warn("### board save validation check {}", errorVal.toString());
        }
        return VarsqlUtils.getResponseResultValidItem(resultObject, result);
    }
    boardRequestDTO.setBoardCode(boardCode);
    return boardService.saveBoardInfo(boardRequestDTO);
}
Also used : ObjectError(org.springframework.validation.ObjectError) ResponseResult(com.vartech.common.app.beans.ResponseResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 73 with ResponseResult

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

the class UserMainController method connectionInfo.

/**
 * @Method Name  : connectionInfo
 * @Method 설명 : 사용자 권한 있는 db 정보.
 * @작성자   : ytkim
 * @작성일   : 2019. 8. 16.
 * @변경이력  :
 * @param req
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/connectionInfo", method = RequestMethod.POST)
@ResponseBody
public ResponseResult connectionInfo(HttpServletRequest req) throws Exception {
    ResponseResult resultObject = new ResponseResult();
    DatabaseUtils.reloadUserDatabaseInfo();
    Collection<DatabaseInfo> dataBaseInfo = SecurityUtil.loginInfo(req).getDatabaseInfo().values();
    List<HashMap<String, String>> databaseList = new ArrayList<>();
    dataBaseInfo.forEach(item -> {
        HashMap<String, String> addMap = new HashMap<>();
        addMap.put("uuid", item.getConnUUID());
        addMap.put("type", item.getType());
        addMap.put("name", item.getName());
        databaseList.add(addMap);
    });
    resultObject.setItemList(databaseList);
    return resultObject;
}
Also used : DatabaseInfo(com.varsql.core.db.valueobject.DatabaseInfo) HashMap(java.util.HashMap) ResponseResult(com.vartech.common.app.beans.ResponseResult) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 74 with ResponseResult

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

the class UserPreferencesController method passwordSave.

/**
 * @Method Name  : passwordSave
 * @Method 설명 : 비밀번호 변경.
 * @작성자   : ytkim
 * @작성일   : 2017. 11. 29.
 * @변경이력  :
 * @param passwordForm
 * @param result
 * @param req
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/passwordSave", method = RequestMethod.POST)
@ResponseBody
public ResponseResult passwordSave(@Valid PasswordRequestDTO passwordForm, BindingResult result, HttpServletRequest req) throws Exception {
    ResponseResult resultObject = new ResponseResult();
    if (result.hasErrors()) {
        for (ObjectError errorVal : result.getAllErrors()) {
            logger.warn("###  UserMainController passwordSave check {}", errorVal.toString());
        }
        resultObject = VarsqlUtils.getResponseResultValidItem(resultObject, result);
    } else {
        passwordForm.setViewid(SecurityUtil.userViewId(req));
        resultObject = userPreferencesServiceImpl.updatePasswordInfo(passwordForm);
    }
    return resultObject;
}
Also used : ObjectError(org.springframework.validation.ObjectError) ResponseResult(com.vartech.common.app.beans.ResponseResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 75 with ResponseResult

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

the class DatabaseController method dbObjectList.

/**
 * @Method Name  : dbObjectList
 * @Method 설명 : db object list
 * @작성자   : ytkim
 * @작성일   : 2017. 11. 6.
 * @변경이력  :
 * @param databaseParamInfo
 * @param mav
 * @param req
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/dbObjectList", method = RequestMethod.POST)
@ResponseBody
public ResponseResult dbObjectList(DatabaseParamInfo databaseParamInfo, HttpServletRequest req) throws Exception {
    if (databaseParamInfo.isRefresh()) {
        String cacheKey = CacheUtils.getObjectTypeKey(databaseParamInfo);
        Cache tableMetaCache = cacheManager.getCache(CacheInfo.CacheType.OBJECT_TYPE_METADATA.getCacheName());
        ValueWrapper value = tableMetaCache.get(cacheKey);
        if (value != null && databaseParamInfo.getObjectNames() != null && databaseParamInfo.getObjectNames().length > 0) {
            ResponseResult objValue = (ResponseResult) value.get();
            ResponseResult result = databaseServiceImpl.dbObjectList(databaseParamInfo);
            List<BaseObjectInfo> resultItems = result.getItems();
            HashMap<String, BaseObjectInfo> newItemInfos = new HashMap<String, BaseObjectInfo>();
            resultItems.stream().forEach(item -> {
                newItemInfos.put(item.getName(), item);
            });
            List<BaseObjectInfo> cacheItems = objValue.getItems();
            cacheItems = cacheItems.stream().map(item -> {
                if (newItemInfos.containsKey(item.getName())) {
                    return newItemInfos.get(item.getName());
                }
                return item;
            }).collect(Collectors.toList());
            objValue.setItemList(cacheItems);
            ;
            tableMetaCache.put(cacheKey, objValue);
            return objValue;
        } else {
            tableMetaCache.evict(cacheKey);
        }
    }
    return databaseServiceImpl.dbObjectList(databaseParamInfo);
}
Also used : BaseObjectInfo(com.varsql.core.db.valueobject.BaseObjectInfo) ValueWrapper(org.springframework.cache.Cache.ValueWrapper) HashMap(java.util.HashMap) ResponseResult(com.vartech.common.app.beans.ResponseResult) Cache(org.springframework.cache.Cache) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

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