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
669c2fb5
Commit
669c2fb5
authored
Nov 13, 2019
by
姚书霞
🐘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户组接口
parent
0c0f0d0b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
26 deletions
+36
-26
urlmanager.php
backend/config/urlmanager.php
+5
-0
ShopUserMembergradeController.php
...controllers/v1/shopuser/ShopUserMembergradeController.php
+31
-26
No files found.
backend/config/urlmanager.php
View file @
669c2fb5
...
@@ -26,6 +26,11 @@ return [
...
@@ -26,6 +26,11 @@ return [
'GET,OPTIONS user-complain'
=>
'user-complain'
,
'GET,OPTIONS user-complain'
=>
'user-complain'
,
'GET employee-info'
=>
'employee-info'
,
'GET employee-info'
=>
'employee-info'
,
'GET employee-list'
=>
'employee-list'
,
'GET employee-list'
=>
'employee-list'
,
'GET,OPTIONS list'
=>
'list'
,
'GET,OPTIONS one'
=>
'one'
,
'PUT,OPTIONS revise'
=>
'revise'
,
'POST,OPTIONS add'
=>
'add'
,
'DELETE,OPTIONS del'
=>
'del'
,
],
],
],
],
'GET swaggers/swagger/<id>'
=>
'swagger/swagger'
,
'GET swaggers/swagger/<id>'
=>
'swagger/swagger'
,
...
...
backend/controllers/v1/shopuser/ShopUserMembergradeController.php
View file @
669c2fb5
...
@@ -6,27 +6,28 @@ use Yii;
...
@@ -6,27 +6,28 @@ use Yii;
use
backend\controllers\v1\BaseController
;
use
backend\controllers\v1\BaseController
;
use
backend\helpers\Func
;
use
backend\helpers\Func
;
use
yii\data\ActiveDataProvider
;
use
yii\data\ActiveDataProvider
;
use
yii\web\BadRequestHttpException
;
use
yii\web\ServerErrorHttpException
;
class
ShopUserMembergradeController
extends
BaseController
class
ShopUserMembergradeController
extends
BaseController
{
{
public
$modelClass
=
'app\models\v1\shopuser\ShopUserMembergrade'
;
public
$modelClass
=
'app\models\v1\shopuser\ShopUserMembergrade'
;
//重定义action方法
//重定义action方法
public
function
actions
()
//
public function actions()
{
//
{
$actions
=
parent
::
actions
();
//
$actions = parent::actions();
// 重写 "create" 动作
//
// 重写 "create" 动作
unset
(
//
unset(
$actions
[
'create'
],
$actions
[
'update'
],
$actions
[
'view'
],
$actions
[
'index'
]
//
$actions['create'],$actions['update'],$actions['view'],$actions['index']
);
//
);
return
$actions
;
//
return $actions;
}
//
}
/**
/**
* @OA\Get(
* @OA\Get(
* path="/backend/web/v1/shopuser/shop-user-membergrades",
* path="/backend/web/v1/shopuser/shop-user-membergrades
/list
",
* tags={"用户&员工接口"},
* tags={"用户&员工接口"},
* summary="用户组列表接口(姚书侠)",
* summary="用户组列表接口(姚书侠)",
* description="用户组列表接口",
* description="用户组列表接口",
...
@@ -37,7 +38,7 @@ class ShopUserMembergradeController extends BaseController
...
@@ -37,7 +38,7 @@ class ShopUserMembergradeController extends BaseController
* )
* )
*/
*/
//重写index
//重写index
public
function
action
Index
()
public
function
action
List
()
{
{
$requestParams
=
Yii
::
$app
->
getRequest
()
->
get
();
$requestParams
=
Yii
::
$app
->
getRequest
()
->
get
();
$query
=
$this
->
modelClass
::
find
();
$query
=
$this
->
modelClass
::
find
();
...
@@ -51,25 +52,26 @@ class ShopUserMembergradeController extends BaseController
...
@@ -51,25 +52,26 @@ class ShopUserMembergradeController extends BaseController
/**
/**
* @OA\Get(
* @OA\Get(
* path="/backend/web/v1/shopuser/shop-user-membergrades/
{id}
",
* path="/backend/web/v1/shopuser/shop-user-membergrades/
one
",
* tags={"用户&员工接口"},
* tags={"用户&员工接口"},
* summary="用户组详情接口(姚书侠)",
* summary="用户组详情接口(姚书侠)",
* description="用户组详情接口",
* description="用户组详情接口",
* @OA\Parameter(name="
id",in="path
",required=true,description="用户组id",@OA\Schema(type="string")),
* @OA\Parameter(name="
guid",in="query
",required=true,description="用户组id",@OA\Schema(type="string")),
* @OA\Response(response = 200,description = "success"),
* @OA\Response(response = 200,description = "success"),
* security={{"Authorization": {}}}
* security={{"Authorization": {}}}
* )
* )
*/
*/
//编辑用
//编辑用
public
function
action
View
(
$id
)
public
function
action
One
(
)
{
{
$model
=
$this
->
modelClass
::
findOne
(
$id
);
$guid
=
Yii
::
$app
->
getRequest
()
->
get
(
'guid'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
return
$model
;
return
$model
;
}
}
/**
/**
* @OA\POST(
* @OA\POST(
* path="/backend/web/v1/shopuser/shop-user-membergrades",
* path="/backend/web/v1/shopuser/shop-user-membergrades
/add
",
* tags={"用户&员工接口"},
* tags={"用户&员工接口"},
* summary="添加用户组接口(姚书侠)",
* summary="添加用户组接口(姚书侠)",
* description="添加用户组接口",
* description="添加用户组接口",
...
@@ -87,18 +89,17 @@ class ShopUserMembergradeController extends BaseController
...
@@ -87,18 +89,17 @@ class ShopUserMembergradeController extends BaseController
* )
* )
* )
* )
* ),
* ),
* @OA\Response(response=200,description="
成功时返回access-token
"),
* @OA\Response(response=200,description="
success
"),
* security={{"Authorization": {}}}
* security={{"Authorization": {}}}
* )
* )
*/
*/
public
function
action
Create
()
public
function
action
Add
()
{
{
$model
=
new
$this
->
modelClass
();
$model
=
new
$this
->
modelClass
();
$model
->
scenario
=
'create'
;
//创建的场景
$model
->
scenario
=
'create'
;
//创建的场景
$other_param
=
array
(
$other_param
=
array
(
'GUID'
=>
Func
::
create_guid
(),
'GUID'
=>
Func
::
create_guid
(),
'ORG_GUID'
=>
'100'
,
//todo 公共变量
'ORG_GUID'
=>
Yii
::
$app
->
user
->
identity
->
ORG_GUID
,
);
);
$model
->
setAttributes
(
$other_param
);
$model
->
setAttributes
(
$other_param
);
...
@@ -107,7 +108,7 @@ class ShopUserMembergradeController extends BaseController
...
@@ -107,7 +108,7 @@ class ShopUserMembergradeController extends BaseController
// print_r($model);die;
// print_r($model);die;
if
(
$model
->
save
())
{
if
(
$model
->
save
())
{
$response
=
Yii
::
$app
->
getResponse
();
$response
=
Yii
::
$app
->
getResponse
();
$response
->
setStatusCode
(
20
0
);
$response
->
setStatusCode
(
20
1
);
}
elseif
(
!
$model
->
hasErrors
())
{
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to create the object for unknown reason.'
);
throw
new
ServerErrorHttpException
(
'Failed to create the object for unknown reason.'
);
}
}
...
@@ -116,17 +117,17 @@ class ShopUserMembergradeController extends BaseController
...
@@ -116,17 +117,17 @@ class ShopUserMembergradeController extends BaseController
/**
/**
* @OA\PUT(
* @OA\PUT(
* path="/backend/web/v1/shopuser/shop-user-membergrades/
{id}
",
* path="/backend/web/v1/shopuser/shop-user-membergrades/
revise
",
* tags={"用户&员工接口"},
* tags={"用户&员工接口"},
* summary="修改用户组接口(姚书侠)",
* summary="修改用户组接口(姚书侠)",
* description="修改用户组接口",
* description="修改用户组接口",
* @OA\Parameter(name="id",in="path",required=true,description="用户组id", @OA\Schema(type="string")),
* @OA\RequestBody(
* @OA\RequestBody(
* required=true,
* required=true,
* @OA\MediaType(
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* @OA\Schema(
* type="object",
* type="object",
* @OA\Property(property="GUID",description="要修改的用户组GUID",type="string"),
* @OA\Property(property="NAME",description="用户组名称,最长20字",type="string"),
* @OA\Property(property="NAME",description="用户组名称,最长20字",type="string"),
* @OA\Property(property="IS_DEFAULT",description="是否默认用户组 0否1是",type="string"),
* @OA\Property(property="IS_DEFAULT",description="是否默认用户组 0否1是",type="string"),
* @OA\Property(property="GRADE_PERCENT",description="优惠百分比 浮点型",type="string"),
* @OA\Property(property="GRADE_PERCENT",description="优惠百分比 浮点型",type="string"),
...
@@ -139,9 +140,13 @@ class ShopUserMembergradeController extends BaseController
...
@@ -139,9 +140,13 @@ class ShopUserMembergradeController extends BaseController
* security={{"Authorization": {}}}
* security={{"Authorization": {}}}
* )
* )
*/
*/
public
function
action
Update
(
$id
)
public
function
action
Revise
(
)
{
{
$model
=
$this
->
modelClass
::
findOne
(
$id
);
$guid
=
Yii
::
$app
->
getRequest
()
->
post
(
'GUID'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到要修改的记录'
);
}
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
...
...
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