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
56d3c0f5
Commit
56d3c0f5
authored
Nov 15, 2019
by
孙磊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店服务类目
parent
314dafd9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
255 additions
and
0 deletions
+255
-0
urlmanager.php
backend/config/urlmanager.php
+5
-0
BranchServiceTypeController.php
...end/controllers/v1/branch/BranchServiceTypeController.php
+171
-0
BranchServiceType.php
backend/models/v1/branch/BranchServiceType.php
+79
-0
No files found.
backend/config/urlmanager.php
View file @
56d3c0f5
...
@@ -17,6 +17,7 @@ return [
...
@@ -17,6 +17,7 @@ return [
'v1/shopuser/user-department'
,
'v1/shopuser/user-department'
,
'v1/shopuser/shop-user'
,
'v1/shopuser/shop-user'
,
'v1/shopuser/user-complain'
,
'v1/shopuser/user-complain'
,
'v1/branch/branch-service-type'
,
],
],
'extraPatterns'
=>
[
'extraPatterns'
=>
[
'GET,OPTIONS test'
=>
'test'
,
'GET,OPTIONS test'
=>
'test'
,
...
@@ -32,6 +33,10 @@ return [
...
@@ -32,6 +33,10 @@ return [
'POST,OPTIONS add'
=>
'add'
,
'POST,OPTIONS add'
=>
'add'
,
'DELETE,OPTIONS del'
=>
'del'
,
'DELETE,OPTIONS del'
=>
'del'
,
'GET,OPTIONS branch-score-list'
=>
'branch-score-list'
,
'GET,OPTIONS branch-score-list'
=>
'branch-score-list'
,
'GET,OPTIONS branch-service-list'
=>
'branch-service-list'
,
'POST,OPTIONS add-branch-service'
=>
'add-branch-service'
,
'PUT,OPTIONS revise-branch-service'
=>
'revise-branch-service'
,
'DELETE,OPTIONS del-branch-service'
=>
'del-branch-service'
,
],
],
],
],
'GET swaggers/swagger/<id>'
=>
'swagger/swagger'
,
'GET swaggers/swagger/<id>'
=>
'swagger/swagger'
,
...
...
backend/controllers/v1/branch/BranchServiceTypeController.php
0 → 100644
View file @
56d3c0f5
<?php
namespace
backend\controllers\v1\branch
;
use
Yii
;
use
backend\controllers\v1\BaseController
;
use
yii\web\BadRequestHttpException
;
use
app\models\v1\branch\BranchServiceType
;
use
backend\helpers\Func
;
class
BranchServiceTypeController
extends
BaseController
{
public
$modelClass
=
'app\models\v1\branch\BranchServiceType'
;
/**
* @OA\Get(
* path="/backend/web/v1/branch/branch-service-types/branch-service-list",
* tags={"门店&DC"},
* description="门店服务类目列表",
* summary="门店服务类目列表(孙磊)",
* operationId="Department",
* @OA\Parameter(name="code",in="query",description="门店服务类目编号",@OA\Schema(type="string")),
* @OA\Parameter(name="name",in="query",description="门店服务类目名称",@OA\Schema(type="string")),
* @OA\Response(response="200",description="OK。一切正常"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionBranchServiceList
()
{
$model
=
new
$this
->
modelClass
();
//用户输入数据赋值到模型属性
$model
->
CODE
=
Yii
::
$app
->
request
->
get
(
'code'
);
$model
->
NAME
=
Yii
::
$app
->
request
->
get
(
'name'
);
if
(
$model
->
validate
())
{
//所有输入数据都有效 all inputs are valid
$code
=
$model
->
CODE
;
$name
=
$model
->
NAME
;
$info
=
$model
->
BranchServiceInfo
(
$code
,
$name
);
if
(
!
$info
->
getModels
())
{
throw
new
BadRequestHttpException
(
'未找到符合的门店服务类目信息'
);
}
return
$info
;
}
else
{
//验证失败:$errors 是一个包含错误信息的数组
$errors
=
$model
->
errors
;
return
$errors
;
}
}
/**
* @OA\POST(
* path="/backend/web/v1/branch/branch-service-types/add-branch-service",
* tags={"门店&DC"},
* summary="添加门店服务类目接口(孙磊)",
* description="添加门店服务类目接口",
* @OA\RequestBody(
* required=true,
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* @OA\Property(property="CODE",description="服务类目编号",type="string"),
* @OA\Property(property="NAME",description="服务类目名称,最长20字",type="string"),
* @OA\Property(property="DESCRIPTION",description="服务类目描述",type="string"),
* @OA\Property(property="THEME_COLOR",description="主题颜色",type="string"),
* )
* )
* ),
* @OA\Response(response=200,description="success"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionAddBranchService
()
{
$model
=
new
$this
->
modelClass
();
$model
->
scenario
=
'create'
;
//创建的场景
// $datetime = new \DateTime;
// $create_time = $datetime->format('Y-m-d H:i:s');
$create_time
=
date
(
'Y-m-d H:i:s'
,
time
());
$other_param
=
array
(
'GUID'
=>
Func
::
create_guid
(),
'ORG_GUID'
=>
Yii
::
$app
->
user
->
identity
->
ORG_GUID
,
'CREATE_TIME'
=>
$create_time
,
);
$model
->
setAttributes
(
$other_param
);
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
if
(
$model
->
save
())
{
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
201
);
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to create the object for unknown reason.'
);
}
return
$model
;
}
/**
* @OA\PUT(
* path="/backend/web/v1/branch/branch-service-types/revise-branch-service",
* tags={"门店&DC"},
* summary="修改门店服务类目接口(孙磊)",
* description="修改门店服务类目接口",
* @OA\RequestBody(
* required=true,
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* @OA\Property(property="GUID",description="要修改的服务类目GUID",type="string"),
* @OA\Property(property="CODE",description="服务类目编号",type="string"),
* @OA\Property(property="NAME",description="服务类目名称,最长20字",type="string"),
* @OA\Property(property="DESCRIPTION",description="服务类目描述",type="string"),
* @OA\Property(property="THEME_COLOR",description="主题颜色",type="string"),
* )
* )
* ),
* @OA\Response(response=200,description="成功时返回access-token"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionReviseBranchService
()
{
$guid
=
Yii
::
$app
->
getRequest
()
->
post
(
'GUID'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到要修改的记录'
);
}
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
if
(
$model
->
save
()
===
false
&&
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to update the object for unknown reason.'
);
}
return
$model
;
}
/**
* @OA\DELETE(
* path="/backend/web/v1/branch/branch-service-types/del-branch-service",
* tags={"门店&DC"},
* summary="删除门店服务类目接口(孙磊)",
* description="删除门店服务类目接口",
* @OA\RequestBody(
* required=true,
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* @OA\Property(property="GUID",description="要删除的门店服务类目GUID",type="string"),
* )
* )
* ),
* @OA\Response(response=204,description="门店服务类目删除成功"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionDelBranchService
()
{
$guid
=
Yii
::
$app
->
getRequest
()
->
post
(
'GUID'
);
$model
=
new
$this
->
modelClass
();
$branchservice
=
$model
::
findOne
(
$guid
);
if
(
!
$branchservice
){
throw
new
BadRequestHttpException
(
'没有找到要删除的记录'
);
}
else
if
(
$branchservice
->
delete
()
===
false
)
{
throw
new
ServerErrorHttpException
(
'Failed to delete the object for unknown reason.'
);
}
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
204
);
return
$branchservice
;
}
}
backend/models/v1/branch/BranchServiceType.php
0 → 100644
View file @
56d3c0f5
<?php
namespace
app\models\v1\branch
;
use
Yii
;
use
app\models\v1\BaseModel
;
use
yii\data\ActiveDataProvider
;
/**
* This is the model class for table "shop_branch_service_type".
*
* @property string $GUID
* @property string $ORG_GUID 组织机构号
* @property string $CODE 服务类目编号
* @property string $NAME 服务类目名称
* @property string $THEME_COLOR 主题颜色
* @property string $DESCRIPTION 服务类目描述
* @property string $CREATE_TIME 创建时间
*/
class
BranchServiceType
extends
BaseModel
{
/**
* {@inheritdoc}
*/
public
static
function
tableName
()
{
return
'shop_branch_service_type'
;
}
/**
* {@inheritdoc}
*/
public
function
rules
()
{
return
[
[[
'GUID'
],
'required'
,
'on'
=>
[
'create'
,
'update'
]],
[[
'CREATE_TIME'
],
'safe'
],
[[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'NAME'
],
'string'
,
'max'
=>
50
],
[[
'THEME_COLOR'
,
'DESCRIPTION'
],
'string'
,
'max'
=>
255
],
[[
'GUID'
],
'unique'
],
];
}
/**
* {@inheritdoc}
*/
public
function
attributeLabels
()
{
return
[
'GUID'
=>
'Guid'
,
'ORG_GUID'
=>
'Org Guid'
,
'CODE'
=>
'Code'
,
'NAME'
=>
'Name'
,
'THEME_COLOR'
=>
'Theme Color'
,
'DESCRIPTION'
=>
'Description'
,
'CREATE_TIME'
=>
'Create Time'
,
];
}
//门店-门店服务类目信息
public
function
BranchServiceInfo
(
$code
,
$name
)
{
$query
=
static
::
find
()
->
select
(
'GUID,NAME,CODE,THEME_COLOR,DESCRIPTION,CREATE_TIME'
);
if
(
isset
(
$name
)
&&
!
empty
(
$name
))
{
$query
->
andWhere
([
'like'
,
'NAME'
,
$name
]);
}
if
(
isset
(
$code
)
&&
!
empty
(
$code
))
{
$query
->
andWhere
([
'like'
,
'CODE'
,
$code
]);
}
return
new
ActiveDataProvider
(
[
'query'
=>
$query
->
asArray
(),
'pagination'
=>
[
'pageSize'
=>
15
,
]
]
);
}
}
\ 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