chroe: add view error logs redirect
This commit is contained in:
@@ -37,7 +37,7 @@ type LogsResult struct {
|
||||
}
|
||||
|
||||
// GetSendLogs 获取所有日志记录
|
||||
func GetSendLogs(pageNum int, pageSize int, name string, taskId string, maps interface{}) ([]LogsResult, error) {
|
||||
func GetSendLogs(pageNum int, pageSize int, name string, taskId string, maps map[string]interface{}) ([]LogsResult, error) {
|
||||
var logs []LogsResult
|
||||
logt := db.NewScope(SendTasksLogs{}).TableName()
|
||||
taskt := db.NewScope(SendTasks{}).TableName()
|
||||
@@ -47,6 +47,13 @@ func GetSendLogs(pageNum int, pageSize int, name string, taskId string, maps int
|
||||
Select(fmt.Sprintf("%s.*, %s.name as task_name", logt, taskt)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s ON %s.task_id = %s.id", taskt, logt, taskt))
|
||||
|
||||
dayVal, ok := maps["day_created_on"]
|
||||
if ok {
|
||||
delete(maps, "day_created_on")
|
||||
query = query.Where(fmt.Sprintf("DATE(%s.created_on) = ?", logt), dayVal)
|
||||
}
|
||||
|
||||
query = query.Where(maps)
|
||||
if name != "" {
|
||||
query = query.Where(fmt.Sprintf("%s.name like ?", taskt), fmt.Sprintf("%%%s%%", name))
|
||||
}
|
||||
@@ -63,13 +70,21 @@ func GetSendLogs(pageNum int, pageSize int, name string, taskId string, maps int
|
||||
}
|
||||
|
||||
// GetSendLogsTotal 获取所有日志总数
|
||||
func GetSendLogsTotal(name string, taskId string, maps interface{}) (int, error) {
|
||||
func GetSendLogsTotal(name string, taskId string, maps map[string]interface{}) (int, error) {
|
||||
var total int
|
||||
logt := db.NewScope(SendTasksLogs{}).TableName()
|
||||
taskt := db.NewScope(SendTasks{}).TableName()
|
||||
query := db.
|
||||
Table(logt).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s ON %s.task_id = %s.id", taskt, logt, taskt))
|
||||
|
||||
dayVal, ok := maps["day_created_on"]
|
||||
if ok {
|
||||
delete(maps, "day_created_on")
|
||||
query = query.Where(fmt.Sprintf("DATE(%s.created_on) = ?", logt), dayVal)
|
||||
}
|
||||
|
||||
query = query.Where(maps)
|
||||
if name != "" {
|
||||
query = query.Where(fmt.Sprintf("%s.name like ?", taskt), fmt.Sprintf("%%%s%%", name))
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ func GetTaskSendLogsList(c *gin.Context) {
|
||||
appG := app.Gin{C: c}
|
||||
name := c.Query("name")
|
||||
taskId := c.Query("taskid")
|
||||
query := c.Query("query")
|
||||
|
||||
offset, limit := util.GetPageSize(c)
|
||||
logsService := send_logs_service.SendTaskLogsService{
|
||||
@@ -20,6 +21,7 @@ func GetTaskSendLogsList(c *gin.Context) {
|
||||
Name: name,
|
||||
PageNum: offset,
|
||||
PageSize: limit,
|
||||
Query: query,
|
||||
}
|
||||
ways, err := logsService.GetAll()
|
||||
if err != nil {
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package send_logs_service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/sirupsen/logrus"
|
||||
"message-nest/models"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type SendTaskLogsService struct {
|
||||
ID int
|
||||
TaskId string
|
||||
Name string
|
||||
Query string
|
||||
|
||||
PageNum int
|
||||
PageSize int
|
||||
@@ -27,5 +31,17 @@ func (st *SendTaskLogsService) GetAll() ([]models.LogsResult, error) {
|
||||
|
||||
func (st *SendTaskLogsService) getMaps() map[string]interface{} {
|
||||
maps := make(map[string]interface{})
|
||||
if len(st.Query) > 0 {
|
||||
decodedString, err := url.QueryUnescape(st.Query)
|
||||
if err != nil {
|
||||
logrus.Errorf("queryUrl编码解码失败: %s", err)
|
||||
return maps
|
||||
}
|
||||
err = json.Unmarshal([]byte(decodedString), &maps)
|
||||
if err != nil {
|
||||
logrus.Errorf("queryJson反序列化失败: %s", err)
|
||||
return maps
|
||||
}
|
||||
}
|
||||
return maps
|
||||
}
|
||||
|
||||
@@ -134,14 +134,13 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const filterFunc = async () => {
|
||||
await queryListData(state.currPage, state.pageSize, state.search, state.optionValue);
|
||||
|
||||
}
|
||||
|
||||
const queryListData = async (page, size, name = '', taskid = '') => {
|
||||
let params = { page: page, size: size, name: name, taskid: taskid };
|
||||
const queryListData = async (page, size, name = '', taskid = '', query = '') => {
|
||||
let params = { page: page, size: size, name: name, taskid: taskid, query: query };
|
||||
const rsp = await request.get('/sendlogs/list', { params: params });
|
||||
state.tableData = await rsp.data.data.lists;
|
||||
state.total = await rsp.data.data.total;
|
||||
@@ -149,7 +148,7 @@ export default {
|
||||
|
||||
onMounted(async () => {
|
||||
state.search = router.query.name;
|
||||
await queryListData(1, state.pageSize, router.query.name, router.query.taskid);
|
||||
await queryListData(1, state.pageSize, router.query.name, router.query.taskid, router.query.query);
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
今日发送失败数
|
||||
</div>
|
||||
</template>
|
||||
<template #suffix>
|
||||
<el-icon :size="14">
|
||||
<ArrowRight v-if="data.today_failed_num > 0" @click="clickErrorNumDetail()" />
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-statistic>
|
||||
|
||||
</div>
|
||||
@@ -42,7 +47,7 @@
|
||||
|
||||
<div class="echarts-box">
|
||||
<div id="daily-chart" style="width: 65%; height: 350px;"></div>
|
||||
<div id="send-cate-chart" style="width: 35%; height: 300px;"></div>
|
||||
<div id="send-cate-chart" style="width: 35%; height: 350px;"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -50,17 +55,23 @@
|
||||
</template>
|
||||
|
||||
<script >
|
||||
// import {
|
||||
// ArrowRight,
|
||||
// CaretBottom,
|
||||
// CaretTop,
|
||||
// Warning,
|
||||
// } from '@element-plus/icons-vue'
|
||||
import { reactive, toRefs, onMounted, onUnmounted ,inject } from 'vue'
|
||||
import {
|
||||
ArrowRight,
|
||||
CaretBottom,
|
||||
CaretTop,
|
||||
Warning,
|
||||
} from '@element-plus/icons-vue'
|
||||
import { reactive, toRefs, onMounted, onUnmounted, inject } from 'vue'
|
||||
import { request } from '@/api/api'
|
||||
import { useRouter } from 'vue-router';
|
||||
import { CommonUtils } from "@/util/commonUtils.js";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ArrowRight,
|
||||
},
|
||||
setup() {
|
||||
const router = useRouter();
|
||||
const state = reactive({
|
||||
data: {},
|
||||
dailyChart: {},
|
||||
@@ -77,6 +88,7 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化发送失败的数字样式
|
||||
const formatFailedNumStyle = () => {
|
||||
let style = {};
|
||||
if (state.data.today_failed_num) {
|
||||
@@ -85,6 +97,13 @@ export default {
|
||||
return style;
|
||||
}
|
||||
|
||||
const clickErrorNumDetail = () => {
|
||||
let query = { status: 0, day_created_on: CommonUtils.getCurrentTimeStr().slice(0, 10) };
|
||||
let queryStr = encodeURIComponent(JSON.stringify(query));
|
||||
router.push('/sendlogs?query=' + queryStr, { replace: true });
|
||||
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await getStatisticData();
|
||||
formatFailedNumStyle();
|
||||
@@ -179,7 +198,7 @@ export default {
|
||||
}
|
||||
|
||||
return {
|
||||
...toRefs(state), formatFailedNumStyle
|
||||
...toRefs(state), formatFailedNumStyle, clickErrorNumDetail
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user