Search in sources :

Example 1 with SysDataSource

use of org.jeecg.modules.system.entity.SysDataSource in project jeecg-boot by jeecgboot.

the class SysDataSourceController method edit.

/**
 * 编辑
 *
 * @param sysDataSource
 * @return
 */
@AutoLog(value = "多数据源管理-编辑")
@ApiOperation(value = "多数据源管理-编辑", notes = "多数据源管理-编辑")
@RequestMapping(value = "/edit", method = { RequestMethod.PUT, RequestMethod.POST })
public Result<?> edit(@RequestBody SysDataSource sysDataSource) {
    try {
        SysDataSource d = sysDataSourceService.getById(sysDataSource.getId());
        DataSourceCachePool.removeCache(d.getCode());
        String dbPassword = sysDataSource.getDbPassword();
        if (StringUtils.isNotBlank(dbPassword)) {
            String encrypt = SecurityUtil.jiami(dbPassword);
            sysDataSource.setDbPassword(encrypt);
        }
        sysDataSourceService.updateById(sysDataSource);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return Result.ok("编辑成功!");
}
Also used : SysDataSource(org.jeecg.modules.system.entity.SysDataSource) AutoLog(org.jeecg.common.aspect.annotation.AutoLog) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with SysDataSource

use of org.jeecg.modules.system.entity.SysDataSource in project kms by mahonelau.

the class SysDataSourceController method delete.

/**
 * 通过id删除
 *
 * @param id
 * @return
 */
@AutoLog(value = "多数据源管理-通过id删除")
@ApiOperation(value = "多数据源管理-通过id删除", notes = "多数据源管理-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id") String id) {
    SysDataSource sysDataSource = sysDataSourceService.getById(id);
    DataSourceCachePool.removeCache(sysDataSource.getCode());
    sysDataSourceService.removeById(id);
    return Result.ok("删除成功!");
}
Also used : SysDataSource(org.jeecg.modules.system.entity.SysDataSource) AutoLog(org.jeecg.common.aspect.annotation.AutoLog) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with SysDataSource

use of org.jeecg.modules.system.entity.SysDataSource in project kms by mahonelau.

the class SysDataSourceController method queryOptions.

@GetMapping(value = "/options")
public Result<?> queryOptions(SysDataSource sysDataSource, HttpServletRequest req) {
    QueryWrapper<SysDataSource> queryWrapper = QueryGenerator.initQueryWrapper(sysDataSource, req.getParameterMap());
    List<SysDataSource> pageList = sysDataSourceService.list(queryWrapper);
    JSONArray array = new JSONArray(pageList.size());
    for (SysDataSource item : pageList) {
        JSONObject option = new JSONObject(3);
        option.put("value", item.getCode());
        option.put("label", item.getName());
        option.put("text", item.getName());
        array.add(option);
    }
    return Result.ok(array);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONArray(com.alibaba.fastjson.JSONArray) SysDataSource(org.jeecg.modules.system.entity.SysDataSource)

Example 4 with SysDataSource

use of org.jeecg.modules.system.entity.SysDataSource in project kms by mahonelau.

the class SysDataSourceController method edit.

/**
 * 编辑
 *
 * @param sysDataSource
 * @return
 */
@AutoLog(value = "多数据源管理-编辑")
@ApiOperation(value = "多数据源管理-编辑", notes = "多数据源管理-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody SysDataSource sysDataSource) {
    try {
        SysDataSource d = sysDataSourceService.getById(sysDataSource.getId());
        DataSourceCachePool.removeCache(d.getCode());
        String dbPassword = sysDataSource.getDbPassword();
        if (StringUtils.isNotBlank(dbPassword)) {
            String encrypt = SecurityUtil.jiami(dbPassword);
            sysDataSource.setDbPassword(encrypt);
        }
        sysDataSourceService.updateById(sysDataSource);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return Result.ok("编辑成功!");
}
Also used : SysDataSource(org.jeecg.modules.system.entity.SysDataSource) AutoLog(org.jeecg.common.aspect.annotation.AutoLog) ApiOperation(io.swagger.annotations.ApiOperation)

Example 5 with SysDataSource

use of org.jeecg.modules.system.entity.SysDataSource in project kykms by mahonelau.

the class SysDataSourceController method delete.

/**
 * 通过id删除
 *
 * @param id
 * @return
 */
@AutoLog(value = "多数据源管理-通过id删除")
@ApiOperation(value = "多数据源管理-通过id删除", notes = "多数据源管理-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id") String id) {
    SysDataSource sysDataSource = sysDataSourceService.getById(id);
    DataSourceCachePool.removeCache(sysDataSource.getCode());
    sysDataSourceService.removeById(id);
    return Result.ok("删除成功!");
}
Also used : SysDataSource(org.jeecg.modules.system.entity.SysDataSource) AutoLog(org.jeecg.common.aspect.annotation.AutoLog) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

SysDataSource (org.jeecg.modules.system.entity.SysDataSource)12 ApiOperation (io.swagger.annotations.ApiOperation)9 AutoLog (org.jeecg.common.aspect.annotation.AutoLog)9 JSONArray (com.alibaba.fastjson.JSONArray)3 JSONObject (com.alibaba.fastjson.JSONObject)3