修改本地生活上传图片

This commit is contained in:
wangxiaowei 2024-08-22 17:20:33 +08:00
parent 41a42d1c44
commit bf66d7c250
3 changed files with 20 additions and 8 deletions

@ -24,16 +24,12 @@ use app\common\server\FileServer;
use app\common\basics\Api;
use app\common\server\JsonServer;
use app\common\utils\UploadAliOSS;
use app\common\enum\LocalStoreFileEnum;
class File extends Api
{
public $like_not_need_login = [];
// 移动端上传图片路径匹配参数
private static $APP_UPLOAD_PATH = [
'local_shop_add' => 'local_life_shop_goods'
];
/**
* showdoc
* @catalog 接口/上传文件
@ -63,11 +59,11 @@ class File extends Api
try{
$post = $this->request->post();
if (isset(self::$APP_UPLOAD_PATH[$post['type']])) {
$path = self::$APP_UPLOAD_PATH[$post['type']];
if (isset(LocalStoreFileEnum::$APP_UPLOAD_PATH[$post['type']])) {
$path = LocalStoreFileEnum::$APP_UPLOAD_PATH[$post['type']];
// 本地生活商家上传商品
if ($post['type'] === 'local_shop_add' && $post['lstore_id'] > 0) {
$path .= '/' . $this->user_id . '_' .$post['lstore_id'];
$path .= '/' . $this->user_id . '_' . $post['lstore_id'];
} else {
return JsonServer::error('缺少参数');
}

@ -5,6 +5,8 @@ namespace app\api\logic;
use app\common\basics\Logic;
use app\common\model\localstore\LocalStoreGoods;
use app\common\model\localstore\LocalStoreGoodsPic;
use app\common\enum\LocalStoreFileEnum;
use think\facade\Config;
class LocalStoreGoodsLogic extends Logic
{
@ -29,6 +31,10 @@ class LocalStoreGoodsLogic extends Logic
'delete_time' => 0,
])->count();
foreach ($list['pic'] as &$v) {
$v['url'] = Config::get('aliyunoss.domain') . LocalStoreFileEnum::$APP_UPLOAD_PATH['local_shop_add'] . '/' . $get['user_id'] . '_' . $get['lstore_id'] . '/' . $v['url'];
}
$result = [
'count' => $count,
'lists' => $list,

@ -0,0 +1,10 @@
<?php
namespace app\common\enum;
class LocalStoreFileEnum
{
public static $APP_UPLOAD_PATH = [
'local_shop_add' => 'local_life_shop_goods'
];
}