package com.se.simu.controller;
|
|
import com.se.simu.domain.vo.QueryVo;
|
import com.se.simu.domain.vo.R;
|
import com.se.simu.helper.CaffeineHelper;
|
import com.se.simu.helper.StringHelper;
|
import com.se.simu.helper.WebHelper;
|
import com.se.simu.service.DbService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.http.HttpStatus;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
@Api(tags = "数据管理")
|
@Slf4j
|
@RestController
|
@RequestMapping("/db")
|
@SuppressWarnings("ALL")
|
public class DbController extends BaseController {
|
@Resource
|
DbService dbService;
|
|
@ApiOperation(value = "info")
|
@GetMapping(value = "/info")
|
public void info(HttpServletRequest req, HttpServletResponse res) {
|
try {
|
String rs = dbService.info();
|
|
WebHelper.writeStr2Page(res, HttpStatus.OK, rs);
|
} catch (Exception ex) {
|
WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, ex.getMessage());
|
}
|
}
|
|
@ApiOperation(value = "config")
|
@GetMapping(value = "/config")
|
public void config(HttpServletRequest req, HttpServletResponse res) {
|
try {
|
String rs = dbService.getConfig();
|
|
WebHelper.writeStr2Page(res, HttpStatus.OK, rs);
|
} catch (Exception ex) {
|
WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, ex.getMessage());
|
}
|
}
|
|
@ApiOperation(value = "query")
|
@PostMapping(value = "/query")
|
public void query(@RequestBody QueryVo vo, HttpServletRequest req, HttpServletResponse res) {
|
try {
|
if (null == vo || StringHelper.isEmpty(vo.getLayerid())) throw new Exception("layerid不能为空");
|
|
vo.setDefault();
|
|
dbService.query(vo, req, res);
|
} catch (Exception ex) {
|
WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, ex.getMessage());
|
}
|
}
|
|
@ApiOperation(value = "clearCache")
|
@GetMapping(value = "/clearCache")
|
public R<Object> clearCache() {
|
CaffeineHelper.clear();
|
|
return success("ok");
|
}
|
}
|