Files
douba_shop/app/controller/supplier/system/SupplierAdmin.php
Karlcarlo c9a98f342c chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材
添加系统版本配置文件(.version)和常量定义文件(.constant)
更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件
添加验证码配置文件(captcha.php)和.gitignore规则
2026-03-06 20:14:23 +08:00

175 lines
4.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\supplier\system;
use app\controller\supplier\AuthController;
use app\services\supplier\SystemSupplierServices;
use app\services\system\admin\SystemAdminServices;
use think\annotation\Inject;
/**
* Class SystemAdmin
* @package app\controller\admin\v1\setting
*/
class SupplierAdmin extends AuthController
{
/**
* @var SystemSupplierServices
*/
#[Inject]
protected SystemSupplierServices $services;
/**
* @var SystemAdminServices
*/
#[Inject]
protected SystemAdminServices $adminServices;
/**
* 显示管理员资源列表
*
* @return \think\Response
*/
public function index()
{
$where = [
'is_del' => 1,
'admin_type' => 4,
'relation_id' => $this->supplierId,
'level' => 1
];
return $this->success($this->adminServices->getAdminList($where));
}
/**
* 创建表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return $this->success($this->adminServices->createForm(0, '/admin'));
}
/**
* 保存管理员
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['account', ''],
['phone', ''],
['conf_pwd', ''],
['pwd', ''],
['real_name', ''],
['phone', ''],
['roles', []],
['status', 0],
['head_pic', ''],
]);
$this->validate($data, \app\validate\admin\setting\SystemAdminValidate::class, 'supplier_save');
$data['admin_type'] = 4;
$data['relation_id'] = $this->supplierId;
if ($this->adminServices->create($data)) {
return $this->success('添加成功');
} else {
return $this->fail('添加失败');
}
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit(int $id)
{
if (!$id) {
return $this->fail('管理员信息读取失败');
}
return $this->success($this->adminServices->updateForm(0, (int)$id, '/admin/'));
}
/**
* 更新管理员
* @param int $id
* @return mixed
*/
public function update(int $id)
{
$data = $this->request->postMore([
['account', ''],
['phone', ''],
['conf_pwd', ''],
['pwd', ''],
['real_name', ''],
['phone', ''],
['roles', []],
['status', 0],
['head_pic', ''],
]);
$this->validate($data, \app\validate\admin\setting\SystemAdminValidate::class, 'supplier_update');
if ($this->adminServices->save($id, $data)) {
return $this->success('修改成功');
} else {
return $this->fail('修改失败');
}
}
/**
* 管理员详情
* @param int $id
* @return mixed
*/
public function read(int $id)
{
$info = $this->adminServices->get($id);
if (!$info) {
return $this->fail('获取失败');
}
return $this->success($info->toArray());
}
/**
* 删除管理员
* @param int $id
* @return void
*/
public function delete(int $id)
{
if (!$id) {
return $this->fail('删除失败,缺少参数');
}
if ($this->adminServices->update($id, ['is_del' => 1, 'status' => 0])) {
return $this->success('删除成功!');
} else {
return $this->fail('删除失败');
}
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
$this->adminServices->update((int)$id, ['status' => $status]);
return $this->success($status == 0 ? '关闭成功' : '开启成功');
}
}