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
1cd5eeb3
Commit
1cd5eeb3
authored
Dec 30, 2019
by
姚书霞
🐘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
快递方式修改
parent
99fdac0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
CompanyController.php
backend/controllers/v1/transport/CompanyController.php
+9
-5
ShopTransportCompany.php
backend/models/v1/transport/ShopTransportCompany.php
+4
-3
No files found.
backend/controllers/v1/transport/CompanyController.php
View file @
1cd5eeb3
...
...
@@ -116,7 +116,7 @@ class CompanyController extends BaseController
$model
->
scenario
=
'create'
;
//创建的场景
$other_param
=
array
(
'GUID'
=>
Func
::
create_guid
(),
'ORG_GUID'
=>
Yii
::
$app
->
user
->
identity
->
ORG_GUID
,
'ORG_GUID'
=>
'100'
,
//
Yii::$app->user->identity->ORG_GUID,
);
$model
->
setAttributes
(
$other_param
);
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
...
...
@@ -125,6 +125,8 @@ class CompanyController extends BaseController
throw
new
HttpException
(
201
,
'添加成功'
);
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
HttpException
(
500
,
'添加失败'
);
}
else
{
return
$model
;
}
}
...
...
@@ -167,11 +169,13 @@ class CompanyController extends BaseController
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
if
(
$model
->
save
()
===
false
&&
!
$model
->
hasErrors
())
{
throw
new
HttpException
(
500
,
'修改失败'
);
if
(
$model
->
save
())
{
throw
new
HttpException
(
200
,
'修改成功'
);
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
HttpException
(
500
,
'添加失败'
);
}
else
{
return
$model
;
}
throw
new
HttpException
(
200
,
'修改成功'
);
}
/**
...
...
backend/models/v1/transport/ShopTransportCompany.php
View file @
1cd5eeb3
...
...
@@ -38,10 +38,11 @@ class ShopTransportCompany extends BaseModel
*/
public
function
scenarios
()
{
return
[
$scenarios
=
[
self
::
SCENARIO_CREATE
=>
[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'NAME'
,
'PHONE'
,
'DESCRIPTION'
,
'IS_DEFAULT'
],
self
::
SCENARIO_UPDATE
=>
[
'CODE'
,
'NAME'
,
'PHONE'
,
'DESCRIPTION'
,
'IS_DEFAULT'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
/**
...
...
@@ -50,8 +51,8 @@ class ShopTransportCompany extends BaseModel
public
function
rules
()
{
return
[
[[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'
message'
=>
'{attribute}为必填项'
,
'on'
=>
self
::
SCENARIO_CREATE
],
[[
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'
message'
=>
'{attribute}为必填项'
,
'on'
=>
self
::
SCENARIO_UPDATE
],
[[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'
on'
=>
[
self
::
SCENARIO_CREATE
]
],
[[
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'
on'
=>
[
self
::
SCENARIO_UPDATE
]
],
[[
'PHONE'
],
'match'
,
'pattern'
=>
'/^1\d{10}$/'
,
'message'
=>
'手机号格式不正确'
],
[[
'IS_DEFAULT'
],
'boolean'
,
'message'
=>
'{attribute}传值错误'
],
];
...
...
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