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
|
}
|