parent
ede181d001
commit
2f75b19ccd
@ -0,0 +1,18 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询爬虫日志列表
|
||||||
|
export function listWebmagicLog(query) {
|
||||||
|
return request({
|
||||||
|
url: '/log/reptileLog/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除爬虫日志
|
||||||
|
export function delWebmagicLog(id) {
|
||||||
|
return request({
|
||||||
|
url: '/log/reptileLog/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,260 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :rules="queryRules" :inline="true" v-show="showSearch"
|
||||||
|
label-width="68px">
|
||||||
|
<el-form-item label="爬虫名称" prop="name">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.name"
|
||||||
|
placeholder="请输入爬虫名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="爬虫地址" prop="url">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.url"
|
||||||
|
placeholder="请输入爬虫地址"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="请求时间" prop="beginRequestTime">
|
||||||
|
<el-input
|
||||||
|
v-model.number="queryParams.beginRequestTime"
|
||||||
|
placeholder=""
|
||||||
|
size="small"
|
||||||
|
style="width: 90px"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item prop="endRequestTime">
|
||||||
|
-
|
||||||
|
<el-input
|
||||||
|
v-model.number="queryParams.endRequestTime"
|
||||||
|
placeholder=""
|
||||||
|
size="small"
|
||||||
|
style="width: 90px"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="daterangeCreateTime"
|
||||||
|
size="small"
|
||||||
|
style="width: 240px"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery('queryForm')">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['log:webmagicLog:remove']"
|
||||||
|
>删除
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['log:webmagicLog:export']"
|
||||||
|
>导出
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="webmagicLogList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center"/>
|
||||||
|
<el-table-column label="爬虫名称" align="center" prop="name"/>
|
||||||
|
<el-table-column label="爬虫地址" align="center" prop="url" :show-overflow-tooltip="true"/>
|
||||||
|
<el-table-column label="请求时间" align="center" prop="requestTime">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ Math.round(scope.row.requestTime / 1000) }}秒</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="复杂度" align="center" prop="complexRate">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.complexRate }}次</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" :show-overflow-tooltip="true"/>
|
||||||
|
|
||||||
|
<el-table-column label="请求结果" align="center" prop="status">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag :type="scope.row.status===1?'success':'danger'">
|
||||||
|
{{ scope.row.status === 1 ? '成功' : '失败' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['log:webmagicLog:remove']"
|
||||||
|
>删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {listWebmagicLog, delWebmagicLog} from "@/api/business/log/reptilelog";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "ReptileLog",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 爬虫日志表格数据
|
||||||
|
webmagicLogList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 创建时间时间范围
|
||||||
|
daterangeCreateTime: [],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
name: null,
|
||||||
|
url: null,
|
||||||
|
requestTime: null,
|
||||||
|
createTime: null,
|
||||||
|
beginRequestTime: null,
|
||||||
|
endRequestTime: null,
|
||||||
|
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
|
||||||
|
// 表单校验
|
||||||
|
queryRules: {
|
||||||
|
beginRequestTime: [
|
||||||
|
{ type: 'number', message: '必须数字!', trigger: 'blur'}
|
||||||
|
],
|
||||||
|
endRequestTime: [
|
||||||
|
{ type: 'number', message: '必须数字!', trigger: 'blur'}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询爬虫日志列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
|
||||||
|
this.queryParams.createTime = this.daterangeCreateTime[0];
|
||||||
|
this.queryParams.endCreateTime = this.daterangeCreateTime[1];
|
||||||
|
}
|
||||||
|
listWebmagicLog(this.queryParams).then(response => {
|
||||||
|
this.webmagicLogList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery(formName) {
|
||||||
|
this.$refs[formName].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
} else {
|
||||||
|
console.log('error submit!!');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.daterangeCreateTime = [];
|
||||||
|
this.queryParams.createTime = null
|
||||||
|
this.queryParams.endCreateTime = null
|
||||||
|
|
||||||
|
//这个方法封装了重置属性
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery("queryForm");
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length !== 1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const ids = row.id || this.ids;
|
||||||
|
this.$modal.confirm('是否确认删除爬虫日志编号为"' + ids + '"的数据项?').then(function () {
|
||||||
|
return delWebmagicLog(ids);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.$modal.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
this.download('log/reptileLog/export', {
|
||||||
|
...this.queryParams
|
||||||
|
}, `webmagicLog_${new Date().getTime()}.xlsx`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -1,38 +1,82 @@
|
|||||||
package com.xjs.reptileLog.controller;
|
package com.xjs.reptileLog.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
import com.xjs.reptileLog.domain.WebmagicLog;
|
import com.xjs.reptileLog.domain.WebmagicLog;
|
||||||
import com.xjs.reptileLog.service.WebmagicLogService;
|
import com.xjs.reptileLog.service.WebmagicLogService;
|
||||||
|
import com.xjs.web.MyBaseController;
|
||||||
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 javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 爬虫日志控制器
|
* 爬虫日志控制器
|
||||||
|
*
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @since 2022-02-17
|
* @since 2022-02-17
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("reptileLog")
|
@RequestMapping("reptileLog")
|
||||||
@Api(tags = "业务模块-爬虫日志")
|
@Api(tags = "业务模块-爬虫日志")
|
||||||
public class WebmagicLogController {
|
public class WebmagicLogController extends MyBaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WebmagicLogService webmagicLogService;
|
private WebmagicLogService webmagicLogService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------内部调用rpc------------------------
|
//-----------------------内部调用rpc------------------------
|
||||||
|
|
||||||
@PostMapping("saveForPRC")
|
@PostMapping("saveForPRC")
|
||||||
@ApiOperation("供AOP切面RPC远程调用")
|
@ApiOperation("供AOP切面RPC远程调用")
|
||||||
public R<Object> saveReptileLog(@RequestBody WebmagicLog webmagicLog) {
|
public R<Object> saveReptileLog(@RequestBody WebmagicLog webmagicLog) {
|
||||||
boolean save = webmagicLogService.save(webmagicLog);
|
boolean save = webmagicLogService.save(webmagicLog);
|
||||||
return save?R.ok():R.fail();
|
return save ? R.ok() : R.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------代码生成----------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询爬虫日志列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("log:webmagicLog:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(WebmagicLog webmagicLog) {
|
||||||
|
startPage();
|
||||||
|
List<WebmagicLog> list = webmagicLogService.selectWebmagicLogList(webmagicLog);
|
||||||
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出爬虫日志列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("log:webmagicLog:export")
|
||||||
|
@Log(title = "爬虫日志", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, WebmagicLog webmagicLog) {
|
||||||
|
List<WebmagicLog> list = webmagicLogService.selectWebmagicLogList(webmagicLog);
|
||||||
|
ExcelUtil<WebmagicLog> util = new ExcelUtil<>(WebmagicLog.class);
|
||||||
|
util.exportExcel(response, list, "爬虫日志数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除爬虫日志
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("log:webmagicLog:remove")
|
||||||
|
@Log(title = "爬虫日志", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
|
return toAjax(webmagicLogService.deleteWebmagicLogByIds(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
<?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.xjs.reptileLog.mapper.WebmagicLogMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.xjs.reptileLog.domain.WebmagicLog" id="WebmagicLogResult">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="name" column="name"/>
|
||||||
|
<result property="url" column="url"/>
|
||||||
|
<result property="status" column="status"/>
|
||||||
|
<result property="requestTime" column="request_time"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="complexRate" column="complex_rate"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectWebmagicLogVo">
|
||||||
|
select id, name, url, request_time, create_time, complex_rate, status
|
||||||
|
from webmagic_log
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectWebmagicLogList" parameterType="com.xjs.reptileLog.domain.WebmagicLog"
|
||||||
|
resultMap="WebmagicLogResult">
|
||||||
|
<include refid="selectWebmagicLogVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
|
||||||
|
<if test="url != null and url != ''">and url like concat('%', #{url}, '%')</if>
|
||||||
|
<if test="beginRequestTime != null and endRequestTime != null">
|
||||||
|
and request_time between #{beginRequestTime} and #{endRequestTime}
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null and endCreateTime != null">and create_time between #{createTime} and
|
||||||
|
#{endCreateTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteWebmagicLogById" parameterType="Long">
|
||||||
|
delete
|
||||||
|
from webmagic_log
|
||||||
|
where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteWebmagicLogByIds" parameterType="String">
|
||||||
|
delete from webmagic_log where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in new issue