Commit f987bf7e authored by 赵啸非's avatar 赵啸非

修改远程ip地址

parent ef0d21c2
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,28 +2,26 @@ package com.mortals.xhx.base.system.param.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.RepeatSubmit;
import com.alibaba.nacos.common.utils.IpUtils;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.code.PageDisplayType;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.util.FileUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.param.model.ParamEntity;
import com.mortals.xhx.base.system.param.model.ParamQuery;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DataSatusEnum;
import com.mortals.xhx.common.code.ModStatusEnum;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_URL;
/**
* 参数信息
*
......@@ -49,6 +47,82 @@ public class ParamController extends BaseCRUDJsonBodyMappingController<ParamServ
model.put(KEY_RESULT_DICT, status);
}
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "key")
@UnAuth
public String getValueByKey(@RequestParam(name = "key") String key) {
JSONObject jsonObject = new JSONObject();
String busiDesc = "通过key查询参数值" + this.getModuleDesc();
try {
String value = this.service.getValueByKey(key);
jsonObject.put(KEY_RESULT_DATA, value);
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc + "成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "dict")
@UnAuth
public String getDict(@RequestParam(name = "first") String first, @RequestParam(name = "second") String second) {
JSONObject jsonObject = new JSONObject();
String busiDesc = "通过key查询字典参数值" + this.getModuleDesc();
try {
Map<String, String> dict = this.service.getParamBySecondOrganize(first, second);
// String value = this.service.getValueByKey(key);
jsonObject.put(KEY_RESULT_DATA, dict);
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc + "成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
/**
* 更新终端访问服务器应用ip地址
*/
@GetMapping(value = "updateServerIp")
@UnAuth
public String updateServerip(String serverIp) {
JSONObject jsonObject = new JSONObject();
try {
//校验ip地址
boolean ipv4 = IpUtils.isIpv4(serverIp);
if (!ipv4) {
throw new AppException("请输入正确的ip地址");
}
ParamQuery paramQuery = new ParamQuery();
paramQuery.setParamKey(PARAM_SERVER_HTTP_URL);
ParamEntity paramEntity = this.service.selectOne(paramQuery);
if (!ObjectUtils.isEmpty(paramEntity)) {
String value = "http://" + serverIp + ":11078";
paramEntity.setParamValue(value);
this.service.update(paramEntity);
}
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "更新终端访问服务端ip成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
private Map<String, Object> getPageDisplayType() {
PageDisplayType[] pageDisplayTypes = PageDisplayType.values();
......
......@@ -91,7 +91,7 @@ public interface ErrorCode {
public static final String DEVICE_UNACTIVE_CONTENT = "当前设备未激活,请在后台配置后再激活!";
public static final int PLATFORM_IS_EMPTY = 1005;
public static final String PLATFORM_IS_EMPTY_CONTENT = "当前设备编码不存在!";
public static final String PLATFORM_IS_EMPTY_CONTENT = "当前平台编码不存在!";
public static final int PLATFORM_UNEXIST = 1006;
public static final String PLATFORM_UNEXIST_CONTENT = "当前设备所属产品平台未配置,请在后台配置后再激活!";
......
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