Commit 7d0abfd9 authored by zhangc's avatar zhangc

commit修改一些问题

parent 91802923
...@@ -87,8 +87,9 @@ CREATE TABLE `t_api_org` ( ...@@ -87,8 +87,9 @@ CREATE TABLE `t_api_org` (
`org_desc` varchar(300) DEFAULT NULL COMMENT '组织描述', `org_desc` varchar(300) DEFAULT NULL COMMENT '组织描述',
`org_cn_name` varchar(100) DEFAULT NULL COMMENT '组织英文名称', `org_cn_name` varchar(100) DEFAULT NULL COMMENT '组织英文名称',
`org_phone` varchar(20) NULL DEFAULT NULL COMMENT '组织电话', `org_phone` varchar(20) NULL DEFAULT NULL COMMENT '组织电话',
`linkman` varchar(50) NULL DEFAULT NULL COMMENT '组织联系人'
`org_type` varchar(20) NULL DEFAULT NULL COMMENT '组织类型:OUT 外部组织, IN 内部组织', `org_type` varchar(20) NULL DEFAULT NULL COMMENT '组织类型:OUT 外部组织, IN 内部组织',
`status` varchar(100) NOT NULL COMMENT '状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销)', `status` varchar(100) NOT NULL COMMENT '状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销)',
`org_mail` varchar(100) DEFAULT NULL COMMENT '组织邮箱', `org_mail` varchar(100) DEFAULT NULL COMMENT '组织邮箱',
`org_sort` int(10) DEFAULT '999' COMMENT '组织排序', `org_sort` int(10) DEFAULT '999' COMMENT '组织排序',
`parent_id` varchar(100) DEFAULT NULL COMMENT '父类组织编码', `parent_id` varchar(100) DEFAULT NULL COMMENT '父类组织编码',
...@@ -145,7 +146,9 @@ CREATE TABLE `t_api_req_log` ( ...@@ -145,7 +146,9 @@ CREATE TABLE `t_api_req_log` (
`encry_mode` varchar(20) DEFAULT NULL COMMENT '加密方式:MD5,RSA', `encry_mode` varchar(20) DEFAULT NULL COMMENT '加密方式:MD5,RSA',
`trans_mode` varchar(20) DEFAULT NULL COMMENT '传输方式:POST,GET', `trans_mode` varchar(20) DEFAULT NULL COMMENT '传输方式:POST,GET',
`request_token` varchar(64) DEFAULT NULL COMMENT '客户请求token', `request_token` varchar(64) DEFAULT NULL COMMENT '客户请求token',
`request_time` datetime DEFAULT NULL COMMENT '请求时间', `request_consuming` varchar(64) DEFAULT NULL COMMENT '请求总耗时',
`request_start_time` datetime DEFAULT NULL COMMENT '请求开始时间',
`request_end_time` datetime DEFAULT NULL COMMENT '请求结束时间',
`status` varchar(50) DEFAULT NULL COMMENT '状态:SUCCEED 请求成功, FAIL 请求失败', `status` varchar(50) DEFAULT NULL COMMENT '状态:SUCCEED 请求成功, FAIL 请求失败',
`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 '创建时间',
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>jz-dm-apigateway</artifactId> <artifactId>jz-dm-apigateway</artifactId>
<dependencies> <dependencies>
<!-- spring-boot --> <!-- spring-boot -->
<dependency> <dependency>
...@@ -98,6 +97,27 @@ ...@@ -98,6 +97,27 @@
<!-- <version>0.9.0.RELEASE</version>--> <!-- <version>0.9.0.RELEASE</version>-->
</dependency> </dependency>
<!-- 客户端需要引入 Transport 模块来与 Sentinel 控制台进行通信 -->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-transport-simple-http</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-parameter-flow-control</artifactId>
</dependency>
<!-- 开启注解 -->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-annotation-aspectj</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-core</artifactId>
</dependency>
<dependency> <dependency>
<groupId>net.sf.json-lib</groupId> <groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId> <artifactId>json-lib</artifactId>
......
...@@ -85,4 +85,5 @@ public class ApiInterfaceController { ...@@ -85,4 +85,5 @@ public class ApiInterfaceController {
public Mono<Result> apiTestApiInterface(@RequestParam (name="apiKey")String apiKey) { public Mono<Result> apiTestApiInterface(@RequestParam (name="apiKey")String apiKey) {
return Mono.fromSupplier(() -> apiInterfaceService.apiTestInterface(apiKey)); return Mono.fromSupplier(() -> apiInterfaceService.apiTestInterface(apiKey));
} }
} }
...@@ -7,10 +7,7 @@ import com.jz.dm.service.ApiLogService; ...@@ -7,10 +7,7 @@ import com.jz.dm.service.ApiLogService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import javax.validation.Valid; import javax.validation.Valid;
...@@ -54,4 +51,15 @@ public class ApiLogController { ...@@ -54,4 +51,15 @@ public class ApiLogController {
public Mono<Result> getApiLogDetail(@RequestBody @Valid LogInfoDetailReq req) { public Mono<Result> getApiLogDetail(@RequestBody @Valid LogInfoDetailReq req) {
return Mono.fromSupplier(() -> apiLogService.getApiLogDetail(req)); return Mono.fromSupplier(() -> apiLogService.getApiLogDetail(req));
} }
/**
* @Description:Api调用统计
* @return: DMP-Api调用统计
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation("DMP-Api调用统计")
@GetMapping(value = "/countAPiCallStat")
public Mono<Result> countAPiCallStat(@RequestParam(name = "date") String date) {
return Mono.fromSupplier(() -> apiLogService.countAPiCallStat(date));
}
} }
...@@ -73,6 +73,17 @@ public class AuthController { ...@@ -73,6 +73,17 @@ public class AuthController {
public Mono<Result> selectAuthListInfo(@RequestBody @Valid AuthListInfoReq req) { public Mono<Result> selectAuthListInfo(@RequestBody @Valid AuthListInfoReq req) {
return Mono.fromSupplier(() -> authService.getAuthListInfo(req)); return Mono.fromSupplier(() -> authService.getAuthListInfo(req));
} }
/**
* @Description: 授权模糊查询列表信息
* @return: 认证列表查询
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("授权模糊查询列表信息")
@GetMapping(value = "/getAuthNameList")
public Mono<Result> getAuthNameList(@RequestParam("key") String key) {
return Mono.fromSupplier(() -> authService.getAuthNameList(key));
}
/** /**
* @Description: 认证信息修改 * @Description: 认证信息修改
* @return: 认证信息修改 * @return: 认证信息修改
......
...@@ -4,7 +4,6 @@ import com.jz.common.utils.Result; ...@@ -4,7 +4,6 @@ import com.jz.common.utils.Result;
import com.jz.dm.models.req.organizationManage.OrganizationManageAddReq; import com.jz.dm.models.req.organizationManage.OrganizationManageAddReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq; import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq; import com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageUpdateReq;
import com.jz.dm.service.OrganizationManageService; import com.jz.dm.service.OrganizationManageService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -58,7 +57,7 @@ public class OrganizationManageController { ...@@ -58,7 +57,7 @@ public class OrganizationManageController {
* @Author: Mr.zhang * @Author: Mr.zhang
* @Date: 2020-12-24 * @Date: 2020-12-24
*/ */
@ApiOperation("添加组织") @ApiOperation("添加/更新组织")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Mono<Result> add(@RequestBody @Valid OrganizationManageAddReq req) { public Mono<Result> add(@RequestBody @Valid OrganizationManageAddReq req) {
return Mono.fromSupplier(() -> organizationManageService.add(req)); return Mono.fromSupplier(() -> organizationManageService.add(req));
...@@ -68,11 +67,11 @@ public class OrganizationManageController { ...@@ -68,11 +67,11 @@ public class OrganizationManageController {
* @Author: Mr.zhang * @Author: Mr.zhang
* @Date: 2020-12-24 * @Date: 2020-12-24
*/ */
@ApiOperation("更新组织信息") /* @ApiOperation("更新组织信息")
@PostMapping(value = "/update") @PostMapping(value = "/update")
public Mono<Result> update(@RequestBody @Valid OrganizationManageUpdateReq req) { public Mono<Result> update(@RequestBody @Valid OrganizationManageUpdateReq req) {
return Mono.fromSupplier(() -> organizationManageService.update(req)); return Mono.fromSupplier(() -> organizationManageService.update(req));
} }*/
/** /**
* @Description:注销组织 * @Description:注销组织
* @Author: Mr.zhang * @Author: Mr.zhang
......
...@@ -2,8 +2,12 @@ package com.jz.dm.mapper; ...@@ -2,8 +2,12 @@ package com.jz.dm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jz.dm.models.domian.ApiReqLog; import com.jz.dm.models.domian.ApiReqLog;
import com.jz.dm.models.dto.ApiCallDataDto;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List;
/**api请求日志表 mapper /**api请求日志表 mapper
* @author ybz * @author ybz
*/ */
...@@ -16,4 +20,11 @@ public interface ApiReqLogMapper extends BaseMapper<ApiReqLog> { ...@@ -16,4 +20,11 @@ public interface ApiReqLogMapper extends BaseMapper<ApiReqLog> {
*/ */
@Select("SELECT * FROM t_api_req_log WHERE id =(SELECT MAX(id) FROM t_api_req_log)") @Select("SELECT * FROM t_api_req_log WHERE id =(SELECT MAX(id) FROM t_api_req_log)")
ApiReqLog maxId(Long id); ApiReqLog maxId(Long id);
/**
* 统计API调用
* @return
*/
List<ApiCallDataDto> countApiCallMonthData(Date date);
} }
...@@ -50,6 +50,11 @@ public class ApiOrg extends BaseObject implements Serializable { ...@@ -50,6 +50,11 @@ public class ApiOrg extends BaseObject implements Serializable {
*/ */
@TableField("org_phone") @TableField("org_phone")
private String orgPhone; private String orgPhone;
/**
* 组织联系人
*/
@TableField("linkman")
private String linkman;
/** /**
* 组织类型 OUT 外部组织 IN 内部组织 * 组织类型 OUT 外部组织 IN 内部组织
*/ */
......
...@@ -90,13 +90,27 @@ public class ApiReqLog implements Serializable { ...@@ -90,13 +90,27 @@ public class ApiReqLog implements Serializable {
private String requestToken; private String requestToken;
/** /**
* 请求时间 * 请求总耗时
*/ */
@ApiModelProperty("请求时间") @ApiModelProperty("请求总耗时")
@TableField("request_time") @TableField("request_consuming")
private Double requestConsuming;
/**
* 请求开始时间
*/
@ApiModelProperty("请求开始时间")
@TableField("request_start_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date requestStartTime;
/**
* 请求结束时间
*/
@ApiModelProperty("请求结束时间")
@TableField("request_end_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date requestTime; private Date requestEndTime;
/** /**
* 请求状态: SUCCEED 成功 ,FAIL 失败 * 请求状态: SUCCEED 成功 ,FAIL 失败
......
...@@ -40,9 +40,22 @@ public class OrganizationManageAddReq implements Serializable { ...@@ -40,9 +40,22 @@ public class OrganizationManageAddReq implements Serializable {
@ApiModelProperty(value = "组织电话",required = false) @ApiModelProperty(value = "组织电话",required = false)
private String orgPhone; private String orgPhone;
@ApiModelProperty(value = "组织联系人",required = false)
private String linkman;
@ApiModelProperty(value = "备注",required = false) @ApiModelProperty(value = "备注",required = false)
private String remark; private String remark;
@ApiModelProperty(value = "创建用户",required = false) @ApiModelProperty(value = "创建用户",required = false)
private String createUser; private String createUser;
@ApiModelProperty(value = "创建用户",required = false)
private String updateUser;
@ApiModelProperty(value = "id ----更新时必传",required = false)
private Long id;
@ApiModelProperty(value = "状态(true-正常 false-注销----更新时传",required = false)
private Boolean status;
} }
...@@ -82,4 +82,7 @@ public interface ApiInterfaceService { ...@@ -82,4 +82,7 @@ public interface ApiInterfaceService {
* @return * @return
*/ */
Result apiTestInterface(String apiKey); Result apiTestInterface(String apiKey);
} }
...@@ -43,4 +43,11 @@ public interface ApiLogService { ...@@ -43,4 +43,11 @@ public interface ApiLogService {
* @param jsonObject * @param jsonObject
*/ */
void updateLog(Long id, JSONObject jsonObject); void updateLog(Long id, JSONObject jsonObject);
/**
* 统计API调用数据
* @param date
* @return
*/
Result countAPiCallStat(String date);
} }
...@@ -77,4 +77,11 @@ public interface AuthService { ...@@ -77,4 +77,11 @@ public interface AuthService {
* @return * @return
*/ */
int updateApiAuthStatus(ApiAuth apiAuth); int updateApiAuthStatus(ApiAuth apiAuth);
/**
* 根据名称/组织编号摸索查询
* @param key
* @return
*/
Result getAuthNameList(String key);
} }
...@@ -6,7 +6,6 @@ import com.jz.dm.models.domian.ApiOrg; ...@@ -6,7 +6,6 @@ import com.jz.dm.models.domian.ApiOrg;
import com.jz.dm.models.req.organizationManage.OrganizationManageAddReq; import com.jz.dm.models.req.organizationManage.OrganizationManageAddReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq; import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq; import com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageUpdateReq;
/** /**
* @author ZC * @author ZC
...@@ -44,7 +43,7 @@ public interface OrganizationManageService { ...@@ -44,7 +43,7 @@ public interface OrganizationManageService {
* @param req * @param req
* @return * @return
*/ */
Result update(OrganizationManageUpdateReq req); //Result update(OrganizationManageUpdateReq req);
/** /**
* 根据id注销组织 * 根据id注销组织
......
...@@ -226,6 +226,7 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService { ...@@ -226,6 +226,7 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
} }
/** /**
* 获取用户授权信息 * 获取用户授权信息
* *
......
...@@ -19,6 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -19,6 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
/** /**
...@@ -34,6 +36,7 @@ import java.util.Date; ...@@ -34,6 +36,7 @@ import java.util.Date;
@Slf4j @Slf4j
public class ApiLogServiceImpl implements ApiLogService { public class ApiLogServiceImpl implements ApiLogService {
@Resource @Resource
private ApiReqLogMapper apiReqLogMapper; private ApiReqLogMapper apiReqLogMapper;
// 加锁 // 加锁
...@@ -77,7 +80,22 @@ public class ApiLogServiceImpl implements ApiLogService { ...@@ -77,7 +80,22 @@ public class ApiLogServiceImpl implements ApiLogService {
public void insetLogInfo(ApiReqLog reqLog) { public void insetLogInfo(ApiReqLog reqLog) {
apiReqLogMapper.insert(reqLog); apiReqLogMapper.insert(reqLog);
} }
/**
* api计量统计
* @param date
* @return
*/
@Override
public Result countAPiCallStat(String date ) {
Date dateParam =null;
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM");
dateParam = dateFormat.parse(date);
}catch (Exception ex){
log.error("时间转换异常:{}",ex.getMessage());
}
return Result.of_success(apiReqLogMapper.countApiCallMonthData(dateParam));
}
/** /**
* 根据id更新日志 * 根据id更新日志
...@@ -98,6 +116,12 @@ public class ApiLogServiceImpl implements ApiLogService { ...@@ -98,6 +116,12 @@ public class ApiLogServiceImpl implements ApiLogService {
} }
update.set("response_params",jsonObject.toString()); update.set("response_params",jsonObject.toString());
update.set("update_date",new Date()); update.set("update_date",new Date());
update.set("request_end_time",new Date());
Calendar calendar = Calendar.getInstance();
calendar.setTime(apiReqLog.getRequestStartTime());
Long time = System.currentTimeMillis() - calendar.getTimeInMillis() / 1000;
double timeConsuming = time.doubleValue();
update.set("request_consuming",timeConsuming);
update.eq("id",id); update.eq("id",id);
if (apiReqLogMapper.update(null,update) == 0){ if (apiReqLogMapper.update(null,update) == 0){
log.info("~~~~~~~~~~~更新日志信息失败~~~~~~~~"); log.info("~~~~~~~~~~~更新日志信息失败~~~~~~~~");
...@@ -109,4 +133,6 @@ public class ApiLogServiceImpl implements ApiLogService { ...@@ -109,4 +133,6 @@ public class ApiLogServiceImpl implements ApiLogService {
log.error("更新日志返回信息异常:{}",ex.getMessage()); log.error("更新日志返回信息异常:{}",ex.getMessage());
} }
} }
} }
...@@ -346,6 +346,21 @@ public class AuthServiceImpl implements AuthService { ...@@ -346,6 +346,21 @@ public class AuthServiceImpl implements AuthService {
return apiAuthMapper.update(null,update); return apiAuthMapper.update(null,update);
} }
/**
* 模糊查询/
* @param key
* @return
*/
@Override
public Result getAuthNameList(String key) {
QueryWrapper<ApiOrg> query = new QueryWrapper<>();
if (StringUtils.isNotBlank(key)){
query.and(wrapper -> wrapper.like("org_name",key)
.or().like("org_code",key));
}
return Result.of_success(apiOrgMapper.selectList(query));
}
private ApiInterface getInterface(String apiKey) { private ApiInterface getInterface(String apiKey) {
QueryWrapper<ApiInterface> queryInface = new QueryWrapper<>(); QueryWrapper<ApiInterface> queryInface = new QueryWrapper<>();
queryInface.last("where is_deleted=0 and api_key ='" + apiKey + "'"); queryInface.last("where is_deleted=0 and api_key ='" + apiKey + "'");
......
...@@ -14,7 +14,6 @@ import com.jz.dm.models.domian.ApiOrg; ...@@ -14,7 +14,6 @@ import com.jz.dm.models.domian.ApiOrg;
import com.jz.dm.models.req.organizationManage.OrganizationManageAddReq; import com.jz.dm.models.req.organizationManage.OrganizationManageAddReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq; import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq; import com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageUpdateReq;
import com.jz.dm.service.OrganizationManageService; import com.jz.dm.service.OrganizationManageService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -24,7 +23,6 @@ import org.springframework.stereotype.Service; ...@@ -24,7 +23,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import static com.jz.dm.common.enums.org.OrgStatusEnum.fromTypeName;
import static com.jz.dm.common.enums.org.OrgTypeEnum.fromOrgTypeEnumName; import static com.jz.dm.common.enums.org.OrgTypeEnum.fromOrgTypeEnumName;
/** /**
...@@ -102,21 +100,39 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -102,21 +100,39 @@ public class OrganizationManageImpl implements OrganizationManageService {
String coding = ""; String coding = "";
ApiOrg apiOrg = new ApiOrg(); ApiOrg apiOrg = new ApiOrg();
BeanUtils.copyProperties(req, apiOrg); BeanUtils.copyProperties(req, apiOrg);
if (StringUtils.isNotBlank(req.getOrgType()) //内部组织 //更新
&& Constants.AUTH_INT.equals(req.getOrgType())) { if (null != req.getId()){
coding = generateCode(req.getOrgName(), Constants.AUTH_INT); ApiOrg org = apiOrgMapper.selectById(req.getId());
} else { if (null == org){
coding = generateCode(req.getOrgName(), Constants.AUTH_OUT); return Result.of_error(ResultMsg.DATA_NOT_EXIST);
} }
if (StringUtils.isBlank(coding)) { if (req.getStatus()){
return Result.of_error("生成组织编码异常!"); org.setStatus(OrgStatusEnum.NORMAL.name());
} }else {
apiOrg.setOrgCode(coding);//组织编码 org.setStatus(OrgStatusEnum.CANCEL.name());
apiOrg.setStatus(OrgStatusEnum.NORMAL.name());//正常 }
if (apiOrgMapper.insert(apiOrg) > 0) { org.setUpdateDate(new Date());
return Result.of_success(ResultMsg.INSERT_SUCCESS); if ( apiOrgMapper.updateById(apiOrg) > 0){
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
}
//添加
}else {
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);//组织编码
apiOrg.setStatus(OrgStatusEnum.NORMAL.name());//正常
if (apiOrgMapper.insert(apiOrg) > 0) {
return Result.of_success(ResultMsg.INSERT_SUCCESS);
}
} }
return Result.of_error(ResultMsg.INSERT_FAIL); return Result.of_error(ResultMsg.FAILURE);
} }
/** /**
...@@ -144,7 +160,7 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -144,7 +160,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
* @param req * @param req
* @return * @return
*/ */
@Override /* @Override
public Result update(OrganizationManageUpdateReq req) { public Result update(OrganizationManageUpdateReq req) {
ApiOrg apiOrg = apiOrgMapper.selectById(req.getId()); ApiOrg apiOrg = apiOrgMapper.selectById(req.getId());
if (null == apiOrg) { if (null == apiOrg) {
...@@ -166,7 +182,7 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -166,7 +182,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
return Result.of_success(ResultMsg.UPDATE_SUCCESS); return Result.of_success(ResultMsg.UPDATE_SUCCESS);
} }
return Result.of_success(ResultMsg.UPDATE_FAIL); return Result.of_success(ResultMsg.UPDATE_FAIL);
} }*/
/** /**
* 注销组织 * 注销组织
......
...@@ -12,7 +12,6 @@ import com.jz.common.utils.HttpsUtils; ...@@ -12,7 +12,6 @@ import com.jz.common.utils.HttpsUtils;
import com.jz.common.utils.Md5; import com.jz.common.utils.Md5;
import com.jz.common.utils.RedisUtils; import com.jz.common.utils.RedisUtils;
import com.jz.common.utils.Result; import com.jz.common.utils.Result;
import com.jz.dm.common.constant.TagConstants;
import com.jz.dm.common.enums.GeneralStatusTypeEnum; import com.jz.dm.common.enums.GeneralStatusTypeEnum;
import com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum; import com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum;
import com.jz.dm.common.enums.apiInterface.ApiStatusEnum; import com.jz.dm.common.enums.apiInterface.ApiStatusEnum;
...@@ -156,17 +155,18 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -156,17 +155,18 @@ public class ProducerServiceImpl implements ProducerService {
if (fileSource.size() == 0 || fileSource.size() >= 2) { if (fileSource.size() == 0 || fileSource.size() >= 2) {
return Result.of_error("文件夹信息异常!"); return Result.of_error("文件夹信息异常!");
} }
if (StringUtils.isNotBlank(req.getOutputType()) && if (StringUtils.isNotBlank(req.getOutputType())) {
(!req.getOutputType().contains(ApiInfoOutTypeEnum.JSON.name()) || if (!req.getOutputType().contains(ApiInfoOutTypeEnum.JSON.name()) ||
!req.getOutputType().contains(ApiInfoOutTypeEnum.FLOW.name()))) { !req.getOutputType().contains(ApiInfoOutTypeEnum.FLOW.name())) {
return Result.of_error("输出类型不存在!"); return Result.of_error("输出类型不存在!");
}
} }
if (StringUtils.isNotBlank(req.getReqType())) { if (StringUtils.isNotBlank(req.getReqType())) {
if (null == fromAuthReqTypeEnum(req.getReqType())) { if (null == fromAuthReqTypeEnum(req.getReqType())) {
return Result.of_error("限流类型不存在!"); return Result.of_error("限流类型不存在!");
} }
} }
String signStr = dataBankToken + req.getJoinType() + System.currentTimeMillis(); String signStr = dataBankToken + req.getJoinType();
String signResult = Md5.encrypt(signStr, ""); String signResult = Md5.encrypt(signStr, "");
if (!signResult.equals(req.getSign())) { if (!signResult.equals(req.getSign())) {
return Result.of_error("签名错误!"); return Result.of_error("签名错误!");
...@@ -199,9 +199,9 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -199,9 +199,9 @@ public class ProducerServiceImpl implements ProducerService {
ApiInterface apiInterface = saveApiInterFace(req, apiKey, apiType); ApiInterface apiInterface = saveApiInterFace(req, apiKey, apiType);
saveApiInterFaceCustom(req, apiKey, apiInterface.getId()); saveApiInterFaceCustom(req, apiKey, apiInterface.getId());
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
object.put("targetUrl",req.getTargetUrl()); object.put("targetUrl", req.getTargetUrl());
object.put("outputType",req.getOutputType()); object.put("outputType", req.getOutputType());
saveObjOnRedis(apiInterface.getApiKey(),object); saveObjOnRedis(apiInterface.getApiKey(), object);
} }
/** /**
...@@ -300,12 +300,12 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -300,12 +300,12 @@ public class ProducerServiceImpl implements ProducerService {
if (CollectionUtils.isNotEmpty(listApiEsFields)) { if (CollectionUtils.isNotEmpty(listApiEsFields)) {
apiOpenApiEsFieldsMapper.insetBatch(listApiEsFields); apiOpenApiEsFieldsMapper.insetBatch(listApiEsFields);
} }
//调用dmp接口获取数据库连接信息 /* //调用dmp接口获取数据库连接信息
ApiSyncingDatasource dataSource = apiSyncingDatasourceMapper.selectById(req.getEsDataSource()); ApiSyncingDatasource dataSource = apiSyncingDatasourceMapper.selectById(req.getEsDataSource());
if (null != dataSource) { if (null != dataSource) {
//esjdbc 连接地址 用于接口中调用获取es数据 //esjdbc 连接地址 用于接口中调用获取es数据
redisUtils.set(TagConstants.OPEN_API_ESTAG_JDBC_INFO_NAMESPACE + apiInterface.getApiKey(), dataSource.getJdbcUrl()); redisUtils.set(TagConstants.OPEN_API_ESTAG_JDBC_INFO_NAMESPACE + apiInterface.getApiKey(), dataSource.getJdbcUrl());
} }*/
int result = 0; int result = 0;
ApiInterfaceCustom interfaceCustom = new ApiInterfaceCustom(); ApiInterfaceCustom interfaceCustom = new ApiInterfaceCustom();
if (null != req.getId() && !"".equals(req.getId())) {//更新 if (null != req.getId() && !"".equals(req.getId())) {//更新
...@@ -367,9 +367,9 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -367,9 +367,9 @@ public class ProducerServiceImpl implements ProducerService {
throw ResponseException.of_error("保存Api信息失败!"); throw ResponseException.of_error("保存Api信息失败!");
} }
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());
saveObjOnRedis(apiInterface.getApiKey(),object); saveObjOnRedis(apiInterface.getApiKey(), object);
return Result.of_success(ResultMsg.INSERT_SUCCESS, apiKey); return Result.of_success(ResultMsg.INSERT_SUCCESS, apiKey);
} }
...@@ -386,13 +386,13 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -386,13 +386,13 @@ public class ProducerServiceImpl implements ProducerService {
} }
try { try {
String paramKey = redisUtils.get(apiKey); String paramKey = redisUtils.get(apiKey);
if (null != paramKey){ if (null != paramKey) {
redisUtils.del(apiKey); redisUtils.del(apiKey);
} }
redisUtils.set(apiKey, params.toString()); redisUtils.set(apiKey, params.toString());
} catch (Exception ex) { } catch (Exception ex) {
log.error("缓存api制作数据异常:{}",ex.getMessage()); log.error("缓存api制作数据异常:{}", ex.getMessage());
ex.printStackTrace(); ex.printStackTrace();
} }
} }
...@@ -505,9 +505,9 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -505,9 +505,9 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_success(ResultMsg.UPDATE_SUCCESS); return Result.of_success(ResultMsg.UPDATE_SUCCESS);
} }
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());
saveObjOnRedis(apiInterface.getApiKey(),object); saveObjOnRedis(apiInterface.getApiKey(), object);
return Result.of_success(ResultMsg.UPDATE_FAIL); return Result.of_success(ResultMsg.UPDATE_FAIL);
} }
...@@ -707,9 +707,9 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -707,9 +707,9 @@ public class ProducerServiceImpl implements ProducerService {
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(bankApiReq); net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(bankApiReq);
redisUtils.set("apiKeyTest", jsonObject, 300);*/ redisUtils.set("apiKeyTest", jsonObject, 300);*/
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
object.put("targetUrl","www.baidu.common"); object.put("targetUrl", "www.baidu.common");
object.put("outputType",ApiInfoOutTypeEnum.JSON.name()); object.put("outputType", ApiInfoOutTypeEnum.JSON.name());
saveObjOnRedis("apiKeyTest002",object); saveObjOnRedis("apiKeyTest002", object);
return Result.ok(); return Result.ok();
} }
......
...@@ -105,7 +105,7 @@ public class SystemLogAspect { ...@@ -105,7 +105,7 @@ public class SystemLogAspect {
reqLog.setEncryMode("MD5"); //加密方式暂时写死MD5 reqLog.setEncryMode("MD5"); //加密方式暂时写死MD5
reqLog.setTransMode(request.getMethod());//传输方式 GET POST reqLog.setTransMode(request.getMethod());//传输方式 GET POST
reqLog.setRequestToken(jsonParamsList.getString("authCode")); reqLog.setRequestToken(jsonParamsList.getString("authCode"));
reqLog.setRequestTime(new Date()); reqLog.setRequestStartTime(new Date());
reqLog.setRemark(getServiceMethodDescription(joinPoint)); reqLog.setRemark(getServiceMethodDescription(joinPoint));
log.info("请求参数:",reqLog); log.info("请求参数:",reqLog);
if (null != reqLog) { if (null != reqLog) {
......
...@@ -21,21 +21,24 @@ spring: ...@@ -21,21 +21,24 @@ spring:
profiles: profiles:
active: test #默认使用的配置文件 active: test #默认使用的配置文件
cloud: cloud:
sentinel: #sentinel 限流框架配置 sentinel:
transport: transport:
# 项目本地会启动一个服务的端口号,默认8719,用于与sentinel-dashboard通讯
port: 8719
# sentinel-dashboard服务地址 # sentinel-dashboard-1.6.0 的访问路径 , # sentinel-dashboard服务地址 # sentinel-dashboard-1.6.0 的访问路径 ,
#启动方式java -jar sentinel-dashboard-1.6.0.jar --server.port=9090 #启动方式java -jar sentinel-dashboard-1.6.0.jar --server.port=9090
dashboard: localhost:9090 dashboard: localhost:8080
heartbeat-interval-ms: 500
# 项目本地会启动一个服务的端口号,默认8719,用于与sentinel-dashboard通讯
port: 8719
#服务器ip
clientIp: 192.168.1.114
filter: filter:
# 需要进行限流监控的接口,多个匹配用逗号隔开 # 需要进行限流监控的接口,多个匹配用逗号隔开
url-patterns: /* url-patterns: /*
servlet: servlet:
# 触发限流后重定向的页面 # 触发限流后重定向的页面
block-page: /sentinel/block block-page: /sentinel/block
#取消Sentinel控制台懒加载 #取消Sentinel控制台懒加载
#eager: true eager: true
# ====================MybatisPlus==================== # ====================MybatisPlus====================
mybatis-plus: mybatis-plus:
......
...@@ -7,5 +7,11 @@ ...@@ -7,5 +7,11 @@
request_token, request_time, remark, create_date, create_user, request_token, request_time, remark, create_date, create_user,
update_date, update_user, is_deleted update_date, update_user, is_deleted
</sql> </sql>
<select id="countApiCallMonthData" resultType="com.jz.dm.models.dto.ApiCallDataDto">
SELECT COUNT(1) AS callLimit,
SUM(request_consuming) AS timeStat
FROM t_api_req_log
WHERE DATE_FORMAT(create_date,'%Y:%m')=DATE_FORMAT(#{date},'%Y:%m')
</select>
</mapper> </mapper>
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