From c1098109a949755ec92ec6935b9cccc907c9f0d7 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 6 Apr 2025 20:43:40 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=A2=9E=E5=8A=A0=20social=20?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/system/social/client/index.ts | 44 ++++ .../src/api/system/social/user/index.ts | 32 +++ .../src/views/system/social/client/data.ts | 228 ++++++++++++++++++ .../src/views/system/social/client/index.vue | 116 +++++++++ .../system/social/client/modules/form.vue | 75 ++++++ .../src/views/system/social/user/data.ts | 121 ++++++++++ .../src/views/system/social/user/index.vue | 78 ++++++ .../system/social/user/modules/detail.vue | 65 +++++ 8 files changed, 759 insertions(+) create mode 100644 apps/web-antd/src/api/system/social/client/index.ts create mode 100644 apps/web-antd/src/api/system/social/user/index.ts create mode 100644 apps/web-antd/src/views/system/social/client/data.ts create mode 100644 apps/web-antd/src/views/system/social/client/index.vue create mode 100644 apps/web-antd/src/views/system/social/client/modules/form.vue create mode 100644 apps/web-antd/src/views/system/social/user/data.ts create mode 100644 apps/web-antd/src/views/system/social/user/index.vue create mode 100644 apps/web-antd/src/views/system/social/user/modules/detail.vue diff --git a/apps/web-antd/src/api/system/social/client/index.ts b/apps/web-antd/src/api/system/social/client/index.ts new file mode 100644 index 000000000..59b1da639 --- /dev/null +++ b/apps/web-antd/src/api/system/social/client/index.ts @@ -0,0 +1,44 @@ +import { requestClient } from '#/api/request'; +import type { PageParam, PageResult } from '@vben/request'; + +export namespace SystemSocialClientApi { + /** 社交客户端信息 */ + export interface SystemSocialClient { + id?: number; + name: string; + socialType: number; + userType: number; + clientId: string; + clientSecret: string; + agentId?: string; + status: number; + createTime?: Date; + } +} + +/** 查询社交客户端列表 */ +export function getSocialClientPage(params: PageParam) { + return requestClient.get>('/system/social-client/page', + { params } + ); +} + +/** 查询社交客户端详情 */ +export function getSocialClient(id: number) { + return requestClient.get(`/system/social-client/get?id=${id}`); +} + +/** 新增社交客户端 */ +export function createSocialClient(data: SystemSocialClientApi.SystemSocialClient) { + return requestClient.post('/system/social-client/create', data); +} + +/** 修改社交客户端 */ +export function updateSocialClient(data: SystemSocialClientApi.SystemSocialClient) { + return requestClient.put('/system/social-client/update', data); +} + +/** 删除社交客户端 */ +export function deleteSocialClient(id: number) { + return requestClient.delete(`/system/social-client/delete?id=${id}`); +} diff --git a/apps/web-antd/src/api/system/social/user/index.ts b/apps/web-antd/src/api/system/social/user/index.ts new file mode 100644 index 000000000..f259be46a --- /dev/null +++ b/apps/web-antd/src/api/system/social/user/index.ts @@ -0,0 +1,32 @@ +import { requestClient } from '#/api/request'; +import type { PageParam, PageResult } from '@vben/request'; + +export namespace SystemSocialUserApi { + /** 社交用户信息 */ + export interface SystemSocialUser { + id?: number; + type: number; + openid: string; + token: string; + rawTokenInfo: string; + nickname: string; + avatar: string; + rawUserInfo: string; + code: string; + state: string; + createTime?: Date; + updateTime?: Date; + } +} + +/** 查询社交用户列表 */ +export function getSocialUserPage(params: PageParam) { + return requestClient.get>('/system/social-user/page', + { params } + ); +} + +/** 查询社交用户详情 */ +export function getSocialUser(id: number) { + return requestClient.get(`/system/social-user/get?id=${id}`); +} diff --git a/apps/web-antd/src/views/system/social/client/data.ts b/apps/web-antd/src/views/system/social/client/data.ts new file mode 100644 index 000000000..9d6bc8f57 --- /dev/null +++ b/apps/web-antd/src/views/system/social/client/data.ts @@ -0,0 +1,228 @@ +import { type VbenFormSchema, z } from '#/adapter/form'; +import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { SystemSocialClientApi } from '#/api/system/social/client'; + +import { DICT_TYPE, getDictOptions } from '#/utils/dict'; +import { CommonStatusEnum, SystemUserSocialTypeEnum } from '#/utils/constants'; +import { useAccess } from '@vben/access'; + +const { hasAccessByCodes } = useAccess(); + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + label: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '应用名', + component: 'Input', + componentProps: { + placeholder: '请输入应用名', + }, + rules: 'required', + }, + { + fieldName: 'socialType', + label: '社交平台', + component: 'Select', + componentProps: { + options: getDictOptions(DICT_TYPE.SYSTEM_SOCIAL_TYPE, 'number'), + class: 'w-full', + }, + rules: 'required', + }, + { + fieldName: 'userType', + label: '用户类型', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.USER_TYPE, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: 'required', + }, + { + fieldName: 'clientId', + label: '客户端编号', + component: 'Input', + componentProps: { + placeholder: '请输入客户端编号,对应各平台的 appKey', + }, + rules: 'required', + }, + { + fieldName: 'clientSecret', + label: '客户端密钥', + component: 'Input', + componentProps: { + placeholder: '请输入客户端密钥,对应各平台的 appSecret', + }, + rules: 'required', + }, + { + fieldName: 'agentId', + label: 'agentId', + component: 'Input', + componentProps: { + placeholder: '授权方的网页应用 ID,有则填', + }, + dependencies: { + triggerFields: ['socialType'], + show: (values) => values.socialType === SystemUserSocialTypeEnum.WECHAT_ENTERPRISE.type, + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '应用名', + component: 'Input', + componentProps: { + placeholder: '请输入应用名', + }, + }, + { + fieldName: 'socialType', + label: '社交平台', + component: 'Select', + componentProps: { + options: getDictOptions(DICT_TYPE.SYSTEM_SOCIAL_TYPE, 'number'), + placeholder: '请选择社交平台', + allowClear: true, + }, + }, + { + fieldName: 'userType', + label: '用户类型', + component: 'Select', + componentProps: { + options: getDictOptions(DICT_TYPE.USER_TYPE, 'number'), + placeholder: '请选择用户类型', + allowClear: true, + }, + }, + { + fieldName: 'clientId', + label: '客户端编号', + component: 'Input', + componentProps: { + placeholder: '请输入客户端编号', + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'Select', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + placeholder: '请选择状态', + allowClear: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + onActionClick: OnActionClickFn, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: '编号', + minWidth: 80, + }, + { + field: 'name', + title: '应用名', + minWidth: 120, + }, + { + field: 'socialType', + title: '社交平台', + minWidth: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE }, + }, + }, + { + field: 'userType', + title: '用户类型', + minWidth: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.USER_TYPE }, + }, + }, + { + field: 'clientId', + title: '客户端编号', + minWidth: 180, + }, + { + field: 'status', + title: '状态', + minWidth: 80, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + { + field: 'operation', + title: '操作', + minWidth: 130, + align: 'center', + fixed: 'right', + cellRender: { + attrs: { + nameField: 'name', + nameTitle: '社交客户端', + onClick: onActionClick, + }, + name: 'CellOperation', + options: [ + { + code: 'edit', + show: hasAccessByCodes(['system:social-client:update']), + }, + { + code: 'delete', + show: hasAccessByCodes(['system:social-client:delete']), + }, + ], + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/system/social/client/index.vue b/apps/web-antd/src/views/system/social/client/index.vue new file mode 100644 index 000000000..b6d5b418c --- /dev/null +++ b/apps/web-antd/src/views/system/social/client/index.vue @@ -0,0 +1,116 @@ + + + diff --git a/apps/web-antd/src/views/system/social/client/modules/form.vue b/apps/web-antd/src/views/system/social/client/modules/form.vue new file mode 100644 index 000000000..6233c28f2 --- /dev/null +++ b/apps/web-antd/src/views/system/social/client/modules/form.vue @@ -0,0 +1,75 @@ + + + diff --git a/apps/web-antd/src/views/system/social/user/data.ts b/apps/web-antd/src/views/system/social/user/data.ts new file mode 100644 index 000000000..9e7b4e3c9 --- /dev/null +++ b/apps/web-antd/src/views/system/social/user/data.ts @@ -0,0 +1,121 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { SystemSocialUserApi } from '#/api/system/social/user'; + +import { DICT_TYPE, getDictOptions } from '#/utils/dict'; +import { useAccess } from '@vben/access'; +import { getRangePickerDefaultProps } from '#/utils/date'; + +const { hasAccessByCodes } = useAccess(); + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'type', + label: '社交平台', + component: 'Select', + componentProps: { + options: getDictOptions(DICT_TYPE.SYSTEM_SOCIAL_TYPE, 'number'), + placeholder: '请选择社交平台', + allowClear: true, + }, + }, + { + fieldName: 'nickname', + label: '用户昵称', + component: 'Input', + componentProps: { + placeholder: '请输入用户昵称', + allowClear: true, + }, + }, + { + fieldName: 'openid', + label: '社交 openid', + component: 'Input', + componentProps: { + placeholder: '请输入社交 openid', + allowClear: true, + }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: { + ...getRangePickerDefaultProps(), + allowClear: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + onActionClick: OnActionClickFn, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'type', + title: '社交平台', + minWidth: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE }, + }, + }, + { + field: 'openid', + title: '社交 openid', + minWidth: 180, + }, + { + field: 'nickname', + title: '用户昵称', + minWidth: 120, + }, + { + field: 'avatar', + title: '用户头像', + minWidth: 80, + cellRender: { + name: 'CellImage', + }, + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + { + field: 'updateTime', + title: '更新时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + { + field: 'operation', + title: '操作', + minWidth: 100, + align: 'center', + fixed: 'right', + cellRender: { + attrs: { + nameField: 'nickname', + nameTitle: '社交用户', + onClick: onActionClick, + }, + name: 'CellOperation', + options: [ + { + code: 'view', + text: '详情', + show: hasAccessByCodes(['system:social-user:query']), + }, + ], + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/system/social/user/index.vue b/apps/web-antd/src/views/system/social/user/index.vue new file mode 100644 index 000000000..8d8a5ba87 --- /dev/null +++ b/apps/web-antd/src/views/system/social/user/index.vue @@ -0,0 +1,78 @@ + + + diff --git a/apps/web-antd/src/views/system/social/user/modules/detail.vue b/apps/web-antd/src/views/system/social/user/modules/detail.vue new file mode 100644 index 000000000..96518fd9f --- /dev/null +++ b/apps/web-antd/src/views/system/social/user/modules/detail.vue @@ -0,0 +1,65 @@ + + +