代码生成优化

This commit is contained in:
xiangheng
2024-06-17 22:29:30 +08:00
parent a700a39992
commit 9de418ce1d
20 changed files with 1228 additions and 361 deletions

View File

@@ -1,30 +1,86 @@
import request from '@/utils/request'
import type { Pages } from '@/utils/request'
// 客户端信息列表
export function monitor_client_list(params?: Record<string, any>) {
return request.get({ url: '/monitor_client/list', params })
import config from '@/config'
import queryString from 'query-string'
import { getToken } from '@/utils/auth'
export type type_monitor_client = {
id?: number;
projectKey?: string;
clientId?: string;
userId?: string;
os?: string;
browser?: string;
city?: string;
width?: number;
height?: number;
ua?: string;
createTime?: string;
clientTime?: string;
}
// 客户端信息列表-所有
export function monitor_client_list_all(params?: Record<string, any>) {
return request.get({ url: '/monitor_client/listAll', params })
// 查询
export type type_monitor_client_query = {
projectKey?: string;
clientId?: string;
userId?: string;
os?: string;
browser?: string;
city?: string;
width?: number;
height?: number;
ua?: string;
createTimeStart?: string;
createTimeEnd?: string;
clientTimeStart?: string;
clientTimeEnd?: string;
}
// 添加编辑
export type type_monitor_client_edit = {
clientId?: string;
userId?: string;
os?: string;
browser?: string;
city?: string;
width?: number;
height?: number;
ua?: string;
clientTime?: string;
}
// 客户端信息详情
export function monitor_client_detail(params: { id: string }) {
return request.get({ url: '/monitor_client/detail', params })
// 监控-客户端信息列表
export function monitor_client_list(params?: type_monitor_client_query) {
return request.get<Pages<type_monitor_client>>({ url: '/monitor_client/list', params })
}
// 监控-客户端信息列表-所有
export function monitor_client_list_all(params?: type_monitor_client_query) {
return request.get<Pages<type_monitor_client>>({ url: '/monitor_client/listAll', params })
}
// 客户端信息新增
export function monitor_client_add(data: Record<string, any>) {
return request.post({ url: '/monitor_client/add', data })
// 监控-客户端信息详情
export function monitor_client_detail(id: number | string) {
return request.get<type_monitor_client>({ url: '/monitor_client/detail', params: { id } })
}
// 客户端信息编辑
export function monitor_client_edit(data: Record<string, any>) {
return request.post({ url: '/monitor_client/edit', data })
// 监控-客户端信息新增
export function monitor_client_add(data: type_monitor_client_edit) {
return request.post<null>({ url: '/monitor_client/add', data })
}
// 客户端信息删除
export function monitor_client_delete(data: Record<string, any>) {
return request.post({ url: '/monitor_client/del', data })
// 监控-客户端信息编辑
export function monitor_client_edit(data: type_monitor_client_edit) {
return request.post<null>({ url: '/monitor_client/edit', data })
}
// 监控-客户端信息删除
export function monitor_client_delete(id: number | string) {
return request.post<null>({ url: '/monitor_client/del', data: { id } })
}
// 监控-客户端信息导入
export const monitor_client_import_file = '/monitor_client/ImportFile'
// 监控-客户端信息导出
export function monitor_client_export_file(params: any) {
return (window.location.href =`${config.baseUrl}${config.urlPrefix}/monitor_client/ExportFile?token=${getToken()}&` + queryString.stringify(params))
}

View File

@@ -10,47 +10,48 @@
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
<el-form-item label="项目key" prop="projectKey">
<el-input v-model="formData.projectKey" placeholder="请输入项目key" />
</el-form-item>
<el-form-item label="客户端id" prop="clientId">
<el-input v-model="formData.clientId" placeholder="请输入sdk生成的客户端id" />
</el-form-item>
<el-form-item label="用户id" prop="userId">
<el-input v-model="formData.userId" placeholder="请输入用户id" />
</el-form-item>
<el-form-item label="系统" prop="os">
<el-input v-model="formData.os" placeholder="请输入系统" />
</el-form-item>
<el-form-item label="浏览器" prop="browser">
<el-input v-model="formData.browser" placeholder="请输入浏览器" />
</el-form-item>
<el-form-item label="城市" prop="city">
<el-input v-model="formData.city" placeholder="请输入城市" />
</el-form-item>
<el-form-item label="屏幕" prop="width">
<el-input v-model.number="formData.width" placeholder="请输入屏幕" />
</el-form-item>
<el-form-item label="屏幕高度" prop="height">
<el-input v-model.number="formData.height" placeholder="请输入屏幕高度" />
</el-form-item>
<el-form-item label="ua记录" prop="ua">
<el-input v-model="formData.ua" placeholder="请输入ua记录" />
</el-form-item>
<el-form-item label="时间" prop="clientTime">
<el-input v-model="formData.clientTime" placeholder="请输入客户端时间" />
</el-form-item>
<el-form-item label="sdk生成的客户端id" prop="clientId">
<el-input v-model="formData.clientId" placeholder="请输入sdk生成的客户端id" />
</el-form-item>
<el-form-item label="用户id" prop="userId">
<el-input v-model="formData.userId" placeholder="请输入用户id" />
</el-form-item>
<el-form-item label="系统" prop="os">
<el-input v-model="formData.os" placeholder="请输入系统" />
</el-form-item>
<el-form-item label="浏览器" prop="browser">
<el-input v-model="formData.browser" placeholder="请输入浏览器" />
</el-form-item>
<el-form-item label="城市" prop="city">
<el-input v-model="formData.city" placeholder="请输入城市" />
</el-form-item>
<el-form-item label="屏幕" prop="width">
<el-input v-model="formData.width" placeholder="请输入屏幕" />
</el-form-item>
<el-form-item label="屏幕高度" prop="height">
<el-input v-model="formData.height" placeholder="请输入屏幕高度" />
</el-form-item>
<el-form-item label="ua记录" prop="ua">
<el-input v-model="formData.ua" placeholder="请输入ua记录" />
</el-form-item>
<el-form-item label="更新时间" prop="clientTime">
<el-date-picker
class="flex-1 !flex"
v-model="formData.clientTime"
type="datetime"
clearable
value-format="YYYY-MM-DD hh:mm:ss"
placeholder="请选择更新时间"
/>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup>
import type { FormInstance } from 'element-plus'
import {
monitor_client_edit,
monitor_client_add,
monitor_client_detail
} from '@/api/monitor_client'
import { monitor_client_edit, monitor_client_add, monitor_client_detail } from '@/api/monitor_client'
import Popup from '@/components/popup/index.vue'
import feedback from '@/utils/feedback'
import type { PropType } from 'vue'
@@ -65,12 +66,11 @@ const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑客户端信息' : '新增客户端信息'
return mode.value == 'edit' ? '编辑监控-客户端信息' : '新增监控-客户端信息'
})
const formData = reactive({
id: '',
projectKey: '',
clientId: '',
userId: '',
os: '',
@@ -79,27 +79,13 @@ const formData = reactive({
width: '',
height: '',
ua: '',
clientTime: ''
clientTime: '',
})
const formRules = {
id: [
{
required: true,
message: '请输入uuid',
trigger: ['blur']
}
],
projectKey: [
{
required: true,
message: '请输入项目key',
trigger: ['blur']
}
],
clientId: [
{
// required: true,
required: true,
message: '请输入sdk生成的客户端id',
trigger: ['blur']
}
@@ -156,34 +142,21 @@ const formRules = {
clientTime: [
{
required: true,
message: '请输入客户端时间',
message: '请选择更新时间',
trigger: ['blur']
}
]
],
}
const handleSubmit = async () => {
formRef.value
?.validate()
.then(() => {
try {
const data: any = { ...formData }
let req = null
if (mode.value == 'edit') {
req = monitor_client_edit(data)
} else {
req = monitor_client_add(data)
}
req.then(() => {
popupRef.value?.close()
feedback.msgSuccess('操作成功')
emit('success')
}).catch((err) => {
feedback.msgError(err.message)
})
} catch (error) {}
})
.catch(() => {})
try {
await formRef.value?.validate()
const data: any = { ...formData }
mode.value == 'edit' ? await monitor_client_edit(data) : await monitor_client_add(data)
popupRef.value?.close()
feedback.msgSuccess('操作成功')
emit('success')
} catch (error) {}
}
const open = (type = 'add') => {
@@ -194,18 +167,17 @@ const open = (type = 'add') => {
const setFormData = async (data: Record<string, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
try {
const data = await monitor_client_detail({
id: row.id
})
try {
const data = await monitor_client_detail(row.id)
setFormData(data)
} catch (error) {}
} catch (error) {}
}
const handleClose = () => {

View File

@@ -1,30 +1,51 @@
<template>
<div class="index-lists">
<el-card class="!border-none" shadow="never">
<el-form
ref="formRef"
class="mb-[-16px]"
:model="queryParams"
:inline="true"
label-width="70px"
label-position="left"
>
<el-form-item label="项目key" prop="projectKey" class="w-[280px]">
<el-input v-model="queryParams.projectKey" />
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true" label-width="70px"
label-position="left">
<el-form-item label="项目key" prop="projectKey" class="w-[280px]">
<el-select
v-model="queryParams.projectKey"
clearable
>
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="客户端id" prop="clientId" class="w-[280px]">
<el-input v-model="queryParams.clientId" />
<el-form-item label="sdk生成的客户端id" prop="clientId" class="w-[280px]">
<el-input v-model="queryParams.clientId" />
</el-form-item>
<el-form-item label="用户id" prop="userId" class="w-[280px]">
<el-input v-model="queryParams.userId" />
<el-input v-model="queryParams.userId" />
</el-form-item>
<el-form-item label="系统" prop="os" class="w-[280px]">
<el-input v-model="queryParams.os" />
</el-form-item>
<el-form-item label="浏览器" prop="browser" class="w-[280px]">
<el-input v-model="queryParams.browser" />
</el-form-item>
<el-form-item label="城市" prop="city" class="w-[280px]">
<el-input v-model="queryParams.city" />
<el-input v-model="queryParams.city" />
</el-form-item>
<el-form-item label="时间" prop="clientTime" class="w-[280px]">
<el-input v-model="queryParams.clientTime" />
<el-form-item label="屏幕" prop="width" class="w-[280px]">
<el-input v-model="queryParams.width" />
</el-form-item>
<el-form-item label="屏幕高度" prop="height" class="w-[280px]">
<el-input v-model="queryParams.height" />
</el-form-item>
<el-form-item label="ua记录" prop="ua" class="w-[280px]">
<el-input v-model="queryParams.ua" />
</el-form-item>
<el-form-item label="创建时间" prop="createTime" class="w-[280px]">
<daterange-picker
v-model:startTime="queryParams.createTimeStart"
v-model:endTime="queryParams.createTimeEnd"
/>
</el-form-item>
<el-form-item label="更新时间" prop="clientTime" class="w-[280px]">
<daterange-picker
v-model:startTime="queryParams.clientTimeStart"
v-model:endTime="queryParams.clientTimeEnd"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
@@ -34,20 +55,42 @@
</el-card>
<el-card class="!border-none mt-4" shadow="never">
<div>
<el-button
v-perms="['admin:monitor_client:add']"
type="primary"
@click="handleAdd()"
>
<el-button v-perms="['admin:monitor_client:add']" type="primary" @click="handleAdd()">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<upload
class="ml-3 mr-3"
:url="monitor_client_export_file"
:data="{ cid: 0 }"
type="file"
:show-progress="true"
@change="resetPage"
>
<el-button type="primary">
<template #icon>
<icon name="el-icon-Upload" />
</template>
导入
</el-button>
</upload>
<el-button type="primary" @click="exportFile">
<template #icon>
<icon name="el-icon-Download" />
</template>
导出
</el-button>
</div>
<el-table class="mt-4" size="large" v-loading="pager.loading" :data="pager.lists">
<el-table
class="mt-4"
size="large"
v-loading="pager.loading"
:data="pager.lists"
>
<el-table-column label="项目key" prop="projectKey" min-width="130" />
<el-table-column label="客户端id" prop="clientId" min-width="130" />
<el-table-column label="sdk生成的客户端id" prop="clientId" min-width="130" />
<el-table-column label="用户id" prop="userId" min-width="130" />
<el-table-column label="系统" prop="os" min-width="130" />
<el-table-column label="浏览器" prop="browser" min-width="130" />
@@ -55,12 +98,18 @@
<el-table-column label="屏幕" prop="width" min-width="130" />
<el-table-column label="屏幕高度" prop="height" min-width="130" />
<el-table-column label="ua记录" prop="ua" min-width="130" />
<el-table-column label="客户端时间" prop="clientTime" min-width="130" />
<!-- <el-table-column label="创建时间" prop="createTime" min-width="130" /> -->
<el-table-column label="操作" width="160" fixed="right">
<el-table-column label="创建时间" prop="createTime" min-width="130" />
<el-table-column label="更新时间" prop="clientTime" min-width="130" />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button type="primary" link @click="to_monitor_web(row)">日志</el-button>
<el-button
v-perms="['admin:monitor_client:edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['admin:monitor_client:del']"
type="danger"
@@ -76,23 +125,26 @@
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
<edit-popup
v-if="showEdit"
ref="editRef"
@success="getLists"
@close="showEdit = false"
/>
</div>
</template>
<script lang="ts" setup>
import { monitor_client_delete, monitor_client_list } from '@/api/monitor_client'
import { monitor_client_delete, monitor_client_list,monitor_client_import_file, monitor_client_export_file } from '@/api/monitor_client'
import type { type_monitor_client,type_monitor_client_query } from "@/api/monitor_client";
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const router = useRouter()
defineOptions({
name: 'monitor_client'
name:"monitor_client"
})
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)
const queryParams = reactive({
const queryParams = reactive<type_monitor_client_query>({
projectKey: '',
clientId: '',
userId: '',
@@ -102,30 +154,44 @@ const queryParams = reactive({
width: '',
height: '',
ua: '',
clientTime: ''
createTimeStart: '',
createTimeEnd: '',
clientTimeStart: '',
clientTimeEnd: '',
})
const { pager, getLists, resetPage, resetParams } = usePaging({
const { pager, getLists, resetPage, resetParams } = usePaging<type_monitor_client>({
fetchFun: monitor_client_list,
params: queryParams
})
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
const handleDelete = async (id: number) => {
await feedback.confirm('确定要删除?')
await monitor_client_delete({ id })
feedback.msgSuccess('删除成功')
getLists()
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.getDetail(data)
}
const to_monitor_web = async (data: any) => {
router.push(
`/setting/monitor_web/index?clientId=${data.clientId}&projectKey=${data.projectKey}`
)
const handleDelete = async (id: number) => {
try {
await feedback.confirm('确定要删除?')
await monitor_client_delete( id )
feedback.msgSuccess('删除成功')
getLists()
} catch (error) {}
}
const exportFile = async () => {
try {
await feedback.confirm('确定要导出?')
await monitor_client_export_file(queryParams)
} catch (error) {}
}
getLists()
</script>

View File

@@ -50,6 +50,7 @@ func (service {{{ toCamelCase .EntityName }}}Service) GetModel(listReq {{{ title
{{{- if contains .AllFields "is_delete" }}}
dbModel = dbModel.Where("is_delete = ?", 0)
{{{- end }}}
return dbModel
}
// List {{{ .FunctionName }}}列表
func (service {{{ toCamelCase .EntityName }}}Service) List(page request.PageReq, listReq {{{ title (toCamelCase .EntityName) }}}ListReq) (res response.PageResp, e error) {

View File

@@ -10,12 +10,14 @@
<uv-number-box v-model="form.{{{ (toCamelCase .GoField) }}}" :min="-99999999" :max="99999999" :integer="true"></uv-number-box>
{{{- else if eq .HtmlType "textarea" }}}
<uv-textarea v-model="form.{{{ (toCamelCase .GoField) }}}" border="surround"></uv-textarea>
{{{- else if eq .HtmlType "datetime" }}}
<x-date v-model:time="form.{{{ (toCamelCase .GoField) }}}"></x-date>
{{{- else if or (eq .HtmlType "checkbox") (eq .HtmlType "radio") (eq .HtmlType "select")}}}
{{{- if ne .DictType "" }}}
<x-picker v-model="form.{{{ (toCamelCase .GoField) }}}" valueKey="value" labelKey="name" :columns="dictData.{{{ .DictType }}}"></x-picker>
{{{- else }}}
请选择字典生成代码
{{{- end }}}
{{{- if ne .DictType "" }}}
<x-picker v-model="form.{{{ (toCamelCase .GoField) }}}" valueKey="value" labelKey="name" :columns="dictData.{{{ .DictType }}}"></x-picker>
{{{- else }}}
请选择字典生成代码
{{{- end }}}
{{{- end }}}
</uv-form-item>
{{{- end }}}

View File

@@ -3,35 +3,38 @@ package monitor_client
import (
"net/http"
"time"
"github.com/gin-gonic/gin"
"x_admin/core/request"
"x_admin/core/response"
"x_admin/util"
"x_admin/util/excel"
"github.com/gin-gonic/gin"
)
type MonitorClientHandler struct{}
type MonitorClientHandler struct {}
// @Summary 客户端信息列表
// @Tags monitor_client-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param PageNo query int true "页码"
// @Param PageSize query int true "每页数量"
// @Param projectKey query string false "项目key."
// @Param clientId query string false "sdk生成的客户端id."
// @Param userId query string false "用户id."
// @Param os query string false "系统."
// @Param browser query string false "浏览器."
// @Param city query string false "城市."
// @Param width query int false "屏幕."
// @Param height query int false "屏幕高度."
// @Param ua query string false "ua记录."
// @Param clientTime query int false "客户端时间."
// @Success 200 {object} []MonitorClientResp "成功"
// @Failure 400 {object} string "请求错误"
// @Router /api/admin/monitor_client/list [get]
// @Summary 监控-客户端信息列表
// @Tags monitor_client-监控-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param PageNo query int true "页码"
// @Param PageSize query int true "每页数量"
// @Param projectKey query string false "项目key."
// @Param clientId query string false "sdk生成的客户端id."
// @Param userId query string false "用户id."
// @Param os query string false "系统."
// @Param browser query string false "浏览器."
// @Param city query string false "城市."
// @Param width query int false "屏幕."
// @Param height query int false "屏幕高度."
// @Param ua query string false "ua记录."
// @Param createTimeStart query core.TsTime false "创建时间."
// @Param createTimeEnd query core.TsTime false "创建时间."
// @Param clientTimeStart query core.TsTime false "更新时间."
// @Param clientTimeEnd query core.TsTime false "更新时间."
// @Success 200 {object} []MonitorClientResp "成功"
// @Failure 400 {object} string "请求错误"
// @Router /api/admin/monitor_client/list [get]
func (hd MonitorClientHandler) List(c *gin.Context) {
var page request.PageReq
var listReq MonitorClientListReq
@@ -45,28 +48,40 @@ func (hd MonitorClientHandler) List(c *gin.Context) {
response.CheckAndRespWithData(c, res, err)
}
// @Summary 客户端信息列表-所有
// @Tags monitor_client-客户端信息
// @Produce json
// @Success 200 {object} []MonitorClientResp "成功"
// @Router /api/admin/monitor_client/listAll [get]
// @Summary 监控-客户端信息列表-所有
// @Tags monitor_client-监控-客户端信息
// @Produce json
// @Param projectKey query string false "项目key."
// @Param clientId query string false "sdk生成的客户端id."
// @Param userId query string false "用户id."
// @Param os query string false "系统."
// @Param browser query string false "浏览器."
// @Param city query string false "城市."
// @Param width query int false "屏幕."
// @Param height query int false "屏幕高度."
// @Param ua query string false "ua记录."
// @Param createTimeStart query core.TsTime false "创建时间."
// @Param createTimeEnd query core.TsTime false "创建时间."
// @Param clientTimeStart query core.TsTime false "更新时间."
// @Param clientTimeEnd query core.TsTime false "更新时间."
// @Success 200 {object} []MonitorClientResp "成功"
// @Router /api/admin/monitor_client/listAll [get]
func (hd MonitorClientHandler) ListAll(c *gin.Context) {
//var listReq MonitorClientListReq
//if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
// return
//}
res, err := Service.ListAll()
var listReq MonitorClientListReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
return
}
res, err := Service.ListAll(listReq)
response.CheckAndRespWithData(c, res, err)
}
// @Summary 客户端信息详情
// @Tags monitor_client-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param id query int false "uuid."
// @Success 200 {object} MonitorClientResp "成功"
// @Router /api/admin/monitor_client/detail [get]
// @Summary 监控-客户端信息详情
// @Tags monitor_client-监控-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param id query int false "uuid."
// @Success 200 {object} MonitorClientResp "成功"
// @Router /api/admin/monitor_client/detail [get]
func (hd MonitorClientHandler) Detail(c *gin.Context) {
var detailReq MonitorClientDetailReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
@@ -76,22 +91,22 @@ func (hd MonitorClientHandler) Detail(c *gin.Context) {
response.CheckAndRespWithData(c, res, err)
}
// @Summary 客户端信息新增
// @Tags monitor_client-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param projectKey body string false "项目key."
// @Param clientId body string false "sdk生成的客户端id."
// @Param userId body string false "用户id."
// @Param os body string false "系统."
// @Param browser body string false "浏览器."
// @Param city body string false "城市."
// @Param width body int false "屏幕."
// @Param height body int false "屏幕高度."
// @Param ua body string false "ua记录."
// @Param clientTime body int false "客户端时间."
// @Success 200 {object} response.RespType "成功"
// @Router /api/admin/monitor_client/add [post]
// @Summary 监控-客户端信息新增
// @Tags monitor_client-监控-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param clientId body string false "sdk生成的客户端id."
// @Param userId body string false "用户id."
// @Param os body string false "系统."
// @Param browser body string false "浏览器."
// @Param city body string false "城市."
// @Param width body int false "屏幕."
// @Param height body int false "屏幕高度."
// @Param ua body string false "ua记录."
// @Param clientTime body core.TsTime false "更新时间."
// @Success 200 {object} response.RespType "成功"
// @Router /api/admin/monitor_client/add [post]
func (hd MonitorClientHandler) Add(c *gin.Context) {
var addReq MonitorClientAddReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &addReq)) {
@@ -99,24 +114,21 @@ func (hd MonitorClientHandler) Add(c *gin.Context) {
}
response.CheckAndResp(c, Service.Add(addReq))
}
// @Summary 客户端信息编辑
// @Tags monitor_client-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param id body int false "uuid."
// @Param projectKey body string false "项目key."
// @Param clientId body string false "sdk生成的客户端id."
// @Param userId body string false "用户id."
// @Param os body string false "系统."
// @Param browser body string false "浏览器."
// @Param city body string false "城市."
// @Param width body int false "屏幕."
// @Param height body int false "屏幕高度."
// @Param ua body string false "ua记录."
// @Param clientTime body int false "客户端时间."
// @Success 200 {object} response.RespType "成功"
// @Router /api/admin/monitor_client/edit [post]
// @Summary 监控-客户端信息编辑
// @Tags monitor_client-监控-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param clientId body string false "sdk生成的客户端id."
// @Param userId body string false "用户id."
// @Param os body string false "系统."
// @Param browser body string false "浏览器."
// @Param city body string false "城市."
// @Param width body int false "屏幕."
// @Param height body int false "屏幕高度."
// @Param ua body string false "ua记录."
// @Param clientTime body core.TsTime false "更新时间."
// @Success 200 {object} response.RespType "成功"
// @Router /api/admin/monitor_client/edit [post]
func (hd MonitorClientHandler) Edit(c *gin.Context) {
var editReq MonitorClientEditReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &editReq)) {
@@ -124,14 +136,13 @@ func (hd MonitorClientHandler) Edit(c *gin.Context) {
}
response.CheckAndResp(c, Service.Edit(editReq))
}
// @Summary 客户端信息删除
// @Tags monitor_client-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param id body int false "uuid."
// @Success 200 {object} response.RespType "成功"
// @Router /api/admin/monitor_client/del [post]
// @Summary 监控-客户端信息删除
// @Tags monitor_client-监控-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param id body int false "uuid."
// @Success 200 {object} response.RespType "成功"
// @Router /api/admin/monitor_client/del [post]
func (hd MonitorClientHandler) Del(c *gin.Context) {
var delReq MonitorClientDelReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &delReq)) {
@@ -140,21 +151,24 @@ func (hd MonitorClientHandler) Del(c *gin.Context) {
response.CheckAndResp(c, Service.Del(delReq.Id))
}
// @Summary 客户端信息导出
// @Tags monitor_client-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param projectKey query string false "项目key."
// @Param clientId query string false "sdk生成的客户端id."
// @Param userId query string false "用户id."
// @Param os query string false "系统."
// @Param browser query string false "浏览器."
// @Param city query string false "城市."
// @Param width query int false "屏幕."
// @Param height query int false "屏幕高度."
// @Param ua query string false "ua记录."
// @Param clientTime query int false "客户端时间."
// @Router /api/admin/monitor_client/ExportFile [get]
// @Summary 监控-客户端信息导出
// @Tags monitor_client-监控-客户端信息
// @Produce json
// @Param Token header string true "token"
// @Param projectKey query string false "项目key."
// @Param clientId query string false "sdk生成的客户端id."
// @Param userId query string false "用户id."
// @Param os query string false "系统."
// @Param browser query string false "浏览器."
// @Param city query string false "城市."
// @Param width query int false "屏幕."
// @Param height query int false "屏幕高度."
// @Param ua query string false "ua记录."
// @Param createTime query core.TsTime false "创建时间."
// @Param clientTime query core.TsTime false "更新时间."
// @Router /api/admin/monitor_client/ExportFile [get]
func (hd MonitorClientHandler) ExportFile(c *gin.Context) {
var listReq MonitorClientListReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
@@ -165,17 +179,17 @@ func (hd MonitorClientHandler) ExportFile(c *gin.Context) {
response.FailWithMsg(c, response.SystemError, "查询信息失败")
return
}
f, err := excel.NormalDynamicExport(res, "Sheet1", "客户端信息", nil)
f, err := excel.NormalDynamicExport(res, "Sheet1", "监控-客户端信息", nil)
if err != nil {
response.FailWithMsg(c, response.SystemError, "导出失败")
return
}
excel.DownLoadExcel("客户端信息"+time.Now().Format("2006-01-02 15:04:05"), c.Writer, f)
excel.DownLoadExcel("监控-客户端信息" + time.Now().Format("20060102-150405"), c.Writer, f)
}
// @Summary 客户端信息导入
// @Tags monitor_client-客户端信息
// @Produce json
// @Summary 监控-客户端信息导入
// @Tags monitor_client-监控-客户端信息
// @Produce json
func (hd MonitorClientHandler) ImportFile(c *gin.Context) {
file, _, err := c.Request.FormFile("file")
if err != nil {
@@ -189,9 +203,9 @@ func (hd MonitorClientHandler) ImportFile(c *gin.Context) {
c.String(http.StatusInternalServerError, err.Error())
return
}
// for _, t := range importList {
// fmt.Printf("%#v", t)
// }
// for _, t := range importList {
// fmt.Printf("%#v", t)
// }
err = Service.ImportFile(importList)
response.CheckAndResp(c, err)
}
}

View File

@@ -2,62 +2,63 @@ package monitor_client
import "x_admin/core"
//MonitorClientListReq 客户端信息列表参数
//MonitorClientListReq 监控-客户端信息列表参数
type MonitorClientListReq struct {
ProjectKey string `form:"projectKey"` // 项目key
ClientId string `form:"clientId"` // sdk生成的客户端id
UserId string `form:"userId"` // 用户id
Os string `form:"os"` // 系统
Browser string `form:"browser"` // 浏览器
City string `form:"city"` // 城市
Width int `form:"width"` // 屏幕
Height int `form:"height"` // 屏幕高度
Ua string `form:"ua"` // ua记录
ClientTime string `form:"clientTime"` // 客户端时间
ProjectKey string `form:"projectKey"` // 项目key
ClientId string `form:"clientId"` // sdk生成的客户端id
UserId string `form:"userId"` // 用户id
Os string `form:"os"` // 系统
Browser string `form:"browser"` // 浏览器
City string `form:"city"` // 城市
Width int `form:"width"` // 屏幕
Height int `form:"height"` // 屏幕高度
Ua string `form:"ua"` // ua记录
CreateTimeStart string `form:"createTimeStart"` // 开始创建时间
CreateTimeEnd string `form:"createTimeEnd"` // 结束创建时间
ClientTimeStart string `form:"clientTimeStart"` // 开始更新时间
ClientTimeEnd string `form:"clientTimeEnd"` // 结束更新时间
}
//MonitorClientDetailReq 客户端信息详情参数
//MonitorClientDetailReq 监控-客户端信息详情参数
type MonitorClientDetailReq struct {
Id int `form:"id"` // uuid
}
//MonitorClientAddReq 客户端信息新增参数
//MonitorClientAddReq 监控-客户端信息新增参数
type MonitorClientAddReq struct {
ProjectKey string `form:"projectKey"` // 项目key
ClientId string `form:"clientId"` // sdk生成的客户端id
UserId string `form:"userId"` // 用户id
Os string `form:"os"` // 系统
Browser string `form:"browser"` // 浏览器
City string `form:"city"` // 城市
Width int `form:"width"` // 屏幕
Height int `form:"height"` // 屏幕高度
Ua string `form:"ua"` // ua记录
ClientTime string `form:"clientTime"` // 客户端时间
ClientId string `form:"clientId"` // sdk生成的客户端id
UserId string `form:"userId"` // 用户id
Os string `form:"os"` // 系统
Browser string `form:"browser"` // 浏览器
City string `form:"city"` // 城市
Width int `form:"width"` // 屏幕
Height int `form:"height"` // 屏幕高度
Ua string `form:"ua"` // ua记录
ClientTime core.TsTime `form:"clientTime"` // 更新时间
}
//MonitorClientEditReq 客户端信息编辑参数
//MonitorClientEditReq 监控-客户端信息编辑参数
type MonitorClientEditReq struct {
Id int `form:"id"` // uuid
ProjectKey string `form:"projectKey"` // 项目key
ClientId string `form:"clientId"` // sdk生成的客户端id
UserId string `form:"userId"` // 用户id
Os string `form:"os"` // 系统
Browser string `form:"browser"` // 浏览器
City string `form:"city"` // 城市
Width int `form:"width"` // 屏幕
Height int `form:"height"` // 屏幕高度
Ua string `form:"ua"` // ua记录
ClientTime string `form:"clientTime"` // 客户端时间
Id int `form:"id"` // id
ClientId string `form:"clientId"` // sdk生成的客户端id
UserId string `form:"userId"` // 用户id
Os string `form:"os"` // 系统
Browser string `form:"browser"` // 浏览器
City string `form:"city"` // 城市
Width int `form:"width"` // 屏幕
Height int `form:"height"` // 屏幕高度
Ua string `form:"ua"` // ua记录
ClientTime core.TsTime `form:"clientTime"` // 更新时间
}
//MonitorClientDelReq 客户端信息新增参数
//MonitorClientDelReq 监控-客户端信息新增参数
type MonitorClientDelReq struct {
Id int `form:"id"` // uuid
}
//MonitorClientResp 客户端信息返回信息
//MonitorClientResp 监控-客户端信息返回信息
type MonitorClientResp struct {
Id int `json:"id" structs:"id" excel:"name:uuid;"` // uuid
Id int `json:"id" structs:"id"` // uuid
ProjectKey string `json:"projectKey" structs:"projectKey" excel:"name:项目key;"` // 项目key
ClientId string `json:"clientId" structs:"clientId" excel:"name:sdk生成的客户端id;"` // sdk生成的客户端id
UserId string `json:"userId" structs:"userId" excel:"name:用户id;"` // 用户id
@@ -67,6 +68,6 @@ type MonitorClientResp struct {
Width int `json:"width" structs:"width" excel:"name:屏幕;"` // 屏幕
Height int `json:"height" structs:"height" excel:"name:屏幕高度;"` // 屏幕高度
Ua string `json:"ua" structs:"ua" excel:"name:ua记录;"` // ua记录
ClientTime core.TsTime `json:"clientTime" structs:"clientTime" excel:"name:客户端时间;"` // 客户端时间
CreateTime core.TsTime `json:"createTime" structs:"createTime" excel:"name:创建时间;"` // 创建时间
ClientTime core.TsTime `json:"clientTime" structs:"clientTime" excel:"name:更新时间;"` // 更新时间
}

View File

@@ -9,16 +9,6 @@ import (
"gorm.io/gorm"
)
type IMonitorClientService interface {
List(page request.PageReq, listReq MonitorClientListReq) (res response.PageResp, e error)
ListAll() (res []MonitorClientResp, e error)
Detail(id int) (res MonitorClientResp, e error)
Add(addReq MonitorClientAddReq) (e error)
Edit(editReq MonitorClientEditReq) (e error)
Del(id int) (e error)
}
var Service = NewMonitorClientService()
// NewMonitorClientService 初始化
@@ -27,11 +17,12 @@ func NewMonitorClientService() *monitorClientService {
return &monitorClientService{db: db}
}
// monitorClientService 客户端信息服务实现类
// monitorClientService 监控-客户端信息服务实现类
type monitorClientService struct {
db *gorm.DB
}
// List 监控-客户端信息列表
func (service monitorClientService) GetModel(listReq MonitorClientListReq) *gorm.DB {
// 查询
dbModel := service.db.Model(&model.MonitorClient{})
@@ -62,72 +53,81 @@ func (service monitorClientService) GetModel(listReq MonitorClientListReq) *gorm
if listReq.Ua != "" {
dbModel = dbModel.Where("ua = ?", listReq.Ua)
}
if listReq.CreateTimeStart != "" {
dbModel = dbModel.Where("create_time >= ?", listReq.CreateTimeStart)
}
if listReq.CreateTimeEnd != "" {
dbModel = dbModel.Where("create_time <= ?", listReq.CreateTimeEnd)
}
if listReq.ClientTimeStart != "" {
dbModel = dbModel.Where("client_time >= ?", listReq.ClientTimeStart)
}
if listReq.ClientTimeEnd != "" {
dbModel = dbModel.Where("client_time <= ?", listReq.ClientTimeEnd)
}
return dbModel
}
// List 客户端信息列表
// List 监控-客户端信息列表
func (service monitorClientService) List(page request.PageReq, listReq MonitorClientListReq) (res response.PageResp, e error) {
// 分页信息
limit := page.PageSize
offset := page.PageSize * (page.PageNo - 1)
dbModel := service.GetModel(listReq)
// 总数
var count int64
err := dbModel.Count(&count).Error
if e = response.CheckErr(err, "列表总数获取失败"); e != nil {
if e = response.CheckErr(err, "失败"); e != nil {
return
}
// 数据
var objs []model.MonitorClient
err = dbModel.Limit(limit).Offset(offset).Order("id desc").Find(&objs).Error
if e = response.CheckErr(err, "列表获取失败"); e != nil {
var modelList []model.MonitorClient
err = dbModel.Limit(limit).Offset(offset).Order("id desc").Find(&modelList).Error
if e = response.CheckErr(err, "查询失败"); e != nil {
return
}
resps := []MonitorClientResp{}
response.Copy(&resps, objs)
result := []MonitorClientResp{}
response.Copy(&result, modelList)
return response.PageResp{
PageNo: page.PageNo,
PageSize: page.PageSize,
Count: count,
Lists: resps,
Lists: result,
}, nil
}
// ListAll 客户端信息列表
func (service monitorClientService) ListAll() (res []MonitorClientResp, e error) {
var objs []model.MonitorClient
// ListAll 监控-客户端信息列表
func (service monitorClientService) ListAll(listReq MonitorClientListReq) (res []MonitorClientResp, e error) {
dbModel := service.GetModel(listReq)
err := service.db.Find(&objs).Error
if e = response.CheckErr(err, "获取列表失败"); e != nil {
var modelList []model.MonitorClient
err := dbModel.Find(&modelList).Error
if e = response.CheckErr(err, "查询全部失败"); e != nil {
return
}
response.Copy(&res, objs)
response.Copy(&res, modelList)
return res, nil
}
// Detail 客户端信息详情
// Detail 监控-客户端信息详情
func (service monitorClientService) Detail(id int) (res MonitorClientResp, e error) {
var obj model.MonitorClient
err := service.db.Where("id = ?", id).Limit(1).First(&obj).Error
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
return
}
if e = response.CheckErr(err, "详情获取失败"); e != nil {
if e = response.CheckErr(err, "获取详情失败"); e != nil {
return
}
response.Copy(&res, obj)
return
}
// Add 客户端信息新增
// Add 监控-客户端信息新增
func (service monitorClientService) Add(addReq MonitorClientAddReq) (e error) {
var obj model.MonitorClient
response.Copy(&obj, addReq)
// obj.ClientTime = core.ToUnix(addReq.ClientTime)
err := service.db.Create(&obj).Error
e = response.CheckMysqlErr(err)
if e != nil {
@@ -137,7 +137,7 @@ func (service monitorClientService) Add(addReq MonitorClientAddReq) (e error) {
return
}
// Edit 客户端信息编辑
// Edit 监控-客户端信息编辑
func (service monitorClientService) Edit(editReq MonitorClientEditReq) (e error) {
var obj model.MonitorClient
err := service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
@@ -145,17 +145,17 @@ func (service monitorClientService) Edit(editReq MonitorClientEditReq) (e error)
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
return
}
if e = response.CheckErr(err, "待编辑数据查找失败"); e != nil {
if e = response.CheckErr(err, "查询失败"); e != nil {
return
}
// 更新
response.Copy(&obj, editReq)
err = service.db.Model(&obj).Updates(obj).Error
e = response.CheckErr(err, "编辑失败")
err = service.db.Model(&obj).Select("*").Updates(obj).Error
e = response.CheckErr(err, "更新失败")
return
}
// Del 客户端信息删除
// Del 监控-客户端信息删除
func (service monitorClientService) Del(id int) (e error) {
var obj model.MonitorClient
err := service.db.Where("id = ?", id).Limit(1).First(&obj).Error
@@ -163,7 +163,7 @@ func (service monitorClientService) Del(id int) (e error) {
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
return
}
if e = response.CheckErr(err, "待删除数据查找失败"); e != nil {
if e = response.CheckErr(err, "查询数据失败"); e != nil {
return
}
// 删除
@@ -172,20 +172,20 @@ func (service monitorClientService) Del(id int) (e error) {
return
}
// ExportFile 客户端信息导出
// ExportFile 监控-客户端信息导出
func (service monitorClientService) ExportFile(listReq MonitorClientListReq) (res []MonitorClientResp, e error) {
// 查询
dbModel := service.GetModel(listReq)
// 数据
var objs []model.MonitorClient
err := dbModel.Order("id asc").Find(&objs).Error
if e = response.CheckErr(err, "列表获取失败"); e != nil {
var modelList []model.MonitorClient
err := dbModel.Order("id asc").Find(&modelList).Error
if e = response.CheckErr(err, "查询失败"); e != nil {
return
}
resps := []MonitorClientResp{}
response.Copy(&resps, objs)
return resps, nil
result := []MonitorClientResp{}
response.Copy(&result, modelList)
return result, nil
}
// 导入

View File

@@ -1,10 +1,9 @@
package admin
import (
"x_admin/admin/monitor_client"
"x_admin/middleware"
"github.com/gin-gonic/gin"
"x_admin/middleware"
"x_admin/admin/monitor_client"
)
/**
@@ -17,14 +16,29 @@ import (
请在 admin/entry.go 文件引入MonitorClientRoute注册路由
3. 后台手动添加菜单和按钮
monitor_client:add
monitor_client:edit
monitor_client:del
monitor_client:list
monitor_client:listAll
monitor_client:detail
admin:monitor_client:add
admin:monitor_client:edit
admin:monitor_client:del
admin:monitor_client:list
admin:monitor_client:listAll
admin:monitor_client:detail
admin:monitor_client:ExportFile
admin:monitor_client:ImportFile
// 列表-先添加菜单获取菜单id
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, paths, component, is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'C', '监控-客户端信息', '/monitor_client/index', 'monitor_client/index', 0, 1, 0, now(), now());
按钮-替换pid参数为菜单id
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '监控-客户端信息添加','admin:monitor_client:add', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '监控-客户端信息编辑','admin:monitor_client:edit', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '监控-客户端信息删除','admin:monitor_client:del', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '监控-客户端信息列表','admin:monitor_client:list', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '监控-客户端信息全部列表','admin:monitor_client:listAll', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '监控-客户端信息详情','admin:monitor_client:detail', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '监控-客户端信息导出excel','admin:monitor_client:ExportFile', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '监控-客户端信息导入excel','admin:monitor_client:ImportFile', 0, 1, 0, now(), now());
*/
// MonitorClientRoute(rg)
func MonitorClientRoute(rg *gin.RouterGroup) {
handle := monitor_client.MonitorClientHandler{}
@@ -33,9 +47,9 @@ func MonitorClientRoute(rg *gin.RouterGroup) {
r.GET("/monitor_client/list", handle.List)
r.GET("/monitor_client/listAll", handle.ListAll)
r.GET("/monitor_client/detail", handle.Detail)
r.POST("/monitor_client/add", middleware.RecordLog("客户端信息新增"), handle.Add)
r.POST("/monitor_client/edit", middleware.RecordLog("客户端信息编辑"), handle.Edit)
r.POST("/monitor_client/del", middleware.RecordLog("客户端信息删除"), handle.Del)
r.GET("/monitor_client/ExportFile", middleware.RecordLog("客户端信息导出"), handle.ExportFile)
r.POST("/monitor_client/add",middleware.RecordLog("监控-客户端信息新增"), handle.Add)
r.POST("/monitor_client/edit",middleware.RecordLog("监控-客户端信息编辑"), handle.Edit)
r.POST("/monitor_client/del", middleware.RecordLog("监控-客户端信息删除"), handle.Del)
r.GET("/monitor_client/ExportFile", middleware.RecordLog("监控-客户端信息导出"), handle.ExportFile)
r.POST("/monitor_client/ImportFile", handle.ImportFile)
}
}

View File

@@ -1,8 +1,10 @@
package model
import "x_admin/core"
import (
"x_admin/core"
)
//MonitorClient 客户端信息实体
// MonitorClient 监控-客户端信息实体
type MonitorClient struct {
Id int `gorm:"primarykey;comment:'uuid'" excel:"name:uuid;"` // uuid
@@ -24,8 +26,8 @@ type MonitorClient struct {
Ua string `gorm:"comment:'ua记录'" excel:"name:ua记录;"` // ua记录
ClientTime core.TsTime `gorm:"comment:'客户端时间'" excel:"name:客户端时间;"` // 客户端时间
CreateTime core.TsTime `gorm:"autoCreateTime;comment:'创建时间'" excel:"name:创建时间;"` // 创建时间
ClientTime core.TsTime `gorm:"comment:'更新时间'" excel:"name:更新时间;"` // 更新时间
}

View File

@@ -0,0 +1,103 @@
import { request } from '@/utils/request'
import { clearObjEmpty } from '@/utils/utils'
import type { Pages } from '@/utils/request'
export type type_monitor_client = {
id?: number;
projectKey?: string;
clientId?: string;
userId?: string;
os?: string;
browser?: string;
city?: string;
width?: number;
height?: number;
ua?: string;
createTime?: string;
clientTime?: string;
}
// 查询
export type type_monitor_client_query = {
projectKey?: string;
clientId?: string;
userId?: string;
os?: string;
browser?: string;
city?: string;
width?: number;
height?: number;
ua?: string;
createTimeStart?: string;
createTimeEnd?: string;
clientTimeStart?: string;
clientTimeEnd?: string;
}
// 添加编辑
export type type_monitor_client_edit = {
id?: number;
clientId?: string;
userId?: string;
os?: string;
browser?: string;
city?: string;
width?: number;
height?: number;
ua?: string;
clientTime?: string;
}
// 监控-客户端信息列表
export function monitor_client_list(params?: type_monitor_client_query) {
return request<Pages<type_monitor_client>>({
url: '/monitor_client/list',
method: 'GET',
data: clearObjEmpty(params)
})
}
// 监控-客户端信息列表-所有
export function monitor_client_list_all(params?: type_monitor_client_query) {
return request<type_monitor_client[]>({
url: '/monitor_client/listAll',
method: 'GET',
data: clearObjEmpty(params)
})
}
// 监控-客户端信息详情
export function monitor_client_detail(id: number | string) {
return request<type_monitor_client>({
url: '/monitor_client/detail',
method: 'GET',
data: { id }
})
}
// 监控-客户端信息新增
export function monitor_client_add(data: type_monitor_client_edit) {
return request<null>({
url: '/monitor_client/add',
method: "POST",
data,
});
}
// 监控-客户端信息编辑
export function monitor_client_edit(data: type_monitor_client_edit) {
return request<null>({
url: '/monitor_client/edit',
method: "POST",
data,
});
}
// 监控-客户端信息删除
export function monitor_client_delete(id: number | string) {
return request<null>({
url: '/monitor_client/del',
method: "POST",
data:{
id
},
});
}

View File

@@ -0,0 +1,31 @@
<template>
<view style="flex: 1" @click="calendarsRef.open()">
<uv-input :modelValue="title" :readonly="true" placeholder="请选择时间">
</uv-input>
</view>
<uv-calendars ref="calendarsRef" :date="props.time" @confirm="Confirm" />
</template>
<script setup>
import { ref, computed } from "vue";
const emit = defineEmits(["update:time"]);
const props = defineProps({
time: {
type: String,
default: "",
},
});
let calendarsRef = ref(null);
function Confirm(e) {
console.log(e);
emit("update:time", e.fulldate);
// emit("update:endTime", e.range.after);
}
const title = computed(() => {
return props.time;
});
</script>
<style lang="scss" scoped></style>

View File

@@ -61,6 +61,7 @@ export function usePaging<T>(options: Options) {
pager.loading = "loadmore";
}
}else{
toast(res.message);
pager.loading = "loadmore";
}
return Promise.resolve(res);

View File

@@ -45,6 +45,34 @@
"style": {
"navigationBarTitleText": "搜索项目监控"
}
},
{
"path": "pages/monitor_client/index",
"style": {
"navigationBarTitleText": "监控-客户端信息",
"enablePullDownRefresh": true,
"onReachBottomDistance": 100
}
},
{
"path": "pages/monitor_client/details",
"style": {
"navigationBarTitleText": "监控-客户端信息详情",
"enablePullDownRefresh": true
}
},
{
"path": "pages/monitor_client/edit",
"style": {
"navigationBarTitleText": "编辑监控-客户端信息"
}
},
{
"path": "pages/monitor_client/search",
"style": {
"navigationBarTitleText": "搜索监控-客户端信息"
}
}

View File

@@ -38,6 +38,11 @@
path: "/pages/monitor_project/index",
title: "项目监控",
},
{
icon: "/static/index/equipment.png",
path: "/pages/monitor_client/index",
title: "项目用户",
},
{

View File

@@ -0,0 +1,114 @@
<template>
<view class="page-content">
<uv-form labelPosition="left" :model="form">
<uv-form-item label="项目key" prop="projectKey" borderBottom>
{{form.projectKey}}
</uv-form-item>
<uv-form-item label="sdk生成的客户端id" prop="clientId" borderBottom>
{{form.clientId}}
</uv-form-item>
<uv-form-item label="用户id" prop="userId" borderBottom>
{{form.userId}}
</uv-form-item>
<uv-form-item label="系统" prop="os" borderBottom>
{{form.os}}
</uv-form-item>
<uv-form-item label="浏览器" prop="browser" borderBottom>
{{form.browser}}
</uv-form-item>
<uv-form-item label="城市" prop="city" borderBottom>
{{form.city}}
</uv-form-item>
<uv-form-item label="屏幕" prop="width" borderBottom>
{{form.width}}
</uv-form-item>
<uv-form-item label="屏幕高度" prop="height" borderBottom>
{{form.height}}
</uv-form-item>
<uv-form-item label="ua记录" prop="ua" borderBottom>
{{form.ua}}
</uv-form-item>
<uv-form-item label="创建时间" prop="createTime" borderBottom>
{{form.createTime}}
</uv-form-item>
<uv-form-item label="更新时间" prop="clientTime" borderBottom>
{{form.clientTime}}
</uv-form-item>
</uv-form>
<uv-button
v-if="$perms('admin:monitor_client:edit')"
type="primary"
text="编辑"
customStyle="margin: 40rpx 0"
@click="edit"
></uv-button>
</view>
</template>
<script setup lang="ts">
import {ref} from "vue";
import { onLoad,onShow } from "@dcloudio/uni-app";
import { useDictData } from "@/hooks/useDictOptions";
import { monitor_client_detail } from "@/api/monitor_client";
import {
toast,
alert,
toPath
} from "@/utils/utils";
let form = ref({
id: "",
projectKey: "",
clientId: "",
userId: "",
os: "",
browser: "",
city: "",
width: "",
height: "",
ua: "",
createTime: "",
clientTime: "",
});
onLoad((e) => {
console.log("onLoad", e);
getDetails(e.id);
});
onShow((e) => {
if (form.value?.id) {
getDetails(form.value.id);
}
});
onPullDownRefresh(() => {
getDetails(form.value.id);
});
function getDetails(id: number | string) {
monitor_client_detail(id).then((res) => {
uni.stopPullDownRefresh();
if (res.code == 200) {
if (res?.data) {
form.value = res?.data
}
} else {
toast(res.message);
}
})
.catch((err) => {
uni.stopPullDownRefresh();
toast(err.message||"网络错误");
});
}
function edit() {
toPath("/pages/monitor_client/edit", { id: form.value.id });
}
</script>
<style lang="scss" scoped>
.page-content {
padding: 10rpx 20rpx 300rpx;
}
</style>

View File

@@ -0,0 +1,191 @@
<template>
<view class="page-content">
<uv-form
labelPosition="left"
:model="form"
:rules="formRules"
ref="formRef"
>
<uv-form-item label="sdk生成的客户端id" prop="clientId" borderBottom>
<uv-input v-model="form.clientId" border="surround"></uv-input>
</uv-form-item>
<uv-form-item label="用户id" prop="userId" borderBottom>
<uv-input v-model="form.userId" border="surround"></uv-input>
</uv-form-item>
<uv-form-item label="系统" prop="os" borderBottom>
<uv-input v-model="form.os" border="surround"></uv-input>
</uv-form-item>
<uv-form-item label="浏览器" prop="browser" borderBottom>
<uv-input v-model="form.browser" border="surround"></uv-input>
</uv-form-item>
<uv-form-item label="城市" prop="city" borderBottom>
<uv-input v-model="form.city" border="surround"></uv-input>
</uv-form-item>
<uv-form-item label="屏幕" prop="width" borderBottom>
<uv-input v-model="form.width" border="surround"></uv-input>
</uv-form-item>
<uv-form-item label="屏幕高度" prop="height" borderBottom>
<uv-input v-model="form.height" border="surround"></uv-input>
</uv-form-item>
<uv-form-item label="ua记录" prop="ua" borderBottom>
<uv-input v-model="form.ua" border="surround"></uv-input>
</uv-form-item>
<uv-form-item label="更新时间" prop="clientTime" borderBottom>
<x-date v-model:time="form.clientTime"></x-date>
</uv-form-item>
<uv-button
type="primary"
text="提交"
customStyle="margin: 40rpx 0"
@click="submit"
></uv-button>
</uv-form>
</view>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import {
monitor_client_detail,
monitor_client_edit,
monitor_client_add,
} from "@/api/monitor_client";
import type { type_monitor_client_edit } from "@/api/monitor_client";
import { toast, alert } from "@/utils/utils";
import { useDictData } from "@/hooks/useDictOptions";
let formRef = ref();
let form = ref<type_monitor_client_edit>({
id: null,
clientId: "",
userId: "",
os: "",
browser: "",
city: "",
width: null,
height: null,
ua: "",
clientTime: "",
});
const formRules = {
clientId: [
{
required: true,
message: "请输入sdk生成的客户端id",
trigger: ["blur"],
},
],
userId: [
{
required: true,
message: "请输入用户id",
trigger: ["blur"],
},
],
os: [
{
required: true,
message: "请输入系统",
trigger: ["blur"],
},
],
browser: [
{
required: true,
message: "请输入浏览器",
trigger: ["blur"],
},
],
city: [
{
required: true,
message: "请输入城市",
trigger: ["blur"],
},
],
width: [
{
required: true,
message: "请输入屏幕",
trigger: ["blur"],
},
],
height: [
{
required: true,
message: "请输入屏幕高度",
trigger: ["blur"],
},
],
ua: [
{
required: true,
message: "请输入ua记录",
trigger: ["blur"],
},
],
clientTime: [
{
required: true,
message: "请选择更新时间",
trigger: ["blur"],
},
],
};
onLoad((e) => {
console.log("onLoad", e);
if (e.id) {
getDetails(e.id);
}
});
function getDetails(id) {
monitor_client_detail(id)
.then((res) => {
if (res.code == 200) {
if (res?.data) {
form.value = res?.data;
}
} else {
toast(res.message);
}
})
.catch((err) => {
toast(err.message || "网络错误");
});
}
function submit() {
console.log("submit", form.value);
formRef.value.validate().then(() => {
if (form.value.id) {
monitor_client_edit(form.value).then((res) => {
if (res.code == 200) {
toast("编辑成功");
getDetails(form.value?.id);
} else {
toast(res.message);
}
});
} else {
monitor_client_add(form.value).then((res) => {
if (res.code == 200) {
toast("添加成功");
uni.navigateBack();
} else {
toast(res.message);
}
});
}
});
}
</script>
<style lang="scss" scoped>
.page-content {
padding: 10rpx 20rpx 300rpx;
}
</style>

View File

@@ -0,0 +1,135 @@
<template>
<view>
<!--
<uv-sticky :customNavHeight="0" bgColor="#fff">
<uv-status-bar></uv-status-bar>
<uv-navbar
leftText=""
:safeAreaInsetTop="false"
:fixed="false"
title="监控-客户端信息"
autoBack
>
<template v-slot:right>
<uv-icon v-if="!fromSearch" name="search" size="24" @click="moreSearch"></uv-icon>
</template>
</uv-navbar>
</uv-sticky>
-->
<uv-list>
<uv-list-item
v-for="item of pager.lists"
:key="item.id"
clickable
show-arrow
:title="item.id"
:right-text="item.id"
@click="toDetails(item)"
></uv-list-item>
</uv-list>
<wd-fab v-model:active="activeFab" :draggable="true">
<wd-button v-if="!fromSearch" custom-class="fab-button" type="primary" round @click="moreSearch" >
<wd-icon name="search" size="20px"></wd-icon>
</wd-button>
<wd-button v-if="$perms('admin:monitor_client:add')" custom-class="fab-button" type="primary" round @click="add">
<wd-icon name="add" size="20px"></wd-icon>
</wd-button>
</wd-fab>
<uv-back-top :scroll-top="scrollTop"></uv-back-top>
<uv-empty v-if="pager.loading =='nomore'&&pager.lists.length == 0" marginTop="150" mode="data"></uv-empty>
<uv-loading-page
:loading="pager.pageNo == 1 && pager.loading == 'loading'"
loading-text="加载中..."
font-size="24rpx"
></uv-loading-page>
<uv-load-more
v-if="pager.lists.length > 0"
:status="pager.loading"
:loading-text="pager.loadingText"
:loadmore-text="pager.loadmoreText"
:nomore-text="pager.nomoreText"
@loadmore="NextPage"
/>
</view>
</template>
<script setup lang="ts">
import { reactive, ref } from "vue";
import {
onLoad,
onPullDownRefresh,
onReachBottom,
onPageScroll,
} from "@dcloudio/uni-app";
import { monitor_client_list } from "@/api/monitor_client";
import type { type_monitor_client,type_monitor_client_query } from "@/api/monitor_client";
import { usePaging } from "@/hooks/usePaging";
import { toPath } from "@/utils/utils";
const queryParams = reactive<type_monitor_client_query>({
projectKey: '',
clientId: '',
userId: '',
os: '',
browser: '',
city: '',
width: null,
height: null,
ua: '',
createTimeStart: '',
createTimeEnd: '',
clientTimeStart: '',
clientTimeEnd: '',
});
let activeFab = ref(false);
let fromSearch=ref(false);
onLoad((e) => {
console.log("monitor_client onLoad", e);
if (e) {
for (const key in e) {
if (Object.hasOwnProperty.call(e, key)) {
fromSearch.value = true;
queryParams[key] = e[key];
}
}
}
getLists();
});
const { pager, getLists, NextPage, resetPage, resetParams } = usePaging<type_monitor_client>({
fetchFun: monitor_client_list,
params: queryParams,
});
let scrollTop = ref(0);
onPageScroll((e) => {
scrollTop.value = e.scrollTop;
});
onPullDownRefresh(() => {
resetPage();
});
onReachBottom(() => {
NextPage();
});
function toDetails(item) {
toPath("/pages/monitor_client/details", { id: item.id });
}
function moreSearch() {
toPath("/pages/monitor_client/search");
}
function add() {
toPath("/pages/monitor_client/edit");
}
</script>
<style lang="scss" scoped>
:deep(.fab-button) {
min-width: auto !important;
box-sizing: border-box;
width: 40px !important;
height: 40px !important;
border-radius: 40px !important;
margin: 8rpx;
}
</style>

View File

@@ -0,0 +1,32 @@
// 请将pages里的数据手动合并到根目录下pages.json中
{
"pages": [
{
"path": "pages/monitor_client/index",
"style": {
"navigationBarTitleText": "监控-客户端信息",
"enablePullDownRefresh": true,
"onReachBottomDistance": 100
}
},
{
"path": "pages/monitor_client/details",
"style": {
"navigationBarTitleText": "监控-客户端信息详情",
"enablePullDownRefresh": true
}
},
{
"path": "pages/monitor_client/edit",
"style": {
"navigationBarTitleText": "编辑监控-客户端信息"
}
},
{
"path": "pages/monitor_client/search",
"style": {
"navigationBarTitleText": "搜索监控-客户端信息"
}
}
]
}

View File

@@ -0,0 +1,99 @@
<template>
<view class="page-content">
<uv-form labelPosition="left" labelWidth="80" :model="form">
<uv-form-item label="项目key" prop="projectKey" borderBottom>
</uv-form-item>
<uv-form-item label="sdk生成的客户端id" prop="clientId" borderBottom>
<uv-input v-model="form.clientId"> </uv-input>
</uv-form-item>
<uv-form-item label="用户id" prop="userId" borderBottom>
<uv-input v-model="form.userId"> </uv-input>
</uv-form-item>
<uv-form-item label="系统" prop="os" borderBottom>
<uv-input v-model="form.os"> </uv-input>
</uv-form-item>
<uv-form-item label="浏览器" prop="browser" borderBottom>
<uv-input v-model="form.browser"> </uv-input>
</uv-form-item>
<uv-form-item label="城市" prop="city" borderBottom>
<uv-input v-model="form.city"> </uv-input>
</uv-form-item>
<uv-form-item label="屏幕" prop="width" borderBottom>
<uv-input v-model="form.width"> </uv-input>
</uv-form-item>
<uv-form-item label="屏幕高度" prop="height" borderBottom>
<uv-input v-model="form.height"> </uv-input>
</uv-form-item>
<uv-form-item label="ua记录" prop="ua" borderBottom>
<uv-input v-model="form.ua"> </uv-input>
</uv-form-item>
<uv-form-item label="创建时间" prop="createTime" borderBottom>
<x-date-range v-model:startTime="form.createTimeStart"
v-model:endTime="form.createTimeEnd"></x-date-range>
</uv-form-item>
<uv-form-item label="更新时间" prop="clientTime" borderBottom>
<x-date-range v-model:startTime="form.clientTimeStart"
v-model:endTime="form.clientTimeEnd"></x-date-range>
</uv-form-item>
<uv-button type="primary" text="搜索" customStyle="margin-top: 20rpx" @click="submit"></uv-button>
</uv-form>
</view>
</template>
<script setup lang="ts">
import {
onLoad
} from "@dcloudio/uni-app";
import {
reactive,
ref,
computed
} from "vue";
import {
toPath,
toast,
clearObjEmpty
} from "@/utils/utils";
import {
useDictData
} from "@/hooks/useDictOptions";
import xDateRange from "@/components/x-date-range/x-date-range.vue";
import type {type_monitor_client_query} from "@/api/monitor_project";
let form = ref<type_monitor_client_query>({
projectKey: '',
clientId: '',
userId: '',
os: '',
browser: '',
city: '',
width: '',
height: '',
ua: '',
createTimeStart: '',
createTimeEnd: '',
clientTimeStart: '',
clientTimeEnd: '',
});
function submit() {
console.log("submit", form.value);
const search = clearObjEmpty(form.value);
if (Object.keys(search).length === 0) {
return toast("请输入查询条件");
}
toPath("/pages/monitor_client/index", search);
}
</script>
<style lang="scss" scoped>
.page-content {
padding: 10rpx 20rpx 300rpx;
}
</style>