Merge branch 'develop' of https://gitee.com/L-Shilin/go-fly-platform-services into test
# Conflicts: # zlt-config/src/main/resources/bootstrap.properties
This commit is contained in:
@@ -4,10 +4,10 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: file-center
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
# ip: 119.45.169.13
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: 119.45.169.13
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 20MB
|
||||
|
||||
+81
@@ -723,6 +723,87 @@ public class OrderController {
|
||||
return new PageResult<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版:查询用户订单详情列表(含视频/图片/一键成片)
|
||||
*/
|
||||
@Operation(summary = "新版-查询用户订单详情列表(含视频/图片/一键成片)")
|
||||
@Parameters({
|
||||
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/user/v2")
|
||||
public PageResult<Map> listInfoByUserV2(@RequestParam Map<String, Object> params) {
|
||||
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||
params.put("userId", user.getId());
|
||||
List<Integer> orderStatusList = List.of(OrderStatus.COMPLETE.getId(), OrderStatus.UPLOADING.getId(), OrderStatus.UPLOADED.getId());
|
||||
params.put("orderStatusList", orderStatusList);
|
||||
|
||||
PageResult<Order> result = orderService.findListByUser(params);
|
||||
if (result.getCount() > 0){
|
||||
List<Map> page = new ArrayList<>();
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("style", fileStyle);
|
||||
for(Order order : result.getData()){
|
||||
Map<String,Object> orderFileMap = new HashMap<>();
|
||||
orderFileMap.put("time", sdf.format(order.getCreateTime()));
|
||||
orderFileMap.put("addr", tourismService.getTourismById(order.getTourismId()).getTourismAddress());
|
||||
orderFileMap.put("orderNo", order.getOrderNo());
|
||||
|
||||
// 只查一次所有文件
|
||||
List<OrderFile> allFiles = orderFileService.getOrderFileByOrderNo(order.getOrderNo());
|
||||
|
||||
// aiVideo
|
||||
List<OrderFile> aiVideoFiles = allFiles.stream()
|
||||
.filter(f -> "ai_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
String aiVideoUrl = null;
|
||||
if (!aiVideoFiles.isEmpty()) {
|
||||
fileMap.put("path", aiVideoFiles.get(0).getFilePath());
|
||||
aiVideoUrl = fileCenterService.getViewUrlByPathStyle(fileMap);
|
||||
}
|
||||
orderFileMap.put("aiVideo", aiVideoUrl);
|
||||
|
||||
// 图片素材
|
||||
List<OrderFile> imgFiles = allFiles.stream()
|
||||
.filter(f -> "image/jpeg".equals(f.getFileType()))
|
||||
.toList();
|
||||
List<Map<String,String>> imgList = new ArrayList<>();
|
||||
for (OrderFile orderFile : imgFiles){
|
||||
Map<String,String> imgMap = new HashMap<>();
|
||||
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||
imgMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||
imgMap.put("contentType", orderFile.getFileType());
|
||||
imgMap.put("path", orderFile.getFilePath());
|
||||
fileMap.put("path",orderFile.getFilePath());
|
||||
imgMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||
imgList.add(imgMap);
|
||||
}
|
||||
orderFileMap.put("imgList", imgList);
|
||||
|
||||
// 视频素材
|
||||
List<OrderFile> videoFiles = allFiles.stream()
|
||||
.filter(f -> "raw_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
List<Map<String,String>> videoList = new ArrayList<>();
|
||||
for (OrderFile orderFile : videoFiles){
|
||||
Map<String,String> videoMap = new HashMap<>();
|
||||
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||
videoMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||
videoMap.put("contentType", orderFile.getFileType());
|
||||
videoMap.put("path", orderFile.getFilePath());
|
||||
fileMap.put("path",orderFile.getFilePath());
|
||||
videoMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||
videoList.add(videoMap);
|
||||
}
|
||||
orderFileMap.put("videoList", videoList);
|
||||
|
||||
page.add(orderFileMap);
|
||||
}
|
||||
return PageResult.<Map>builder().data(page).resp_code(0).count(result.getCount()).build();
|
||||
}
|
||||
return new PageResult<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除URL中的参数
|
||||
* @param url 原始URL
|
||||
|
||||
+4
@@ -220,6 +220,10 @@ public class OrderFileController {
|
||||
orderFile.setFilePath(fileInfo.getPath());
|
||||
orderFile.setFileType(fileInfo.getContentType());
|
||||
orderFile.setTourismId(order.getTourismId());
|
||||
// 新增:如果是视频素材且未指定fileTag,默认标记为raw_video
|
||||
if ("video/mp4".equals(orderFile.getFileType()) && (orderFile.getFileTag() == null || orderFile.getFileTag().isEmpty())) {
|
||||
orderFile.setFileTag("raw_video");
|
||||
}
|
||||
|
||||
// 保存记录
|
||||
boolean saved = orderFileService.save(orderFile);
|
||||
|
||||
+3
-1
@@ -14,7 +14,9 @@ public enum HomeCarouselType implements ZltEnum {
|
||||
ACTIVITY(1, "活动"),
|
||||
SHOOTING_ANGLE(2,"拍照角度"),
|
||||
GUIDANCE(3,"引导"),
|
||||
BIG_PICTURE(4,"大图");
|
||||
BIG_PICTURE(4,"大图"),
|
||||
VIDEO(5,"景区视频"),
|
||||
ORDER_SHOW(6,"订单展示图");
|
||||
|
||||
private Integer id;
|
||||
private String content;
|
||||
|
||||
@@ -53,6 +53,7 @@ public class Order extends SuperEntity {
|
||||
|
||||
private transient String waylineLinkUrl;
|
||||
private transient JSONObject streamUrls;
|
||||
private transient String tourismImgUrl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -46,4 +46,8 @@ public class OrderFile extends SuperEntity {
|
||||
private String tenantId;
|
||||
private Integer isDel;
|
||||
|
||||
/**
|
||||
* 文件标签,如ai_video、raw_video等
|
||||
*/
|
||||
private String fileTag;
|
||||
}
|
||||
|
||||
+24
@@ -1,5 +1,6 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.lock.DistributedLock;
|
||||
@@ -8,12 +9,15 @@ import com.central.common.service.impl.SuperServiceImpl;
|
||||
import com.central.order.enums.OrderStatus;
|
||||
import com.central.order.event.OrderStatusChangeEvent;
|
||||
import com.central.order.feign.UserCenterService;
|
||||
import com.central.order.feign.FileCenterService;
|
||||
import com.central.order.mapper.OrderFileMapper;
|
||||
import com.central.order.mapper.OrderMapper;
|
||||
import com.central.order.mapper.TourismFileMapper;
|
||||
import com.central.order.mapper.TourismMapper;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.OrderFile;
|
||||
import com.central.order.model.OrderRanking;
|
||||
import com.central.order.model.TourismFile;
|
||||
import com.central.order.service.IOrderService;
|
||||
import com.central.order.util.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -56,6 +60,10 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
|
||||
@Autowired
|
||||
private TourismMapper tourismMapper;
|
||||
|
||||
@Autowired
|
||||
private TourismFileMapper tourismFileMapper;
|
||||
|
||||
@Autowired
|
||||
private OrderFileMapper orderFileMapper;
|
||||
|
||||
@@ -65,6 +73,9 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
@Autowired
|
||||
private UserCenterService userCenterService;
|
||||
|
||||
@Autowired
|
||||
private FileCenterService fileCenterService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param params
|
||||
@@ -225,6 +236,19 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
for (Order order : list) {
|
||||
order.setTourismName(tourismMapper.getTourismById(order.getTourismId()).getTourismName());
|
||||
order.setCreatedTime(sdf.format(order.getCreateTime()));
|
||||
// 设置景区订单展示图(type=6)的imageUrl
|
||||
List<TourismFile> tourismFiles = tourismFileMapper.selectList(
|
||||
new LambdaQueryWrapper<TourismFile>()
|
||||
.eq(TourismFile::getTourismId, order.getTourismId())
|
||||
.eq(TourismFile::getType, 6)
|
||||
.last("limit 1")
|
||||
);
|
||||
if (tourismFiles != null && !tourismFiles.isEmpty()) {
|
||||
String imgUrl = tourismFiles.get(0).getImageUrl();
|
||||
order.setTourismImgUrl(fileCenterService.getViewUrlByPath(imgUrl));
|
||||
} else {
|
||||
order.setTourismImgUrl(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return PageResult.<Order>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
||||
|
||||
+1
@@ -153,6 +153,7 @@ public class VideoEditServiceImpl implements IVideoEditService {
|
||||
orderFile.setFileId(fileInfo.getId());
|
||||
orderFile.setOrderNo(orderNo);
|
||||
orderFile.setFileType("video/mp4");
|
||||
orderFile.setFileTag("ai_video");
|
||||
orderFile.setFilePath(extractFilePath(outputUrl));
|
||||
orderFile.setUserId(order.getUserId());
|
||||
orderFile.setTourismId(order.getTourismId());
|
||||
|
||||
@@ -7,11 +7,12 @@ import {
|
||||
QueryFilter,
|
||||
ProFormSelect,
|
||||
ProFormText,
|
||||
ModalForm,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Button, Space, Typography, Popconfirm, message, Tag, Tooltip } from 'antd';
|
||||
import { getEditTaskList, deleteEditTask } from '@/services/orders/api';
|
||||
import CreateForm from './components/CreateForm';
|
||||
import { getEditTaskList, deleteEditTask, generateEditTask } from '@/services/orders/api';
|
||||
import UpdateForm from './components/UpdateForm';
|
||||
import { request } from 'umi';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
@@ -24,7 +25,7 @@ const STATUS_OPTIONS = [
|
||||
];
|
||||
|
||||
// 状态颜色映射
|
||||
const statusColorMap = {
|
||||
const statusColorMap: { [key: number]: { color: string; text: string } } = {
|
||||
0: { color: 'default', text: '待处理' },
|
||||
1: { color: 'processing', text: '处理中' },
|
||||
2: { color: 'success', text: '处理完成' },
|
||||
@@ -76,6 +77,36 @@ const TableList: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
// 新增:根据订单号生成建议任务
|
||||
const handleAdd = async (values: { orderSn: string }) => {
|
||||
if (!values.orderSn) {
|
||||
message.error('请输入订单编号');
|
||||
return false;
|
||||
}
|
||||
const hide = message.loading('正在根据订单号生成建议任务...');
|
||||
try {
|
||||
const res = await generateEditTask(values.orderSn);
|
||||
hide();
|
||||
if (res.resp_code === 0) {
|
||||
message.success('生成建议任务成功');
|
||||
return true;
|
||||
} else {
|
||||
message.error(res.resp_msg || '生成建议任务失败');
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
hide();
|
||||
message.error('生成建议任务失败');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// 修复handleEdit未定义
|
||||
const handleEdit = async (record: ORDERS.EditTask, values: Partial<ORDERS.EditTask>) => {
|
||||
// 这里保留原有编辑逻辑,如需自定义可补充
|
||||
return false;
|
||||
};
|
||||
|
||||
// 表格操作处理
|
||||
const handleTableAction = useCallback(async (
|
||||
action: 'add' | 'edit' | 'delete',
|
||||
@@ -85,7 +116,7 @@ const TableList: React.FC = () => {
|
||||
let success = false;
|
||||
switch (action) {
|
||||
case 'add':
|
||||
success = await handleAdd(values as ORDERS.EditTask);
|
||||
success = await handleAdd(values as { orderSn: string });
|
||||
success && handleModalVisible(false);
|
||||
break;
|
||||
case 'edit':
|
||||
@@ -104,6 +135,7 @@ const TableList: React.FC = () => {
|
||||
if (success && actionRef.current) {
|
||||
actionRef.current.reload();
|
||||
}
|
||||
return success;
|
||||
}, []);
|
||||
|
||||
// 修改 request 处理方式
|
||||
@@ -227,8 +259,12 @@ const TableList: React.FC = () => {
|
||||
修改
|
||||
</Link>
|
||||
<Popconfirm
|
||||
title={`确认删除该剪辑任务?`}
|
||||
description="删除后将无法恢复,请谨慎操作"
|
||||
title={
|
||||
<span>
|
||||
确认删除该剪辑任务?<br />
|
||||
<span style={{ color: 'red' }}>删除后将无法恢复,请谨慎操作</span>
|
||||
</span>
|
||||
}
|
||||
onConfirm={() => handleTableAction('delete', record)}
|
||||
>
|
||||
<Link>删除</Link>
|
||||
@@ -245,7 +281,7 @@ const TableList: React.FC = () => {
|
||||
split
|
||||
span={6}
|
||||
className="query-filter"
|
||||
onFinish={setParams}
|
||||
onFinish={async (formData) => { setParams(formData); return true; }}
|
||||
>
|
||||
<ProFormText
|
||||
name="orderSn"
|
||||
@@ -292,11 +328,27 @@ const TableList: React.FC = () => {
|
||||
overflow: 'auto',
|
||||
}}
|
||||
/>
|
||||
<CreateForm
|
||||
<ModalForm
|
||||
title="新增剪辑任务"
|
||||
visible={createModalVisible}
|
||||
onVisibleChange={handleModalVisible}
|
||||
onSubmit={async (values) => handleTableAction('add', undefined, values)}
|
||||
/>
|
||||
modalProps={{ destroyOnClose: true }}
|
||||
onFinish={async (values) => {
|
||||
const success = await handleAdd(values as { orderSn: string });
|
||||
if (success) {
|
||||
handleModalVisible(false);
|
||||
actionRef.current?.reload();
|
||||
}
|
||||
return success;
|
||||
}}
|
||||
>
|
||||
<ProFormText
|
||||
name="orderSn"
|
||||
label="订单编号"
|
||||
placeholder="请输入订单编号"
|
||||
rules={[{ required: true, message: '请输入订单编号' }]}
|
||||
/>
|
||||
</ModalForm>
|
||||
<UpdateForm
|
||||
updateModalVisible={updateModalVisible}
|
||||
onVisibleChange={handleUpdateModalVisible}
|
||||
|
||||
+39
-45
@@ -3,7 +3,8 @@ import { Button, Upload, message } from 'antd';
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import React, { useState } from 'react';
|
||||
import { TYPE_OPTIONS } from '../constants';
|
||||
import { importImage, saveOrUpdateTourismFile } from '@/services/orders/api';
|
||||
import { importImage } from '@/services/system/api';
|
||||
import { saveOrUpdateTourismFile } from '@/services/orders/api';
|
||||
import type { RcFile } from 'antd/lib/upload';
|
||||
import styles from '../index.less';
|
||||
|
||||
@@ -20,7 +21,8 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
tourismOptions,
|
||||
onSuccess,
|
||||
}) => {
|
||||
const [imageUrl, setImageUrl] = useState<string>();
|
||||
const [fileUrl, setFileUrl] = useState<string>();
|
||||
const [fileType, setFileType] = useState<number>();
|
||||
|
||||
const handleUpload = async (file: RcFile) => {
|
||||
const hide = message.loading('正在上传');
|
||||
@@ -29,8 +31,8 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
formData.append('file', file);
|
||||
const result = await importImage(formData);
|
||||
hide();
|
||||
if (result.name) {
|
||||
setImageUrl(result.name);
|
||||
if (result.url) {
|
||||
setFileUrl(result.url);
|
||||
message.success('上传成功');
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -41,20 +43,18 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: Record<string, any>) => {
|
||||
if (!imageUrl) {
|
||||
message.error('请上传素材图片');
|
||||
if (!fileUrl) {
|
||||
message.error('请上传素材文件');
|
||||
return false;
|
||||
}
|
||||
|
||||
const hide = message.loading('正在提交');
|
||||
try {
|
||||
const result = await saveOrUpdateTourismFile({
|
||||
...values,
|
||||
imageUrl,
|
||||
imageUrl: fileUrl,
|
||||
status: 0, // 默认启用
|
||||
});
|
||||
hide();
|
||||
|
||||
if (result.resp_code === 0) {
|
||||
message.success('创建成功');
|
||||
onSuccess();
|
||||
@@ -75,14 +75,12 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
visible={visible}
|
||||
onVisibleChange={(visible) => {
|
||||
if (!visible) {
|
||||
setImageUrl(undefined);
|
||||
setFileUrl(undefined);
|
||||
setFileType(undefined);
|
||||
}
|
||||
onVisibleChange(visible);
|
||||
}}
|
||||
modalProps={{
|
||||
destroyOnClose: true,
|
||||
maskClosable: false,
|
||||
}}
|
||||
modalProps={{ destroyOnClose: true, maskClosable: false }}
|
||||
onFinish={handleSubmit}
|
||||
>
|
||||
<ProForm.Group>
|
||||
@@ -96,7 +94,7 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
showSearch
|
||||
fieldProps={{
|
||||
loading: !tourismOptions.length,
|
||||
filterOption: (input, option) =>
|
||||
filterOption: (input: string, option: any) =>
|
||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
||||
}}
|
||||
/>
|
||||
@@ -106,7 +104,10 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
name="type"
|
||||
label="素材类型"
|
||||
placeholder="请选择素材类型"
|
||||
options={TYPE_OPTIONS}
|
||||
options={TYPE_OPTIONS as any}
|
||||
fieldProps={{
|
||||
onChange: (val: number) => setFileType(val),
|
||||
}}
|
||||
/>
|
||||
<ProFormText
|
||||
width="md"
|
||||
@@ -121,36 +122,29 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
placeholder="请输入素材描述"
|
||||
rules={[{ required: true, message: '请输入素材描述' }]}
|
||||
/>
|
||||
|
||||
<div style={{ width: '100%', marginBottom: 24 }}>
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<span style={{ color: '#666' }}>素材图片:</span>
|
||||
<span style={{ color: '#ff4d4f' }}>*</span>
|
||||
</div>
|
||||
{imageUrl && (
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt="preview"
|
||||
style={{
|
||||
maxWidth: '200px',
|
||||
maxHeight: '200px',
|
||||
objectFit: 'contain'
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<Upload
|
||||
maxCount={1}
|
||||
showUploadList={false}
|
||||
beforeUpload={handleUpload}
|
||||
accept="image/*"
|
||||
>
|
||||
<Button icon={<UploadOutlined />}>
|
||||
{imageUrl ? '重新上传' : '上传素材'}
|
||||
</Button>
|
||||
</Upload>
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<span style={{ color: '#666' }}>素材文件:</span>
|
||||
<span style={{ color: '#ff4d4f' }}>*</span>
|
||||
</div>
|
||||
{fileUrl && (
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
{fileType === 5 ? (
|
||||
<video src={fileUrl} controls style={{ maxWidth: '200px', maxHeight: '200px' }} />
|
||||
) : (
|
||||
<img src={fileUrl} alt="preview" style={{ maxWidth: '200px', maxHeight: '200px', objectFit: 'contain' }} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<Upload
|
||||
maxCount={1}
|
||||
showUploadList={false}
|
||||
beforeUpload={handleUpload}
|
||||
accept={fileType === 5 ? 'video/*' : 'image/*'}
|
||||
>
|
||||
<Button icon={<UploadOutlined />}>
|
||||
{fileUrl ? '重新上传' : fileType === 5 ? '上传视频' : '上传图片'}
|
||||
</Button>
|
||||
</Upload>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
|
||||
+52
-48
@@ -11,6 +11,11 @@ import type { RcFile } from 'antd/lib/upload';
|
||||
import React, { useState } from 'react';
|
||||
import type { TYPE_OPTIONS } from '../constants';
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ label: '启用', value: 0, color: 'success' },
|
||||
{ label: '未启用', value: 1, color: 'error' },
|
||||
] as const;
|
||||
|
||||
interface UpdateFormProps {
|
||||
onSubmit: (values: any) => Promise<void>;
|
||||
onVisibleChange: (visible: boolean) => void;
|
||||
@@ -22,30 +27,26 @@ interface UpdateFormProps {
|
||||
}
|
||||
|
||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||
const [imageUrl, setImageUrl] = useState<string>();
|
||||
const [imagePath, setImagePath] = useState<string>();
|
||||
const [fileUrl, setFileUrl] = useState<string>((props.values as any)?.fileUrl || (props.values as any)?.imageUrl || '');
|
||||
const [fileType, setFileType] = useState<number | undefined>((props.values as any)?.type);
|
||||
|
||||
const handleUpload = async (file: RcFile) => {
|
||||
const hide = message.loading('正在上传...');
|
||||
const handleUpload = async (file: RcFile): Promise<boolean> => {
|
||||
const hide = message.loading('正在上传');
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const result = await importImage(formData);
|
||||
hide();
|
||||
|
||||
if (result.url && result.path) {
|
||||
if (result.url) {
|
||||
setFileUrl(result.url);
|
||||
message.success('上传成功');
|
||||
setImageUrl(result.url);
|
||||
setImagePath(result.path);
|
||||
return true;
|
||||
}
|
||||
message.error('上传失败:未获取到文件信息');
|
||||
return false;
|
||||
} catch (error) {
|
||||
hide();
|
||||
message.error('上传失败:' + (error.message || '未知错误'));
|
||||
return false;
|
||||
message.error('上传失败');
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -55,13 +56,13 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||
onVisibleChange={props.onVisibleChange}
|
||||
modalProps={{ destroyOnClose: true }}
|
||||
onFinish={async (values) => {
|
||||
if (imagePath) {
|
||||
values.imageUrl = imagePath;
|
||||
if (fileUrl) {
|
||||
values.fileUrl = fileUrl;
|
||||
}
|
||||
const success = await props.onSubmit(values);
|
||||
if (success) {
|
||||
setImageUrl(undefined);
|
||||
setImagePath(undefined);
|
||||
setFileUrl('');
|
||||
setFileType(undefined);
|
||||
}
|
||||
return success;
|
||||
}}
|
||||
@@ -83,7 +84,10 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||
name="type"
|
||||
label="素材类型"
|
||||
placeholder="请选择素材类型"
|
||||
options={props.typeOptions}
|
||||
options={props.typeOptions as any}
|
||||
fieldProps={{
|
||||
onChange: (val: number) => setFileType(val),
|
||||
}}
|
||||
/>
|
||||
<ProFormSelect
|
||||
rules={[{ required: true, message: '请选择状态' }]}
|
||||
@@ -91,7 +95,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||
name="status"
|
||||
label="状态"
|
||||
placeholder="请选择状态"
|
||||
options={props.statusOptions}
|
||||
options={STATUS_OPTIONS as any}
|
||||
/>
|
||||
<ProFormText
|
||||
width="md"
|
||||
@@ -105,38 +109,38 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||
label="素材描述"
|
||||
placeholder="输入描述"
|
||||
/>
|
||||
|
||||
<Form.Item label="素材图片" required>
|
||||
<Upload
|
||||
maxCount={1}
|
||||
accept="image/*"
|
||||
showUploadList={false}
|
||||
customRequest={async ({ file, onSuccess, onError }) => {
|
||||
try {
|
||||
if (file instanceof File) {
|
||||
const success = await handleUpload(file as RcFile);
|
||||
if (success) {
|
||||
onSuccess?.('ok');
|
||||
} else {
|
||||
onError?.(new Error('上传失败'));
|
||||
}
|
||||
<Upload
|
||||
maxCount={1}
|
||||
accept={fileType === 5 ? 'video/*' : 'image/*'}
|
||||
showUploadList={false}
|
||||
customRequest={async ({ file, onSuccess, onError }) => {
|
||||
try {
|
||||
if (file instanceof File) {
|
||||
const success = await handleUpload(file as RcFile);
|
||||
if (success) {
|
||||
onSuccess?.('ok');
|
||||
} else {
|
||||
onError?.(new Error('上传失败') as any);
|
||||
}
|
||||
} catch (error) {
|
||||
onError?.(error);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Button icon={<UploadOutlined />}>上传素材</Button>
|
||||
</Upload>
|
||||
|
||||
<div style={{ marginTop: 16 }}>
|
||||
<Image
|
||||
src={imageUrl || props.values?.imageUrl}
|
||||
width={200}
|
||||
style={{ objectFit: 'cover' }}
|
||||
/>
|
||||
</div>
|
||||
</Form.Item>
|
||||
} catch (error) {
|
||||
onError?.(error as any);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Button icon={<UploadOutlined />}>
|
||||
{fileUrl ? '重新上传' : fileType === 5 ? '上传视频' : '上传图片'}
|
||||
</Button>
|
||||
</Upload>
|
||||
<div style={{ marginTop: 16 }}>
|
||||
{fileUrl ? (
|
||||
fileType === 5 ? (
|
||||
<video src={fileUrl} controls style={{ maxWidth: '200px', maxHeight: '200px' }} />
|
||||
) : (
|
||||
<Image src={fileUrl} width={200} style={{ objectFit: 'cover' }} />
|
||||
)
|
||||
) : null}
|
||||
</div>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// 将常量配置抽离到单独文件
|
||||
export const TYPE_OPTIONS = [
|
||||
{ label: '景区视频', value: 5 },
|
||||
{ label: '景区订单展示图', value: 6 },
|
||||
{ label: '展示大图', value: 4 },
|
||||
{ label: '拍照引导图', value: 3 },
|
||||
{ label: '拍照角度展示图', value: 2 },
|
||||
@@ -17,4 +19,6 @@ export const TYPE_CONFIG = {
|
||||
2: { color: '#13c2c2', text: '拍照角度' }, // 青色
|
||||
3: { color: '#722ed1', text: '引导' }, // 紫色
|
||||
4: { color: '#52c41a', text: '大图' }, // 绿色
|
||||
5: { color: '#f5222d', text: '景区视频' }, // 红色
|
||||
6: { color: '#2f54eb', text: '订单展示图' }, // 蓝色
|
||||
} as const;
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
import { Typography, Popconfirm, Space, message, Image, Button, Tag, Upload, Spin } from 'antd';
|
||||
import type { RcFile } from 'antd/lib/upload';
|
||||
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
||||
import { STATUS_CONFIG, TYPE_CONFIG } from './constants';
|
||||
import { STATUS_CONFIG, TYPE_CONFIG, TYPE_OPTIONS } from './constants';
|
||||
import CreateForm from './components/CreateForm';
|
||||
import UpdateForm from './components/UpdateForm';
|
||||
import SearchForm from './components/SearchForm';
|
||||
@@ -28,14 +28,6 @@ const STATUS_OPTIONS = [
|
||||
{ label: '未启用', value: 1, color: 'error' },
|
||||
] as const;
|
||||
|
||||
// 类型常量
|
||||
const TYPE_OPTIONS = [
|
||||
{ label: '展示大图', value: 4, color: 'blue' },
|
||||
{ label: '拍照引导图', value: 3, color: 'green' },
|
||||
{ label: '拍照角度展示图', value: 2, color: 'cyan' },
|
||||
{ label: '活动', value: 1, color: 'orange' },
|
||||
] as const;
|
||||
|
||||
// 状态映射
|
||||
const statusColorMap = {
|
||||
0: { color: 'green', text: '启用' },
|
||||
|
||||
@@ -432,4 +432,12 @@ export async function updateExpiredCoupons() {
|
||||
method: 'POST',
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// 根据订单号生成建议剪辑任务
|
||||
export async function generateEditTask(orderNo: string) {
|
||||
return request<API.Result<string>>('/api-order/auto/cut/generate', {
|
||||
method: 'POST',
|
||||
params: { orderNo },
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user