Commit 1031aad6 authored by ysongq's avatar ysongq

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

parents b9097432 d1e3e360
......@@ -23,12 +23,13 @@ public class MapUtil {
/**
* 获取签名参数
*
* @param apiKey
* @param method
* @param signType
* @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();
builder.append("apiKey=").append(apiKey).append(LoggingConstants.AND_SPILT)
.append("method=").append(method).append(LoggingConstants.AND_SPILT)
......@@ -39,21 +40,22 @@ public class MapUtil {
/**
* 给map集合中的key实现字典排序
*
* @param map
* @return
*/
public Map<String , Object> MapKeySort(Map<String , Object> map){
public Map<String, Object> mapKeySort(Map<String, Object> map) {
ArrayList list = new ArrayList();
for (Map.Entry<String, Object> entry : map.entrySet()) {
list.add(entry.getKey());
//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(list, new SpellComparatorUtils());
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;
}
......@@ -118,11 +120,37 @@ public class MapUtil {
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 需要排序并参与字符拼接的参数组
*   * @return 拼接后字符串
*   * @throws UnsupportedEncodingException
*   
*/
public static String createLinkStringByGet(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet());
......@@ -144,7 +172,8 @@ public class MapUtil {
}
return prestr;
}
class SpellComparatorUtils implements Comparator {
class SpellComparatorUtils implements Comparator {
@Override
public int compare(Object o1, Object o2) {
try {
......@@ -161,9 +190,14 @@ class SpellComparatorUtils implements Comparator {
}
public static void main(String[] args) {
Map<String, String> map = new HashMap();
map.put("name", "hello");
map.put("value", "world");
System.out.println(createLinkStringByGet(map));
//Map<String, String> map = new HashMap();
//map.put("name", "hello");
//map.put("value", "world");
//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 {
*/
@TableField(exist = false)
private String responseParam;
/**
* 固定参数
*/
@TableField(exist = false)
private String inboxParam;
/**
* 响应状态码
*/
@TableField(exist = false)
private String respCode;
/**
* 最大行数
*/
@TableField(exist = false)
private Integer maxRow;
/**
* 每页返回行数
*/
@TableField(exist = false)
private Integer pageRow;
/*---------------------------------日志查询--------------------------------*/
/**
* 日志id
* */
**/
@TableField(exist = false)
private Long logId;
/**
......
......@@ -20,8 +20,8 @@ import java.io.Serializable;
@ApiModel("API详情信息")
public class ApiInterfaceDetailReq implements Serializable {
@ApiModelProperty(value = "id",required = false)
private Long id;
/* @ApiModelProperty(value = "id",required = false)
private Long id;*/
@ApiModelProperty(value = "apiKey",required = true)
@NotNull(message = "apiKey不能为空")
......
......@@ -173,8 +173,8 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
if (ApiStatusEnum.EXPIRY.name().equals(apiInterface.getStatus())) {
return Result.of_error("API已失效无法再次操作!");
}
Integer authStat = getAuthCall(apiKey, AuthModeEnum.POWER_CALL_MODE.name(), null);
Integer authDateStat = getAuthCall(apiKey, AuthModeEnum.PERMANENT_TIME_MODE.name(), new Date());
Integer authStat = getAuthCall(apiInterface.getId(), AuthModeEnum.POWER_CALL_MODE.name(), null);
Integer authDateStat = getAuthCall(apiInterface.getId(), AuthModeEnum.PERMANENT_TIME_MODE.name(), new Date());
UpdateWrapper<ApiInterface> updateInfo = new UpdateWrapper<>();
if (authStat + authDateStat > 0) { //有已授权未使用的先将状态置为$$ 下架
updateInfo.set("status", ApiStatusEnum.SOLDOUT);//下架状态%%可以调用,但不可以购买
......@@ -197,17 +197,17 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
*/
@Override
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)) {//确认是否删除
Integer call = getAuthCall(apiKey, AuthModeEnum.PERMANENT_TIME_MODE.name(), null);
Integer call = getAuthCall(apiInterface.getId(), AuthModeEnum.PERMANENT_TIME_MODE.name(), null);
if (call > 0) {
return Result.of_error("已存在授权用户,是否要删除!");
}
return Result.of_success(ResultMsg.SUCCESS);
} 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())) {
return Result.of_error("API已失效无法再次操作!");
}
......@@ -244,15 +244,15 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
/**
* 获取单次调用有效授权
*
* @param apiKey
* @param apiId
* @param modeType
* @param date
* @return
*/
private Integer getAuthCall(String apiKey, String modeType, Date date) {
private Integer getAuthCall(Long apiId, String modeType, Date date) {
//按次调用统计
QueryWrapper<ApiAuth> query = new QueryWrapper<>();
query.eq("api_key", apiKey);
query.eq("api_interface_id", apiId);
query.eq("handler", 0);//主要是确认单次调用是否调用
query.eq("auth_mode", modeType);
if (null != date) {
......@@ -272,8 +272,8 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
*/
@Override
public Integer getValidAuthStatus(ApiInterface apiInterface) {
Integer authCall = getAuthCall(apiInterface.getApiKey(), AuthModeEnum.POWER_CALL_MODE.name(), null);
Integer authDateCall = getAuthCall(apiInterface.getApiKey(), AuthModeEnum.PERMANENT_TIME_MODE.name(), new Date());
Integer authCall = getAuthCall(apiInterface.getId(), AuthModeEnum.POWER_CALL_MODE.name(), null);
Integer authDateCall = getAuthCall(apiInterface.getId(), AuthModeEnum.PERMANENT_TIME_MODE.name(), new Date());
return authCall + authDateCall;
}
......
......@@ -114,10 +114,10 @@ public class AuthServiceImpl implements AuthService {
query.eq("ai.api_name",req.getApiName());
}
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.orderByDesc("au.create_time");
query.orderByDesc("au.create_date");
return Result.of_success(apiInterfaceMapper.listApiAuthService(page, query));
}
......
......@@ -239,6 +239,7 @@ public class ProducerServiceImpl implements ProducerService {
}
UpdateWrapper<ApiInterface> updateWra = new UpdateWrapper<>();
updateWra.set("is_send_bank",1);
updateWra.eq("id",id);
if (apiInterfaceMapper.update(null,updateWra) == 0){
return Result.of_error(ResultMsg.UPDATE_FAIL);
}
......
......@@ -28,8 +28,11 @@
</select>
<select id="selectDetail" resultType="com.jz.dm.models.domian.ApiInterface">
SELECT ai.*,
aic.inbox_param AS inboxParam,
aic.request_param AS requestParam,
aic.response_param AS responseParam,
aic.max_row AS maxRow,
aic.page_row AS pageRow,
aic.resp_code AS respCode
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
......@@ -37,9 +40,6 @@
<if test="apiKey != null and apiKey !=''">
ai.api_key =#{apiKey}
</if>
<if test="id != null and id !=''">
AND ai.id =#{id}
</if>
</select>
<select id="getTestData" resultType="com.jz.dm.models.domian.ApiInterfaceCustom">
SELECT aic.*
......@@ -73,11 +73,12 @@
aic.max_row AS maxRow,
aic.page_row AS pageRow,
au.auth_code AS authCode,
au.org_name AS orgName,
ar.org_name AS orgName,
au.create_date AS createDate
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
JOIN t_api_org AS ar ON ar.id = au.api_org_id AND ar.is_deleted =0
${ew.customSqlSegment}
</select>
<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