package com.landtool.lanbase.modules.res.controller; import com.alibaba.fastjson.JSONObject; import com.landtool.lanbase.modules.res.entity.Res_DiyLayerInfo; import com.landtool.lanbase.modules.res.entity.Res_ExtMapUrl; import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService; import com.landtool.lanbase.modules.res.service.ResExtMapUrlService; import org.apache.commons.lang3.StringUtils; 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 java.util.List; /** * @Author: lizhao * @Date: 2018-03-05 15:49 * @Description:5资源支持协议与地址(RES_EXTMAPURL) * */ @Controller @RequestMapping("/res/ResExtMapUrl") public class ResExtMapUrlController { @Autowired private ResExtMapUrlService resExtMapUrlService; @Autowired private ResDiyLayerInfoService resDiyLayerInfoService; /** * 根据id 删除资源支持协议与地址列表功能 */ @ResponseBody @RequestMapping("deleteByPrimaryKey") public int deleteByPrimaryKey(int urlid) { return resExtMapUrlService.deleteByPrimaryKey(urlid); } /** * 插入资源支持协议与地址列表功能(所有元素不能为空) */ @ResponseBody @RequestMapping("insert") public int insert(Res_ExtMapUrl record) { return resExtMapUrlService.insert(record); } /** * 插入资源支持协议与地址列表功能(可以只填写必填字段) */ @ResponseBody @RequestMapping("insertSelective") public int insertSelective(Res_ExtMapUrl record) { return resExtMapUrlService.insertSelective(record); } /** * 根据id查询资源支持协议与地址列表 */ @ResponseBody @RequestMapping("selectByPrimaryKey") public Res_ExtMapUrl selectByPrimaryKey(int urlid) { return resExtMapUrlService.selectByPrimaryKey(urlid); } /** * 根据id更新资源支持协议与地址列表(更新部分数据) */ @ResponseBody @RequestMapping("updateByPrimaryKeySelective") public int updateByPrimaryKeySelective(Res_ExtMapUrl record) { return resExtMapUrlService.updateByPrimaryKeySelective(record); } /** * 根据id更新资源支持协议与地址列表(更新所有数据) */ @ResponseBody @RequestMapping("updateByPrimaryKey") public int updateByPrimaryKey(Res_ExtMapUrl record) { return resExtMapUrlService.updateByPrimaryKey(record); } /** * 更新服务路径及diylayerinfo里的content */ @ResponseBody @RequestMapping("updateUrlByPrimaryKey") public String updateUrlByPrimaryKey(Res_ExtMapUrl extMapUrl, String oldurl,Integer isUpdateDiy) { int result = 0; Res_ExtMapUrl urlmodel = resExtMapUrlService.selectByPrimaryKey(extMapUrl.getUrlid()); if (urlmodel != null) { urlmodel.setServerurl(extMapUrl.getServerurl()); if(extMapUrl.getEsbid() != null && extMapUrl.getEsbid() != 0){ urlmodel.setEsbid(extMapUrl.getEsbid()); } if(extMapUrl.getOldserverurl() != null && extMapUrl.getOldserverurl().length() != 0){ urlmodel.setOldserverurl(extMapUrl.getOldserverurl()); } urlmodel.setContextpath(extMapUrl.getContextpath()); urlmodel.setSublayer(extMapUrl.getSublayer()); urlmodel.setAgentserverurl(extMapUrl.getAgentserverurl()); result = resExtMapUrlService.updateByPrimaryKey(urlmodel); List diyinfoList = resDiyLayerInfoService.selectByResourceid(extMapUrl.getResourceid()); if (isUpdateDiy == 1 && diyinfoList != null && diyinfoList.size() > 0) { for (Res_DiyLayerInfo info : diyinfoList) { if (info.getContent().indexOf(oldurl) != -1) {//存在则替换 String content = info.getContent().replace(oldurl, extMapUrl.getServerurl()); info.setContent(content); resDiyLayerInfoService.updateByPrimaryKeySelective(info); } } } } return "{'result':'" + result + "'}"; } /** * 检查上下文地址是否唯一 */ @ResponseBody @RequestMapping("isExistContextPath") public int isExistContextPath(Res_ExtMapUrl extMapUrl) { int result = resExtMapUrlService.isExistContextPath(extMapUrl.getContextpath()); return result; } @ResponseBody @RequestMapping("queryResourceId") public String queryResourceId(String serverurl) { // 处理serverurl的show问题 if (serverurl.contains("MapServer")){ String [] split = serverurl.split("/"); if (null != split && split.length > 0){ String lastStr = (String)split[split.length-1]; if (StringUtils.isNumeric(lastStr)){ serverurl = serverurl.replace("MapServer/"+lastStr,"MapServer"+"?layers=show:"+lastStr); } } } Res_ExtMapUrl res_extMapUrl = new Res_ExtMapUrl(); res_extMapUrl.setServerurl(serverurl); Res_ExtMapUrl result = resExtMapUrlService.queryResourceId( res_extMapUrl); return JSONObject.toJSONString(result); } }