Commit 86d6f621 authored by zhangc's avatar zhangc

添加api制作相关接口,修改组织管理额相关接口

parent 7f2c7f50
...@@ -6,19 +6,18 @@ CREATE TABLE `t_api_interface` ( ...@@ -6,19 +6,18 @@ CREATE TABLE `t_api_interface` (
`api_name` varchar(100) DEFAULT NULL COMMENT 'api名称', `api_name` varchar(100) DEFAULT NULL COMMENT 'api名称',
`api_protocl` varchar(32) DEFAULT NULL COMMENT 'api请求协议:http,https', `api_protocl` varchar(32) DEFAULT NULL COMMENT 'api请求协议:http,https',
`target_url` varchar(100) DEFAULT NULL COMMENT '目标url', `target_url` varchar(100) DEFAULT NULL COMMENT '目标url',
`api_type` varchar(50) NULL DEFAULT '' COMMENT 'api类型:1 数据银行制作大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 6 标签查询 9自定义', `api_type` varchar(50) NULL DEFAULT '' COMMENT '接入类型:字典表对应key值',
`req_method` varchar(20) NULL DEFAULT NULL COMMENT '请求方式: GET, POST', `req_type` varchar(20) NULL DEFAULT NULL COMMENT '请求方式: GET, POST',
`api_function` varchar(200) DEFAULT NULL COMMENT '接口功能', `api_function` varchar(200) DEFAULT NULL COMMENT '接口功能',
`join_type` varchar(50) NULL DEFAULT NULL COMMENT '接入类型:字典表对应key值',
`status` varchar(50) NOT NULL COMMENT '状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)', `status` varchar(50) NOT NULL COMMENT '状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)',
`output_type` varchar(50) NULL DEFAULT 'JSON' COMMENT '输出类型:flow 流形式输出, json格式输出', `output_type` varchar(50) NULL DEFAULT 'JSON' COMMENT '输出类型:flow 流形式输出, json格式输出',
`version` varchar(20) DEFAULT 'v1.0' COMMENT '版本号', `version` varchar(20) DEFAULT 'v1.0' COMMENT '版本号',
`sign_type` varchar(50) DEFAULT NULL COMMENT '加密方式: MD5 RSA', `sign_type` varchar(50) DEFAULT NULL COMMENT '加密方式: MD5 RSA',
`timeout` varchar(50) DEFAULT NULL COMMENT '超时时间', `timeout` varchar(50) DEFAULT NULL COMMENT '超时时间',
`file_id` bigint(20) NOT NULL COMMENT '文件夹id', `file_id` bigint(20) DEFAULT NULL COMMENT '文件夹id',
`req_type` varchar(20) DEFAULT NULL COMMENT '限流类型:DAY 按天,MONTH 按月, YEAR 按年', `limit_type` varchar(20) DEFAULT NULL COMMENT '限流类型:DAY 按天,MONTH 按月, YEAR 按年',
`req_frequency` bigint(20) DEFAULT '100' COMMENT '限制次数', `req_frequency` bigint(20) DEFAULT '100' COMMENT '限制次数',
`api_custom_id` bigint(20) NULL COMMENT 'API扩展表id' `is_send_bank` tinyint(2) NULL DEFAULT 0 COMMENT '是否发送到数据银行: 0 false ,1 true '
`remark` varchar(500) DEFAULT NULL COMMENT '备注', `remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`create_user` varchar(100) DEFAULT NULL COMMENT '创建人', `create_user` varchar(100) DEFAULT NULL COMMENT '创建人',
...@@ -116,6 +115,7 @@ CREATE TABLE `t_api_auth` ( ...@@ -116,6 +115,7 @@ CREATE TABLE `t_api_auth` (
`auth_mode` varchar(50) DEFAULT NULL COMMENT '授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用 PERMANENT_TIME_MODE 永久有效', `auth_mode` varchar(50) DEFAULT NULL COMMENT '授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用 PERMANENT_TIME_MODE 永久有效',
`valid_start_time` datetime DEFAULT NULL COMMENT '开始时间', `valid_start_time` datetime DEFAULT NULL COMMENT '开始时间',
`valid_end_time` datetime DEFAULT NULL COMMENT '结束时间', `valid_end_time` datetime DEFAULT NULL COMMENT '结束时间',
`valid_expr_date` datetime DEFAULT NULL COMMENT '有效截止时间',
`handler` tinyint(2) NULL DEFAULT '0' COMMENT '处理状态:0 未处理, 1 已处理', `handler` tinyint(2) NULL DEFAULT '0' COMMENT '处理状态:0 未处理, 1 已处理',
`status` varchar(50) NOT NULL COMMENT '状态(VALID-正常 UN_VALID-无效)', `status` varchar(50) NOT NULL COMMENT '状态(VALID-正常 UN_VALID-无效)',
`remark` varchar(500) DEFAULT NULL COMMENT '备注', `remark` varchar(500) DEFAULT NULL COMMENT '备注',
......
...@@ -75,6 +75,9 @@ public enum GatewayResultCode implements ResultCode { ...@@ -75,6 +75,9 @@ public enum GatewayResultCode implements ResultCode {
/** 单次调用金额不足 */ /** 单次调用金额不足 */
CALL_AMOUNT_NOT_ENOUGH("CALL_AMOUNT_NOT_ENOUGH", "单次调用金额不足"), CALL_AMOUNT_NOT_ENOUGH("CALL_AMOUNT_NOT_ENOUGH", "单次调用金额不足"),
/** 认证API已过有效期 */
AUTH_EXCEED_TIME("AUTH_EXCEED_TIME", "认证API已过有效期"),
/** 输出类型错误 */ /** 输出类型错误 */
OUTPUT_TYPE_EXCEPTION("OUTPUT_TYPE_EXCEPTION", "输出类型错误!"); OUTPUT_TYPE_EXCEPTION("OUTPUT_TYPE_EXCEPTION", "输出类型错误!");
/** /**
......
...@@ -30,7 +30,7 @@ public enum AuthTypeEnum { ...@@ -30,7 +30,7 @@ public enum AuthTypeEnum {
return text; return text;
} }
public static AuthTypeEnum fromTypeName(String typeName) { public static AuthTypeEnum fromAuthTypeName(String typeName) {
for (AuthTypeEnum type : AuthTypeEnum.values()) { for (AuthTypeEnum type : AuthTypeEnum.values()) {
if (type.name().equals(typeName)) { if (type.name().equals(typeName)) {
return type; return type;
......
...@@ -43,6 +43,24 @@ public class DateUtil { ...@@ -43,6 +43,24 @@ public class DateUtil {
c.set(Calendar.SECOND, 59); c.set(Calendar.SECOND, 59);
return (c.getTimeInMillis() - System.currentTimeMillis()) / 1000; return (c.getTimeInMillis() - System.currentTimeMillis()) / 1000;
} }
/**
* 获取指定年份的时间
* @param year
* @return
*/
public static Date getAssignYearDate(Integer year){
Calendar cal = Calendar.getInstance();
/* int year =cal.get(Calendar.YEAR)+1;
int month=cal.get(Calendar.MONTH)+1;
cal.add(Calendar.MONTH, 0);*/
//Date date = cal.getTime(); //结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
cal.set(Calendar.YEAR,cal.get(Calendar.YEAR)+year);
Date date=cal.getTime();
System.out.println(sdf.format(date));
return date;
}
public static void main(String[] args) { public static void main(String[] args) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//System.out.println(calculateNowResidueTime()); //System.out.println(calculateNowResidueTime());
......
...@@ -125,6 +125,11 @@ public class RandomUtil { ...@@ -125,6 +125,11 @@ public class RandomUtil {
builder.append(userNum); builder.append(userNum);
} }
coding = getCodeInfo(userId, coding, builder, month, day, hour, minute, second); coding = getCodeInfo(userId, coding, builder, month, day, hour, minute, second);
}else { //无内外部之分
if (StringUtils.isBlank(orgCode)) {
return "";
}
coding = getCodeInfo(orgCode, coding, builder, month, day, hour, minute, second);
} }
return coding; return coding;
} }
......
...@@ -31,7 +31,6 @@ public class ApiInterfaceController { ...@@ -31,7 +31,6 @@ public class ApiInterfaceController {
/** /**
* @Description:API列表查询 * @Description:API列表查询
* @return: API列表
* @Author: Mr.zhang * @Author: Mr.zhang
* @Date: 2020-12-24 * @Date: 2020-12-24
*/ */
...@@ -42,7 +41,6 @@ public class ApiInterfaceController { ...@@ -42,7 +41,6 @@ public class ApiInterfaceController {
} }
/** /**
* @Description:API列表查询 * @Description:API列表查询
* @return: API列表
* @Author: Mr.zhang * @Author: Mr.zhang
* @Date: 2020-12-24 * @Date: 2020-12-24
*/ */
...@@ -53,7 +51,6 @@ public class ApiInterfaceController { ...@@ -53,7 +51,6 @@ public class ApiInterfaceController {
} }
/** /**
* @Description:API详情查询 * @Description:API详情查询
* @return: API详情查询
* @Author: Mr.zhang * @Author: Mr.zhang
* @Date: 2020-12-24 * @Date: 2020-12-24
*/ */
...@@ -64,7 +61,6 @@ public class ApiInterfaceController { ...@@ -64,7 +61,6 @@ public class ApiInterfaceController {
} }
/** /**
* @Description:API删除 * @Description:API删除
* @return: API删除
* @Author: Mr.zhang * @Author: Mr.zhang
* @Date: 2020-12-24 * @Date: 2020-12-24
*/ */
...@@ -75,7 +71,6 @@ public class ApiInterfaceController { ...@@ -75,7 +71,6 @@ public class ApiInterfaceController {
} }
/** /**
* @Description:DMP-API删除 * @Description:DMP-API删除
* @return: DMP-API删除
* @Author: Mr.zhang * @Author: Mr.zhang
* @Date: 2020-12-24 * @Date: 2020-12-24
*/ */
...@@ -86,5 +81,26 @@ public class ApiInterfaceController { ...@@ -86,5 +81,26 @@ public class ApiInterfaceController {
return Mono.fromSupplier(() -> apiInterfaceService.dmpDeleteAuth(type,apiKey)); return Mono.fromSupplier(() -> apiInterfaceService.dmpDeleteAuth(type,apiKey));
} }
/**
* @Description:数据修改发送状态接口
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation("数据修改发送状态接口")
@GetMapping(value = "/updateSendStatus")
public Mono<Result> updateApiSendStatus(@RequestParam (name="apiKey")String apiKey) {
return Mono.fromSupplier(() -> apiInterfaceService.updateApiSendStatus(apiKey));
}
/**
* @Description: 已发送到数据银行API列表
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation("已发送到数据银行API列表")
@GetMapping(value = "/listSendDataBank")
public Mono<Result> listSendDataBank(@RequestParam (name="pageNum",defaultValue = "1",required = false)String pageNum,
@RequestParam (name="pageSize",defaultValue = "20",required = false)String pageSize) {
return Mono.fromSupplier(() -> apiInterfaceService.getSendDataBankList(pageNum, pageSize));
}
} }
...@@ -29,6 +29,16 @@ public class AuthController { ...@@ -29,6 +29,16 @@ public class AuthController {
@Autowired @Autowired
private AuthService authService; private AuthService authService;
/**
* @Description:服务授权列表
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("服务授权列表")
@PostMapping(value = "/getServiceAuthList")
public Mono<Result> getServiceAuthList(@RequestBody @Valid ServiceAuthReq req) {
return Mono.fromSupplier(() -> authService.getServiceAuthList(req));
}
/** /**
* @Description:商城用户API认证 * @Description:商城用户API认证
* @return: 商城用户API认证 * @return: 商城用户API认证
......
package com.jz.dm.controller; package com.jz.dm.controller;
import com.jz.common.utils.Result; import com.jz.common.utils.Result;
import com.jz.dm.models.req.CreateFolderReq; import com.jz.dm.models.req.folder.CreateFolderReq;
import com.jz.dm.models.req.make.ApiInterfaceReq; import com.jz.dm.models.req.producer.ApiInterfaceReq;
import com.jz.dm.models.req.producer.ServiceIssueReq;
import com.jz.dm.service.ProducerService; import com.jz.dm.service.ProducerService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -50,6 +51,28 @@ public class ProducerController { ...@@ -50,6 +51,28 @@ public class ProducerController {
public Mono<Result> createProjectFolder(@RequestBody @Valid CreateFolderReq req) { public Mono<Result> createProjectFolder(@RequestBody @Valid CreateFolderReq req) {
return Mono.fromSupplier(() -> producerService.createProjectFolder(req)); return Mono.fromSupplier(() -> producerService.createProjectFolder(req));
} }
/**
* @Description:服务发布列表
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("服务发布列表")
@PostMapping(value = "/getServiceIssueList")
public Mono<Result> getServiceIssueList(@RequestBody @Valid ServiceIssueReq req) {
return Mono.fromSupplier(() -> producerService.getServiceIssueList(req));
}
/**
* @Description:服务发布/服务取消
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("服务发布/服务取消")
@GetMapping(value = "/optionApiIssueStatus")
public Mono<Result> optionApiIssueStatus(@RequestParam(name = "id")Long id,
@RequestParam(name="optStatus")Boolean optStatus) {
return Mono.fromSupplier(() -> producerService.optionApiIssueStatus(id,optStatus));
}
/** /**
* @Description:获取APIID * @Description:获取APIID
* @Author: Mr.zhang * @Author: Mr.zhang
...@@ -58,7 +81,7 @@ public class ProducerController { ...@@ -58,7 +81,7 @@ public class ProducerController {
@ApiOperation("Api制作(获取ApiId)") @ApiOperation("Api制作(获取ApiId)")
@PostMapping(value = "/getCustomApiId") @PostMapping(value = "/getCustomApiId")
public Mono<Result> getCustomApiId() { public Mono<Result> getCustomApiId() {
return Mono.fromSupplier(() -> Result.of_success(producerService.getCustomApiId())); return Mono.fromSupplier(() ->producerService.getCustomApiId());
} }
/** /**
......
...@@ -140,11 +140,18 @@ public class AuthFilter extends AbstractFilter { ...@@ -140,11 +140,18 @@ public class AuthFilter extends AbstractFilter {
*/ */
private void checkBill(GatewayRequest request, String authCode, private void checkBill(GatewayRequest request, String authCode,
ApiAuth authAuth) throws ParseException { ApiAuth authAuth) throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat(Constants.DATE_TIME_FORMAT);
String formatDate = dateFormat.format(new Date());
Date currentDate = dateFormat.parse(formatDate);
switch (authAuth.getAuthMode()) { switch (authAuth.getAuthMode()) {
case "POWER_CALL_MODE": //按次调用 case "POWER_CALL_MODE": //按次调用
Date validExprDate = authAuth.getValidExprDate();
if (currentDate.after(validExprDate)) {//超出时间
throw new GatewayException(GatewayResultCode.AUTH_EXCEED_TIME);
}
try { //记录请求次数(每天限制请求次数)
//查询数据银行银行余额是否充足 //查询数据银行银行余额是否充足
getDataAmountResult(request); getDataAmountResult(request);
try { //记录请求次数(每天限制请求次数)
String limitKey = TagConstants.OPEN_API_REDIS_LIMIT_KEY + authCode; String limitKey = TagConstants.OPEN_API_REDIS_LIMIT_KEY + authCode;
Integer reqValue = (Integer) redisUtils.getObj(limitKey); Integer reqValue = (Integer) redisUtils.getObj(limitKey);
long timeOut = 0; long timeOut = 0;
...@@ -172,9 +179,6 @@ public class AuthFilter extends AbstractFilter { ...@@ -172,9 +179,6 @@ public class AuthFilter extends AbstractFilter {
} }
break; break;
case "RECORD_TIME_MODE": //按时间调用 case "RECORD_TIME_MODE": //按时间调用
SimpleDateFormat dateFormat = new SimpleDateFormat(Constants.DATE_TIME_FORMAT);
String formatDate = dateFormat.format(new Date());
Date currentDate = dateFormat.parse(formatDate);
Date validEndTime = authAuth.getValidEndTime(); Date validEndTime = authAuth.getValidEndTime();
//如果 date1 在 date2 之前,before 返回 true,否则返回 false //如果 date1 在 date2 之前,before 返回 true,否则返回 false
if (currentDate.after(validEndTime)) {//超出时间 if (currentDate.after(validEndTime)) {//超出时间
...@@ -183,6 +187,10 @@ public class AuthFilter extends AbstractFilter { ...@@ -183,6 +187,10 @@ public class AuthFilter extends AbstractFilter {
} }
break; break;
case "PERMANENT_TIME_MODE"://永久有效(直接跳出) case "PERMANENT_TIME_MODE"://永久有效(直接跳出)
Date validExpr = authAuth.getValidExprDate();
if (currentDate.after(validExpr)) {//超出时间
throw new GatewayException(GatewayResultCode.AUTH_EXCEED_TIME);
}
break; break;
default: default:
throw new GatewayException(GatewayResultCode.ILLEGAL_REQUEST); throw new GatewayException(GatewayResultCode.ILLEGAL_REQUEST);
......
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jz.dm.models.domian.ApiInterface; import com.jz.dm.models.domian.ApiInterface;
import com.jz.dm.models.domian.ApiInterfaceCustom; import com.jz.dm.models.domian.ApiInterfaceCustom;
import com.jz.dm.models.dto.ApiServiceApplyDto;
import com.jz.dm.models.req.api.ApiInterfaceDetailReq; import com.jz.dm.models.req.api.ApiInterfaceDetailReq;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -52,5 +53,19 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> { ...@@ -52,5 +53,19 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
ApiInterfaceCustom getTestData(String apiKey); ApiInterfaceCustom getTestData(String apiKey);
/**
* 查询服务发布列表
* @param page
* @param query
* @return
*/
IPage<ApiServiceApplyDto > listApiIssueService(IPage<ApiServiceApplyDto> page, @Param("ew") Wrapper<ApiServiceApplyDto> query);
/**
* 查询服务授权列表
* @param page
* @param query
* @return
*/
IPage<ApiServiceApplyDto > listApiAuthService(IPage<ApiServiceApplyDto> page, @Param("ew") Wrapper<ApiServiceApplyDto> query);
} }
...@@ -97,6 +97,15 @@ public class ApiAuth extends BaseObject implements Serializable { ...@@ -97,6 +97,15 @@ public class ApiAuth extends BaseObject implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date validEndTime; private Date validEndTime;
/**
* 有效截止时间
*/
@ApiModelProperty("有效截止时间")
@TableField("valid_expr_date")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date validExprDate;
/** /**
* 处理状态:0 未处理, 1 已处理 * 处理状态:0 未处理, 1 已处理
......
...@@ -45,7 +45,7 @@ public class ApiInterface extends BaseObject implements Serializable { ...@@ -45,7 +45,7 @@ public class ApiInterface extends BaseObject implements Serializable {
private String apiProtocl; private String apiProtocl;
/** /**
* api类型: 1 API实时接入 2 DMP标签查询 3 数据表查询 4 三方查询' * 接入类型:对应字典表key
*/ */
@TableField("api_type") @TableField("api_type")
private String apiType; private String apiType;
...@@ -55,16 +55,12 @@ public class ApiInterface extends BaseObject implements Serializable { ...@@ -55,16 +55,12 @@ public class ApiInterface extends BaseObject implements Serializable {
*/ */
@TableField("target_url") @TableField("target_url")
private String targetUrl; private String targetUrl;
/** /**
* 请求方式:GET POST * 请求方式:GET POST
*/ */
@TableField("req_method") @TableField("req_type")
private String reqMethod; private String reqType;
/**
* 接入类型:对应字典表key
*/
@TableField("join_type")
private String joinType;
/** /**
* '输出类型:flow 流形式输出, json格式输出', * '输出类型:flow 流形式输出, json格式输出',
...@@ -99,8 +95,8 @@ public class ApiInterface extends BaseObject implements Serializable { ...@@ -99,8 +95,8 @@ public class ApiInterface extends BaseObject implements Serializable {
/** /**
* 限流类型:DAY 按天,MONTH 按月, YEAR 按年 * 限流类型:DAY 按天,MONTH 按月, YEAR 按年
*/ */
@TableField("req_type") @TableField("limit_type")
private String reqType; private String limitType;
/** /**
* 限制次数 * 限制次数
...@@ -113,6 +109,7 @@ public class ApiInterface extends BaseObject implements Serializable { ...@@ -113,6 +109,7 @@ public class ApiInterface extends BaseObject implements Serializable {
@TableField("timeout") @TableField("timeout")
private String timeout; private String timeout;
/** /**
* 文件夹id * 文件夹id
*/ */
...@@ -120,10 +117,10 @@ public class ApiInterface extends BaseObject implements Serializable { ...@@ -120,10 +117,10 @@ public class ApiInterface extends BaseObject implements Serializable {
private Long fileId; private Long fileId;
/** /**
* API扩展表id * 是否发送到数据银行
*/ */
@TableField("api_custom_id") @TableField("is_send_bank")
private Long apiCustomId; private Boolean isSendBank;
/*-----------------------------------保存数据库时忽略字段--------------------------------*/ /*-----------------------------------保存数据库时忽略字段--------------------------------*/
/** /**
......
...@@ -33,8 +33,8 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable { ...@@ -33,8 +33,8 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
/** /**
* apiInterfaceId * apiInterfaceId
*/ */
/* @TableField("api_interface_id") @TableField("api_interface_id")
private Long apiInterfaceId;*/ private Long apiInterfaceId;
/** /**
...@@ -105,4 +105,7 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable { ...@@ -105,4 +105,7 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
@TableField("page_row") @TableField("page_row")
private Long pageRow; private Long pageRow;
} }
package com.jz.dm.models.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.dto
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiServiceApplyDto
* @DATE: 2021-1-28/11:10
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel(value = "服务发布/授权应用类")
public class ApiServiceApplyDto implements Serializable {
@ApiModelProperty(value = "apiId")
private String apiId;
@ApiModelProperty(value = "api名称")
private String apiName;
@ApiModelProperty(value = "api类型")
private String apiType;
@ApiModelProperty(value = "返回类型")
private String outputType;
@ApiModelProperty(value = "请求方式")
private String reqType;
@ApiModelProperty(value = "最大数据量")
private Long maxRow;
@ApiModelProperty(value = "每页行数")
private Long pageRow;
@ApiModelProperty(value = "描述")
private String apiFunction;
@ApiModelProperty(value = "是否发布到数据银行,0 false 1 true")
private Boolean isSendBank;
@ApiModelProperty(value = "授权码")
private String authCode;
}
...@@ -38,9 +38,9 @@ public class AuthUserApiReq implements Serializable { ...@@ -38,9 +38,9 @@ public class AuthUserApiReq implements Serializable {
@NotNull(message = "组织编码不能为空") @NotNull(message = "组织编码不能为空")
private String orgCode; private String orgCode;
/* @ApiModelProperty(value = "授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH 授权",required = true) @ApiModelProperty(value = "授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH 授权",required = true)
@NotNull(message = "授权类型不能为空") @NotNull(message = "授权类型不能为空")
private String authType;*/ private String authType;
@ApiModelProperty(value = "授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效",required = true) @ApiModelProperty(value = "授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效",required = true)
@NotNull(message = "授权方式不能为空") @NotNull(message = "授权方式不能为空")
......
package com.jz.dm.models.req.auth;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req.auth
* @PROJECT_NAME: jz-dm-parent
* @NAME: ServiceAuthReq
* @DATE: 2021-1-28/11:50
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel(value = "服务授权请求体")
public class ServiceAuthReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "文件夹id",required = false)
private Long folderId;
@ApiModelProperty(value = "api名称",required = false)
private String apiName;
@ApiModelProperty(value = "apiId",required = false)
private String apiId;
}
package com.jz.dm.models.req.folder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: CreateFolderReq
* @DATE: 2021-1-27/18:12
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@Data
@ApiModel("创建文件请求体")
public class CreateFolderReq implements Serializable {
@ApiModelProperty(value = "项目id",required = false)
private Long projectId;
@ApiModelProperty(value = "父类文件夹id ,创建同级不传",required = false)
private Long parentId;
@ApiModelProperty(value = "文件夹名称",required = true)
@NotBlank(message = "文件夹名称不能为空!")
private String fileName;
@ApiModelProperty(value = "文件来源:,1 API制做,2 组织创建",required = true)
@NotBlank(message = "文件来源不能为空")
private String fileSource;
@ApiModelProperty(value = "创建用户",required = false)
private String createUser;
}
package com.jz.dm.models.req.make;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeBigDataApiReq
* @DATE: 2020-12-26/13:08
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel("Api制作大数据查询/标签查询请求体")
public class MakeBigDataApiReq implements Serializable {
@ApiModelProperty(value = "id--更新时id不能为空",required = false)
private Long id;
/* @ApiModelProperty(value = "数据类型:api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 8 查询hive数据源 9自定义",required = true)
@NotNull(message = "apiType不能为空")
private String apiType;*/
@ApiModelProperty(value = "apiKey",required = false)
@NotNull(message = "apiKey不能为空")
public String apiKey;
//@ApiModelProperty(value = "是否分页",required = false)
//public Boolean page;
@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;
//@ApiModelProperty(value = "项目id",required = true)
//@NotNull(message="项目id不能为空")
//public Long projectId;
//@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
//public Long parentId;
//
//@ApiModelProperty(value = "文件id",required = false)
//public Long fileId;
}
...@@ -29,4 +29,9 @@ public class OrganizationManageListQueryReq extends BasePageBean implements Seri ...@@ -29,4 +29,9 @@ public class OrganizationManageListQueryReq extends BasePageBean implements Seri
@ApiModelProperty(value = "组织联系人") @ApiModelProperty(value = "组织联系人")
private String linkman; private String linkman;
@ApiModelProperty(value = "组织文件夹")
private Long fileId;
} }
package com.jz.dm.models.req.make; package com.jz.dm.models.req.producer;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -30,19 +30,18 @@ public class ApiInterfaceReq implements Serializable { ...@@ -30,19 +30,18 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "Api类型:对应字典表key",required = true) @ApiModelProperty(value = "Api类型:对应字典表key",required = true)
@NotNull(message = "Api类型不能为空") @NotNull(message = "Api类型不能为空")
public String joinType; public String apiType;
@ApiModelProperty(value = "apiKey",required = true) @ApiModelProperty(value = "apiKey",required = true)
@NotNull(message = "apiKey不能为空") @NotNull(message = "apiKey不能为空")
public String apiKey; public String apiKey;
@ApiModelProperty(value = "目标地址",required = true) @ApiModelProperty(value = "目标地址",required = false)
@NotNull(message="目标地址不能为空")
public String targetUrl; public String targetUrl;
@ApiModelProperty(value = "请求方式:GET POST",required = true) @ApiModelProperty(value = "请求方式:GET POST",required = true)
@NotNull(message="请求方式不能为空") @NotNull(message="请求方式不能为空")
public String reqMethod; public String reqType;
@ApiModelProperty(value = "超时时间",required = true) @ApiModelProperty(value = "超时时间",required = true)
@NotNull(message="超时时间不能为空") @NotNull(message="超时时间不能为空")
...@@ -50,7 +49,7 @@ public class ApiInterfaceReq implements Serializable { ...@@ -50,7 +49,7 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "限流类型:DAY 按天,MONTH 按月, YEAR 按年",required = true) @ApiModelProperty(value = "限流类型:DAY 按天,MONTH 按月, YEAR 按年",required = true)
@NotNull(message = "限流类型不能为空") @NotNull(message = "限流类型不能为空")
public String reqType; public String limitType;
@ApiModelProperty(value = "API名称",required = false) @ApiModelProperty(value = "API名称",required = false)
public String apiName; public String apiName;
...@@ -63,7 +62,7 @@ public class ApiInterfaceReq implements Serializable { ...@@ -63,7 +62,7 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "文件夹Id",required = true) @ApiModelProperty(value = "文件夹Id",required = true)
@NotNull(message="文件夹Id不能为空") @NotNull(message="文件夹Id不能为空")
public Long folderId; public Long fileId;
@ApiModelProperty(value = "项目编号",required = true) @ApiModelProperty(value = "项目编号",required = true)
@NotNull(message="项目编号不能为空") @NotNull(message="项目编号不能为空")
...@@ -106,9 +105,9 @@ public class ApiInterfaceReq implements Serializable { ...@@ -106,9 +105,9 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "创建用户",hidden = true) @ApiModelProperty(value = "创建用户",hidden = true)
public String updateUser; public String updateUser;
@ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " + /* @ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " +
"2 数据银行制作数据包,3,数据银行制作自定义API " + "2 数据银行制作数据包,3,数据银行制作自定义API " +
"4 API实时接入 6 标签查询 9自定义",hidden = true) "4 API实时接入 6 标签查询 9自定义",hidden = true)
public String apiType; public String apiType;*/
} }
package com.jz.dm.models.req.producer;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeBigDataApiReq
* @DATE: 2020-12-26/13:08
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel("Api制作大数据查询/标签查询请求体")
public class MakeBigDataApiReq implements Serializable {
// @ApiModelProperty(value = "id--更新时id不能为空",required = false)
// private Long id;
//
///* @ApiModelProperty(value = "数据类型:api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 8 查询hive数据源 9自定义",required = true)
// @NotNull(message = "apiType不能为空")
// private String apiType;*/
//
// @ApiModelProperty(value = "apiKey",required = false)
// @NotNull(message = "apiKey不能为空")
// public String apiKey;
//
// //@ApiModelProperty(value = "是否分页",required = false)
// //public Boolean page;
//
// @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;
//
// //@ApiModelProperty(value = "项目id",required = true)
// //@NotNull(message="项目id不能为空")
// //public Long projectId;
//
// //@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
// //public Long parentId;
// //
// //@ApiModelProperty(value = "文件id",required = false)
// //public Long fileId;
}
package com.jz.dm.models.req.make; package com.jz.dm.models.req.producer;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
......
package com.jz.dm.models.req.make; package com.jz.dm.models.req.producer;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import lombok.Data; import lombok.Data;
......
package com.jz.dm.models.req.producer;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req.producer
* @PROJECT_NAME: jz-dm-parent
* @NAME: ServiceIssueReq
* @DATE: 2021-1-28/11:00
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel(value = "服务发布请求体")
public class ServiceIssueReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "文件夹id",required = false)
private Long fileId;
@ApiModelProperty(value = "api名称",required = false)
private String apiName;
@ApiModelProperty(value = "apiId",required = false)
private String apiId;
}
package com.jz.dm.models.req.make; package com.jz.dm.models.req.producer;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
......
...@@ -92,4 +92,18 @@ public interface ApiInterfaceService { ...@@ -92,4 +92,18 @@ public interface ApiInterfaceService {
*/ */
ApiInterfaceCustom getApiCustomInfo(Long apiInterfaceId); ApiInterfaceCustom getApiCustomInfo(Long apiInterfaceId);
/**
* 更新数据银行调用状态
* @param apiKey
* @return
*/
Result updateApiSendStatus(String apiKey);
/**
* 获取已发送到数据API列表
* @param pageNum
* @param pageSize
* @return
*/
Result getSendDataBankList(String pageNum, String pageSize);
} }
...@@ -84,4 +84,11 @@ public interface AuthService { ...@@ -84,4 +84,11 @@ public interface AuthService {
* @return * @return
*/ */
Result getAuthNameList(String key); Result getAuthNameList(String key);
/**
* 获取服务授权列表
* @param req
* @return
*/
Result getServiceAuthList(ServiceAuthReq req);
} }
package com.jz.dm.service; package com.jz.dm.service;
import com.jz.common.utils.Result; import com.jz.common.utils.Result;
import com.jz.dm.models.req.CreateFolderReq; import com.jz.dm.models.req.folder.CreateFolderReq;
import com.jz.dm.models.req.make.ApiInterfaceReq; import com.jz.dm.models.req.producer.ApiInterfaceReq;
import com.jz.dm.models.req.producer.ServiceIssueReq;
/** /**
* @author ZC * @author ZC
...@@ -22,12 +23,7 @@ public interface ProducerService { ...@@ -22,12 +23,7 @@ public interface ProducerService {
*/ */
// Result addRealCustomApi(MakeRealCustomApiReq req); // Result addRealCustomApi(MakeRealCustomApiReq req);
/**
* Api制作(数据查询/标签查询)
* @param req
* @return
*/
Result addBigDataMakeApi(ApiInterfaceReq req);
/** /**
* 获取数据源配置 * 获取数据源配置
...@@ -74,7 +70,12 @@ public interface ProducerService { ...@@ -74,7 +70,12 @@ public interface ProducerService {
*/ */
//Result saveUpdateAPiInfo(ApiInterfaceReq req); //Result saveUpdateAPiInfo(ApiInterfaceReq req);
/**
* Api制作(数据查询/标签查询)
* @param req
* @return
*/
Result addBigDataMakeApi(ApiInterfaceReq req);
/** /**
* 保存 API基本信息 * 保存 API基本信息
* @param req * @param req
...@@ -102,6 +103,21 @@ public interface ProducerService { ...@@ -102,6 +103,21 @@ public interface ProducerService {
*/ */
Result getCustomApiId(); Result getCustomApiId();
/**
* 获取服务发布列表
* @param req
* @return
*/
Result getServiceIssueList(ServiceIssueReq req);
/**
* 服务发布/取消操作
* @param id
* @param optStatus
* @return
*/
Result optionApiIssueStatus(Long id, Boolean optStatus);
//Result saveObjOnRedis(); //Result saveObjOnRedis();
//Result getObjOnRedis(); //Result getObjOnRedis();
......
...@@ -285,4 +285,39 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService { ...@@ -285,4 +285,39 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
query.eq("is_deleted", 0); query.eq("is_deleted", 0);
return apiInterfaceMapper.selectOne(query); return apiInterfaceMapper.selectOne(query);
} }
/**
* 更新APi是否发送到数据银行状态
* @param apiKey
* @return
*/
@Override
public Result updateApiSendStatus(String apiKey) {
QueryWrapper<ApiInterface> queryWra = new QueryWrapper<>();
queryWra.eq("api_key",apiKey);
queryWra.eq("is_deleted",0);
ApiInterface apiInterface = apiInterfaceMapper.selectOne(queryWra);
if (null == apiInterface){
return Result.of_error(ResultMsg.DATA_NOT_FOUND);
}
UpdateWrapper<ApiInterface> updateWra = new UpdateWrapper<>();
updateWra.set("is_send_bank",0);
if (apiInterfaceMapper.update(null,updateWra) > 0){
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
}
return Result.of_error(ResultMsg.UPDATE_FAIL);
}
@Override
public Result getSendDataBankList(String pageNum, String pageSize) {
Integer pageN = Integer.valueOf(pageNum);
Integer pageS = Integer.valueOf(pageSize);
IPage<ApiInterface> page = new Page<>(pageN, pageS);
QueryWrapper<ApiInterface > query = new QueryWrapper<>();
query.eq("is_send_bank",1);
query.eq("status",ApiStatusEnum.ISSUE.name());
query.eq("is_deleted",0);
return Result.of_success(apiInterfaceMapper.selectPage(page, query));
}
} }
...@@ -5,13 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; ...@@ -5,13 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jz.common.constant.ResultMsg; import com.jz.common.constant.ResultMsg;
import com.jz.common.enums.auth.AuthTypeEnum;
import com.jz.common.utils.Result; import com.jz.common.utils.Result;
import com.jz.dm.common.constant.Constants;
import com.jz.dm.common.enums.GeneralStatusTypeEnum; import com.jz.dm.common.enums.GeneralStatusTypeEnum;
import com.jz.dm.common.enums.apiInterface.ApiStatusEnum; import com.jz.dm.common.enums.apiInterface.ApiStatusEnum;
import com.jz.dm.common.enums.auth.AuthModeEnum; import com.jz.dm.common.enums.auth.AuthModeEnum;
import com.jz.dm.common.enums.org.OrgStatusEnum; import com.jz.dm.common.util.DateUtil;
import com.jz.dm.common.util.RandomUtil; import com.jz.dm.common.util.RandomUtil;
import com.jz.dm.mapper.ApiAuthMapper; import com.jz.dm.mapper.ApiAuthMapper;
import com.jz.dm.mapper.ApiInterfaceMapper; import com.jz.dm.mapper.ApiInterfaceMapper;
...@@ -19,6 +17,7 @@ import com.jz.dm.mapper.ApiOrgMapper; ...@@ -19,6 +17,7 @@ import com.jz.dm.mapper.ApiOrgMapper;
import com.jz.dm.models.domian.ApiAuth; import com.jz.dm.models.domian.ApiAuth;
import com.jz.dm.models.domian.ApiInterface; import com.jz.dm.models.domian.ApiInterface;
import com.jz.dm.models.domian.ApiOrg; import com.jz.dm.models.domian.ApiOrg;
import com.jz.dm.models.dto.ApiServiceApplyDto;
import com.jz.dm.models.dto.AuthInfoDto; import com.jz.dm.models.dto.AuthInfoDto;
import com.jz.dm.models.req.auth.*; import com.jz.dm.models.req.auth.*;
import com.jz.dm.models.resp.AuthUserResponse; import com.jz.dm.models.resp.AuthUserResponse;
...@@ -34,6 +33,7 @@ import javax.annotation.Resource; ...@@ -34,6 +33,7 @@ import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import static com.jz.dm.common.enums.auth.AuthModeEnum.fromTypeModeName; import static com.jz.dm.common.enums.auth.AuthModeEnum.fromTypeModeName;
import static com.jz.dm.common.enums.auth.AuthTypeEnum.fromAuthTypeName;
/** /**
* @author ZC * @author ZC
...@@ -89,6 +89,29 @@ public class AuthServiceImpl implements AuthService { ...@@ -89,6 +89,29 @@ public class AuthServiceImpl implements AuthService {
return Result.of_success(apiAuthMapper.selectAuthDetail(req)); return Result.of_success(apiAuthMapper.selectAuthDetail(req));
} }
/**
* 获取服务授权列表
* @param req
* @return
*/
@Override
public Result getServiceAuthList(ServiceAuthReq req) {
IPage<ApiServiceApplyDto> page = new Page<>(req.getPageNum(), req.getPageSize());
QueryWrapper<ApiServiceApplyDto> query = new QueryWrapper<>();
if (null != req.getFolderId()){
query.eq("ai.file_id",req.getFolderId());
}
if (StringUtils.isNotBlank(req.getApiName())){
query.eq("ai.api_name",req.getApiName());
}
if (StringUtils.isNotBlank(req.getApiId())){
query.eq("ai.api_key",req.getApiId());
}
query.eq("ai.is_deleted",0);
query.orderByDesc("ai.create_time");
return Result.of_success(apiInterfaceMapper.listApiAuthService(page, query));
}
/** /**
* 添加dmp认证信息 * 添加dmp认证信息
* *
...@@ -102,20 +125,23 @@ public class AuthServiceImpl implements AuthService { ...@@ -102,20 +125,23 @@ public class AuthServiceImpl implements AuthService {
if (null == apiInterface) { if (null == apiInterface) {
return Result.of_error("api授权信息不存在!"); return Result.of_error("api授权信息不存在!");
} }
if (ApiStatusEnum.DRAFT.name().equals(apiInterface.getStatus())){
return Result.of_error("api未发布,无法授权");
}
if (ApiStatusEnum.EXPIRY.name().equals(apiInterface.getStatus())) { if (ApiStatusEnum.EXPIRY.name().equals(apiInterface.getStatus())) {
return Result.of_error("api已下架,无法授权"); return Result.of_error("api已下架,无法授权");
} }
ApiOrg apiOrg = apiOrgMapper.selectOne(new QueryWrapper<ApiOrg>().eq("org_code", req.getOrgCode())); ApiOrg apiOrg = apiOrgMapper.selectOne(new QueryWrapper<ApiOrg>().eq("org_code", req.getOrgCode()));
if (null == apiOrg || OrgStatusEnum.CANCEL.name().equals(apiOrg)) { if (null == apiOrg || !apiOrg.getStatus()) {
return Result.of_error("组织信息不存在!"); return Result.of_error("组织信息不存在!");
} }
//授权验证 //授权验证
//if (StringUtils.isNotBlank(req.getAuthType())){ if (StringUtils.isNotBlank(req.getAuthType())){
// if (null == fromTypeName(req.getAuthType())){ if (null == fromAuthTypeName(req.getAuthType())){
// return Result.of_error("授权类型不存在!"); return Result.of_error("授权类型不存在!");
// } }
//} }
//验证授权方式 //验证授权方式
if (StringUtils.isNotBlank(req.getAuthMode())) { if (StringUtils.isNotBlank(req.getAuthMode())) {
if (null == fromTypeModeName(req.getAuthMode())) { if (null == fromTypeModeName(req.getAuthMode())) {
...@@ -130,7 +156,7 @@ public class AuthServiceImpl implements AuthService { ...@@ -130,7 +156,7 @@ public class AuthServiceImpl implements AuthService {
if (StringUtils.isBlank(apiOrg.getOrgCode())) { if (StringUtils.isBlank(apiOrg.getOrgCode())) {
return Result.of_error("内部授权组织编码不能为空!!"); return Result.of_error("内部授权组织编码不能为空!!");
} }
return saveAuthInfo(apiInterface, apiOrg, req, Constants.AUTH_INT); return saveAuthInfo(apiInterface, apiOrg, req);
} }
/** /**
...@@ -149,16 +175,19 @@ public class AuthServiceImpl implements AuthService { ...@@ -149,16 +175,19 @@ public class AuthServiceImpl implements AuthService {
if (ApiStatusEnum.SOLDOUT.name().equals(apiInterface.getStatus())) { if (ApiStatusEnum.SOLDOUT.name().equals(apiInterface.getStatus())) {
return Result.of_error("api已下架,无法授权"); return Result.of_error("api已下架,无法授权");
} }
if (ApiStatusEnum.DRAFT.name().equals(apiInterface.getStatus())){
return Result.of_error("api未发布,无法授权");
}
ApiOrg apiOrg = apiOrgMapper.selectOne(new QueryWrapper<ApiOrg>().eq("org_code", req.getOrgCode())); ApiOrg apiOrg = apiOrgMapper.selectOne(new QueryWrapper<ApiOrg>().eq("org_code", req.getOrgCode()));
if (null == apiOrg || OrgStatusEnum.CANCEL.name().equals(apiOrg)) { if (null == apiOrg || !apiOrg.getStatus()) {
return Result.of_error("组织信息不存在!"); return Result.of_error("组织信息不存在!");
} }
//授权验证 //授权验证
//if (StringUtils.isNotBlank(req.getAuthType())){ if (StringUtils.isNotBlank(req.getAuthType())){
// if (null == fromTypeName(req.getAuthType())){ if (null == fromAuthTypeName(req.getAuthType())){
// return Result.of_error("授权类型不存在!"); return Result.of_error("授权类型不存在!");
// } }
//} }
//验证授权方式 //验证授权方式
if (StringUtils.isNotBlank(req.getAuthMode())) { if (StringUtils.isNotBlank(req.getAuthMode())) {
if (null == fromTypeModeName(req.getAuthMode())) { if (null == fromTypeModeName(req.getAuthMode())) {
...@@ -181,7 +210,7 @@ public class AuthServiceImpl implements AuthService { ...@@ -181,7 +210,7 @@ public class AuthServiceImpl implements AuthService {
if (StringUtils.isBlank(req.getUserId())) { if (StringUtils.isBlank(req.getUserId())) {
return Result.of_error("外部授权用户Id不能为空"); return Result.of_error("外部授权用户Id不能为空");
} }
return saveAuthInfo(apiInterface, apiOrg, req, Constants.AUTH_OUT); return saveAuthInfo(apiInterface, apiOrg, req);
} }
/** /**
...@@ -190,11 +219,10 @@ public class AuthServiceImpl implements AuthService { ...@@ -190,11 +219,10 @@ public class AuthServiceImpl implements AuthService {
* @param apiInterface * @param apiInterface
* @param apiOrg * @param apiOrg
* @param req * @param req
* @param orgType
* @return * @return
*/ */
private Result saveAuthInfo(ApiInterface apiInterface, ApiOrg apiOrg, private Result saveAuthInfo(ApiInterface apiInterface, ApiOrg apiOrg,
AuthUserApiReq req, String orgType) { AuthUserApiReq req) {
AuthUserResponse response = new AuthUserResponse(); AuthUserResponse response = new AuthUserResponse();
ApiAuth apiAuth = new ApiAuth(); ApiAuth apiAuth = new ApiAuth();
BeanUtils.copyProperties(req, apiAuth); BeanUtils.copyProperties(req, apiAuth);
...@@ -202,21 +230,11 @@ public class AuthServiceImpl implements AuthService { ...@@ -202,21 +230,11 @@ public class AuthServiceImpl implements AuthService {
apiAuth.setApiOrgId(apiOrg.getId()); apiAuth.setApiOrgId(apiOrg.getId());
apiAuth.setReqType(apiInterface.getReqType()); apiAuth.setReqType(apiInterface.getReqType());
apiAuth.setReqFrequency(apiInterface.getReqFrequency()); apiAuth.setReqFrequency(apiInterface.getReqFrequency());
if (Constants.AUTH_INT.equals(orgType)) {//内部授权 if (!AuthModeEnum.RECORD_TIME_MODE.name().equals(req.getAuthMode())){
apiAuth.setAuthType(AuthTypeEnum.DMP_AUTH.name()); apiAuth.setValidExprDate(DateUtil.getAssignYearDate(99));//过期时间
} else {
apiAuth.setAuthType(AuthTypeEnum.DATA_BANK_AUTH.name());
} }
//商城只有外部授权 //商城只有外部授权
String authCode = ""; String authCode = getAuthCode(apiOrg.getOrgCode(), "","");
//内部组织
if (StringUtils.isNotBlank(orgType) && Constants.AUTH_INT.equalsIgnoreCase(orgType)) {
authCode = getAuthCode(apiOrg.getOrgCode(), "", Constants.AUTH_INT);
//外部组织
} else if (StringUtils.isNotBlank(orgType)
&& Constants.AUTH_OUT.equalsIgnoreCase(orgType)) {
authCode = getAuthCode("", req.getUserId(), Constants.AUTH_OUT);
}
//生成盐值 //生成盐值
String salt = RandomUtil.getStringRandom(8); String salt = RandomUtil.getStringRandom(8);
apiAuth.setAuthCode(authCode);//授权码 apiAuth.setAuthCode(authCode);//授权码
......
...@@ -60,6 +60,9 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -60,6 +60,9 @@ public class OrganizationManageImpl implements OrganizationManageService {
if (StringUtils.isNotBlank(req.getOrgCode())) { if (StringUtils.isNotBlank(req.getOrgCode())) {
query.eq("org_code", req.getOrgCode()); query.eq("org_code", req.getOrgCode());
} }
if (null != req.getFileId()){
query.eq("org_folder_id",req.getFileId());
}
query.eq("is_deleted", 0); query.eq("is_deleted", 0);
query.orderByDesc("create_date"); query.orderByDesc("create_date");
return apiOrgMapper.selectPage(page, query); return apiOrgMapper.selectPage(page, query);
......
...@@ -3,6 +3,9 @@ package com.jz.dm.service.impl; ...@@ -3,6 +3,9 @@ package com.jz.dm.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jz.common.constant.ResultMsg; import com.jz.common.constant.ResultMsg;
import com.jz.common.exception.ResponseException; import com.jz.common.exception.ResponseException;
import com.jz.common.utils.HttpsUtils; import com.jz.common.utils.HttpsUtils;
...@@ -18,8 +21,10 @@ import com.jz.dm.models.domian.ApiInterface; ...@@ -18,8 +21,10 @@ import com.jz.dm.models.domian.ApiInterface;
import com.jz.dm.models.domian.ApiInterfaceCustom; import com.jz.dm.models.domian.ApiInterfaceCustom;
import com.jz.dm.models.domian.ApiInterfaceFile; import com.jz.dm.models.domian.ApiInterfaceFile;
import com.jz.dm.models.domian.ApiOpenApiEsFields; import com.jz.dm.models.domian.ApiOpenApiEsFields;
import com.jz.dm.models.req.CreateFolderReq; import com.jz.dm.models.dto.ApiServiceApplyDto;
import com.jz.dm.models.req.make.ApiInterfaceReq; import com.jz.dm.models.req.folder.CreateFolderReq;
import com.jz.dm.models.req.producer.ApiInterfaceReq;
import com.jz.dm.models.req.producer.ServiceIssueReq;
import com.jz.dm.service.ApiInterfaceService; import com.jz.dm.service.ApiInterfaceService;
import com.jz.dm.service.ProducerService; import com.jz.dm.service.ProducerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -107,22 +112,26 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -107,22 +112,26 @@ public class ProducerServiceImpl implements ProducerService {
@Override @Override
public Result createProjectFolder(CreateFolderReq req) { public Result createProjectFolder(CreateFolderReq req) {
if (null != req.getParentId()) { if (null != req.getParentId()) {
if (null == apiInterfaceFileMapper.selectById(req.getParentId())) { ApiInterfaceFile interfaceFile = apiInterfaceFileMapper.selectById(req.getParentId());
if (null == interfaceFile) {
return Result.of_error("父级文件夹不存在!"); return Result.of_error("父级文件夹不存在!");
} }
if (!req.getFileSource().equals(interfaceFile.getFileSource())){
return Result.of_error("父级文件类型错误!");
}
} }
if (StringUtils.isNotBlank(req.getFileSource()) && if (StringUtils.isNotBlank(req.getFileSource()) &&
"1".equals(req.getFileSource())) { //api制作创建文件夹 "1".equals(req.getFileSource())) { //api制作创建文件夹
if (null == req.getProjectId()) { if (null == req.getProjectId()) {
return Result.of_error("项目id不存在!"); return Result.of_error("项目id不存在!");
} }
if (addFolder(req)){ if (!addFolder(req)) {
return Result.of_error(ResultMsg.INSERT_FAIL); return Result.of_success(ResultMsg.INSERT_SUCCESS);
} }
} else if (StringUtils.isNotBlank(req.getFileSource()) && } else if (StringUtils.isNotBlank(req.getFileSource()) &&
"2".equals(req.getFileSource())) { //组织创建文件夹 "2".equals(req.getFileSource())) { //组织创建文件夹
if (addFolder(req)){ if (!addFolder(req)) {
return Result.of_error(ResultMsg.INSERT_FAIL); return Result.of_success(ResultMsg.INSERT_SUCCESS);
} }
} }
return Result.of_error(ResultMsg.INSERT_FAIL); return Result.of_error(ResultMsg.INSERT_FAIL);
...@@ -130,6 +139,7 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -130,6 +139,7 @@ public class ProducerServiceImpl implements ProducerService {
/** /**
* 添加文件夹 * 添加文件夹
*
* @param req * @param req
* @return * @return
*/ */
...@@ -137,6 +147,9 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -137,6 +147,9 @@ public class ProducerServiceImpl implements ProducerService {
ApiInterfaceFile interfaceFile = new ApiInterfaceFile(); ApiInterfaceFile interfaceFile = new ApiInterfaceFile();
BeanUtils.copyProperties(req, interfaceFile); BeanUtils.copyProperties(req, interfaceFile);
interfaceFile.setStatus(GeneralStatusTypeEnum.VALID.name()); interfaceFile.setStatus(GeneralStatusTypeEnum.VALID.name());
if (null == interfaceFile.getParentId() || "".equals(interfaceFile.getParentId())){
interfaceFile.setParentId(0L);//默认父类id为零
}
if (apiInterfaceFileMapper.insert(interfaceFile) == 0) { if (apiInterfaceFileMapper.insert(interfaceFile) == 0) {
return true; return true;
} }
...@@ -144,13 +157,75 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -144,13 +157,75 @@ public class ProducerServiceImpl implements ProducerService {
} }
/** /**
* 获取APIID * 获取服务发布列表
*
* @param req
* @return
*/
@Override
public Result getServiceIssueList(ServiceIssueReq req) {
IPage<ApiServiceApplyDto> page = new Page<>(req.getPageNum(), req.getPageSize());
QueryWrapper<ApiServiceApplyDto> query = new QueryWrapper<>();
if (null != req.getFileId()) {
query.eq("ai.file_id", req.getFileId());
}
if (StringUtils.isNotBlank(req.getApiName())) {
query.eq("ai.api_name", req.getApiName());
}
if (StringUtils.isNotBlank(req.getApiId())) {
query.eq("ai.api_key", req.getApiId());
}
query.eq("ai.is_deleted", 0);
query.orderByDesc("ai.create_date");
return Result.of_success(apiInterfaceMapper.listApiIssueService(page, query));
}
/**
* 服务发布取消操作
*
* @param id
* @param optStatus
* @return
*/
@Override
public Result optionApiIssueStatus(Long id, Boolean optStatus) {
int updateStatus = 0;
ApiInterface apiInterface = apiInterfaceMapper.selectById(id);
if (null == apiInterface) {
return Result.of_error(ResultMsg.DATA_NOT_FOUND);
}
//修改前后状态一致,无需修改直接返回
if (optStatus.equals(apiInterface.getStatus())) {
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
}
if (optStatus) {//发布
UpdateWrapper<ApiInterface> updateWra = new UpdateWrapper<>();
updateWra.set("status", ApiStatusEnum.ISSUE.name());
updateWra.eq("id", id);
updateStatus = apiInterfaceMapper.update(null, updateWra);
} else {//取消发布
if (apiInterface.getIsSendBank()) {
return Result.of_error("API信息已锁定,无法取消发布");
}
UpdateWrapper<ApiInterface> updateWra = new UpdateWrapper<>();
updateWra.set("status", ApiStatusEnum.DRAFT.name());
updateWra.eq("id", id);
updateStatus = apiInterfaceMapper.update(null, updateWra);
}
if (updateStatus > 0) {
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
}
return Result.of_error(ResultMsg.UPDATE_FAIL);
}
/**
* 获取ApiId
* *
* @return * @return
*/ */
@Override @Override
public Result getCustomApiId() { public Result getCustomApiId() {
return Result.of_success(getApiKey()); return Result.of_success(ResultMsg.SUCCESS,getApiKey());
} }
...@@ -163,7 +238,11 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -163,7 +238,11 @@ public class ProducerServiceImpl implements ProducerService {
@Override @Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Result addBigDataMakeApi(ApiInterfaceReq req) { public Result addBigDataMakeApi(ApiInterfaceReq req) {
if ("10002".equals(req.getJoinType())) {//数据查询 ApiInterface anInterface = apiInterfaceService.getApiInfo(req.apiKey);
if (null != anInterface){
return Result.of_error("API已存在!");
}
if ("10002".equals(req.getApiType())) {//数据查询
if (StringUtils.isBlank(req.getEsDataSource()) || if (StringUtils.isBlank(req.getEsDataSource()) ||
StringUtils.isBlank(req.getEsDataBase()) || StringUtils.isBlank(req.getEsDataBase()) ||
StringUtils.isBlank(req.getEsTable())) { StringUtils.isBlank(req.getEsTable())) {
...@@ -178,13 +257,13 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -178,13 +257,13 @@ public class ProducerServiceImpl implements ProducerService {
if (StringUtils.isBlank(req.getSignType()) || "0".equals(req.getSignType())) { if (StringUtils.isBlank(req.getSignType()) || "0".equals(req.getSignType())) {
return Result.of_error("加密类型错误!"); return Result.of_error("加密类型错误!");
} }
if (StringUtils.isNotBlank(req.getReqType())) { if (StringUtils.isNotBlank(req.getLimitType())) {
if (null == fromAuthReqTypeEnum(req.getReqType())) { if (null == fromAuthReqTypeEnum(req.getLimitType())) {
return Result.of_error("限流类型不存在!"); return Result.of_error("限流类型不存在!");
} }
} }
//校验文件夹信息 //校验文件夹信息
if (checkFileifExist(req.getFolderId(), req.getProjectId())) { if (checkFileifExist(req.getFileId(), req.getProjectId())) {
return Result.of_error("目标文件夹不存在!"); return Result.of_error("目标文件夹不存在!");
} }
//保存表字段信息 //保存表字段信息
...@@ -194,7 +273,8 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -194,7 +273,8 @@ public class ProducerServiceImpl implements ProducerService {
throw ResponseException.of_error(ResultMsg.UPDATE_FAIL); throw ResponseException.of_error(ResultMsg.UPDATE_FAIL);
} }
} else { //保存 } else { //保存
if (saveApiExtendData(req) || saveApiBaseData(req)) { ApiInterface apiInterface = saveApiBaseData(req);
if (saveApiExtendData(req,apiInterface.getId())) {
throw ResponseException.of_error(ResultMsg.INSERT_FAIL); throw ResponseException.of_error(ResultMsg.INSERT_FAIL);
} }
} }
...@@ -209,6 +289,9 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -209,6 +289,9 @@ public class ProducerServiceImpl implements ProducerService {
* @param req * @param req
*/ */
private void saveTableField(ApiInterfaceReq req) { private void saveTableField(ApiInterfaceReq req) {
if (StringUtils.isBlank(req.getTableFields())){
return;
}
QueryWrapper<ApiOpenApiEsFields> queryOpenApi = new QueryWrapper<>(); QueryWrapper<ApiOpenApiEsFields> queryOpenApi = new QueryWrapper<>();
queryOpenApi.eq("es_database", req.getEsDataBase()); queryOpenApi.eq("es_database", req.getEsDataBase());
queryOpenApi.eq("es_table", req.getEsTable()); queryOpenApi.eq("es_table", req.getEsTable());
...@@ -242,7 +325,7 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -242,7 +325,7 @@ public class ProducerServiceImpl implements ProducerService {
} }
/** /**
* DMP保存api基本信息/自定义API * DMP保存api基本信息/自定义API(三方查询)
* *
* @param req * @param req
* @return * @return
...@@ -250,8 +333,12 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -250,8 +333,12 @@ public class ProducerServiceImpl implements ProducerService {
@Override @Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public Result saveInterfaceAPi(ApiInterfaceReq req) { public Result saveInterfaceAPi(ApiInterfaceReq req) {
if (StringUtils.isNotBlank(req.getReqType())) { ApiInterface anInterface = apiInterfaceService.getApiInfo(req.apiKey);
if (null == fromAuthReqTypeEnum(req.getReqType())) { if (null != anInterface){
return Result.of_error("API已存在!");
}
if (StringUtils.isNotBlank(req.getLimitType())) {
if (null == fromAuthReqTypeEnum(req.getLimitType())) {
return Result.of_error("限流类型不存在!"); return Result.of_error("限流类型不存在!");
} }
} }
...@@ -263,14 +350,15 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -263,14 +350,15 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_error("限流次数不能小于或者等于零"); return Result.of_error("限流次数不能小于或者等于零");
} }
} }
if (StringUtils.isBlank(req.getTargetUrl())){
return Result.of_error("目标地址不存在!");
}
//校验文件夹信息 //校验文件夹信息
if (checkFileifExist(req.getFolderId(), req.getProjectId())) { if (checkFileifExist(req.getFileId(), req.getProjectId())) {
return Result.of_error("目标文件夹不存在!"); return Result.of_error("目标文件夹不存在!");
} }
if (saveApiBaseData(req)) { ApiInterface apiInterface = saveApiBaseData(req);
throw ResponseException.of_error("保存Api基本信息失败!"); if (saveApiExtendData(req,apiInterface.getId())) {
}
if (saveApiExtendData(req)) {
throw ResponseException.of_error("保存Api扩展信息失败!"); throw ResponseException.of_error("保存Api扩展信息失败!");
} }
//缓存API信息 //缓存API信息
...@@ -280,13 +368,14 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -280,13 +368,14 @@ public class ProducerServiceImpl implements ProducerService {
/** /**
* 保存APi扩展信息 * 保存APi扩展信息
* * @param id
* @param req * @param req
* @return * @return
*/ */
private boolean saveApiExtendData(ApiInterfaceReq req) { private boolean saveApiExtendData(ApiInterfaceReq req,Long id) {
ApiInterfaceCustom custom = new ApiInterfaceCustom(); ApiInterfaceCustom custom = new ApiInterfaceCustom();
BeanUtils.copyProperties(req, custom); BeanUtils.copyProperties(req, custom);
custom.setApiInterfaceId(id);
if (apiInterfaceCustomMapper.insert(custom) == 0) { if (apiInterfaceCustomMapper.insert(custom) == 0) {
return true; return true;
} }
...@@ -299,7 +388,7 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -299,7 +388,7 @@ public class ProducerServiceImpl implements ProducerService {
* @param req * @param req
* @return * @return
*/ */
private boolean saveApiBaseData(ApiInterfaceReq req) { private ApiInterface saveApiBaseData(ApiInterfaceReq req) {
ApiInterface apiInterface = new ApiInterface(); ApiInterface apiInterface = new ApiInterface();
BeanUtils.copyProperties(req, apiInterface); BeanUtils.copyProperties(req, apiInterface);
apiInterface.setStatus(ApiStatusEnum.DRAFT.name());//草稿状态 apiInterface.setStatus(ApiStatusEnum.DRAFT.name());//草稿状态
...@@ -313,7 +402,7 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -313,7 +402,7 @@ public class ProducerServiceImpl implements ProducerService {
throw ResponseException.of_error("接口超时时间最大5000ms"); throw ResponseException.of_error("接口超时时间最大5000ms");
} }
apiInterface.setTimeout(req.getTimeout()); apiInterface.setTimeout(req.getTimeout());
if ("10002".equals(req.getJoinType())) {//数据表查询时添加 if ("10002".equals(req.getApiType())) {//数据表查询时添加
if (ApiInfoOutTypeEnum.JSON.name().equals(req.getOutType())) { if (ApiInfoOutTypeEnum.JSON.name().equals(req.getOutType())) {
apiInterface.setTargetUrl(jsonUrl); apiInterface.setTargetUrl(jsonUrl);
} else if (ApiInfoOutTypeEnum.FLOW.name().equals(req.getOutType())) { } else if (ApiInfoOutTypeEnum.FLOW.name().equals(req.getOutType())) {
...@@ -321,9 +410,9 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -321,9 +410,9 @@ public class ProducerServiceImpl implements ProducerService {
} }
} }
if (apiInterfaceMapper.insert(apiInterface) == 0) { if (apiInterfaceMapper.insert(apiInterface) == 0) {
return true; throw ResponseException.of_error("添加API基本信息异常!");
} }
return false; return apiInterface;
} }
/** /**
...@@ -402,7 +491,11 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -402,7 +491,11 @@ public class ProducerServiceImpl implements ProducerService {
ApiInterface apiInterface = apiInterfaceMapper.selectById(req.getId()); ApiInterface apiInterface = apiInterfaceMapper.selectById(req.getId());
ApiInterfaceCustom interfaceCustom = null; ApiInterfaceCustom interfaceCustom = null;
if (null != apiInterface) { if (null != apiInterface) {
interfaceCustom = apiInterfaceCustomMapper.selectById(apiInterface.getApiCustomId()); QueryWrapper<ApiInterfaceCustom> query = new QueryWrapper<>();
query.eq("api_interface_id",req.getId());
query.eq("api_key",apiInterface.getApiKey());
query.eq("is_deleted",0);
interfaceCustom = apiInterfaceCustomMapper.selectOne(query);
} }
if (null == interfaceCustom) { if (null == interfaceCustom) {
throw ResponseException.of_error("更新API扩展信息不存在!"); throw ResponseException.of_error("更新API扩展信息不存在!");
...@@ -480,7 +573,8 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -480,7 +573,8 @@ public class ProducerServiceImpl implements ProducerService {
if (StringUtils.isBlank(req.getApiKey()) || if (StringUtils.isBlank(req.getApiKey()) ||
StringUtils.isBlank(req.getOutType()) || StringUtils.isBlank(req.getOutType()) ||
StringUtils.isBlank(req.getTargetUrl()) || StringUtils.isBlank(req.getTargetUrl()) ||
StringUtils.isBlank(req.getReqMethod())) { StringUtils.isBlank(req.getReqType()) ||
StringUtils.isBlank(req.getApiType())) {
log.info("--------------缓存数据为空"); log.info("--------------缓存数据为空");
return; return;
} }
...@@ -488,7 +582,8 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -488,7 +582,8 @@ public class ProducerServiceImpl implements ProducerService {
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
object.put("targetUrl", req.getTargetUrl()); object.put("targetUrl", req.getTargetUrl());
object.put("outputType", ApiInfoOutTypeEnum.JSON.name()); object.put("outputType", ApiInfoOutTypeEnum.JSON.name());
object.put("reqMethod", req.getReqMethod()); object.put("reqType", req.getReqType());
object.put("apiType",req.getApiType());
String apiKey = TagConstants.OPEN_API_CACHE_KEY + req.getApiKey(); String apiKey = TagConstants.OPEN_API_CACHE_KEY + req.getApiKey();
String paramKey = redisUtils.get(apiKey); String paramKey = redisUtils.get(apiKey);
if (null != paramKey) { if (null != paramKey) {
......
...@@ -113,12 +113,12 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService { ...@@ -113,12 +113,12 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
JSONObject jsonObject = JSONObject.parseObject(redisReqParam); JSONObject jsonObject = JSONObject.parseObject(redisReqParam);
String targetUrl = jsonObject.getString("targetUrl"); String targetUrl = jsonObject.getString("targetUrl");
String outputType = jsonObject.getString("outputType"); String outputType = jsonObject.getString("outputType");
String joinType = jsonObject.getString("joinType"); String apiType = jsonObject.getString("apiType");
bResult = rangRequestTarget(outputType, targetUrl, paramMap, bResult = rangRequestTarget(outputType, targetUrl, paramMap,
jsonParams, joinType, apiInterface, response); jsonParams, apiType, apiInterface, response);
} else {//不存在查询数据库 } else {//不存在查询数据库
bResult = rangRequestTarget(apiInterface.getOutputType(), bResult = rangRequestTarget(apiInterface.getOutputType(),
apiInterface.getTargetUrl(), paramMap, jsonParams, apiInterface.getJoinType(), apiInterface, response); apiInterface.getTargetUrl(), paramMap, jsonParams, apiInterface.getApiType(), apiInterface, response);
} }
//调用成功请求数据银行扣款 //调用成功请求数据银行扣款
if (AuthModeEnum.POWER_CALL_MODE.name().equals(apiAuth.getAuthMode())) { if (AuthModeEnum.POWER_CALL_MODE.name().equals(apiAuth.getAuthMode())) {
...@@ -148,11 +148,11 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService { ...@@ -148,11 +148,11 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
* @param outputType * @param outputType
* @param targetUrl * @param targetUrl
* @param param * @param param
* @param joinType * @param apiType
* @param response * @param response
*/ */
private boolean rangRequestTarget(String outputType, String targetUrl, private boolean rangRequestTarget(String outputType, String targetUrl,
Map<String, String> param, JSONObject jsonParams, String joinType, Map<String, String> param, JSONObject jsonParams, String apiType,
ApiInterface apiInterface, OpenApiResponse response) { ApiInterface apiInterface, OpenApiResponse response) {
if (StringUtils.isBlank(outputType)) { if (StringUtils.isBlank(outputType)) {
outputType = ApiInfoOutTypeEnum.JSON.name(); outputType = ApiInfoOutTypeEnum.JSON.name();
...@@ -160,14 +160,14 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService { ...@@ -160,14 +160,14 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
if (StringUtils.isBlank(targetUrl)) { if (StringUtils.isBlank(targetUrl)) {
throw new GatewayException(GatewayResultCode.REQUEST_PARAM_EMPTY); throw new GatewayException(GatewayResultCode.REQUEST_PARAM_EMPTY);
} }
if (StringUtils.isBlank(joinType)) { if (StringUtils.isBlank(apiType)) {
throw new GatewayException(GatewayResultCode.API_TYPE_ERROR); throw new GatewayException(GatewayResultCode.API_TYPE_ERROR);
} }
if ("10002".equals(joinType) || "10009".equals(joinType)) {//数据表查询 if ("10002".equals(apiType) || "10009".equals(apiType)) {//数据表查询
return dataTableSelect(outputType, targetUrl, param, jsonParams, apiInterface, response); return dataTableSelect(outputType, targetUrl, param, jsonParams, apiInterface, response);
} else if ("10004".equals(joinType) || "10008".equals(joinType)) {//三方查询 } else if ("10004".equals(apiType) || "10008".equals(apiType)) {//三方查询
return thirdSelect(targetUrl, apiInterface, response); return thirdSelect(targetUrl, apiInterface,jsonParams, response);
} else if ("10005".equals(joinType) || "10007".equals(joinType)) {//数据包查询 } else if ("10005".equals(apiType) || "10007".equals(apiType)) {//数据包查询
return dataBagDownload(targetUrl,jsonParams,response); return dataBagDownload(targetUrl,jsonParams,response);
} else { } else {
throw new GatewayException(GatewayResultCode.API_TYPE_ERROR); throw new GatewayException(GatewayResultCode.API_TYPE_ERROR);
...@@ -182,11 +182,12 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService { ...@@ -182,11 +182,12 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
* @param response * @param response
* @return * @return
*/ */
private boolean thirdSelect(String targetUrl, ApiInterface apiInterface, OpenApiResponse response) { private boolean thirdSelect(String targetUrl, ApiInterface apiInterface,JSONObject jsonParams, OpenApiResponse response) {
if ("POST".equalsIgnoreCase(apiInterface.getReqType())) { if ("POST".equalsIgnoreCase(apiInterface.getReqType())) {
return callMethodResponse(httpsUtils.submitPost(targetUrl, null), response); return callMethodResponse(httpsUtils.submitPost(targetUrl, jsonParams.toString()), response);
} else { } else {
return callMethodResponse(httpsUtils.doGet(targetUrl, null), response); Map map = JSONObject.parseObject(jsonParams.toString(), Map.class);
return callMethodResponse(httpsUtils.doGet(targetUrl,map), response);
} }
} }
...@@ -319,8 +320,8 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService { ...@@ -319,8 +320,8 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
params.put("is_test",jsonParams.get("is_test"));//是否是测试 params.put("is_test",jsonParams.get("is_test"));//是否是测试
Integer pageNum = jsonParams.getInteger("page_num"); Integer pageNum = jsonParams.getInteger("page_num");
Integer pageSize = jsonParams.getInteger("page_size"); Integer pageSize = jsonParams.getInteger("page_size");
params.put("page_size", apiCustomInfo.getPageSize()); params.put("page_size", apiCustomInfo.getPageRow());
params.put("page_num", apiCustomInfo.getPageNum()); params.put("page_num", 1);
if (null != pageNum) { if (null != pageNum) {
params.put("page_num", pageNum); params.put("page_num", pageNum);
} }
......
...@@ -43,5 +43,35 @@ ...@@ -43,5 +43,35 @@
AND ai.api_key =#{apiKey} AND ai.api_key =#{apiKey}
</select> </select>
<select id="listApiIssueService" resultType="com.jz.dm.models.dto.ApiServiceApplyDto">
SELECT ai.api_key AS apiId,
ai.api_name AS apiName,
ai.api_type AS apiType,
ai.output_type AS outputType,
ai.req_type AS reqType,
ai.api_function AS apiFunction,
aic.max_row AS maxRow,
aic.page_row AS pageRow,
aic.is_send_bank AS isSendBank
FROM t_api_interface AS ai JOIN t_api_interface_custom AS aic
ON ai.id =aic.api_interface_id AND aic.is_deleted =0
${ew.customSqlSegment}
</select>
<select id="listApiAuthService" resultType="com.jz.dm.models.dto.ApiServiceApplyDto">
SELECT ai.api_key AS apiId,
ai.api_name AS apiName,
ai.api_type AS apiType,
ai.output_type AS outputType,
ai.req_type AS reqType,
ai.api_function AS apiFunction,
aic.max_row AS maxRow,
aic.page_row AS pageRow,
au.auth_code AS authCode
FROM t_api_interface AS ai
JOIN t_api_interface_custom AS aic ON ai.id =aic.api_interface_id AND aic.is_deleted =0
JOIN t_api_auth AS au ON au.api_interface_id = ai.id AND aic.is_deleted =0
${ew.customSqlSegment}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -2,7 +2,7 @@ package com.jz.dm.gateway.orther; ...@@ -2,7 +2,7 @@ package com.jz.dm.gateway.orther;
import com.jz.dm.common.util.RedisSerializableUtil; import com.jz.dm.common.util.RedisSerializableUtil;
import com.jz.dm.gateway.SpringTestCase; import com.jz.dm.gateway.SpringTestCase;
import com.jz.dm.models.req.make.MakeDataBankApiReq; import com.jz.dm.models.req.producer.MakeDataBankApiReq;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
...@@ -2,10 +2,8 @@ package com.jz.dm.gateway.orther; ...@@ -2,10 +2,8 @@ package com.jz.dm.gateway.orther;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -16,14 +14,20 @@ import java.util.stream.Collectors; ...@@ -16,14 +14,20 @@ import java.util.stream.Collectors;
*/ */
public class TestStr { public class TestStr {
public static void main(String[] args) { public static void main(String[] args) {
Random ran = new Random(); Calendar cal = Calendar.getInstance();
int num = ran.nextInt(999999); /* int year =cal.get(Calendar.YEAR)+1;
String str = String.format("%06d", num); int month=cal.get(Calendar.MONTH)+1;
System.out.println(str); cal.add(Calendar.MONTH, 0);*/
//Date date = cal.getTime(); //结果
String stereo = "000101"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Integer valueOf = Integer.valueOf(stereo); cal.set(Calendar.YEAR,cal.get(Calendar.YEAR)+2);
System.out.println(valueOf); Date date=cal.getTime();
System.out.println( sdf.format(date));
//String stereo = "000101";
// Integer valueOf = Integer.valueOf(stereo);
// System.out.println(valueOf);
} }
public void resolveParameter(){ public void resolveParameter(){
......
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