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
package com.landtool.lanbase.modules.res.controller;
 
import java.util.HashMap;
import java.util.LinkedHashMap;
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.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.modules.api.utils.PageBean;
import com.landtool.lanbase.modules.res.entity.Res_QueryAround;
import com.landtool.lanbase.modules.res.service.ResQueryAroundService;
import com.landtool.lanbase.modules.sys.service.SysFieldvalueService;
 
@Controller
@RequestMapping("res/queryaround")
public class ResQueryAroundController {
 
    @Autowired
    private ResQueryAroundService resQueryAroundService;
 
    @Autowired
    private SysFieldvalueService FieldUtils;
 
    /**
     * 获取资源设置列表
     */
    @ResponseBody
    @RequestMapping("/getResourceSetZBCX")
    public Result getResourceSetZBCX(Integer resourceid, PageBean pageBean) {
        Page<Res_QueryAround> page = PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());
        List<Res_QueryAround> list = resQueryAroundService.getResourceSetZBCX(resourceid);
        int countNums = (int) ((Page) list).getTotal();
        PageBean<Res_QueryAround> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
        pageData.setItems(list);
        //资源类型
        LinkedHashMap<String, String> resourceTypeList = FieldUtils.getFieldListByKey("ResourceType");//获取资源类型列表
        // 拼接字符串
        StringBuilder rsb = new StringBuilder();
        rsb.append("{'totalCount':'" + countNums);
        rsb.append("','topics':[");
 
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Integer i = 0; i < list.size(); i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("TITLE", list.get(i).getTitle());
            map.put("resourceclass", resourceTypeList.get(list.get(i).getResourceclass()));
            map.put("DATASOURCES", (list.get(i).getDatasources() != null ?list.get(i).getDatasources():""));
            map.put("CREATDATE", "");
            map.put("AROUNDRESID", list.get(i).getAroundresid());
            map.put("QUERYID", list.get(i).getQueryid());
            maps.add(map);
        }
        return Result.ok().put("totalCount", countNums).put("topics", maps);
    }
 
    /**
     * 新增记录
     */
    @ResponseBody
    @RequestMapping("/insert")
    public String insert(Res_QueryAround res_queryAround, String ZiYuanIdStr) {
        res_queryAround.setAdduserid(0);
        String[] arr = ZiYuanIdStr.split("\\|");
        try {
            for (int i = 0; i < arr.length; i++) {
                String s = arr[i];
                res_queryAround.setAroundresid(Integer.valueOf(s));
                resQueryAroundService.insert(res_queryAround);
            }
            return "1"; // 添加成功
        } catch (Exception e) {
            return e.toString();
        }
    }
 
    /**
     * 删除记录
     */
    @ResponseBody
    @RequestMapping("/deleteByPrimaryKey")
    public String deleteByPrimaryKey(Res_QueryAround res_queryAround) {
        try {
            int result = resQueryAroundService.deleteByPrimaryKey(res_queryAround.getQueryid());
            return String.valueOf(result);
        }
        catch (Exception e) {
            return e.toString();
        }
    }
 
}