浏览代码

ログインユーザ作成 契約管理者作成ルートを追加

develop
sosuke.iwabuchi 2 年前
父节点
当前提交
63ccd527bb
共有 2 个文件被更改,包括 20 次插入4 次删除
  1. +16
    -4
      app/Http/Controllers/Web/LoginUser/CreateController.php
  2. +4
    -0
      app/Http/Controllers/Web/LoginUser/CreateParam.php

+ 16
- 4
app/Http/Controllers/Web/LoginUser/CreateController.php 查看文件

@@ -7,7 +7,9 @@ use App\Exceptions\AppCommonException;
use App\Features\LoginUser;
use App\Http\Controllers\Web\IParam;
use App\Http\Controllers\Web\WebController;
use App\Logic\User\ContractAdminUserManager;
use App\Logic\User\LoginUserManager;
use App\Logic\User\UserManager;
use App\Repositories\LoginUserRepository;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -17,19 +19,20 @@ class CreateController extends WebController

use LoginUser;

private UserManager $manager;

public function name(): string
{
return "ログインユーザー一覧取得";
return "ログインユーザー新規登録";
}

public function description(): string
{
return "ログインユーザー一覧を取得する";
return "ログインユーザーを新規登録する";
}

public function __construct(
protected CreateParam $param,
private LoginUserManager $manager
) {
parent::__construct();
$this->roleAllow(UserRole::CONTRACT_ADMIN);
@@ -44,11 +47,20 @@ class CreateController extends WebController
{
$param = $this->param;

// マネージャー起動
if ($param->role === UserRole::CONTRACT_ADMIN) {
if ($this->loginUser()->user()->role === UserRole::SUPER_ADMIN) {
$this->manager = new ContractAdminUserManager();
} else {
$this->unAuthorizedResponse();
}
} else {
$this->manager = new LoginUserManager();
}

try {
$this->transaction->beginTransaction();


$currentContract = $this->loginUser()->getCurrentContract();
if (!$currentContract) {
throw new AppCommonException("認証不正");


+ 4
- 0
app/Http/Controllers/Web/LoginUser/CreateParam.php 查看文件

@@ -2,14 +2,17 @@

namespace App\Http\Controllers\Web\LoginUser;

use App\Codes\UserRole;
use App\Http\Controllers\Web\BaseParam;
use App\Models\User;
use App\Rules\LoginPassword;
use Illuminate\Validation\Rules\Enum;

/**
* @property string $email
* @property string $name
* @property string $password
* @property ?UserRole $role
*/

class CreateParam extends BaseParam
@@ -21,6 +24,7 @@ class CreateParam extends BaseParam
User::COL_NAME_EMAIL => $this->str(['email:dns']),
User::COL_NAME_NAME => $this->str(),
User::COL_NAME_PASSWORD => $this->str([new LoginPassword()]),
User::COL_NAME_ROLE => $this->enum([new Enum(UserRole::class)], true),
];
}
}

正在加载...
取消
保存