Merge pull request #691 from SuanmoSuanyangTechnology/feature/memory_zy
feat(web): user info api update
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-03 14:00:06
|
* @Date: 2026-02-03 14:00:06
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-03-19 18:35:10
|
* @Last Modified time: 2026-03-24 17:48:01
|
||||||
*/
|
*/
|
||||||
import { request } from '@/utils/request'
|
import { request } from '@/utils/request'
|
||||||
import type { AxiosRequestConfig } from 'axios'
|
import type { AxiosRequestConfig } from 'axios'
|
||||||
@@ -87,12 +87,13 @@ export const getUserSummary = (end_user_id: string) => {
|
|||||||
export const getNodeStatistics = (end_user_id: string) => {
|
export const getNodeStatistics = (end_user_id: string) => {
|
||||||
return request.get(`/memory-storage/analytics/node_statistics`, { end_user_id })
|
return request.get(`/memory-storage/analytics/node_statistics`, { end_user_id })
|
||||||
}
|
}
|
||||||
// Basic information
|
// 查询用户别名及信息
|
||||||
export const getEndUserProfile = (end_user_id: string) => {
|
export const getEndUserInfo = (end_user_id: string) => {
|
||||||
return request.get(`/memory-storage/read_end_user/profile`, { end_user_id })
|
return request.get(`/memory-storage/end_user_info`, { end_user_id })
|
||||||
}
|
}
|
||||||
export const updatedEndUserProfile = (values: EndUser) => {
|
// 更新用户别名及信息
|
||||||
return request.post(`/memory-storage/updated_end_user/profile`, values)
|
export const updatedEndUserInfo = (values: EndUser) => {
|
||||||
|
return request.post(`/memory-storage/end_user_info/updated`, values)
|
||||||
}
|
}
|
||||||
// User Memory - Relationship network
|
// User Memory - Relationship network
|
||||||
export const getMemorySearchEdges = (end_user_id: string, config?: AxiosRequestConfig) => {
|
export const getMemorySearchEdges = (end_user_id: string, config?: AxiosRequestConfig) => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-03 18:33:30
|
* @Date: 2026-02-03 18:33:30
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-02-11 14:51:00
|
* @Last Modified time: 2026-03-24 17:55:02
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* End User Profile Component
|
* End User Profile Component
|
||||||
@@ -18,7 +18,7 @@ import clsx from 'clsx'
|
|||||||
|
|
||||||
import RbCard from '@/components/RbCard/Card'
|
import RbCard from '@/components/RbCard/Card'
|
||||||
import {
|
import {
|
||||||
getEndUserProfile,
|
getEndUserInfo,
|
||||||
} from '@/api/memory'
|
} from '@/api/memory'
|
||||||
import EndUserProfileModal from './EndUserProfileModal'
|
import EndUserProfileModal from './EndUserProfileModal'
|
||||||
import type { EndUser, EndUserProfileModalRef, EndUserProfileRef } from '../types'
|
import type { EndUser, EndUserProfileModalRef, EndUserProfileRef } from '../types'
|
||||||
@@ -31,7 +31,7 @@ interface EndUserProfileProps {
|
|||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onDataLoaded, className }, ref) => {
|
const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ className }, ref) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { id } = useParams()
|
const { id } = useParams()
|
||||||
const endUserProfileModalRef = useRef<EndUserProfileModalRef>(null)
|
const endUserProfileModalRef = useRef<EndUserProfileModalRef>(null)
|
||||||
@@ -47,13 +47,9 @@ const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onD
|
|||||||
const getData = () => {
|
const getData = () => {
|
||||||
if (!id) return
|
if (!id) return
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
getEndUserProfile(id).then((res) => {
|
getEndUserInfo(id).then((res) => {
|
||||||
const userData = res as EndUser
|
const userData = res as EndUser
|
||||||
setData(userData)
|
setData(userData)
|
||||||
onDataLoaded?.({
|
|
||||||
other_name: userData.other_name,
|
|
||||||
id: userData.id
|
|
||||||
})
|
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@@ -62,10 +58,10 @@ const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onD
|
|||||||
}
|
}
|
||||||
/** Format profile items for display */
|
/** Format profile items for display */
|
||||||
const formatItems = useCallback(() => {
|
const formatItems = useCallback(() => {
|
||||||
return ['other_name', 'position', 'department', 'contact', 'phone', 'hire_date'].map(key => ({
|
return ['other_name'].map(key => ({
|
||||||
key,
|
key,
|
||||||
label: t(`userMemory.${key}`),
|
label: t(`userMemory.${key}`),
|
||||||
children: key === 'hire_date' && data?.[key] ? dayjs(data[key as keyof EndUser]).format('YYYY-MM-DD') : String(data?.[key as keyof EndUser] || '-'),
|
children: String(data?.[key as keyof EndUser] || '-'),
|
||||||
}))
|
}))
|
||||||
}, [data])
|
}, [data])
|
||||||
/** Open edit modal */
|
/** Open edit modal */
|
||||||
@@ -102,7 +98,7 @@ const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onD
|
|||||||
))}
|
))}
|
||||||
|
|
||||||
<div className="rb:text-[#7B8085] rb:text-[12px] rb:leading-4.5">
|
<div className="rb:text-[#7B8085] rb:text-[12px] rb:leading-4.5">
|
||||||
{t('userMemory.updated_at')}: {data?.updatetime_profile ? dayjs(data?.updatetime_profile).format('YYYY/MM/DD HH:mm:ss') : ''}
|
{t('userMemory.updated_at')}: {data?.updated_at ? dayjs(data?.updated_at).format('YYYY/MM/DD HH:mm:ss') : ''}
|
||||||
</div>
|
</div>
|
||||||
</Flex>
|
</Flex>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-03 18:33:21
|
* @Date: 2026-02-03 18:33:21
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-02-03 18:33:21
|
* @Last Modified time: 2026-03-24 17:58:43
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* End User Profile Modal
|
* End User Profile Modal
|
||||||
@@ -10,13 +10,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { forwardRef, useImperativeHandle, useState } from 'react';
|
import { forwardRef, useImperativeHandle, useState } from 'react';
|
||||||
import { Form, Input, App, DatePicker } from 'antd';
|
import { Form, Input, App } from 'antd';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
|
|
||||||
import type { EndUser, EndUserProfileModalRef } from '../types'
|
import type { EndUser, EndUserProfileModalRef } from '../types'
|
||||||
import RbModal from '@/components/RbModal'
|
import RbModal from '@/components/RbModal'
|
||||||
import { updatedEndUserProfile, } from '@/api/memory'
|
import { updatedEndUserInfo } from '@/api/memory'
|
||||||
|
|
||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
|
|
||||||
@@ -35,6 +34,7 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
|||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [form] = Form.useForm<EndUser>();
|
const [form] = Form.useForm<EndUser>();
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [editVo, setEditVo] = useState<EndUser | null>(null)
|
||||||
|
|
||||||
const values = Form.useWatch([], form);
|
const values = Form.useWatch([], form);
|
||||||
|
|
||||||
@@ -47,11 +47,8 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
|||||||
|
|
||||||
/** Open modal with user data */
|
/** Open modal with user data */
|
||||||
const handleOpen = (user: EndUser) => {
|
const handleOpen = (user: EndUser) => {
|
||||||
form.setFieldsValue({
|
setEditVo(user)
|
||||||
...user,
|
form.setFieldsValue(user);
|
||||||
end_user_id: user.id,
|
|
||||||
hire_date: user.hire_date ? dayjs(user.hire_date) : undefined
|
|
||||||
});
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
};
|
};
|
||||||
/** Save profile changes */
|
/** Save profile changes */
|
||||||
@@ -60,9 +57,10 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
|||||||
.validateFields()
|
.validateFields()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
updatedEndUserProfile({
|
updatedEndUserInfo({
|
||||||
|
...editVo,
|
||||||
...values,
|
...values,
|
||||||
hire_date: values.hire_date?.valueOf() || null
|
// hire_date: values.hire_date?.valueOf() || null
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
@@ -105,7 +103,7 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
|||||||
>
|
>
|
||||||
<Input placeholder={t('common.enter')} />
|
<Input placeholder={t('common.enter')} />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem
|
{/* <FormItem
|
||||||
name="position"
|
name="position"
|
||||||
label={t('userMemory.position')}
|
label={t('userMemory.position')}
|
||||||
>
|
>
|
||||||
@@ -134,7 +132,7 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
|||||||
label={t('userMemory.hire_date')}
|
label={t('userMemory.hire_date')}
|
||||||
>
|
>
|
||||||
<DatePicker className="rb:w-full" allowClear />
|
<DatePicker className="rb:w-full" allowClear />
|
||||||
</FormItem>
|
</FormItem> */}
|
||||||
</Form>
|
</Form>
|
||||||
</RbModal>
|
</RbModal>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,15 +2,13 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-03 17:57:15
|
* @Date: 2026-02-03 17:57:15
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-03-13 11:49:52
|
* @Last Modified time: 2026-03-24 17:58:54
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* User Memory Detail Types
|
* User Memory Detail Types
|
||||||
* Type definitions for user memory detail views including nodes, edges, and statistics
|
* Type definitions for user memory detail views including nodes, edges, and statistics
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Dayjs } from "dayjs";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User memory data structure
|
* User memory data structure
|
||||||
*/
|
*/
|
||||||
@@ -171,15 +169,13 @@ export interface NodeStatisticsItem {
|
|||||||
* End user profile
|
* End user profile
|
||||||
*/
|
*/
|
||||||
export interface EndUser {
|
export interface EndUser {
|
||||||
end_user_id: string;
|
|
||||||
id: string;
|
|
||||||
other_name: string;
|
other_name: string;
|
||||||
position: string;
|
aliases: string | null;
|
||||||
department: string;
|
meta_data: Record<string, string>;
|
||||||
contact: string;
|
end_user_info_id: string;
|
||||||
phone: string;
|
end_user_id: string;
|
||||||
hire_date: string | number | Dayjs | null;
|
created_at: string;
|
||||||
updatetime_profile?: number;
|
updated_at: string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* End user profile modal ref
|
* End user profile modal ref
|
||||||
|
|||||||
Reference in New Issue
Block a user