Commit 1ef7d947 authored by zhangc's avatar zhangc

commit

parent 2b99b384
...@@ -8,7 +8,6 @@ import com.jz.dm.common.constant.Constants; ...@@ -8,7 +8,6 @@ import com.jz.dm.common.constant.Constants;
import com.jz.dm.common.enums.GatewayResultCode; import com.jz.dm.common.enums.GatewayResultCode;
import com.jz.dm.common.enums.apiInterface.ApiStatusEnum; import com.jz.dm.common.enums.apiInterface.ApiStatusEnum;
import com.jz.dm.common.enums.auth.AuthReqTypeEnum; import com.jz.dm.common.enums.auth.AuthReqTypeEnum;
import com.jz.dm.common.enums.org.OrgStatusEnum;
import com.jz.dm.common.exception.GatewayException; import com.jz.dm.common.exception.GatewayException;
import com.jz.dm.common.util.DateUtil; import com.jz.dm.common.util.DateUtil;
import com.jz.dm.common.util.LogUtil; import com.jz.dm.common.util.LogUtil;
...@@ -105,7 +104,7 @@ public class AuthFilter extends AbstractFilter { ...@@ -105,7 +104,7 @@ public class AuthFilter extends AbstractFilter {
throw new GatewayException(GatewayResultCode.ORG_NOT_EXIST); throw new GatewayException(GatewayResultCode.ORG_NOT_EXIST);
} }
//状态检查(只限制按次请求$$ 不限制按时间请求) //状态检查(只限制按次请求$$ 不限制按时间请求)
if (!OrgStatusEnum.NORMAL.name().equals(apiOrg.getStatus())) { if (!apiOrg.getStatus()) {
throw new GatewayException(GatewayResultCode.ORG_STATE_EXCEPTION); throw new GatewayException(GatewayResultCode.ORG_STATE_EXCEPTION);
} }
checkBill(request, authCode, authAuth, apiOrg); checkBill(request, authCode, authAuth, apiOrg);
......
...@@ -89,7 +89,6 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -89,7 +89,6 @@ public class OrganizationManageImpl implements OrganizationManageService {
*/ */
@Override @Override
public Result add(OrganizationManageAddReq req) { public Result add(OrganizationManageAddReq req) {
String coding = "";
ApiOrg apiOrg = new ApiOrg(); ApiOrg apiOrg = new ApiOrg();
BeanUtils.copyProperties(req, apiOrg); BeanUtils.copyProperties(req, apiOrg);
if (null != req.getId()){//更新 if (null != req.getId()){//更新
...@@ -102,32 +101,45 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -102,32 +101,45 @@ public class OrganizationManageImpl implements OrganizationManageService {
return Result.of_success(ResultMsg.UPDATE_SUCCESS); return Result.of_success(ResultMsg.UPDATE_SUCCESS);
} }
}else {//添加 }else {//添加
if (StringUtils.isNotBlank(req.getOrgName())) { Result result = addOrg(req, apiOrg);
ApiOrg orgNameInfo = getOrgNameInfo(req.getOrgName()); if (result != null) return result;
if (null != orgNameInfo) { }
return Result.of_error("组织名称已存在!"); return Result.of_error(ResultMsg.FAILURE);
} }
}
if (StringUtils.isNotBlank(req.getOrgType())) { /**
if (null == fromOrgTypeEnumName(req.getOrgType())){ * 添加组织
return Result.of_error("组织类型不存在!"); * @param req
} * @param apiOrg
} * @return
if (StringUtils.isNotBlank(req.getOrgType()) //内部组织 */
&& Constants.AUTH_INT.equals(req.getOrgType())) { private Result addOrg(OrganizationManageAddReq req, ApiOrg apiOrg) {
coding = generateCode(req.getOrgName(), Constants.AUTH_INT); String coding = "";
} else { if (StringUtils.isNotBlank(req.getOrgName())) {
coding = generateCode(req.getOrgName(), Constants.AUTH_OUT); ApiOrg orgNameInfo = getOrgNameInfo(req.getOrgName());
} if (null != orgNameInfo) {
if (StringUtils.isBlank(coding)) { return Result.of_error("组织名称已存在!");
return Result.of_error("生成组织编码异常!");
} }
apiOrg.setOrgCode(coding);//组织编码 }
if (apiOrgMapper.insert(apiOrg) > 0) { if (StringUtils.isNotBlank(req.getOrgType())) {
return Result.of_success(ResultMsg.INSERT_SUCCESS); if (null == fromOrgTypeEnumName(req.getOrgType())){
return Result.of_error("组织类型不存在!");
} }
} }
return Result.of_error(ResultMsg.FAILURE); if (StringUtils.isNotBlank(req.getOrgType()) //内部组织
&& Constants.AUTH_INT.equals(req.getOrgType())) {
coding = generateCode(req.getOrgName(), Constants.AUTH_INT);
} else {
coding = generateCode(req.getOrgName(), Constants.AUTH_OUT);
}
if (StringUtils.isBlank(coding)) {
return Result.of_error("生成组织编码异常!");
}
apiOrg.setOrgCode(coding);//组织编码
if (apiOrgMapper.insert(apiOrg) > 0) {
return Result.of_success(ResultMsg.INSERT_SUCCESS);
}
return null;
} }
/** /**
......
...@@ -4,6 +4,7 @@ package com.jz.dm.web.aspect; ...@@ -4,6 +4,7 @@ package com.jz.dm.web.aspect;
import com.jz.common.utils.IpUtils; import com.jz.common.utils.IpUtils;
import com.jz.common.utils.JsonUtils; import com.jz.common.utils.JsonUtils;
import com.jz.common.utils.UrlUtil; import com.jz.common.utils.UrlUtil;
import com.jz.dm.common.exception.GatewayException;
import com.jz.dm.mapper.ApiReqLogMapper; import com.jz.dm.mapper.ApiReqLogMapper;
import com.jz.dm.models.domian.ApiReqLog; import com.jz.dm.models.domian.ApiReqLog;
import com.jz.dm.service.ApiLogService; import com.jz.dm.service.ApiLogService;
...@@ -93,8 +94,9 @@ public class SystemLogAspect { ...@@ -93,8 +94,9 @@ public class SystemLogAspect {
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(params); com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(params);
String paramsList = jsonObject.getString("openApiParams"); String paramsList = jsonObject.getString("openApiParams");
com.alibaba.fastjson.JSONObject jsonParamsList = com.alibaba.fastjson.JSONObject.parseObject(paramsList); com.alibaba.fastjson.JSONObject jsonParamsList = com.alibaba.fastjson.JSONObject.parseObject(paramsList);
try { ApiReqLog reqLog = new ApiReqLog();
ApiReqLog reqLog = new ApiReqLog(); JSONObject jsonResult =null;
try {
reqLog.setRequestIp(ip); reqLog.setRequestIp(ip);
reqLog.setApiKey(jsonObject.getString("apiKey")); reqLog.setApiKey(jsonObject.getString("apiKey"));
reqLog.setRequestParams(params); reqLog.setRequestParams(params);
...@@ -112,10 +114,13 @@ public class SystemLogAspect { ...@@ -112,10 +114,13 @@ public class SystemLogAspect {
apiReqLogMapper.insert(reqLog); apiReqLogMapper.insert(reqLog);
} }
Object result = joinPoint.proceed(joinPoint.getArgs()); Object result = joinPoint.proceed(joinPoint.getArgs());
JSONObject jsonResult = JSONObject.fromObject(result); jsonResult = JSONObject.fromObject(result);
log.info("around响应结果为{}", jsonResult); log.info("around响应结果为{}", jsonResult);
apiLogService.updateLog(reqLog.getId(), jsonResult); apiLogService.updateLog(reqLog.getId(), jsonResult);
} catch (Throwable throwable) { } catch (GatewayException ex) {
log.info("切面处理保存异常信息:{}",ex.getMessage());
apiLogService.updateLog(reqLog.getId(), jsonResult);
}catch (Throwable throwable){
throwable.printStackTrace(); throwable.printStackTrace();
} }
} }
......
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