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
4985c66c
Commit
4985c66c
authored
Dec 30, 2019
by
张晓林
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of
http://gitlab-ebiz.yiyao365.cn/newshop/newshopback
into development
parents
8e998340
1cd5eeb3
Changes
2
Show 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 @
4985c66c
...
@@ -116,7 +116,7 @@ class CompanyController extends BaseController
...
@@ -116,7 +116,7 @@ class CompanyController extends BaseController
$model
->
scenario
=
'create'
;
//创建的场景
$model
->
scenario
=
'create'
;
//创建的场景
$other_param
=
array
(
$other_param
=
array
(
'GUID'
=>
Func
::
create_guid
(),
'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
(
$other_param
);
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
...
@@ -125,6 +125,8 @@ class CompanyController extends BaseController
...
@@ -125,6 +125,8 @@ class CompanyController extends BaseController
throw
new
HttpException
(
201
,
'添加成功'
);
throw
new
HttpException
(
201
,
'添加成功'
);
}
elseif
(
!
$model
->
hasErrors
())
{
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
HttpException
(
500
,
'添加失败'
);
throw
new
HttpException
(
500
,
'添加失败'
);
}
else
{
return
$model
;
}
}
}
}
...
@@ -167,11 +169,13 @@ class CompanyController extends BaseController
...
@@ -167,11 +169,13 @@ class CompanyController extends BaseController
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
if
(
$model
->
save
()
===
false
&&
!
$model
->
hasErrors
())
{
if
(
$model
->
save
())
{
throw
new
HttpException
(
500
,
'修改失败'
);
}
throw
new
HttpException
(
200
,
'修改成功'
);
throw
new
HttpException
(
200
,
'修改成功'
);
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
HttpException
(
500
,
'添加失败'
);
}
else
{
return
$model
;
}
}
}
/**
/**
...
...
backend/models/v1/transport/ShopTransportCompany.php
View file @
4985c66c
...
@@ -38,10 +38,11 @@ class ShopTransportCompany extends BaseModel
...
@@ -38,10 +38,11 @@ class ShopTransportCompany extends BaseModel
*/
*/
public
function
scenarios
()
public
function
scenarios
()
{
{
return
[
$scenarios
=
[
self
::
SCENARIO_CREATE
=>
[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'NAME'
,
'PHONE'
,
'DESCRIPTION'
,
'IS_DEFAULT'
],
self
::
SCENARIO_CREATE
=>
[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'NAME'
,
'PHONE'
,
'DESCRIPTION'
,
'IS_DEFAULT'
],
self
::
SCENARIO_UPDATE
=>
[
'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
...
@@ -50,8 +51,8 @@ class ShopTransportCompany extends BaseModel
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'
message'
=>
'{attribute}为必填项'
,
'on'
=>
self
::
SCENARIO_CREATE
],
[[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'
on'
=>
[
self
::
SCENARIO_CREATE
]
],
[[
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'
message'
=>
'{attribute}为必填项'
,
'on'
=>
self
::
SCENARIO_UPDATE
],
[[
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'
on'
=>
[
self
::
SCENARIO_UPDATE
]
],
[[
'PHONE'
],
'match'
,
'pattern'
=>
'/^1\d{10}$/'
,
'message'
=>
'手机号格式不正确'
],
[[
'PHONE'
],
'match'
,
'pattern'
=>
'/^1\d{10}$/'
,
'message'
=>
'手机号格式不正确'
],
[[
'IS_DEFAULT'
],
'boolean'
,
'message'
=>
'{attribute}传值错误'
],
[[
'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