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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package com.landtool.lanbase.modules.api.controller;
 
import java.text.SimpleDateFormat;
import java.util.List;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.landtool.lanbase.modules.res.entity.Res_Catalog;
import com.landtool.lanbase.modules.res.entity.Res_ExtIntegrate;
import com.landtool.lanbase.modules.res.entity.Res_MainInfo;
import com.landtool.lanbase.modules.res.service.ResCatalogService;
import com.landtool.lanbase.modules.res.service.ResExtIntegrateService;
import com.landtool.lanbase.modules.res.service.ResMainInfoService;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
 
/**
 * @author 刘小波
 * @Description: 资源目录相关查询接口
 * @date 2018-01-30
 */
 
@Controller
@RequestMapping("/api/catalog/")
@Api(value = "", tags = { "资源目录查询接口" })
public class CatalogController {
    @Autowired
    private ResCatalogService resCatalogService;
 
    @Autowired
    private ResMainInfoService resMainInfoService;
    
    @Autowired
    private ResExtIntegrateService resExtIntegrateService;
    
    /**
     * @param parentCatalogId
     * @Description: 递归获取获取目录树信息,父节点为0时查询整个目录树 {@link ResCatalogService}
     * @Author: xiaoxuan.xie
     * @Date: 17:30 2018/3/15
     * @return: String
     * @see Res_Catalog
     */
    @ResponseBody
    @GetMapping(path = "getTree/{parentCatalogId}")
    @ApiOperation(value = "递归获取获取目录树信息", notes = "")
    public String getTreeByParentID(
            @ApiParam(name = "parentCatalogId", value = "目录父节点Id", required = true) @PathVariable(name = "parentCatalogId") int parentCatalogId) {
        String resCatalogTreeJson = getTreeChildrenNodeList(parentCatalogId);// 递归获取目录子节点列表
        return "[" + resCatalogTreeJson + "]";
    }
 
    /**
     * @param parentCatalogId
     * @Description: 递归获取目录子节点列表 {@link ResCatalogService}
     * @Author: xiaoxuan.xie
     * @Date: 17:30 2018/3/15
     * @return: String
     */
    private String getTreeChildrenNodeList(int parentCatalogId) {
        String resCatalogTreeJson = "";// 定义目录树Json字符串存储对象
        List<Res_Catalog> res_catalogList = resCatalogService.selectResCatalogToParentid(parentCatalogId);// 根据目录父Id获取子目录列表
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 实例化时间格式转换器
        // 循环构造目录树结构Json
        for (Res_Catalog resCatalog : res_catalogList) {
            if (resCatalogTreeJson != "")
                resCatalogTreeJson += ",";
            resCatalogTreeJson += "{'catlogid':" + resCatalog.getCatlogid();
            resCatalogTreeJson += ",'catlogcode':'" + resCatalog.getCatlogcode() + "'";
            resCatalogTreeJson += ",'parentid':" + resCatalog.getParentid();
            resCatalogTreeJson += ",'title':'" + resCatalog.getTitle() + "'";
            resCatalogTreeJson += ",'pingyinfiirst':'" + resCatalog.getPingyinfiirst() + "'";
            resCatalogTreeJson += ",'description':'" + resCatalog.getDescription() + "'";
            resCatalogTreeJson += ",'imgurl':'" + resCatalog.getImgurl() + "'";
            resCatalogTreeJson += ",'orderid':" + resCatalog.getOrderid();
            resCatalogTreeJson += ",'createuser':'" + resCatalog.getCreateuser() + "'";
            resCatalogTreeJson += ",'createdate':'" + sdf.format(resCatalog.getCreatedate()) + "'";
            resCatalogTreeJson += ",'remark':'" + resCatalog.getRemark() + "'";
            resCatalogTreeJson += ",'childnodes':[";
            String resCatalogChildNode = getTreeChildrenNodeList(resCatalog.getCatlogid());// 递归获取目录子节点列表
            if (resCatalogChildNode != "") {
                resCatalogTreeJson += resCatalogChildNode;
            }
            resCatalogTreeJson += "]}";
        }
 
        return resCatalogTreeJson;
    }
 
    /**
     * @param parentCatalogId
     * @Description: 获取子目录信息列表{@link ResCatalogService}
     * @Author: xiaoxuan.xie
     * @Date: 17:30 2018/3/15
     * @return: List<Res_Catalog>
     * @see Res_Catalog
     */
    @ResponseBody
    @GetMapping(path = "getList/{parentCatalogId}")
    @ApiOperation(value = "获取子目录信息列表", notes = "")
    public List<Res_Catalog> getListByParentID(
            @ApiParam(name = "parentCatalogId", value = "目录父节点Id", required = true) @PathVariable(name = "parentCatalogId") int parentCatalogId) {
        return resCatalogService.selectResCatalogToParentid(parentCatalogId);
    }
 
    /**
     * @param catalogId
     * @Description: 查询目录信息{@link ResCatalogService}
     * @Author: xiaoxuan.xie
     * @Date: 09:30 2018/3/16
     * @return: Res_Catalog
     * @see Res_Catalog
     */
    @ResponseBody
    @GetMapping(path = "info/{catalogId}")
    @ApiOperation(value = "获取目录信息详细信息", notes = "")
    public Res_Catalog getById(
            @ApiParam(name = "catalogId", value = "目录Id", required = true) @PathVariable(name = "catalogId") int catalogId) {
        return resCatalogService.getResCatalogInfoById(catalogId);
    }
    
    //region 平台门户模块面板Iframe配置目录树
    /**
     * 如果放开前端面板的配置权限,后期需要完善权限
     * @Description: 获取业务集成-页面集成-Iframe区块目录树
     */
    @ResponseBody
    @GetMapping(path = "YWJCTree/{id}")
    @ApiOperation(value = "获取业务集成-页面集成-Iframe区块目录树", notes = "")
    public String getYWJCTreeData(
            @ApiParam(name = "id", value = "id", required = true) @PathVariable(name = "id") String id,
            HttpServletRequest request) {
        StringBuilder resCatalogJson = new StringBuilder();
        String leixiId = "YWJC";
        Res_MainInfo resMainInfoTWO = new Res_MainInfo();
        resMainInfoTWO.setResourceclass(leixiId);
        resMainInfoTWO.setCParentid(Integer.parseInt(id));
        resMainInfoTWO.setCatlogid(Integer.parseInt(id));
        List<Res_Catalog> resCatalogList = resCatalogService.getYWJCMuLuTree(Integer.parseInt(id));// 获取子目录列表
        // 循环构造子目录节点
        for (Res_Catalog resCatalog : resCatalogList) {
            if (!"".equals(resCatalogJson.toString())) {
                resCatalogJson.append(',');
            }
            resCatalogJson.append("{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "', isParent: true}");
        }
        // 获取资源类型列表
        List<Res_MainInfo> resMainInfo = resMainInfoService.getYWJCTreeData(resMainInfoTWO); // 获取目录下业务集成--页面集成--Iframe区块资源列表
        // 循环构造资源节点
        for (Res_MainInfo resMainInfo1 : resMainInfo) {
            Res_ExtIntegrate res_extIntegrate = resExtIntegrateService.selectByPrimaryKey(resMainInfo1.getResourceid());// 获取业务集成拓展信息
            if (!"".equals(resCatalogJson.toString())) {
                resCatalogJson.append(',');
            }
 
            String title = resMainInfo1.getTitle();
            //if (resMainInfo1.getTitle().length() > 16) {
            //    title = resMainInfo1.getTitle().substring(0, 16) + "..";
            //}
            //建议分辨率
            if(res_extIntegrate.getResolution() != null && !res_extIntegrate.getResolution().isEmpty()) {
                title += "(" + res_extIntegrate.getResolution() + ")";
            }
 
            String serverUrl = res_extIntegrate.getServerurl();
            if (serverUrl == null)
                serverUrl = "";
 
            resCatalogJson.append("{id: 'ZiYuan_" + resMainInfo1.getResourceid() + "',name:'" + title + "', title: '"
                    + resMainInfo1.getTitle() + "',isParent:false, ServerUrl: '" + serverUrl + "'}");
        }
        return "[" + resCatalogJson.toString() + "]";
    }
    //endregion
}