Commit 1031aad6 authored by ysongq's avatar ysongq

Merge remote-tracking branch 'origin/dm_dev' into dm_dev

parents b9097432 d1e3e360
...@@ -23,37 +23,39 @@ public class MapUtil { ...@@ -23,37 +23,39 @@ public class MapUtil {
/** /**
* 获取签名参数 * 获取签名参数
*
* @param apiKey * @param apiKey
* @param method * @param method
* @param signType * @param signType
* @return * @return
*/ */
public static String getSignValue(String apiKey,String method,String signType){ public static String getSignValue(String apiKey, String method, String signType) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("apiKey=").append(apiKey).append(LoggingConstants.AND_SPILT) builder.append("apiKey=").append(apiKey).append(LoggingConstants.AND_SPILT)
.append("method=").append(method).append(LoggingConstants.AND_SPILT) .append("method=").append(method).append(LoggingConstants.AND_SPILT)
.append("signType=").append(signType); .append("signType=").append(signType);
return builder.toString(); return builder.toString();
} }
/** /**
* 给map集合中的key实现字典排序 * 给map集合中的key实现字典排序
*
* @param map * @param map
* @return * @return
*/ */
public Map<String , Object> MapKeySort(Map<String , Object> map){ public Map<String, Object> mapKeySort(Map<String, Object> map) {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
for (Map.Entry<String, Object> entry : map.entrySet()) { for (Map.Entry<String, Object> entry : map.entrySet()) {
list.add(entry.getKey()); list.add(entry.getKey());
//System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue()); //System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
} }
HashMap<String , Object> newMap = new HashMap<String , Object>(); HashMap<String, Object> newMap = new HashMap<String, Object>();
//运用Collections的sort()方法对其进行排序 sort()方法需要传 连个参数,一个是需要进行排序的Collection 另一个是一个Comparator //运用Collections的sort()方法对其进行排序 sort()方法需要传 连个参数,一个是需要进行排序的Collection 另一个是一个Comparator
Collections.sort(list, new SpellComparatorUtils()); Collections.sort(list, new SpellComparatorUtils());
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
newMap.put(list.get(i).toString() , map.get(list.get(i).toString())); newMap.put(list.get(i).toString(), map.get(list.get(i).toString()));
} }
return newMap; return newMap;
} }
...@@ -118,19 +120,45 @@ public class MapUtil { ...@@ -118,19 +120,45 @@ public class MapUtil {
return sb.toString(); return sb.toString();
} }
/**
* * 把数组元素按照按照字典倒序排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
* @param params 需要排序并参与字符拼接的参数组
* @return 拼接后字符串
*/
public static String stringInvertSort(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet());
Collections.reverse(keys);
String prestr = "";
for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i);
String value = params.get(key);
try {
value = URLEncoder.encode(value, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
if (i == keys.size() - 1) {//拼接时,不包括最后一个&字符
prestr = prestr + key + "=" + value;
} else {
prestr = prestr + key + "=" + value + "&";
}
}
return prestr;
}
/** /**
*   * 把数组所有元素排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串 *   * 把数组所有元素排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
*   * @param params 需要排序并参与字符拼接的参数组 *   * @param params 需要排序并参与字符拼接的参数组
*   * @return 拼接后字符串 *   * @return 拼接后字符串
*   * @throws UnsupportedEncodingException *   
*/ */
public static String createLinkStringByGet(Map<String, String> params) { public static String createLinkStringByGet(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet()); List<String> keys = new ArrayList<String>(params.keySet());
Collections.sort(keys); Collections.sort(keys);
String prestr = ""; String prestr = "";
for (int i = 0; i < keys.size(); i++) { for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i); String key = keys.get(i);
String value = params.get(key); String value = params.get(key);
try { try {
value = URLEncoder.encode(value, "UTF-8"); value = URLEncoder.encode(value, "UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
...@@ -144,7 +172,8 @@ public class MapUtil { ...@@ -144,7 +172,8 @@ public class MapUtil {
} }
return prestr; return prestr;
} }
class SpellComparatorUtils implements Comparator {
class SpellComparatorUtils implements Comparator {
@Override @Override
public int compare(Object o1, Object o2) { public int compare(Object o1, Object o2) {
try { try {
...@@ -160,10 +189,15 @@ class SpellComparatorUtils implements Comparator { ...@@ -160,10 +189,15 @@ class SpellComparatorUtils implements Comparator {
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
Map<String, String> map = new HashMap(); //Map<String, String> map = new HashMap();
map.put("name", "hello"); //map.put("name", "hello");
map.put("value", "world"); //map.put("value", "world");
System.out.println(createLinkStringByGet(map)); //System.out.println(createLinkStringByGet(map));
StringJoiner joiner = new StringJoiner(",","[","]");
joiner.add("123");
joiner.add("456");
joiner.add("789");
System.out.println(joiner);
} }
} }
...@@ -143,16 +143,31 @@ public class ApiInterface extends BaseObject implements Serializable { ...@@ -143,16 +143,31 @@ public class ApiInterface extends BaseObject implements Serializable {
*/ */
@TableField(exist = false) @TableField(exist = false)
private String responseParam; private String responseParam;
/**
* 固定参数
*/
@TableField(exist = false)
private String inboxParam;
/** /**
* 响应状态码 * 响应状态码
*/ */
@TableField(exist = false) @TableField(exist = false)
private String respCode; private String respCode;
/**
* 最大行数
*/
@TableField(exist = false)
private Integer maxRow;
/**
* 每页返回行数
*/
@TableField(exist = false)
private Integer pageRow;
/*---------------------------------日志查询--------------------------------*/ /*---------------------------------日志查询--------------------------------*/
/** /**
* 日志id * 日志id
* */ **/
@TableField(exist = false) @TableField(exist = false)
private Long logId; private Long logId;
/** /**
......
...@@ -20,8 +20,8 @@ import java.io.Serializable; ...@@ -20,8 +20,8 @@ import java.io.Serializable;
@ApiModel("API详情信息") @ApiModel("API详情信息")
public class ApiInterfaceDetailReq implements Serializable { public class ApiInterfaceDetailReq implements Serializable {
@ApiModelProperty(value = "id",required = false) /* @ApiModelProperty(value = "id",required = false)
private Long id; private Long id;*/
@ApiModelProperty(value = "apiKey",required = true) @ApiModelProperty(value = "apiKey",required = true)
@NotNull(message = "apiKey不能为空") @NotNull(message = "apiKey不能为空")
......
...@@ -173,8 +173,8 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService { ...@@ -173,8 +173,8 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
if (ApiStatusEnum.EXPIRY.name().equals(apiInterface.getStatus())) { if (ApiStatusEnum.EXPIRY.name().equals(apiInterface.getStatus())) {
return Result.of_error("API已失效无法再次操作!"); return Result.of_error("API已失效无法再次操作!");
} }
Integer authStat = getAuthCall(apiKey, AuthModeEnum.POWER_CALL_MODE.name(), null); Integer authStat = getAuthCall(apiInterface.getId(), AuthModeEnum.POWER_CALL_MODE.name(), null);
Integer authDateStat = getAuthCall(apiKey, AuthModeEnum.PERMANENT_TIME_MODE.name(), new Date()); Integer authDateStat = getAuthCall(apiInterface.getId(), AuthModeEnum.PERMANENT_TIME_MODE.name(), new Date());
UpdateWrapper<ApiInterface> updateInfo = new UpdateWrapper<>(); UpdateWrapper<ApiInterface> updateInfo = new UpdateWrapper<>();
if (authStat + authDateStat > 0) { //有已授权未使用的先将状态置为$$ 下架 if (authStat + authDateStat > 0) { //有已授权未使用的先将状态置为$$ 下架
updateInfo.set("status", ApiStatusEnum.SOLDOUT);//下架状态%%可以调用,但不可以购买 updateInfo.set("status", ApiStatusEnum.SOLDOUT);//下架状态%%可以调用,但不可以购买
...@@ -197,17 +197,17 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService { ...@@ -197,17 +197,17 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
*/ */
@Override @Override
public Result dmpDeleteAuth(String type, String apiKey) { public Result dmpDeleteAuth(String type, String apiKey) {
ApiInterface apiInterface = getApiInfo(apiKey);
if (null == apiInterface) {
return Result.of_error(ResultMsg.DATA_NOT_EXIST);
}
if ("0".equals(type)) {//确认是否删除 if ("0".equals(type)) {//确认是否删除
Integer call = getAuthCall(apiKey, AuthModeEnum.PERMANENT_TIME_MODE.name(), null); Integer call = getAuthCall(apiInterface.getId(), AuthModeEnum.PERMANENT_TIME_MODE.name(), null);
if (call > 0) { if (call > 0) {
return Result.of_error("已存在授权用户,是否要删除!"); return Result.of_error("已存在授权用户,是否要删除!");
} }
return Result.of_success(ResultMsg.SUCCESS); return Result.of_success(ResultMsg.SUCCESS);
} else if ("1".equals(type)) { //正式删除 } else if ("1".equals(type)) { //正式删除
ApiInterface apiInterface = getApiInfo(apiKey);
if (null == apiInterface) {
return Result.of_error(ResultMsg.DATA_NOT_EXIST);
}
if (ApiStatusEnum.EXPIRY.name().equals(apiInterface.getStatus())) { if (ApiStatusEnum.EXPIRY.name().equals(apiInterface.getStatus())) {
return Result.of_error("API已失效无法再次操作!"); return Result.of_error("API已失效无法再次操作!");
} }
...@@ -244,15 +244,15 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService { ...@@ -244,15 +244,15 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
/** /**
* 获取单次调用有效授权 * 获取单次调用有效授权
* *
* @param apiKey * @param apiId
* @param modeType * @param modeType
* @param date * @param date
* @return * @return
*/ */
private Integer getAuthCall(String apiKey, String modeType, Date date) { private Integer getAuthCall(Long apiId, String modeType, Date date) {
//按次调用统计 //按次调用统计
QueryWrapper<ApiAuth> query = new QueryWrapper<>(); QueryWrapper<ApiAuth> query = new QueryWrapper<>();
query.eq("api_key", apiKey); query.eq("api_interface_id", apiId);
query.eq("handler", 0);//主要是确认单次调用是否调用 query.eq("handler", 0);//主要是确认单次调用是否调用
query.eq("auth_mode", modeType); query.eq("auth_mode", modeType);
if (null != date) { if (null != date) {
...@@ -272,8 +272,8 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService { ...@@ -272,8 +272,8 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
*/ */
@Override @Override
public Integer getValidAuthStatus(ApiInterface apiInterface) { public Integer getValidAuthStatus(ApiInterface apiInterface) {
Integer authCall = getAuthCall(apiInterface.getApiKey(), AuthModeEnum.POWER_CALL_MODE.name(), null); Integer authCall = getAuthCall(apiInterface.getId(), AuthModeEnum.POWER_CALL_MODE.name(), null);
Integer authDateCall = getAuthCall(apiInterface.getApiKey(), AuthModeEnum.PERMANENT_TIME_MODE.name(), new Date()); Integer authDateCall = getAuthCall(apiInterface.getId(), AuthModeEnum.PERMANENT_TIME_MODE.name(), new Date());
return authCall + authDateCall; return authCall + authDateCall;
} }
......
...@@ -114,10 +114,10 @@ public class AuthServiceImpl implements AuthService { ...@@ -114,10 +114,10 @@ public class AuthServiceImpl implements AuthService {
query.eq("ai.api_name",req.getApiName()); query.eq("ai.api_name",req.getApiName());
} }
if (StringUtils.isNotBlank(req.getOrgName())){ if (StringUtils.isNotBlank(req.getOrgName())){
query.like("au.org_name",req.getOrgName()); query.like("ar.org_name",req.getOrgName());
} }
query.eq("ai.is_deleted",0); query.eq("ai.is_deleted",0);
query.orderByDesc("au.create_time"); query.orderByDesc("au.create_date");
return Result.of_success(apiInterfaceMapper.listApiAuthService(page, query)); return Result.of_success(apiInterfaceMapper.listApiAuthService(page, query));
} }
......
...@@ -239,6 +239,7 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -239,6 +239,7 @@ public class ProducerServiceImpl implements ProducerService {
} }
UpdateWrapper<ApiInterface> updateWra = new UpdateWrapper<>(); UpdateWrapper<ApiInterface> updateWra = new UpdateWrapper<>();
updateWra.set("is_send_bank",1); updateWra.set("is_send_bank",1);
updateWra.eq("id",id);
if (apiInterfaceMapper.update(null,updateWra) == 0){ if (apiInterfaceMapper.update(null,updateWra) == 0){
return Result.of_error(ResultMsg.UPDATE_FAIL); return Result.of_error(ResultMsg.UPDATE_FAIL);
} }
......
...@@ -28,8 +28,11 @@ ...@@ -28,8 +28,11 @@
</select> </select>
<select id="selectDetail" resultType="com.jz.dm.models.domian.ApiInterface"> <select id="selectDetail" resultType="com.jz.dm.models.domian.ApiInterface">
SELECT ai.*, SELECT ai.*,
aic.inbox_param AS inboxParam,
aic.request_param AS requestParam, aic.request_param AS requestParam,
aic.response_param AS responseParam, aic.response_param AS responseParam,
aic.max_row AS maxRow,
aic.page_row AS pageRow,
aic.resp_code AS respCode aic.resp_code AS respCode
FROM t_api_interface AS ai FROM t_api_interface AS ai
LEFT JOIN t_api_interface_custom AS aic ON ai.id = aic.api_interface_id AND aic.is_deleted =0 LEFT JOIN t_api_interface_custom AS aic ON ai.id = aic.api_interface_id AND aic.is_deleted =0
...@@ -37,9 +40,6 @@ ...@@ -37,9 +40,6 @@
<if test="apiKey != null and apiKey !=''"> <if test="apiKey != null and apiKey !=''">
ai.api_key =#{apiKey} ai.api_key =#{apiKey}
</if> </if>
<if test="id != null and id !=''">
AND ai.id =#{id}
</if>
</select> </select>
<select id="getTestData" resultType="com.jz.dm.models.domian.ApiInterfaceCustom"> <select id="getTestData" resultType="com.jz.dm.models.domian.ApiInterfaceCustom">
SELECT aic.* SELECT aic.*
...@@ -73,11 +73,12 @@ ...@@ -73,11 +73,12 @@
aic.max_row AS maxRow, aic.max_row AS maxRow,
aic.page_row AS pageRow, aic.page_row AS pageRow,
au.auth_code AS authCode, au.auth_code AS authCode,
au.org_name AS orgName, ar.org_name AS orgName,
au.create_date AS createDate au.create_date AS createDate
FROM t_api_interface AS ai 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_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 JOIN t_api_auth AS au ON au.api_interface_id = ai.id AND aic.is_deleted =0
JOIN t_api_org AS ar ON ar.id = au.api_org_id AND ar.is_deleted =0
${ew.customSqlSegment} ${ew.customSqlSegment}
</select> </select>
<select id="listApiDetail" resultType="com.jz.dm.models.dto.ApiServiceApplyDto"> <select id="listApiDetail" resultType="com.jz.dm.models.dto.ApiServiceApplyDto">
......
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