Commit e5356244 authored by mcb's avatar mcb

no message

parent 4bfc8b2e
package com.jz.dmp.modules.controller.dataService;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.dmp.modules.controller.dataService.bean.*;
import com.jz.dmp.modules.service.DmpApiMangeService;
import com.jz.dmp.modules.service.DmpApiServiceMangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
/**
* 数据服务-服务管理--调用gateway 接口
*
* @author Bellamy
* @since 2021-01-18 10:56:18
*/
@RestController
@RequestMapping("/apiService")
@Api(tags = "数据服务-服务管理")
public class DmpApiServiceMangeController {
private static Logger logger = LoggerFactory.getLogger(DmpApiServiceMangeController.class);
/**
* 服务对象
*/
@Autowired
private DmpApiServiceMangeService dmpApiServiceMangeService;
/**
* 保存API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "保存API(第三方)", notes = "保存API(第三方)")
@PostMapping(value = "/saveApi")
public JsonResult saveApiInfo(@RequestBody ApiInterfaceReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.saveApiInfo(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 保存API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "保存API(大数据查询/标签查询)", notes = "保存API(大数据查询/标签查询)")
@PostMapping(value = "/saveApiBigData")
public JsonResult saveApiBigDataInfo(@RequestBody MakeBigDataApiReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.saveApiBigDataInfo(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
}
\ No newline at end of file
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @ClassName: ApiInterfaceReq
* @Description: api基本信息
* @Author: Bellamy
* @Date 2021/1/19
* @Version 1.0
*/
@Data
@ApiModel(value = "api基本信息")
public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "接口描述",required = false)
public String apiDesc;
@ApiModelProperty(value = "传输方式:http https",required = true)
@NotNull(message = "传输方式不能为空")
public String transMode;
@ApiModelProperty(value = "加密方式0 无,1:MD5 2:RSA",required = true)
@NotNull(message = "加密方式不能为空")
public String signType;
@ApiModelProperty(value = "接入类型:对应字典表key",required = true)
@NotNull(message = "接入类型不能为空")
public String joinType;
@ApiModelProperty(value = "目标地址",required = true)
@NotNull(message="目标地址不能为空")
public String targetUrl;
@ApiModelProperty(value = "超时时间",required = true)
@NotNull(message="超时时间不能为空")
public String timeout;
@ApiModelProperty(value = "限流类型:DAY 按天,MONTH 按月, YEAR 按年",required = true)
@NotNull(message = "限流类型不能为空")
public String reqType;
@ApiModelProperty(value = "限制次数",required = false)
public Long reqFrequency;
@ApiModelProperty(value = "api描述",required = false)
public String apiFunction;
@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
public Long parentId;
@ApiModelProperty(value = "文件id",required = false)
public Long fileId;
@ApiModelProperty(value = "项目id",required = true)
@NotNull(message="项目id不能为空")
public Long projectId;
@ApiModelProperty(value = "状态",required = false)
public String status;
@ApiModelProperty(value = "更新时传入api自增id",required = false)
public Long id;
@ApiModelProperty(value = "创建用户",hidden = true)
public String createUser;
@ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " +
"2 数据银行制作数据包,3,数据银行制作自定义API " +
"4 API实时接入 6 标签查询 9自定义",hidden = true)
public String apiType;
}
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @ClassName: MakeBigDataApiReq
* @Description: Api制作大数据查询
* @Author: Bellamy
* @Date 2021/1/19
* @Version 1.0
*/
@Data
@ApiModel("Api制作大数据查询/标签查询请求体")
public class MakeBigDataApiReq implements Serializable {
@ApiModelProperty(value = "接口描述",required = false)
public String apiDesc;
@ApiModelProperty(value = "传输方式:http https",required = true)
@NotNull(message = "传输方式不能为空")
public String transMode;
@ApiModelProperty(value = "加密方式0 无,1:MD5 2:RSA",required = true)
@NotNull(message = "加密方式不能为空")
public String signType;
@ApiModelProperty(value = "接入类型:对应字典表key",required = true)
@NotNull(message = "接入类型不能为空")
public String joinType;
@ApiModelProperty(value = "目标地址",required = true)
@NotNull(message="目标地址不能为空")
public String targetUrl;
@ApiModelProperty(value = "超时时间",required = true)
@NotNull(message="超时时间不能为空")
public String timeout;
@ApiModelProperty(value = "限流类型:DAY 按天,MONTH 按月, YEAR 按年",required = true)
@NotNull(message = "限流类型不能为空")
public String reqType;
@ApiModelProperty(value = "限制次数",required = false)
public Long reqFrequency;
@ApiModelProperty(value = "api描述",required = false)
public String apiFunction;
@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
public Long parentId;
@ApiModelProperty(value = "文件id",required = false)
public Long fileId;
@ApiModelProperty(value = "项目id",required = true)
@NotNull(message="项目id不能为空")
public Long projectId;
@ApiModelProperty(value = "状态",required = false)
public String status;
@ApiModelProperty(value = "更新时传入api自增id",required = false)
public Long id;
@ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " +
"2 数据银行制作数据包,3,数据银行制作自定义API " +
"4 API实时接入 6 标签查询 9自定义",hidden = true)
public String apiType;
@ApiModelProperty(value = "apiKey",required = false)
public String apiKey;
@ApiModelProperty(value = "数据源Id",required = true)
@NotNull(message = "数据源Id不能为空")
private String esDataSource;
@ApiModelProperty(value = "源库名称",required = true)
@NotNull(message = "源库名称不能为空")
private String esDataBase;
@ApiModelProperty(value = "源表名称",required = true)
@NotNull(message = "源表名称不能为空")
private String esTable;
@ApiModelProperty(value = "处理类型",required = true)
@NotNull(message = "处理类型不能为空")
private String handleType;
@ApiModelProperty(value = "请求参数",required = true)
@NotNull(message = "请求参数不能为空")
private String requestParam;
@ApiModelProperty(value = "返回参数",required = true)
@NotNull(message = "返回参数不能为空")
private String responseParam;
@ApiModelProperty(value = "段列表",required = true)
@NotNull(message = "字段列表不能为空")
private String tableFields;
@ApiModelProperty(value = "创建用户",required = false)
public String createUser;
}
......@@ -75,4 +75,5 @@ public interface DmpApiMangeService {
* @since 2021-01-19
*/
JsonResult checkApiLogInfo(LogInfoListReq req) throws Exception;
}
package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.dmp.modules.controller.dataService.bean.ApiInterfaceReq;
import com.jz.dmp.modules.controller.dataService.bean.MakeBigDataApiReq;
import com.jz.dmp.modules.model.DvRuleT;
import java.util.List;
/**
* 数据服务-服务管理--调用gateway 接口
*
* @author Bellamy
* @since 2021-01-18 10:56:18
*/
public interface DmpApiServiceMangeService {
/**
* 保存API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-19
*/
JsonResult saveApiInfo(ApiInterfaceReq req) throws Exception;
/**
* 保存API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-19
*/
JsonResult saveApiBigDataInfo(MakeBigDataApiReq req) throws Exception;
}
\ No newline at end of file
......@@ -307,4 +307,5 @@ public class DmpApiMangeServiceImpl implements DmpApiMangeService {
}
return result;
}
}
package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.utils.web.HttpClientUtils;
import com.jz.dmp.modules.controller.dataService.bean.ApiInterfaceReq;
import com.jz.dmp.modules.controller.dataService.bean.MakeBigDataApiReq;
import com.jz.dmp.modules.dao.DvRuleTDao;
import com.jz.dmp.modules.model.DvRuleT;
import com.jz.dmp.modules.service.DmpApiServiceMangeService;
import com.jz.dmp.modules.service.DvRuleTService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @ClassName: DmpApiServiceMangeServiceImpl
* @Description: 数据服务-服务管理--调用gateway 接口
* @Author: Bellamy
* @Date 2021/1/19
* @Version 1.0
*/
@Service("dmpApiServiceMangeService")
public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService {
private static Logger logger = LoggerFactory.getLogger(DmpApiServiceMangeServiceImpl.class);
//保存API(第三方)基本信息url
private static final String addApiInfo = "/api/producer/addCustomApi";
//保存API(大数据查询/标签查询)url
private static final String addApiBigData = "/api/producer/makeBigDataApi";
@Value("${spring.gateway-url}")
private String gatewayUrl;
/**
* 保存API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-19
*/
@Override
public JsonResult saveApiInfo(ApiInterfaceReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + addApiInfo;
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("保存失败!");
}
logger.info("#################响应结果数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
Map apiKey = JSONObject.parseObject(jsonObject.get("data").toString());
result.setData(apiKey.get("data")); // 新增API数据的apiKey
return result;
}
}
if (jsonObject.containsKey("message")) {
logger.info(jsonObject.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage(jsonObject.get("message").toString());
}
return result;
}
/**
* 保存API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-19
*/
@Override
public JsonResult saveApiBigDataInfo(MakeBigDataApiReq req) throws Exception {
ApiInterfaceReq baseInfo = new ApiInterfaceReq();
BeanUtils.copyProperties(req, baseInfo);
//保存API基本信息
JsonResult apiKeyData = saveApiInfo(baseInfo);
String apiKey = apiKeyData.getData().toString();
JsonResult result = new JsonResult();
req.setApiKey(apiKey);
String url = gatewayUrl + addApiBigData;//保存API(大数据查询/标签查询)
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("保存失败!");
}
logger.info("#################响应结果数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
return result;
}
}
if (jsonObject.containsKey("message")) {
logger.info(jsonObject.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage(jsonObject.get("message").toString());
}
return result;
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.utils.web.HttpClientUtils;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageDetailQueryReq;
......@@ -67,11 +68,17 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
throw new RuntimeException("查询失败!");
}
logger.info("#################组织管理列数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject != null) {
result.setData(jsonObject.get("data"));
/*Map records = JSONObject.parseObject(jsonObject.get("data").toString());
List<Map> list = (List<Map>) records.get("records");*/
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
return JsonResult.ok(jsonObject.get("data"));
}
}
if (jsonObject.containsKey("message")) {
logger.info(jsonObject.get("message").toString());
result.setMessage(jsonObject.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result;
}
......@@ -94,8 +101,10 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
}
return JsonResult.error("删除失败!");
}
......@@ -109,18 +118,26 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/
@Override
public JsonResult addOrg(OrganizationManageAddReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + addOrg;
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("新增失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
}
logger.info(map.get("message").toString());
return JsonResult.error(map.get("message").toString());
if (map.containsKey("message")) {
logger.info(map.get("message").toString());
result.setMessage(map.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result;
}
/**
......@@ -132,18 +149,26 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/
@Override
public JsonResult updateOrg(OrganizationManageUpdateReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + updateOrg;
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("编辑失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
}
if (map.containsKey("message")) {
logger.info(map.get("message").toString());
result.setMessage(map.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
logger.info(map.get("message").toString());
return JsonResult.error(map.get("message").toString());
return result;
}
/**
......@@ -154,6 +179,7 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/
@Override
public JsonResult getOrgInfoByOrgId(String id) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + orgDetail;
OrganizationManageDetailQueryReq req = new OrganizationManageDetailQueryReq();
req.setId(Long.valueOf(id));
......@@ -162,11 +188,18 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
throw new RuntimeException("查询失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok(map.get("data"));
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok(map.get("data"));
}
}
if (map.containsKey("message")) {
logger.info(map.get("message").toString());
result.setMessage(map.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
logger.info(map.get("message").toString());
return JsonResult.error(map.get("message").toString());
return result;
}
}
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