Commit 25fd310d authored by 廖旭伟's avatar 廖旭伟

应用列表接口增加host

parent d4eff9c5
package com.mortals.xhx.module.apps.web;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.AppsClassifyEnum;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
......@@ -54,12 +59,21 @@ public class AppsInfoController extends BaseCRUDJsonBodyMappingController<AppsIn
protected int doListAfter(AppsInfoEntity query, Map<String, Object> model, Context context) throws AppException {
// String url = request.getRequestURI();
// System.out.println(url);
String host = request.getHeader("Host");
host = "http://" + host + "/";
// String host = request.getHeader("Host");
String host = "";
String serverName = request.getHeader("server-name");
Integer serverPort = DataUtil.converStr2Int(request.getHeader("server-port"),0);
if (!ObjectUtils.isEmpty(serverName) && Validator.isIpv4(serverName)) {
host = UrlBuilder.ofHttp(serverName).setPort(serverPort > 0 ? serverPort : 11078).build();
host = StrUtil.sub(host, 0, host.length() - 1);
}else {
host="";
}
List<AppsInfoEntity> list = (List<AppsInfoEntity>) model.get("data");
if(CollectionUtils.isNotEmpty(list)){
for(AppsInfoEntity appsInfoEntity:list){
appsInfoEntity.setCustUrl(host + appsInfoEntity.getCustUrl());
appsInfoEntity.setCustUrl(host + "/" + appsInfoEntity.getCustUrl());
}
model.put("data",list);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment