2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.landtool.lanbase.modules.res.controller;
 
 
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.landtool.lanbase.common.utils.Result;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.api.utils.PageBean;
import com.landtool.lanbase.modules.res.entity.Res_EchartsConfing;
import com.landtool.lanbase.modules.res.service.ResEchartsCofingService;
 
@Controller
@RequestMapping("res/common")
public class ResEchartsCofingController {
    @Autowired
    private ResEchartsCofingService resEchartsCofingService;
 
    @Autowired
    private SysTemPropertyConfig sysConfig;
 
    /**
     * Echarts模板
     */
    @RequestMapping("chartTemplat")
    public String chartTemplat(Model model) {
        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
        return "common/resource_set_ChartTemplat";
    }
 
    @RequestMapping("addChartTemplat")
    public String addChartTemplat(Model model, Integer echartsid) {
        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
        model.addAttribute("uploadRootPath", sysConfig.getUploadRootPath());
        Res_EchartsConfing resEchartsConfing = new Res_EchartsConfing();
        if (echartsid != null) {
            resEchartsConfing = resEchartsCofingService.selectByPrimaryKey(echartsid);
        }
        model.addAttribute("EchartsConfing", resEchartsConfing);
        return "common/resource_add_ChartTemplat";
    }
 
    @RequestMapping("getChartTemplatList")
    @ResponseBody
    public Result getChartTemplatList(PageBean pageBean,Integer settype) {
        Page<Res_EchartsConfing> page = PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());
        List<Res_EchartsConfing> list = resEchartsCofingService.selectAllChart(settype);
        int countNums = (int) ((Page) list).getTotal();
        PageBean<Res_EchartsConfing> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
        pageData.setItems(list);
        StringBuilder sb = new StringBuilder();
        sb.append("{'totalCount':'" + countNums + "'");
        sb.append(",'topics':[");
        List<Map<String, Object>> maps = new LinkedList<>();
        for (int i = 0; i < list.size(); i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("echartstype", list.get(i).getEchartstype());
            map.put("echartsid", list.get(i).getEchartsid());
            map.put("echartstitle", list.get(i).getEchartstitle());
            map.put("echartsUrl", sysConfig.getUploadRootPath() + list.get(i).getEchartsUrl());
            maps.add(map);
 
//            if (i != 0) {
//                sb.append(",");
//            }
//            sb.append("{");
//            sb.append("'echartstype':'" + list.get(i).getEchartstype() + "'");
//            sb.append(",'echartsid':'" + list.get(i).getEchartsid() + "'");
//            sb.append(",'echartstitle':'" + list.get(i).getEchartstitle() + "'");
//            sb.append(",'echartsUrl':'" +sysConfig.getUploadRootPath() + list.get(i).getEchartsUrl() + "'");
//            sb.append("}");
        }
//        sb.append("]}");
        return Result.ok().put("totalCount", countNums).put("topics", maps);
    }
 
    @ResponseBody
    @RequestMapping("saveChartTemplat")
    public String saveChartTemplat(Res_EchartsConfing resEchartsConfing) {
        Res_EchartsConfing res_echartsConfing = resEchartsCofingService.selectByPrimaryKey(resEchartsConfing.getEchartsid());
        int count = 0;
        if (res_echartsConfing == null) {
            count = resEchartsCofingService.insertSelective(resEchartsConfing);
        } else {
            count = resEchartsCofingService.updateByPrimaryKeySelective(resEchartsConfing);
        }
        return "{'count':'" + count + "','id':'"+resEchartsConfing.getEchartsid()+"'}";
    }
 
    @ResponseBody
    @RequestMapping("deleteChartTemplat")
    public int deleteChartTemplat(Integer echartsid) {
        return resEchartsCofingService.deleteByPrimaryKey(echartsid);
    }
}