73 lines
1.6 KiB
PHP
73 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Admin;
|
|
|
|
use App\Exception\AdminException;
|
|
use App\Extend\StringUtil;
|
|
use App\Model\AdminUser;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
|
class EmployeeService extends BaseService
|
|
{
|
|
/**
|
|
* 注入用户模型
|
|
* @var AdminUser $adminUserModel
|
|
*/
|
|
#[Inject]
|
|
protected AdminUser $adminUserModel;
|
|
|
|
public function handle()
|
|
{
|
|
return $this->return->success();
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$name = $this->request->input('chinese_name');
|
|
$account = $this->request->input('account');
|
|
|
|
$oldAccount = $this->adminUserModel->getAdminInfoByAccount($account);
|
|
$oldName = $this->adminUserModel->getAdminInfoByName($name);
|
|
|
|
if (!empty($oldName) && !empty($oldAccount)) throw new AdminException('账号或者员工已存在');
|
|
|
|
$salt = StringUtil::randStr(6);
|
|
|
|
$model = new AdminUser();
|
|
|
|
$model->username = $account;
|
|
$model->chinese_name = $name;
|
|
$model->salt =
|
|
$model->status = $this->request->input('status', 1);
|
|
$model->avatar = $this->request->input('avatar',0);
|
|
$model->role_id = $this->request->input('role_id', 0);
|
|
|
|
|
|
$model->save();
|
|
|
|
return $this->return->success();
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
return $this->return->success();
|
|
}
|
|
|
|
public function delete()
|
|
{
|
|
return $this->return->success();
|
|
}
|
|
|
|
public function get()
|
|
{
|
|
return $this->return->success();
|
|
}
|
|
} |