From d9fc8219de235b02aa88ae2fdc0e485cd93f0cae Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 09 九月 2024 10:23:35 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/i18n/en.js                                                                       |   14 +
 zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java                          |    4 
 zy-acs-flow/src/page/ResourceContent.js                                                          |    3 
 zy-acs-flow/src/i18n/zh.js                                                                       |   14 +
 zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/OperationRecordController.java |   25 --
 zy-acs-flow/src/page/operationRecord/OperationRecordList.jsx                                     |  165 ++++++++++++++++++
 zy-acs-flow/src/page/operationRecord/index.jsx                                                   |   18 ++
 zy-acs-flow/src/page/operationRecord/OperationRecordPanel.jsx                                    |  117 +++++++++++++
 zy-acs-flow/src/page/operationRecord/OperationRecordEdit.jsx                                     |  166 ++++++++++++++++++
 9 files changed, 500 insertions(+), 26 deletions(-)

diff --git a/zy-acs-flow/src/i18n/en.js b/zy-acs-flow/src/i18n/en.js
index 4229b1d..ae0fe52 100644
--- a/zy-acs-flow/src/i18n/en.js
+++ b/zy-acs-flow/src/i18n/en.js
@@ -67,7 +67,6 @@
         tenant: 'Tenant',
         role: 'Role',
         userLogin: 'Token',
-        user: 'User',
     },
     table: {
         field: {
@@ -146,6 +145,19 @@
                 birthday: "birthday",
                 introduction: "introduction",
             },
+            operationRecord: {
+                namespace: "namespace",
+                url: "url",
+                appkey: "appkey",
+                timestamp: "timestamp",
+                clientIp: "client ip",
+                request: "request",
+                response: "response",
+                spendTime: "spend time",
+                err: "error",
+                result: "result",
+                userId: "user",
+            },
         }
     }
 };
diff --git a/zy-acs-flow/src/i18n/zh.js b/zy-acs-flow/src/i18n/zh.js
index bfe69ed..09516f5 100644
--- a/zy-acs-flow/src/i18n/zh.js
+++ b/zy-acs-flow/src/i18n/zh.js
@@ -67,7 +67,6 @@
         tenant: '绉熸埛绠$悊',
         role: '瑙掕壊绠$悊',
         userLogin: '鐧诲綍鏃ュ織',
-        user: '鐢ㄦ埛绠$悊',
     },
     table: {
         field: {
@@ -146,6 +145,19 @@
                 birthday: "鐢熸棩",
                 introduction: "绠�浠�",
             },
+            operationRecord: {
+                namespace: "鍛藉悕绌洪棿",
+                url: "url",
+                appkey: "瀵嗛挜",
+                timestamp: "鏃堕棿鎴�",
+                clientIp: "瀹㈡埛绔疘P",
+                request: "璇锋眰鍐呭",
+                response: "鍝嶅簲鍐呭",
+                spendTime: "鑺辫垂鏃堕棿",
+                err: "閿欒淇℃伅",
+                result: "result",
+                userId: "鎿嶄綔鐢ㄦ埛",
+            },
         }
     }
 };
diff --git a/zy-acs-flow/src/page/ResourceContent.js b/zy-acs-flow/src/page/ResourceContent.js
index b14d8a7..ef34985 100644
--- a/zy-acs-flow/src/page/ResourceContent.js
+++ b/zy-acs-flow/src/page/ResourceContent.js
@@ -12,6 +12,7 @@
 import dept from "./dept";
 import menu from './menu'
 import user from './user';
+import operationRecord from './operationRecord';
 
 const ResourceContent = (node) => {
     switch (node.component) {
@@ -31,6 +32,8 @@
             return menu;
         case 'user':
             return user;
+        case 'operationRecord':
+            return operationRecord;
         default:
             return {
                 list: ListGuesser,
diff --git a/zy-acs-flow/src/page/operationRecord/OperationRecordEdit.jsx b/zy-acs-flow/src/page/operationRecord/OperationRecordEdit.jsx
new file mode 100644
index 0000000..dbba102
--- /dev/null
+++ b/zy-acs-flow/src/page/operationRecord/OperationRecordEdit.jsx
@@ -0,0 +1,166 @@
+import React, { useState, useRef, useEffect, useMemo } from "react";
+import {
+    Edit,
+    SimpleForm,
+    FormDataConsumer,
+    useTranslate,
+    TextInput,
+    NumberInput,
+    BooleanInput,
+    DateInput,
+    SelectInput,
+    ReferenceInput,
+    ReferenceArrayInput,
+    AutocompleteInput,
+    SaveButton,
+    Toolbar,
+    Labeled,
+    NumberField,
+    required,
+    useRecordContext,
+    DeleteButton,
+} from 'react-admin';
+import { useWatch, useFormContext } from "react-hook-form";
+import { Stack, Grid, Box, Typography } from '@mui/material';
+import * as Common from '@/utils/common';
+import { EDIT_MODE } from '@/config/setting';
+import EditBaseAside from "../components/EditBaseAside";
+import CustomerTopToolBar from "../components/EditTopToolBar";
+import MemoInput from "../components/MemoInput";
+import StatusSelectInput from "../components/StatusSelectInput";
+
+const FormToolbar = () => {
+    const { getValues } = useFormContext();
+
+    return (
+        <Toolbar sx={{ justifyContent: 'space-between' }}>
+            <SaveButton />
+            <DeleteButton mutationMode="optimistic" />
+        </Toolbar>
+    )
+}
+
+const OperationRecordEdit = () => {
+    const translate = useTranslate();
+
+    return (
+        <Edit
+            redirect="list"
+            mutationMode={EDIT_MODE}
+            actions={<CustomerTopToolBar />}
+            aside={<EditBaseAside />}
+        >
+            <SimpleForm
+                shouldUnregister
+                warnWhenUnsavedChanges
+                toolbar={<FormToolbar />}
+                mode="onTouched"
+                defaultValues={{}}
+            // validate={(values) => { }}
+            >
+                <Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}>
+                    <Grid item xs={12} md={8}>
+                        <Typography variant="h6" gutterBottom>
+                            {translate('common.edit.title.main')}
+                        </Typography>
+                        <Stack direction='row' gap={2}>
+                            <TextInput
+                                label="table.field.operationRecord.namespace"
+                                source="namespace"
+                                parse={v => v}
+                                autoFocus
+                            />
+                        </Stack>
+                        <Stack direction='row' gap={2}>
+                            <TextInput
+                                label="table.field.operationRecord.url"
+                                source="url"
+                                parse={v => v}
+                            />
+                        </Stack>
+                        <Stack direction='row' gap={2}>
+                            <TextInput
+                                label="table.field.operationRecord.appkey"
+                                source="appkey"
+                                parse={v => v}
+                            />
+                        </Stack>
+                        <Stack direction='row' gap={2}>
+                            <TextInput
+                                label="table.field.operationRecord.timestamp"
+                                source="timestamp"
+                                parse={v => v}
+                            />
+                        </Stack>
+                        <Stack direction='row' gap={2}>
+                            <TextInput
+                                label="table.field.operationRecord.clientIp"
+                                source="clientIp"
+                                parse={v => v}
+                            />
+                        </Stack>
+                        <Stack direction='row' gap={2}>
+                            <TextInput
+                                label="table.field.operationRecord.request"
+                                source="request"
+                                parse={v => v}
+                            />
+                        </Stack>
+                        <Stack direction='row' gap={2}>
+                            <TextInput
+                                label="table.field.operationRecord.response"
+                                source="response"
+                                parse={v => v}
+                            />
+                        </Stack>
+                        <Stack direction='row' gap={2}>
+                            <NumberInput
+                                label="table.field.operationRecord.spendTime"
+                                source="spendTime"
+                            />
+                        </Stack>
+                        <Stack direction='row' gap={2}>
+                            <TextInput
+                                label="table.field.operationRecord.err"
+                                source="err"
+                                parse={v => v}
+                            />
+                        </Stack>
+                        <Stack direction='row' gap={2}>
+                            <SelectInput
+                                label="table.field.operationRecord.result"
+                                source="result"
+                                choices={[
+                                    { id: 1, name: '鎴愬姛' },
+                                    { id: 0, name: '澶辫触' },
+                                ]}
+                            />
+                        </Stack>
+                        <Stack direction='row' gap={2}>
+                            <ReferenceInput
+                                source="userId"
+                                reference="user"
+                            >
+                                <AutocompleteInput
+                                    label="table.field.operationRecord.userId"
+                                    optionText="nickname"
+                                />
+                            </ReferenceInput>
+                        </Stack>
+
+                    </Grid>
+                    <Grid item xs={12} md={4}>
+                        <Typography variant="h6" gutterBottom>
+                            {translate('common.edit.title.common')}
+                        </Typography>
+                        <StatusSelectInput />
+                        <Box mt="2em" />
+                        <MemoInput />
+                    </Grid>
+                </Grid>
+            </SimpleForm>
+        </Edit >
+    )
+}
+
+export default OperationRecordEdit;
diff --git a/zy-acs-flow/src/page/operationRecord/OperationRecordList.jsx b/zy-acs-flow/src/page/operationRecord/OperationRecordList.jsx
new file mode 100644
index 0000000..8192c27
--- /dev/null
+++ b/zy-acs-flow/src/page/operationRecord/OperationRecordList.jsx
@@ -0,0 +1,165 @@
+import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
+import { useNavigate } from 'react-router-dom';
+import {
+    List,
+    DatagridConfigurable,
+    SearchInput,
+    TopToolbar,
+    SelectColumnsButton,
+    EditButton,
+    FilterButton,
+    CreateButton,
+    ExportButton,
+    BulkDeleteButton,
+    WrapperField,
+    useRecordContext,
+    useTranslate,
+    useListContext,
+    useCreatePath,
+    TextField,
+    NumberField,
+    DateField,
+    BooleanField,
+    ReferenceField,
+    TextInput,
+    DateTimeInput,
+    DateInput,
+    SelectInput,
+    NumberInput,
+    ReferenceInput,
+    ReferenceArrayInput,
+    AutocompleteInput,
+    DeleteButton,
+} from 'react-admin';
+import { Box, Typography, Card, Stack } from '@mui/material';
+import { styled } from '@mui/material/styles';
+import OperationRecordPanel from "./OperationRecordPanel";
+import EmptyData from "../components/EmptyData";
+import MyExportButton from '../components/MyExportButton';
+import PageDrawer from "../components/PageDrawer";
+import MyField from "../components/MyField";
+import { PAGE_DRAWER_WIDTH, OPERATE_MODE } from '@/config/setting';
+import * as Common from '@/utils/common';
+
+const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
+    '& .css-1vooibu-MuiSvgIcon-root': {
+        height: '.9em'
+    },
+    '& .RaDatagrid-row': {
+        cursor: 'auto'
+    },
+    '& .column-name': {
+    },
+    '& .opt': {
+        width: 200
+    },
+}));
+
+const filters = [
+    <SearchInput source="condition" alwaysOn />,
+    <DateInput label='common.time.after' source="timeStart" alwaysOn />,
+    <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
+
+    <TextInput source="namespace" label="table.field.operationRecord.namespace" />,
+    <TextInput source="url" label="table.field.operationRecord.url" />,
+    <TextInput source="appkey" label="table.field.operationRecord.appkey" />,
+    <TextInput source="timestamp" label="table.field.operationRecord.timestamp" />,
+    <TextInput source="clientIp" label="table.field.operationRecord.clientIp" />,
+    <TextInput source="request" label="table.field.operationRecord.request" />,
+    <TextInput source="response" label="table.field.operationRecord.response" />,
+    <NumberInput source="spendTime" label="table.field.operationRecord.spendTime" />,
+    <TextInput source="err" label="table.field.operationRecord.err" />,
+    <SelectInput source="result" label="table.field.operationRecord.result"
+        choices={[
+            { id: 1, name: '鎴愬姛' },
+            { id: 0, name: '澶辫触' },
+        ]}
+    />,
+    <ReferenceInput source="userId" reference="user">
+        <AutocompleteInput label="table.field.operationRecord.userId" optionText="nickname" />
+    </ReferenceInput>,
+
+    <TextInput label="common.field.memo" source="memo" />,
+    <SelectInput
+        label="common.field.status"
+        source="status"
+        choices={[
+            { id: '1', name: 'common.enums.statusTrue' },
+            { id: '0', name: 'common.enums.statusFalse' },
+        ]}
+    />,
+]
+
+const OperationRecordList = () => {
+    const translate = useTranslate();
+
+    const [createDialog, setCreateDialog] = useState(false);
+    const [drawerVal, setDrawerVal] = useState(false);
+
+    return (
+        <Box display="flex">
+            <List
+                sx={{
+                    flexGrow: 1,
+                    transition: (theme) =>
+                        theme.transitions.create(['all'], {
+                            duration: theme.transitions.duration.enteringScreen,
+                        }),
+                    marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
+                }}
+                title={"menu.operationRecord"}
+                empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
+                filters={filters}
+                sort={{ field: "create_time", order: "desc" }}
+                actions={(
+                    <TopToolbar>
+                        <FilterButton />
+                        <SelectColumnsButton preferenceKey='operationRecord' />
+                        <MyExportButton />
+                    </TopToolbar>
+                )}
+                perPage={25}
+            >
+                <StyledDatagrid
+                    preferenceKey='operationRecord'
+                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
+                    rowClick={(id, resource, record) => false}
+                    expand={() => <OperationRecordPanel />}
+                    expandSingle={true}
+                    omit={['id', 'createTime', 'memo']}
+                >
+                    <NumberField source="id" />
+                    <TextField source="namespace" label="table.field.operationRecord.namespace" />
+                    <TextField source="url" label="table.field.operationRecord.url" />
+                    <TextField source="appkey" label="table.field.operationRecord.appkey" />
+                    <TextField source="timestamp" label="table.field.operationRecord.timestamp" />
+                    <TextField source="clientIp" label="table.field.operationRecord.clientIp" />
+                    <TextField source="request" label="table.field.operationRecord.request" />
+                    <TextField source="response" label="table.field.operationRecord.response" />
+                    <NumberField source="spendTime" label="table.field.operationRecord.spendTime" />
+                    <TextField source="err" label="table.field.operationRecord.err" />
+                    <TextField source="result$" label="table.field.operationRecord.result" sortable={false} />
+                    <ReferenceField source="userId" label="table.field.operationRecord.userId" reference="user" link={false}>
+                        <TextField source="nickname" />
+                    </ReferenceField>
+
+                    <DateField source="updateTime" label="common.field.updateTime" showTime />
+                    <DateField source="createTime" label="common.field.createTime" showTime />
+                    <BooleanField source="statusBool" label="common.field.status" sortable={false} />
+                    <TextField source="memo" label="common.field.memo" sortable={false} />
+                    <WrapperField cellClassName="opt" label="common.field.opt">
+                        <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
+                    </WrapperField>
+                </StyledDatagrid>
+            </List>
+            <PageDrawer
+                title='OperationRecord Detail'
+                drawerVal={drawerVal}
+                setDrawerVal={setDrawerVal}
+            >
+            </PageDrawer>
+        </Box>
+    )
+}
+
+export default OperationRecordList;
diff --git a/zy-acs-flow/src/page/operationRecord/OperationRecordPanel.jsx b/zy-acs-flow/src/page/operationRecord/OperationRecordPanel.jsx
new file mode 100644
index 0000000..f929a38
--- /dev/null
+++ b/zy-acs-flow/src/page/operationRecord/OperationRecordPanel.jsx
@@ -0,0 +1,117 @@
+import React, { useState, useRef, useEffect, useMemo } from "react";
+import { Box, Card, CardContent, Grid, Typography, Tooltip } from '@mui/material';
+import {
+    useTranslate,
+    useRecordContext,
+} from 'react-admin';
+import PanelTypography from "../components/PanelTypography";
+import * as Common from '@/utils/common'
+
+const OperationRecordPanel = () => {
+    const record = useRecordContext();
+    if (!record) return null;
+    const translate = useTranslate();
+    return (
+        <>
+            <Card sx={{ width: { xs: 300, sm: 500, md: 600, lg: 800 }, margin: 'auto' }}>
+                <CardContent>
+                    <Grid container spacing={2}>
+                        <Grid item xs={12} sx={{ display: 'flex', justifyContent: 'space-between' }}>
+                            <Typography variant="h6" gutterBottom align="left" sx={{
+                                maxWidth: { xs: '100px', sm: '180px', md: '260px', lg: '360px' },
+                                whiteSpace: 'nowrap',
+                                overflow: 'hidden',
+                                textOverflow: 'ellipsis',
+                            }}>
+                                {Common.camelToPascalWithSpaces(translate('table.field.operationRecord.namespace'))}: {record.namespace}
+                            </Typography>
+                            {/*  inherit, primary, secondary, textPrimary, textSecondary, error */}
+                            <Typography variant="h6" gutterBottom align="right" >
+                                ID: {record.id}
+                            </Typography>
+                        </Grid>
+                    </Grid>
+                    <Grid container spacing={2}>
+                        <Grid item xs={12} container alignContent="flex-end">
+                            <Typography variant="caption" color="textSecondary" sx={{ wordWrap: 'break-word', wordBreak: 'break-all' }}>
+                                {Common.camelToPascalWithSpaces(translate('common.field.memo'))}:{record.memo}
+                            </Typography>
+                        </Grid>
+                    </Grid>
+                    <Box height={20}>&nbsp;</Box>
+                    <Grid container spacing={2}>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.namespace" 
+                                property={record.namespace}
+                            />
+                        </Grid>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.url" 
+                                property={record.url}
+                            />
+                        </Grid>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.appkey" 
+                                property={record.appkey}
+                            />
+                        </Grid>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.timestamp" 
+                                property={record.timestamp}
+                            />
+                        </Grid>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.clientIp" 
+                                property={record.clientIp}
+                            />
+                        </Grid>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.request" 
+                                property={record.request}
+                            />
+                        </Grid>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.response" 
+                                property={record.response}
+                            />
+                        </Grid>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.spendTime" 
+                                property={record.spendTime}
+                            />
+                        </Grid>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.err" 
+                                property={record.err}
+                            />
+                        </Grid>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.result" 
+                                property={record.result$}
+                            />
+                        </Grid>
+                        <Grid item xs={6}>
+                            <PanelTypography
+                                title="table.field.operationRecord.userId" 
+                                property={record.userId$}
+                            />
+                        </Grid>
+
+                    </Grid>
+                </CardContent>
+            </Card >
+        </>
+    );
+};
+
+export default OperationRecordPanel;
diff --git a/zy-acs-flow/src/page/operationRecord/index.jsx b/zy-acs-flow/src/page/operationRecord/index.jsx
new file mode 100644
index 0000000..5a740d2
--- /dev/null
+++ b/zy-acs-flow/src/page/operationRecord/index.jsx
@@ -0,0 +1,18 @@
+import React, { useState, useRef, useEffect, useMemo } from "react";
+import {
+    ListGuesser,
+    EditGuesser,
+    ShowGuesser,
+} from "react-admin";
+
+import OperationRecordList from "./OperationRecordList";
+import OperationRecordEdit from "./OperationRecordEdit";
+
+export default {
+    list: OperationRecordList,
+    edit: OperationRecordEdit,
+    show: ShowGuesser,
+    recordRepresentation: (record) => {
+        return `${record.namespace}`
+    }
+};
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java
index 3ca7c79..37e20ec 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java
@@ -22,8 +22,8 @@
 //        generator.username="sa";
 //        generator.password="Zoneyung@zy56$";
 
-        generator.table="sys_user";
-        generator.tableDesc="User";
+        generator.table="sys_operation_record";
+        generator.tableDesc="OperationRecord";
         generator.packagePath="com.zy.acs.manager.system";
 
         generator.build();
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/OperationRecordController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/OperationRecordController.java
index c75d8d2..a449121 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/OperationRecordController.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/OperationRecordController.java
@@ -54,34 +54,15 @@
         return R.ok().add(operationRecordService.getById(id));
     }
 
-    @PreAuthorize("hasAuthority('system:operationRecord:save')")
-    @OperationLog("娣诲姞鎿嶄綔鏃ュ織")
-    @PostMapping("/operationRecord/save")
-    public R save(@RequestBody OperationRecord operationRecord) {
-        if (!operationRecordService.save(operationRecord)) {
-            return R.error("娣诲姞澶辫触");
-        }
-        return R.ok("娣诲姞鎴愬姛");
-    }
-
-    @PreAuthorize("hasAuthority('system:operationRecord:update')")
-    @OperationLog("淇敼鎿嶄綔鏃ュ織")
-    @PostMapping("/operationRecord/update")
-    public R update(@RequestBody OperationRecord operationRecord) {
-        if (!operationRecordService.updateById(operationRecord)) {
-            return R.error("淇敼澶辫触");
-        }
-        return R.ok("淇敼鎴愬姛");
-    }
 
     @PreAuthorize("hasAuthority('system:operationRecord:remove')")
-    @OperationLog("鍒犻櫎鎿嶄綔鏃ュ織")
+    @OperationLog("Delete OperationRecord")
     @PostMapping("/operationRecord/remove/{ids}")
     public R remove(@PathVariable Long[] ids) {
         if (!operationRecordService.removeByIds(Arrays.asList(ids))) {
-            return R.error("鍒犻櫎澶辫触");
+            return R.error("Delete Fail");
         }
-        return R.ok("鍒犻櫎鎴愬姛");
+        return R.ok("Delete Success");
     }
 
     @PreAuthorize("hasAuthority('system:operationRecord:list')")

--
Gitblit v1.9.1