| | |
| | | tenant: 'Tenant', |
| | | role: 'Role', |
| | | userLogin: 'Token', |
| | | user: 'User', |
| | | }, |
| | | table: { |
| | | field: { |
| | |
| | | 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", |
| | | }, |
| | | } |
| | | } |
| | | }; |
| | |
| | | tenant: '租户管理', |
| | | role: '角色管理', |
| | | userLogin: '登录日志', |
| | | user: '用户管理', |
| | | }, |
| | | table: { |
| | | field: { |
| | |
| | | birthday: "生日", |
| | | introduction: "简介", |
| | | }, |
| | | operationRecord: { |
| | | namespace: "命名空间", |
| | | url: "url", |
| | | appkey: "密钥", |
| | | timestamp: "时间戳", |
| | | clientIp: "客户端IP", |
| | | request: "请求内容", |
| | | response: "响应内容", |
| | | spendTime: "花费时间", |
| | | err: "错误信息", |
| | | result: "result", |
| | | userId: "操作用户", |
| | | }, |
| | | } |
| | | } |
| | | }; |
| | |
| | | import dept from "./dept"; |
| | | import menu from './menu' |
| | | import user from './user'; |
| | | import operationRecord from './operationRecord'; |
| | | |
| | | const ResourceContent = (node) => { |
| | | switch (node.component) { |
| | |
| | | return menu; |
| | | case 'user': |
| | | return user; |
| | | case 'operationRecord': |
| | | return operationRecord; |
| | | default: |
| | | return { |
| | | list: ListGuesser, |
New file |
| | |
| | | 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; |
New file |
| | |
| | | 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; |
New file |
| | |
| | | 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}> </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; |
New file |
| | |
| | | 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}` |
| | | } |
| | | }; |
| | |
| | | // 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(); |
| | |
| | | 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')") |