张洋洋
2025-02-24 9804628abf554c3658345fc8fc9472cfb179fd5f
src/main/java/com/se/simu/controller/DbController.java
@@ -1,14 +1,16 @@
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -27,9 +29,45 @@
    @GetMapping(value = "/info")
    public void info(HttpServletRequest req, HttpServletResponse res) {
        try {
            dbService.info(req, res);
            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");
    }
}