Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
newShopBack
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
newshop
newShopBack
Commits
b3ba15d0
Commit
b3ba15d0
authored
Nov 26, 2019
by
张晓林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图片上传修改,添加Excel上传
parent
83cfcd8c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
urlmanager.php
backend/config/urlmanager.php
+2
-0
BranchLicenceController.php
backend/controllers/v1/branch/BranchLicenceController.php
+50
-2
BranchLicence.php
backend/models/v1/branch/BranchLicence.php
+2
-0
No files found.
backend/config/urlmanager.php
View file @
b3ba15d0
...
...
@@ -164,8 +164,10 @@ return [
'extraPatterns'
=>
[
'GET,OPTIONS licence-list'
=>
'licence-list'
,
'GET,OPTIONS licence-detail'
=>
'licence-detail'
,
'GET,OPTIONS licence-excel-download'
=>
'licence-excel-download'
,
'POST,OPTIONS licence-insert'
=>
'licence-insert'
,
'POST,OPTIONS licence-img-upload'
=>
'licence-img-upload'
,
'POST,OPTIONS licence-excel-upload'
=>
'licence-excel-upload'
,
],
],
//省市区
...
...
backend/controllers/v1/branch/BranchLicenceController.php
View file @
b3ba15d0
...
...
@@ -9,7 +9,7 @@ use backend\helpers\Func;
use
backend\helpers\UploadFiles
;
use
yii\web\UploadedFile
;
use
yii\web\HttpException
;
use
yidas\phpSpreadsheet\Helper
;
class
BranchLicenceController
extends
BaseController
{
public
$modelClass
=
'backend\models\v1\branch\BranchLicence'
;
...
...
@@ -95,6 +95,54 @@ class BranchLicenceController extends BaseController{
$fileInfo
=
$model
->
upload
();
if
(
$fileInfo
[
'CODE'
]
==
200
)
{
// 文件上传成功
return
[
'CODE'
=>
200
,
'imgUrl'
=>
$fileInfo
[
'INFO'
]
];
}
else
{
throw
new
HttpException
(
422
);
}
}
}
/**
* @OA\Post(
* path="/backend/web/v1/branch/branch-licences/licence-excel-upload",
* tags={"门店&DC"},
* summary="批量更新或导入门店证照(张晓林)",
* operationId="uploadFiles",
* @OA\Response(
* response=200,
* description="导入成功",
* ),
* security={{"Authorization":{}}},
* @OA\RequestBody(
* description="上传Excel",
* @OA\MediaType(
* mediaType="multipart/form-data",
* @OA\Schema(
* type="object",
* @OA\Property(
* property="uploadFile",
* type="string",
* format="binary"
* ),
* )
* )
* )
* )
*/
public
function
actionLicenceExcelUpload
(){
//多文件时依赖注入参数参考UploadFiles类
$model
=
new
UploadFiles
([
'jpg'
,
'xls'
]);
if
(
Yii
::
$app
->
request
->
isPost
)
{
//多文件用getInstances
$model
->
uploadFiles
=
UploadedFile
::
getInstance
(
$model
,
'uploadFile'
);
$fileInfo
=
$model
->
upload
();
$file
=
$fileInfo
[
'INFO'
];
Helper
::
getRow
();
return
$file
;
if
(
$fileInfo
[
'CODE'
]
==
200
)
{
// 文件上传成功
throw
new
HttpException
(
200
);
...
...
backend/models/v1/branch/BranchLicence.php
View file @
b3ba15d0
...
...
@@ -5,6 +5,7 @@ use yii\db\ActiveRecord;
class
BranchLicence
extends
ActiveRecord
{
public
$LICENCEEXCEL
;
public
static
function
tableName
()
{
return
'shop_branch_licence'
;
...
...
@@ -21,6 +22,7 @@ class BranchLicence extends ActiveRecord{
[[
'LICENCE_CODE'
,
'LICENCE_NAME'
],
'string'
,
'max'
=>
20
,
'on'
=>
'licenceInsert'
],
[[
'IS_FROM'
,
'IS_SHOW'
],
'default'
,
'value'
=>
1
],
[[
'LICENCE_EXPIRY_DATE'
],
'datetime'
,
'format'
=>
'Y-m-d'
,
'on'
=>
'licenceInsert'
],
[[
'!LICENCEEXCEL'
],
'required'
,
'on'
=>
'excelDown'
,
'message'
=>
'缺少Excel名称'
],
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment