From c00d064ad87576c4ada8c8e6ed9d2b24b253fe94 Mon Sep 17 00:00:00 2001 From: Iamasoldier <1272745473@qq.com> Date: Mon, 17 Feb 2025 18:09:10 +0800 Subject: [PATCH] =?UTF-8?q?fix[=E7=94=A8=E6=88=B7=E4=B8=AD=E5=BF=83]?= =?UTF-8?q?=EF=BC=9A=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../central/file/service/impl/OssService.java | 2 +- .../src/main/resources/bootstrap.yml | 8 +- .../controller/TourismFileController.java | 12 +- .../com/central/oss/template/OssTemplate.java | 6 +- .../src/main/resources/bootstrap.properties | 6 +- .../TourismFile/components/UpdateForm.tsx | 69 +++++ .../src/pages/orders/TourismFile/index.less | 1 + .../src/pages/orders/TourismFile/index.tsx | 275 ++++++++++++++++++ 8 files changed, 368 insertions(+), 11 deletions(-) create mode 100644 zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx create mode 100644 zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.less create mode 100644 zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx diff --git a/zlt-business/file-center/src/main/java/com/central/file/service/impl/OssService.java b/zlt-business/file-center/src/main/java/com/central/file/service/impl/OssService.java index 1be579b8..bbe9e718 100644 --- a/zlt-business/file-center/src/main/java/com/central/file/service/impl/OssService.java +++ b/zlt-business/file-center/src/main/java/com/central/file/service/impl/OssService.java @@ -68,7 +68,7 @@ public class OssService extends AbstractIFileService { public String getViewUrl(String fileId) { FileInfo fileInfo = getFileInfo(fileId); if (fileInfo != null) { - return ossTemplate.getViewUrl(fileInfo.getName()); + return ossTemplate.getViewUrl(fileInfo.getPath()); } return null; } diff --git a/zlt-business/file-center/src/main/resources/bootstrap.yml b/zlt-business/file-center/src/main/resources/bootstrap.yml index 520787bf..ae6f04e8 100644 --- a/zlt-business/file-center/src/main/resources/bootstrap.yml +++ b/zlt-business/file-center/src/main/resources/bootstrap.yml @@ -4,7 +4,7 @@ server: spring: application: name: file-center - cloud: - nacos: - discovery: - ip: 119.45.169.13 +# cloud: +# nacos: +# discovery: +# ip: 119.45.169.13 diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/TourismFileController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/TourismFileController.java index 31eaab36..bb0b81d5 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/TourismFileController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/TourismFileController.java @@ -2,6 +2,7 @@ package com.central.order.controller; import com.central.common.model.PageResult; import com.central.common.model.Result; +import com.central.order.feign.FileCenterService; import com.central.order.model.TourismFile; import com.central.order.service.ITourismFileService; import io.swagger.v3.oas.annotations.Operation; @@ -32,6 +33,9 @@ public class TourismFileController { @Autowired private ITourismFileService tourismFileService; + @Autowired + private FileCenterService fileCenterService; + /** * 列表 */ @@ -42,7 +46,13 @@ public class TourismFileController { }) @GetMapping public PageResult list(@RequestParam Map params) { - return tourismFileService.findList(params); + PageResult pageResult = tourismFileService.findList(params); + if (pageResult.getCount()>0){ + for (TourismFile tourismFile: pageResult.getData()){ + tourismFile.setImageUrl(fileCenterService.getViewUrlByPath(tourismFile.getImageUrl())); + } + } + return pageResult; } @PostMapping() diff --git a/zlt-commons/zlt-oss-spring-boot-starter/src/main/java/com/central/oss/template/OssTemplate.java b/zlt-commons/zlt-oss-spring-boot-starter/src/main/java/com/central/oss/template/OssTemplate.java index 35a95f57..9769a6fe 100644 --- a/zlt-commons/zlt-oss-spring-boot-starter/src/main/java/com/central/oss/template/OssTemplate.java +++ b/zlt-commons/zlt-oss-spring-boot-starter/src/main/java/com/central/oss/template/OssTemplate.java @@ -79,7 +79,7 @@ public class OssTemplate implements InitializingBean { ObjectInfo obj = new ObjectInfo(); obj.setObjectPath(bucketName + PATH_SPLIT + objectName); - obj.setObjectUrl(fileProperties.getOss().getEndpoint() + PATH_SPLIT + obj.getObjectPath()); + obj.setObjectUrl(getViewUrl(objectName)); return obj; } @@ -97,7 +97,9 @@ public class OssTemplate implements InitializingBean { ObjectInfo obj = new ObjectInfo(); obj.setObjectPath(fileProperties.getOss().getBucketName() + PATH_SPLIT + objectName); - obj.setObjectUrl(fileProperties.getOss().getEndpoint() + PATH_SPLIT + obj.getObjectPath()); +// obj.setObjectUrl(fileProperties.getOss().getEndpoint() + PATH_SPLIT + obj.getObjectPath()); + //需要重新获取可访问带有认证信息的url + obj.setObjectUrl(getViewUrl(objectName)); return obj; } diff --git a/zlt-config/src/main/resources/bootstrap.properties b/zlt-config/src/main/resources/bootstrap.properties index 3589fb96..469972e8 100644 --- a/zlt-config/src/main/resources/bootstrap.properties +++ b/zlt-config/src/main/resources/bootstrap.properties @@ -1,10 +1,10 @@ ########################## bootstrap级别通用配置 ########################## # 默认开发环境 -spring.profiles.active=prod +spring.profiles.active=dev ##### nacos(注册中心和配置中心)地址 -spring.cloud.nacos.server-addr=47.94.136.130:8848 -#spring.cloud.nacos.server-addr=127.0.0.1:8848 +#spring.cloud.nacos.server-addr=47.94.136.130:8848 +spring.cloud.nacos.server-addr=127.0.0.1:8848 spring.cloud.nacos.username=nacos spring.cloud.nacos.password=nacos spring.cloud.nacos.config.file-extension=yml diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx new file mode 100644 index 00000000..bad86a1e --- /dev/null +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx @@ -0,0 +1,69 @@ +import { + ModalForm, + ProForm, + ProFormText, +} from '@ant-design/pro-components'; +import { Form } from 'antd'; + +export type FormValueType = Partial; + +export type UpdateFormProps = { + onVisibleChange: (flag: boolean) => void; + onSubmit: (values: FormValueType) => Promise; + updateModalVisible: boolean; + values?: ORDERS.Tourism; +}; + +const UpdateForm: React.FC = (props) => { + const [form] = Form.useForm(); + return ( + + + + + + + + ); +}; + +export default UpdateForm; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.less b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.less new file mode 100644 index 00000000..8d289828 --- /dev/null +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.less @@ -0,0 +1 @@ +@import (reference) '~antd/es/style/themes/index'; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx new file mode 100644 index 00000000..2a6f40a7 --- /dev/null +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx @@ -0,0 +1,275 @@ +import { deleteQrcode, qrcode, saveOrUpdateQrcode } from '@/services/orders/api'; +import { PlusOutlined } from '@ant-design/icons'; +import type { ActionType, ProColumns } from '@ant-design/pro-components'; +import { + ModalForm, + PageContainer, + ProForm, + ProFormSelect, + ProFormText, + ProTable, + QueryFilter, +} from '@ant-design/pro-components'; +import { Typography, Popconfirm, Space, message, Image, Button } from 'antd'; +import React, { useRef, useState } from 'react'; +import UpdateForm from './components/UpdateForm'; + +const { Link } = Typography; + +const handleAdd = async (fields: ORDERS.Qrcode) => { + const hide = message.loading('正在添加'); + try { + const result = await saveOrUpdateQrcode({ ...fields }); + hide(); + if (result.resp_code === 0) { + message.success('添加成功'); + return true; + } else { + message.error(result.resp_msg); + return false; + } + } catch (error) { + hide(); + message.error('添加失败'); + return false; + } +}; + +const handleEdit = async (fields: ORDERS.Qrcode) => { + const hide = message.loading('正在更新'); + try { + const result = await saveOrUpdateQrcode({ ...fields }); + hide(); + if (result.resp_code === 0) { + message.success('修改成功'); + return true; + } else { + message.error(result.resp_msg); + return false; + } + } catch (error) { + hide(); + message.error('修改失败'); + return false; + } +}; + +const handleDelete = async (qrcode: ORDERS.Qrcode) => { + const hide = message.loading('正在删除'); + try { + const result = await deleteQrcode(qrcode.id); + hide(); + if (result.resp_code === 0) { + message.success('删除成功'); + return true; + } else { + message.error(result.resp_msg); + return false; + } + } catch (error) { + hide(); + message.error('删除失败'); + return false; + } +}; + +const TableList: React.FC = () => { + const actionRef = useRef(); + const [params, setParams] = useState>({ }); + const [createModalVisible, handleModalVisible] = useState(false); + const [updateModalVisible, handleUpdateModalVisible] = useState(false); + const [currentRow, setCurrentRow] = useState(); + const columns: ProColumns[] = [ + { + dataIndex: 'index', + valueType: 'indexBorder', + }, + { + title: 'ID', + dataIndex: 'id', + }, + { + title: 'CodeID', + dataIndex: 'codeId', + }, + { + title: '景区ID', + dataIndex: 'tourismId', + }, + { + title: '文件', + dataIndex: 'viewUrl', + render: (viewUrl) => + }, + { + title: '价格', + dataIndex: 'price', + }, + { + title: '设备SN', + dataIndex: 'deviceSn', + }, + { + title: '状态', + dataIndex: 'status', + }, + { + title: '创建时间', + dataIndex: 'createTime', + valueType: 'dateTime', + }, + { + title: '操作', + key: 'action', + render: (_, entity) => + + { + setCurrentRow(entity); + handleUpdateModalVisible(true); + }} + > + 修改 + + { + const success = await handleDelete(entity); + if (success) { + if (actionRef.current) { + actionRef.current.reload(); + } + } + }} + > + 删除 + + + }, + ]; + + return ( + + setParams(values)} + > + + + + rowKey="id" + headerTitle="二维码列表" + request={qrcode} + actionRef={actionRef} + columns={columns} + search={false} + params={params} + pagination={{ + showSizeChanger: true, + showQuickJumper: true, + }} + toolBarRender={() => [ + <> + + , + ]} + /> + { + + const success = await handleAdd(values); + if (success) { + handleModalVisible(false); + if (actionRef.current) { + actionRef.current.reload(); + } + } + }} + > + + + + + + + { + if (currentRow) { + + const success = await handleEdit({ ...currentRow, ...values }); + if (success) { + handleUpdateModalVisible(false); + if (actionRef.current) { + actionRef.current.reload(); + } + } + setCurrentRow(undefined); + } + }} + onVisibleChange={handleUpdateModalVisible} + updateModalVisible={updateModalVisible} + values={currentRow} + /> + + ); +}; + +export default TableList;