fix[用户中心]:用户头像查询逻辑优化
This commit is contained in:
+1
-1
@@ -68,7 +68,7 @@ public class OssService extends AbstractIFileService {
|
|||||||
public String getViewUrl(String fileId) {
|
public String getViewUrl(String fileId) {
|
||||||
FileInfo fileInfo = getFileInfo(fileId);
|
FileInfo fileInfo = getFileInfo(fileId);
|
||||||
if (fileInfo != null) {
|
if (fileInfo != null) {
|
||||||
return ossTemplate.getViewUrl(fileInfo.getName());
|
return ossTemplate.getViewUrl(fileInfo.getPath());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: file-center
|
name: file-center
|
||||||
cloud:
|
# cloud:
|
||||||
nacos:
|
# nacos:
|
||||||
discovery:
|
# discovery:
|
||||||
ip: 119.45.169.13
|
# ip: 119.45.169.13
|
||||||
|
|||||||
+11
-1
@@ -2,6 +2,7 @@ package com.central.order.controller;
|
|||||||
|
|
||||||
import com.central.common.model.PageResult;
|
import com.central.common.model.PageResult;
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
|
import com.central.order.feign.FileCenterService;
|
||||||
import com.central.order.model.TourismFile;
|
import com.central.order.model.TourismFile;
|
||||||
import com.central.order.service.ITourismFileService;
|
import com.central.order.service.ITourismFileService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -32,6 +33,9 @@ public class TourismFileController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ITourismFileService tourismFileService;
|
private ITourismFileService tourismFileService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileCenterService fileCenterService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
@@ -42,7 +46,13 @@ public class TourismFileController {
|
|||||||
})
|
})
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public PageResult list(@RequestParam Map<String, Object> params) {
|
public PageResult list(@RequestParam Map<String, Object> params) {
|
||||||
return tourismFileService.findList(params);
|
PageResult<TourismFile> pageResult = tourismFileService.findList(params);
|
||||||
|
if (pageResult.getCount()>0){
|
||||||
|
for (TourismFile tourismFile: pageResult.getData()){
|
||||||
|
tourismFile.setImageUrl(fileCenterService.getViewUrlByPath(tourismFile.getImageUrl()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pageResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
|
|||||||
+4
-2
@@ -79,7 +79,7 @@ public class OssTemplate implements InitializingBean {
|
|||||||
|
|
||||||
ObjectInfo obj = new ObjectInfo();
|
ObjectInfo obj = new ObjectInfo();
|
||||||
obj.setObjectPath(bucketName + PATH_SPLIT + objectName);
|
obj.setObjectPath(bucketName + PATH_SPLIT + objectName);
|
||||||
obj.setObjectUrl(fileProperties.getOss().getEndpoint() + PATH_SPLIT + obj.getObjectPath());
|
obj.setObjectUrl(getViewUrl(objectName));
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,9 @@ public class OssTemplate implements InitializingBean {
|
|||||||
|
|
||||||
ObjectInfo obj = new ObjectInfo();
|
ObjectInfo obj = new ObjectInfo();
|
||||||
obj.setObjectPath(fileProperties.getOss().getBucketName() + PATH_SPLIT + objectName);
|
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;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
########################## bootstrap级别通用配置 ##########################
|
########################## bootstrap级别通用配置 ##########################
|
||||||
# 默认开发环境
|
# 默认开发环境
|
||||||
spring.profiles.active=prod
|
spring.profiles.active=dev
|
||||||
|
|
||||||
##### nacos(注册中心和配置中心)地址
|
##### nacos(注册中心和配置中心)地址
|
||||||
spring.cloud.nacos.server-addr=47.94.136.130:8848
|
#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=127.0.0.1:8848
|
||||||
spring.cloud.nacos.username=nacos
|
spring.cloud.nacos.username=nacos
|
||||||
spring.cloud.nacos.password=nacos
|
spring.cloud.nacos.password=nacos
|
||||||
spring.cloud.nacos.config.file-extension=yml
|
spring.cloud.nacos.config.file-extension=yml
|
||||||
|
|||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
import {
|
||||||
|
ModalForm,
|
||||||
|
ProForm,
|
||||||
|
ProFormText,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { Form } from 'antd';
|
||||||
|
|
||||||
|
export type FormValueType = Partial<ORDERS.Tourism>;
|
||||||
|
|
||||||
|
export type UpdateFormProps = {
|
||||||
|
onVisibleChange: (flag: boolean) => void;
|
||||||
|
onSubmit: (values: FormValueType) => Promise<void>;
|
||||||
|
updateModalVisible: boolean;
|
||||||
|
values?: ORDERS.Tourism;
|
||||||
|
};
|
||||||
|
|
||||||
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
return (
|
||||||
|
<ModalForm
|
||||||
|
title="修改二维码"
|
||||||
|
form={form}
|
||||||
|
visible={props.updateModalVisible}
|
||||||
|
onFinish={props.onSubmit}
|
||||||
|
onVisibleChange={props.onVisibleChange}
|
||||||
|
>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '名称不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="tourismName"
|
||||||
|
label="名称"
|
||||||
|
placeholder="输入名称"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '地址不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="tourismAddress"
|
||||||
|
label="地址"
|
||||||
|
placeholder="输入地址"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '手机号不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="tourismPhone"
|
||||||
|
label="手机号"
|
||||||
|
placeholder="输入手机号"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default UpdateForm;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
@@ -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<ActionType>();
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>({ });
|
||||||
|
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||||
|
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||||
|
const [currentRow, setCurrentRow] = useState<ORDERS.Qrcode>();
|
||||||
|
const columns: ProColumns<ORDERS.Qrcode>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'ID',
|
||||||
|
dataIndex: 'id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'CodeID',
|
||||||
|
dataIndex: 'codeId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '景区ID',
|
||||||
|
dataIndex: 'tourismId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '文件',
|
||||||
|
dataIndex: 'viewUrl',
|
||||||
|
render: (viewUrl) => <Image src={viewUrl} width={100} />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '价格',
|
||||||
|
dataIndex: 'price',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '设备SN',
|
||||||
|
dataIndex: 'deviceSn',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
valueType: 'dateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
render: (_, entity) =>
|
||||||
|
<Space>
|
||||||
|
<Link
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentRow(entity);
|
||||||
|
handleUpdateModalVisible(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
修改
|
||||||
|
</Link>
|
||||||
|
<Popconfirm
|
||||||
|
title={`确认删除景区[${entity.codeId}]?`}
|
||||||
|
onConfirm={async () => {
|
||||||
|
const success = await handleDelete(entity);
|
||||||
|
if (success) {
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Link>删除</Link>
|
||||||
|
</Popconfirm>
|
||||||
|
</Space>
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '管理任务' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={6}
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => setParams(values)}
|
||||||
|
>
|
||||||
|
<ProFormText name="name" label="搜索" placeholder="输入关键字" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<ORDERS.Qrcode>
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="二维码列表"
|
||||||
|
request={qrcode}
|
||||||
|
actionRef={actionRef}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
toolBarRender={() => [
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => {
|
||||||
|
handleModalVisible(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PlusOutlined /> 添加
|
||||||
|
</Button>
|
||||||
|
</>,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ModalForm
|
||||||
|
title="添加二维码"
|
||||||
|
// layout="horizontal"
|
||||||
|
visible={createModalVisible}
|
||||||
|
onVisibleChange={handleModalVisible}
|
||||||
|
modalProps={{ destroyOnClose: true }}
|
||||||
|
onFinish={async (values) => {
|
||||||
|
|
||||||
|
const success = await handleAdd(values);
|
||||||
|
if (success) {
|
||||||
|
handleModalVisible(false);
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormSelect
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '景区不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="tourismId"
|
||||||
|
label="景区"
|
||||||
|
placeholder="请选择景区"
|
||||||
|
options={[
|
||||||
|
{ label: '北塘古镇', value: 33 },
|
||||||
|
{ label: '海丝首港', value: 32 },
|
||||||
|
{ label: '景区C', value: 2 },
|
||||||
|
// 添加更多选项...
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '价格不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="price"
|
||||||
|
label="景点打卡价格"
|
||||||
|
placeholder="输入价格(单位:分)"
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '设备不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="deviceSn"
|
||||||
|
label="设备编号"
|
||||||
|
placeholder="输入设备编号"
|
||||||
|
options={[
|
||||||
|
{ label: '7CTDM6F00B744S', value: '7CTDM6F00B744S' },
|
||||||
|
// 添加更多选项...
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
<UpdateForm
|
||||||
|
onSubmit={async (values) => {
|
||||||
|
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}
|
||||||
|
/>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TableList;
|
||||||
Reference in New Issue
Block a user