//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.jeecg.modules.jmreport.desreport.a;

import java.util.Date;
import javax.servlet.http.HttpServletRequest;

import org.jeecg.modules.jmreport.common.constant.CommonConstant;
import org.jeecg.modules.jmreport.common.util.oConvertUtils;
import org.jeecg.modules.jmreport.common.vo.Result;
import org.jeecg.modules.jmreport.config.client.JmReportTokenClient;
import org.jeecg.modules.jmreport.desreport.entity.JmReportMap;
import org.jeecg.modules.jmreport.desreport.model.JmPage;
import org.jeecg.modules.jmreport.desreport.service.IJmReportMapService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController("jimuReportMapController")
@RequestMapping({"/jmreport/map"})
public class e {
    private static final Logger a = LoggerFactory.getLogger(e.class);
    @Autowired
    private IJmReportMapService jmReportMapService;
    @Autowired
    private JmReportTokenClient jimuTokenClient;

    public e() {
    }

    @GetMapping({"/mapList"})
    public Result<?> a(HttpServletRequest var1, @RequestParam(name = "label", required = false) String var2, @RequestParam(name = "name", required = false) String var3, @RequestParam(name = "current", defaultValue = "1") Integer var4, @RequestParam(name = "size", defaultValue = "10") Integer var5) {
        String var6 = this.jimuTokenClient.getUsername(var1);
        a.debug("============地图列表查询==========");
        JmReportMap var7 = new JmReportMap();
        var7.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
        var7.setCreateBy(var6);
        if (oConvertUtils.isNotEmpty(var2)) {
            var7.setLabel(var2);
        }

        if (oConvertUtils.isNotEmpty(var3)) {
            var7.setName(var3);
        }

        JmPage var8 = this.jmReportMapService.queryPageList(var7, var4, var5);
        return Result.OK(var8);
    }

    @PostMapping({"/addMapData"})
    public Result<?> a(HttpServletRequest var1, @RequestBody JmReportMap var2) {
        try {
            String var3 = this.jimuTokenClient.getUsername(var1);
            var2.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
            var2.setCreateBy(var3);
            var2.setCreateTime(new Date());
            var2.setUpdateTime(new Date());
            this.jmReportMapService.saveMapSource(var2);
        } catch (Exception var4) {
            return Result.error(403, "操作失败");
        }

        return Result.OK("添加成功！", true);
    }

    @PostMapping({"/delMapSource"})
    public Result<?> b(HttpServletRequest var1, @RequestBody JmReportMap var2) {
        this.jmReportMapService.removeById(var2.getId());
        return Result.OK("删除成功！", true);
    }

    @PostMapping({"/queryMapByCode"})
    public Result<?> c(HttpServletRequest var1, @RequestBody JmReportMap var2) {
        String var3 = this.jimuTokenClient.getUsername(var1);
        a.debug("============地图信息查询==========");
        var2.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
        String var4 = var2.getReportId();
        var2.setCreateBy(var3);
        String var5 = this.jimuTokenClient.getToken(var1);
        JmReportMap var6 = this.jmReportMapService.queryMapByCode(var2, var5);
        return Result.OK(var6);
    }
}
