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
c1da6a83
Commit
c1da6a83
authored
Dec 27, 2019
by
姚书霞
🐘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改数据格式
parent
62bd3c6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
18 deletions
+34
-18
CompanyController.php
backend/controllers/v1/transport/CompanyController.php
+34
-18
No files found.
backend/controllers/v1/transport/CompanyController.php
View file @
c1da6a83
...
...
@@ -6,8 +6,7 @@ use Yii;
use
backend\controllers\v1\BaseController
;
use
backend\helpers\Func
;
use
yii\data\ActiveDataProvider
;
use
yii\web\BadRequestHttpException
;
use
yii\web\ServerErrorHttpException
;
use
yii\web\HttpException
;
class
CompanyController
extends
BaseController
{
...
...
@@ -30,6 +29,8 @@ class CompanyController extends BaseController
* DESCRIPTION:描述,
* IS_DEFAULT:是否默认 1是0否
* "),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
* )
*/
...
...
@@ -64,6 +65,8 @@ class CompanyController extends BaseController
* DESCRIPTION:描述,
* IS_DEFAULT:是否默认 1是0否
* "),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
* )
*/
...
...
@@ -71,8 +74,13 @@ class CompanyController extends BaseController
public
function
actionCompanyDetail
()
{
$guid
=
Yii
::
$app
->
request
->
getQueryparam
(
'guid'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
return
$model
;
$result
=
$this
->
modelClass
::
findOne
(
$guid
)
->
toArray
();
return
new
ActiveDataProvider
(
[
'models'
=>
$result
,
'pagination'
=>
false
]
);
}
/**
...
...
@@ -95,7 +103,10 @@ class CompanyController extends BaseController
* )
* )
* ),
* @OA\Response(response=201,description="success"),
* @OA\Response(response=201,description="添加成功"),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 422,description = "数据验证未通过"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
* )
*/
...
...
@@ -105,17 +116,16 @@ class CompanyController extends BaseController
$model
->
scenario
=
'create'
;
//创建的场景
$other_param
=
array
(
'GUID'
=>
Func
::
create_guid
(),
'ORG_GUID'
=>
'100'
,
//
Yii::$app->user->identity->ORG_GUID,
'ORG_GUID'
=>
Yii
::
$app
->
user
->
identity
->
ORG_GUID
,
);
$model
->
setAttributes
(
$other_param
);
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
if
(
$model
->
save
())
{
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
201
);
throw
new
HttpException
(
201
,
'添加成功'
);
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to create the object for unknown reason.
'
);
throw
new
HttpException
(
500
,
'添加失败
'
);
}
return
$model
;
}
/**
...
...
@@ -139,26 +149,29 @@ class CompanyController extends BaseController
* )
* )
* ),
* @OA\Response(response=200,description="success"),
* @OA\Response(response = 200,description = "修改成功"),
* @OA\Response(response = 400,description = "失败的请求"),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 422,description = "数据验证未通过"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionCompanyRevise
()
{
$guid
=
Yii
::
$app
->
request
->
getBodyparam
(
'GUID'
);
// var_dump($guid);die;
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到记录
'
);
throw
new
HttpException
(
400
,
'记录不存在
'
);
}
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
if
(
$model
->
save
()
===
false
&&
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to update the object for unknown reason.
'
);
throw
new
HttpException
(
500
,
'修改失败
'
);
}
return
$model
;
throw
new
HttpException
(
200
,
'修改成功'
)
;
}
/**
...
...
@@ -177,7 +190,10 @@ class CompanyController extends BaseController
* )
* )
* ),
* @OA\Response(response=204,description="success"),
* @OA\Response(response = 204,description = "删除成功"),
* @OA\Response(response = 400,description = "失败的请求"),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
* )
*/
...
...
@@ -186,13 +202,13 @@ class CompanyController extends BaseController
$guid
=
Yii
::
$app
->
request
->
getBodyparam
(
'GUID'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到记录
'
);
throw
new
HttpException
(
400
,
'记录不存在
'
);
}
else
if
(
$model
->
delete
()
===
false
)
{
throw
new
ServerErrorHttpException
(
'Failed to delete the object for unknown reason.
'
);
throw
new
HttpException
(
500
,
'删除失败
'
);
}
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
204
);
return
$mode
l
;
return
nul
l
;
}
}
\ No newline at end of file
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