148 lines
6.6 KiB
PHP
148 lines
6.6 KiB
PHP
<?php
|
||
|
||
namespace app\store\controller;
|
||
|
||
use app\common\controller\Definitions;
|
||
use app\common\lists\StoreStaffLists;
|
||
use app\common\logic\SystemStoreStaffLogic;
|
||
use hg\apidoc\annotation as ApiDoc;
|
||
|
||
#[ApiDoc\title('店员管理')]
|
||
class StaffController extends BaseAdminController
|
||
{
|
||
|
||
#[
|
||
ApiDoc\Title('列表'),
|
||
ApiDoc\url('/store/staff/lists'),
|
||
ApiDoc\Method('GET'),
|
||
ApiDoc\NotHeaders(),
|
||
ApiDoc\Author('中国队长'),
|
||
ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '店员名称/手机号/账号'),
|
||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||
ApiDoc\Query(ref: [Definitions::class, "page"]),
|
||
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
||
['name' => 'id', 'desc' => 'id', 'type' => 'int'],
|
||
['name' => 'staff_name', 'desc' => '店员名称', 'type' => 'string'],
|
||
['name' => 'avatar', 'desc' => '头像', 'type' => 'string'],
|
||
['name' => 'account', 'desc' => '账号', 'type' => 'string'],
|
||
['name' => 'phone', 'desc' => '手机号', 'type' => 'string'],
|
||
['name' => 'is_admin', 'desc' => '是否是管理员,1是,0不是', 'type' => 'int'],
|
||
['name' => 'is_manager', 'desc' => '是否是店长,1是,0不是', 'type' => 'int'],
|
||
]),
|
||
]
|
||
public function lists()
|
||
{
|
||
return $this->dataLists(new StoreStaffLists());
|
||
}
|
||
|
||
#[
|
||
ApiDoc\Title('添加'),
|
||
ApiDoc\url('/store/staff/add'),
|
||
ApiDoc\Method('POST'),
|
||
ApiDoc\NotHeaders(),
|
||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||
ApiDoc\Param(name: 'account', type: 'string', require: true, desc: '账号'),
|
||
ApiDoc\Param(name: 'pwd', type: 'string', require: true, desc: '密码'),
|
||
ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'),
|
||
ApiDoc\Param(name: 'staff_name', type: 'string', require: true, desc: '店员名称'),
|
||
ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'),
|
||
ApiDoc\Param(name: 'verify_status', type: 'string', require: true, desc: '核销开关,1开启,0关闭'),
|
||
ApiDoc\Param(name: 'order_status', type: 'string', require: true, desc: '订单状态,1开启,0关闭'),
|
||
ApiDoc\Param(name: 'is_manager', type: 'string', require: true, desc: '是否是店长,1是,0不是'),
|
||
ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'),
|
||
ApiDoc\ResponseSuccess("data", type: "array"),
|
||
]
|
||
public function add(SystemStoreStaffLogic $staffLogic)
|
||
{
|
||
$params = $this->request->post();
|
||
$staffLogic->add($params);
|
||
return $this->success('操作成功', [], 1, 1);
|
||
}
|
||
|
||
#[
|
||
ApiDoc\Title('编辑'),
|
||
ApiDoc\url('/store/staff/edit'),
|
||
ApiDoc\Method('POST'),
|
||
ApiDoc\NotHeaders(),
|
||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||
ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'),
|
||
ApiDoc\Param(name: 'account', type: 'string', require: true, desc: '账号'),
|
||
ApiDoc\Param(name: 'pwd', type: 'string', require: true, desc: '密码'),
|
||
ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'),
|
||
ApiDoc\Param(name: 'staff_name', type: 'string', require: true, desc: '店员名称'),
|
||
ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'),
|
||
ApiDoc\Param(name: 'verify_status', type: 'string', require: true, desc: '核销开关,1开启,0关闭'),
|
||
ApiDoc\Param(name: 'order_status', type: 'string', require: true, desc: '订单状态,1开启,0关闭'),
|
||
ApiDoc\Param(name: 'is_manager', type: 'string', require: true, desc: '是否是店长,1是,0不是'),
|
||
ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'),
|
||
ApiDoc\ResponseSuccess("data", type: "array"),
|
||
]
|
||
public function edit(SystemStoreStaffLogic $staffLogic)
|
||
{
|
||
$id = $this->request->post('id');
|
||
$params = $this->request->post();
|
||
$staffLogic->edit($id, $params);
|
||
return $this->success('操作成功', [], 1, 1);
|
||
}
|
||
|
||
#[
|
||
ApiDoc\Title('删除'),
|
||
ApiDoc\url('/store/staff/delete'),
|
||
ApiDoc\Method('POST'),
|
||
ApiDoc\NotHeaders(),
|
||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||
ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'),
|
||
ApiDoc\ResponseSuccess("data", type: "array"),
|
||
]
|
||
public function delete(SystemStoreStaffLogic $staffLogic)
|
||
{
|
||
$id = $this->request->post('id');
|
||
$staffLogic->delete($id);
|
||
return $this->success('操作成功', [], 1, 1);
|
||
}
|
||
|
||
#[
|
||
ApiDoc\Title('详情'),
|
||
ApiDoc\url('/store/staff/detail'),
|
||
ApiDoc\Method('GET'),
|
||
ApiDoc\NotHeaders(),
|
||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||
ApiDoc\Query(name: 'id', type: 'int', require: true, desc: 'id'),
|
||
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
||
['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
|
||
['name' => 'account', 'desc' => '账号', 'type' => 'string'],
|
||
['name' => 'avatar', 'desc' => '头像', 'type' => 'string'],
|
||
['name' => 'staff_name', 'desc' => '店员名称', 'type' => 'string'],
|
||
['name' => 'phone', 'desc' => '手机号', 'type' => 'string'],
|
||
['name' => 'verify_status', 'desc' => '核销开关,1开启,0关闭', 'type' => 'int'],
|
||
['name' => 'order_status', 'desc' => '订单状态,1开启,0关闭', 'type' => 'int'],
|
||
['name' => 'is_admin', 'desc' => '是否管理员,1是,0不是', 'type' => 'int'],
|
||
['name' => 'is_manager', 'desc' => '是否是店长,1是,0不是', 'type' => 'int'],
|
||
['name' => 'status', 'desc' => '状态,1启用,0禁用', 'type' => 'int'],
|
||
]),
|
||
]
|
||
public function detail(SystemStoreStaffLogic $staffLogic)
|
||
{
|
||
$id = $this->request->get('id');
|
||
$data = $staffLogic->detail($id);
|
||
return $this->data($data);
|
||
}
|
||
|
||
#[
|
||
ApiDoc\Title('开启/关闭'),
|
||
ApiDoc\url('/store/staff/status'),
|
||
ApiDoc\Method('POST'),
|
||
ApiDoc\NotHeaders(),
|
||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||
ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'),
|
||
ApiDoc\ResponseSuccess("data", type: "array"),
|
||
]
|
||
public function status(SystemStoreStaffLogic $logic)
|
||
{
|
||
$id = $this->request->post('id');
|
||
$logic->status($id);
|
||
return $this->success('操作成功', [], 1, 1);
|
||
}
|
||
|
||
}
|