Browse Source

日志管理新增第三方接口调用日志列表功能

dev
尹作梅 6 years ago
parent
commit
2e9903a0b8
  1. 96
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/interfacelog/InterfaceLogDTO.java
  2. 94
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/controller/InterfaceLogController.java
  3. 42
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/dao/InterfaceLogDao.java
  4. 69
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/entity/InterfaceLogEntity.java
  5. 71
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/excel/InterfaceLogExcel.java
  6. 47
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/redis/InterfaceLogRedis.java
  7. 95
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/service/InterfaceLogService.java
  8. 101
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/service/impl/InterfaceLogServiceImpl.java
  9. 61
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/interfacelog/InterfaceLogDao.xml

96
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/interfacelog/InterfaceLogDTO.java

@ -0,0 +1,96 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto.interfacelog;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 接口日志表 接口日志表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-11-14
*/
@Data
public class InterfaceLogDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 引用ID
*/
private String referenceId;
/**
* 业务类型
*/
private String businessType;
/**
* 调用接口名称
*/
private String interfaceName;
/**
* 调用是否成功 0-调用失败1-调用成功
*/
private String successFlag;
/**
* 调用消息体
*/
private String callMsgBody;
/**
* 调用返回消息体
*/
private String returnMsgBody;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 删除标记
*/
private String delFlag;
}

94
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/controller/InterfaceLogController.java

@ -0,0 +1,94 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.interfacelog.controller;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.dto.interfacelog.InterfaceLogDTO;
import com.elink.esua.epdc.modules.interfacelog.excel.InterfaceLogExcel;
import com.elink.esua.epdc.modules.interfacelog.service.InterfaceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 接口日志表 接口日志表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-11-14
*/
@RestController
@RequestMapping("interfacelog")
public class InterfaceLogController {
@Autowired
private InterfaceLogService interfaceLogService;
@GetMapping("page")
public Result<PageData<InterfaceLogDTO>> page(@RequestParam Map<String, Object> params){
PageData<InterfaceLogDTO> page = interfaceLogService.listInterfaceLog(params);
return new Result<PageData<InterfaceLogDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<InterfaceLogDTO> get(@PathVariable("id") String id){
InterfaceLogDTO data = interfaceLogService.get(id);
return new Result<InterfaceLogDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody InterfaceLogDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
interfaceLogService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody InterfaceLogDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
interfaceLogService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
interfaceLogService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<InterfaceLogDTO> list = interfaceLogService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, InterfaceLogExcel.class);
}
}

42
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/dao/InterfaceLogDao.java

@ -0,0 +1,42 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.interfacelog.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.interfacelog.InterfaceLogDTO;
import com.elink.esua.epdc.modules.interfacelog.entity.InterfaceLogEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
* 接口日志表 接口日志表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-11-14
*/
@Mapper
public interface InterfaceLogDao extends BaseDao<InterfaceLogEntity> {
/**
*
* @param params
* @return 获取接口日志列表
*/
List<InterfaceLogDTO> listInterfaceLog(Map<String, Object> params);
}

69
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/entity/InterfaceLogEntity.java

@ -0,0 +1,69 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.interfacelog.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 接口日志表 接口日志表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-11-14
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("epdc_interface_log")
public class InterfaceLogEntity extends BaseEpdcEntity {
private static final long serialVersionUID = 1L;
/**
* 引用ID
*/
private String referenceId;
/**
* 业务类型
*/
private String businessType;
/**
* 调用接口名称
*/
private String interfaceName;
/**
* 调用是否成功 0-调用失败1-调用成功
*/
private String successFlag;
/**
* 调用消息体
*/
private String callMsgBody;
/**
* 调用返回消息体
*/
private String returnMsgBody;
}

71
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/excel/InterfaceLogExcel.java

@ -0,0 +1,71 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.interfacelog.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 接口日志表 接口日志表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-11-14
*/
@Data
public class InterfaceLogExcel {
@Excel(name = "主键")
private String id;
@Excel(name = "引用ID")
private String referenceId;
@Excel(name = "业务类型")
private String businessType;
@Excel(name = "调用接口名称")
private String interfaceName;
@Excel(name = "调用是否成功 0-调用失败,1-调用成功")
private String successFlag;
@Excel(name = "调用消息体")
private String callMsgBody;
@Excel(name = "调用返回消息体")
private String returnMsgBody;
@Excel(name = "创建人")
private String createdBy;
@Excel(name = "创建时间")
private Date createdTime;
@Excel(name = "更新人")
private String updatedBy;
@Excel(name = "更新时间")
private Date updatedTime;
@Excel(name = "删除标记")
private String delFlag;
}

47
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/redis/InterfaceLogRedis.java

@ -0,0 +1,47 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.interfacelog.redis;
import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 接口日志表 接口日志表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-11-14
*/
@Component
public class InterfaceLogRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

95
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/service/InterfaceLogService.java

@ -0,0 +1,95 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.interfacelog.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.dto.interfacelog.InterfaceLogDTO;
import com.elink.esua.epdc.modules.interfacelog.entity.InterfaceLogEntity;
import java.util.List;
import java.util.Map;
/**
* 接口日志表 接口日志表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-11-14
*/
public interface InterfaceLogService extends BaseService<InterfaceLogEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<InterfaceLogDTO>
* @author generator
* @date 2019-11-14
*/
PageData<InterfaceLogDTO> listInterfaceLog(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<InterfaceLogDTO>
* @author generator
* @date 2019-11-14
*/
List<InterfaceLogDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return InterfaceLogDTO
* @author generator
* @date 2019-11-14
*/
InterfaceLogDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2019-11-14
*/
void save(InterfaceLogDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2019-11-14
*/
void update(InterfaceLogDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2019-11-14
*/
void delete(String[] ids);
}

101
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/interfacelog/service/impl/InterfaceLogServiceImpl.java

@ -0,0 +1,101 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.interfacelog.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.dto.interfacelog.InterfaceLogDTO;
import com.elink.esua.epdc.modules.interfacelog.dao.InterfaceLogDao;
import com.elink.esua.epdc.modules.interfacelog.entity.InterfaceLogEntity;
import com.elink.esua.epdc.modules.interfacelog.redis.InterfaceLogRedis;
import com.elink.esua.epdc.modules.interfacelog.service.InterfaceLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 接口日志表 接口日志表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-11-14
*/
@Service
public class InterfaceLogServiceImpl extends BaseServiceImpl<InterfaceLogDao, InterfaceLogEntity> implements InterfaceLogService {
@Autowired
private InterfaceLogRedis interfaceLogRedis;
@Override
public PageData<InterfaceLogDTO> listInterfaceLog(Map<String, Object> params) {
IPage<InterfaceLogDTO> page = getPage(params);
List<InterfaceLogDTO> list = baseDao.listInterfaceLog(params);
return new PageData<>(list, page.getTotal());
}
@Override
public List<InterfaceLogDTO> list(Map<String, Object> params) {
List<InterfaceLogEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, InterfaceLogDTO.class);
}
private QueryWrapper<InterfaceLogEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<InterfaceLogEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public InterfaceLogDTO get(String id) {
InterfaceLogEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, InterfaceLogDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(InterfaceLogDTO dto) {
InterfaceLogEntity entity = ConvertUtils.sourceToTarget(dto, InterfaceLogEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(InterfaceLogDTO dto) {
InterfaceLogEntity entity = ConvertUtils.sourceToTarget(dto, InterfaceLogEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
}

61
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/interfacelog/InterfaceLogDao.xml

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.elink.esua.epdc.modules.interfacelog.dao.InterfaceLogDao">
<resultMap type="com.elink.esua.epdc.modules.interfacelog.entity.InterfaceLogEntity" id="interfaceLogMap">
<result property="id" column="ID"/>
<result property="referenceId" column="REFERENCE_ID"/>
<result property="businessType" column="BUSINESS_TYPE"/>
<result property="interfaceName" column="INTERFACE_NAME"/>
<result property="successFlag" column="SUCCESS_FLAG"/>
<result property="callMsgBody" column="CALL_MSG_BODY"/>
<result property="returnMsgBody" column="RETURN_MSG_BODY"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="delFlag" column="DEL_FLAG"/>
</resultMap>
<!-- -->
<select id="listInterfaceLog" parameterType="map"
resultType="com.elink.esua.epdc.dto.interfacelog.InterfaceLogDTO">
select eil.id,
eil.REFERENCE_ID as referenceId,
eil.BUSINESS_TYPE as businessType,
eil.INTERFACE_NAME as interfaceName,
eil.SUCCESS_FLAG as successFlag,
eil.CALL_MSG_BODY as callMsgBody,
eil.RETURN_MSG_BODY as returnMsgBody,
eil.CREATED_BY as createdBy,
eil.CREATED_TIME as createdTime,
eil.UPDATED_BY as updatedBy,
eil.UPDATED_TIME as updatedTime,
eil.DEL_FLAG as delFlag
from epdc_interface_log eil
where eil.DEL_FLAG='0'
<if test="businessType != null and businessType != ''">
and eil.BUSINESS_TYPE=#{businessType}
</if>
<if test="interfaceName != null and interfaceName != ''">
and eil.INTERFACE_NAME like concat('%',#{interfaceName},'%')
</if>
<if test="successFlag != null and successFlag != ''">
and eil.SUCCESS_FLAG=#{successFlag}
</if>
<if test="callMsgBody != null and callMsgBody != ''">
and eil.CALL_MSG_BODY like concat('%',#{callMsgBody},'%')
</if>
<if test="returnMsgBody != null and returnMsgBody != ''">
and eil.RETURN_MSG_BODY like concat('%',#{returnMsgBody},'%')
</if>
<if test="startTime != null and startTime != ''">
and DATE_FORMAT( eil.CREATED_TIME, '%Y-%m-%d' ) &gt;=#{startTime}
</if>
<if test="endTime != null and endTime != ''">
and DATE_FORMAT( eil.CREATED_TIME, '%Y-%m-%d' ) &lt;=#{endTime}
</if>
order by eil.CREATED_TIME desc
</select>
</mapper>
Loading…
Cancel
Save