multi-store/app/store/controller/auth/AdminController.php

144 lines
5.0 KiB
PHP
Raw Normal View History

2024-06-01 16:07:53 +08:00
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\store\controller\auth;
use app\store\controller\BaseAdminController;
use app\store\lists\auth\AdminLists;
use app\store\validate\auth\AdminValidate;
use app\store\logic\auth\AdminLogic;
use app\store\validate\auth\editSelfValidate;
/**
* 管理员控制器
* Class AdminController
* @package app\store\controller\auth
*/
2024-06-14 15:53:47 +08:00
// #[ApiDoc\title('管理员信息')]
2024-06-01 16:07:53 +08:00
class AdminController extends BaseAdminController
{
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title("查看管理员列表"),
// ApiDoc\url('/store/auth/admin/lists'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-01 16:07:53 +08:00
public function lists()
{
return $this->dataLists(new AdminLists());
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title("添加管理员"),
// ApiDoc\url('/store/auth/admin/add'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-01 16:07:53 +08:00
public function add()
{
$params = (new AdminValidate())->post()->goCheck('add');
$result = AdminLogic::add($params);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(AdminLogic::getError());
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title("编辑管理员"),
// ApiDoc\url('/store/auth/admin/edit'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-01 16:07:53 +08:00
public function edit()
{
$params = (new AdminValidate())->post()->goCheck('edit');
$result = AdminLogic::edit($params);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(AdminLogic::getError());
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title("删除管理员"),
// ApiDoc\url('/store/auth/admin/delete'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-01 16:07:53 +08:00
public function delete()
{
$params = (new AdminValidate())->post()->goCheck('delete');
$result = AdminLogic::delete($params);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(AdminLogic::getError());
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title("查看管理员详情"),
// ApiDoc\url('/store/auth/admin/detail'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-01 16:07:53 +08:00
public function detail()
{
$params = (new AdminValidate())->goCheck('detail');
$result = AdminLogic::detail($params);
return $this->data($result);
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title("获取当前管理员信息"),
// ApiDoc\url('/store/auth/admin/mySelf'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-01 16:07:53 +08:00
public function mySelf()
{
$result = AdminLogic::detail(['id' => $this->adminId], 'auth');
return $this->data($result);
}
2024-06-14 15:53:47 +08:00
// #[
// ApiDoc\Title("编辑超级管理员信息"),
// ApiDoc\url('/store/auth/admin/editSelf'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
2024-06-01 16:07:53 +08:00
public function editSelf()
{
$params = (new editSelfValidate())->post()->goCheck('', ['admin_id' => $this->adminId]);
$result = AdminLogic::editSelf($params);
return $this->success('操作成功', [], 1, 1);
}
}