This commit is contained in:
zhang zhuo 2026-01-25 20:38:36 +08:00
parent 79acf74445
commit 79d55ef669
8 changed files with 52 additions and 52 deletions

View File

@ -72,7 +72,7 @@ class System extends Base
#[Auth(needAuth: false, auth: "menu:add")] #[Auth(needAuth: false, auth: "menu:add")]
public function menuAdd() public function menuAdd()
{ {
$data = Param::only(['pid' => 0, 'title' => '', 'account_type' => 1, 'type' => 0, 'method', 'flag', 'name', $data = Param::only(['parent_id' => 0, 'title' => '', 'account_type' => 1, 'type' => 0, 'method', 'flag', 'name',
'path', 'icon', 'rank', 'hidden', 'remark' 'path', 'icon', 'rank', 'hidden', 'remark'
], $this->request->post()); ], $this->request->post());
$request = $this->container->get(mRequest::class); $request = $this->container->get(mRequest::class);
@ -85,7 +85,7 @@ class System extends Base
#[Auth(needAuth: false, auth: "menu:edit")] #[Auth(needAuth: false, auth: "menu:edit")]
public function menuEdit() public function menuEdit()
{ {
$data = Param::only(['pid' => 0, 'title' => '', 'account_type' => 1, 'type' => 0, 'method', 'flag', 'name', $data = Param::only(['parent_id' => 0, 'title' => '', 'account_type' => 1, 'type' => 0, 'method', 'flag', 'name',
'path', 'icon', 'rank', 'hidden', 'remark', 'menu_id' => 0 'path', 'icon', 'rank', 'hidden', 'remark', 'menu_id' => 0
], $this->request->post()); ], $this->request->post());
$request = $this->container->get(mRequest::class); $request = $this->container->get(mRequest::class);
@ -106,7 +106,7 @@ class System extends Base
#[Auth(needAuth: false, auth: "menu:quick")] #[Auth(needAuth: false, auth: "menu:quick")]
public function menuQuickAdd() public function menuQuickAdd()
{ {
$data = Param::only(['pid' => 0, 'title' => '', 'flag', 'name', 'path', 'icon', 'account_type' => 1], $this->request->post()); $data = Param::only(['parent_id' => 0, 'title' => '', 'flag', 'name', 'path', 'icon', 'account_type' => 1], $this->request->post());
$request = $this->container->get(mRequest::class); $request = $this->container->get(mRequest::class);
$request->scene('quick')->validateResolved(); $request->scene('quick')->validateResolved();
$res = mModel::quickAdd($data); $res = mModel::quickAdd($data);
@ -134,7 +134,7 @@ class System extends Base
{ {
$request = $this->container->get(dRequest::class); $request = $this->container->get(dRequest::class);
$request->scene('add')->validateResolved(); $request->scene('add')->validateResolved();
$data = Param::only(['dept_name' => '', 'pid' => 0, 'rank', 'status' => 1]); $data = Param::only(['dept_name' => '', 'parent_id' => 0, 'rank', 'status' => 1]);
$data['belong_id'] = $this->account()['belong_id']; $data['belong_id'] = $this->account()['belong_id'];
$data['account_type'] = $this->account()['account_type']; $data['account_type'] = $this->account()['account_type'];
$res = dModel::add($data); $res = dModel::add($data);
@ -147,7 +147,7 @@ class System extends Base
{ {
$request = $this->container->get(dRequest::class); $request = $this->container->get(dRequest::class);
$request->scene('edit')->validateResolved(); $request->scene('edit')->validateResolved();
$data = Param::only(['dept_id' => '', 'dept_name' => '', 'pid' => 0, 'rank', 'status' => 1]); $data = Param::only(['dept_id' => '', 'dept_name' => '', 'parent_id' => 0, 'rank', 'status' => 1]);
$res = dModel::edit($data); $res = dModel::edit($data);
return $res ? $this->success("操作成功") : $this->error("操作失败"); return $res ? $this->success("操作成功") : $this->error("操作失败");
} }
@ -482,7 +482,7 @@ class System extends Base
{ {
$request = $this->container->get(acRequest::class); $request = $this->container->get(acRequest::class);
$request->scene('add')->validateResolved(); $request->scene('add')->validateResolved();
$data = Param::only(["category_name", "pid" => 0, "rank", "type" => "image"]); $data = Param::only(["category_name", "parent_id" => 0, "rank", "type" => "image"]);
$data['belong_id'] = $this->account()['belong_id']; $data['belong_id'] = $this->account()['belong_id'];
$data['account_type'] = $this->account()['account_type']; $data['account_type'] = $this->account()['account_type'];
return $this->toAjax(acModel::add($data)); return $this->toAjax(acModel::add($data));
@ -494,7 +494,7 @@ class System extends Base
{ {
$request = $this->container->get(acRequest::class); $request = $this->container->get(acRequest::class);
$request->scene('edit')->validateResolved(); $request->scene('edit')->validateResolved();
$data = Param::only(["category_id", "category_name", "pid" => 0, "rank", "type" => "image"]); $data = Param::only(["category_id", "category_name", "parent_id" => 0, "rank", "type" => "image"]);
return $this->toAjax(acModel::edit($data)); return $this->toAjax(acModel::edit($data));
} }

View File

@ -78,7 +78,7 @@ class Account extends Model
public static function getMenu(array $account) public static function getMenu(array $account)
{ {
// 总后台账号 // 总后台账号
$field = ['m.title', 'm.path', 'm.pid', 'm.name', 'm.menu_id', 'm.icon', 'm.hidden', 'm.type']; $field = ['m.title', 'm.path', 'm.parent_id', 'm.name', 'm.menu_id', 'm.icon', 'm.hidden', 'm.type'];
// 获取角色 // 获取角色
$roles = match ($account['account_type']) { $roles = match ($account['account_type']) {
0 => ["ADMIN"], 0 => ["ADMIN"],

View File

@ -9,7 +9,7 @@ namespace App\Model;
* @property string $category_name * @property string $category_name
* @property int $account_type * @property int $account_type
* @property int $belong_id * @property int $belong_id
* @property int $pid * @property int $parent_id
* @property string $type * @property string $type
* @property int $rank * @property int $rank
* @property string $create_time * @property string $create_time
@ -33,7 +33,7 @@ class AssetCategory extends Model
/** /**
* The attributes that should be cast to native types. * The attributes that should be cast to native types.
*/ */
protected array $casts = ['category_id' => 'integer', 'account_type' => 'integer', 'belong_id' => 'integer', 'pid' => 'integer', 'rank' => 'integer']; protected array $casts = ['category_id' => 'integer', 'account_type' => 'integer', 'belong_id' => 'integer', 'parent_id' => 'integer', 'rank' => 'integer'];
public static function list(array $param) public static function list(array $param)
{ {
@ -48,7 +48,7 @@ class AssetCategory extends Model
$model = $model->where('type', $param['type']); $model = $model->where('type', $param['type']);
} }
return $model return $model
->select(["category_id", "category_name", "pid"]) ->select(["category_id", "category_name", "parent_id"])
->get(); ->get();
} }
} }

View File

@ -6,7 +6,7 @@ namespace App\Model;
/** /**
* @property int $dept_id * @property int $dept_id
* @property int $pid * @property int $parent_id
* @property int $belong_id * @property int $belong_id
* @property int $account_type * @property int $account_type
* @property string $dept_name * @property string $dept_name
@ -39,7 +39,7 @@ class Dept extends Model
* *
* @var array * @var array
*/ */
protected array $casts = ['dept_id' => 'integer', 'pid' => 'integer', 'belong_id' => 'integer', 'account_type' => 'integer', 'status' => 'integer', 'rank' => 'integer', 'del_flag' => 'integer']; protected array $casts = ['dept_id' => 'integer', 'parent_id' => 'integer', 'belong_id' => 'integer', 'account_type' => 'integer', 'status' => 'integer', 'rank' => 'integer', 'del_flag' => 'integer'];
public static function list(int $belong_id, int $account_type, string $dept_name) public static function list(int $belong_id, int $account_type, string $dept_name)
{ {
@ -49,7 +49,7 @@ class Dept extends Model
$model = $model->where('dept_name', "like", "%$dept_name%"); $model = $model->where('dept_name', "like", "%$dept_name%");
} }
return $model->orderByDesc("rank") return $model->orderByDesc("rank")
->select(["dept_id", "pid", "dept_name", "rank", "status", "create_time"]) ->select(["dept_id", "parent_id", "dept_name", "rank", "status", "create_time"])
->get()->toArray(); ->get()->toArray();
} }
@ -59,17 +59,17 @@ class Dept extends Model
->where('account_type', $account_type) ->where('account_type', $account_type)
->where("status", 1) ->where("status", 1)
->orderByDesc("rank") ->orderByDesc("rank")
->select(["dept_id", "pid", "dept_name"]) ->select(["dept_id", "parent_id", "dept_name"])
->get()->toArray(); ->get()->toArray();
} }
public static function getTop(int $dept_id, array &$depts) public static function getTop(int $dept_id, array &$depts)
{ {
$info = self::select(["dept_name", "pid", "dept_id"])->find($dept_id); $info = self::select(["dept_name", "parent_id", "dept_id"])->find($dept_id);
if (!empty($info)) { if (!empty($info)) {
$depts[] = $info; $depts[] = $info;
if ($info['pid'] != 0) { if ($info['parent_id'] != 0) {
self::getTop($info['pid'], $depts); self::getTop($info['parent_id'], $depts);
} }
} }
} }

View File

@ -9,7 +9,7 @@ use Hyperf\DbConnection\Db;
/** /**
* @property int $menu_id * @property int $menu_id
* @property int $pid * @property int $parent_id
* @property string $title * @property string $title
* @property int $account_type * @property int $account_type
* @property int $type * @property int $type
@ -42,7 +42,7 @@ class Menu extends Model
/** /**
* The attributes that should be cast to native types. * The attributes that should be cast to native types.
*/ */
protected array $casts = ['menu_id' => 'integer', 'pid' => 'integer', 'account_type' => 'integer', 'type' => 'integer', 'rank' => 'integer', 'hidden' => 'integer']; protected array $casts = ['menu_id' => 'integer', 'parent_id' => 'integer', 'account_type' => 'integer', 'type' => 'integer', 'rank' => 'integer', 'hidden' => 'integer'];
/** /**
* 根据账号类型获取权限(主账号) * 根据账号类型获取权限(主账号)
@ -202,7 +202,7 @@ class Menu extends Model
{ {
return self::where('account_type', $account_type) return self::where('account_type', $account_type)
->orderByDesc("rank") ->orderByDesc("rank")
->select(["menu_id", "title", "flag", "pid", "type", "method", "name", "path", "icon", "rank", "hidden", "account_type"]) ->select(["menu_id", "title", "flag", "parent_id", "type", "method", "name", "path", "icon", "rank", "hidden", "account_type"])
->groupBy(["menu_id"]) ->groupBy(["menu_id"])
->get() ->get()
->toArray(); ->toArray();
@ -212,32 +212,32 @@ class Menu extends Model
{ {
Db::beginTransaction(); Db::beginTransaction();
// 1.菜单 // 1.菜单
$data1 = ['pid' => $data['pid'], 'title' => $data['title'] . "管理", 'account_type' => $data['account_type'], 'type' => 0, 'name' => $data['name'], 'path' => $data['path'], 'icon' => $data['icon']]; $data1 = ['parent_id' => $data['parent_id'], 'title' => $data['title'] . "管理", 'account_type' => $data['account_type'], 'type' => 0, 'name' => $data['name'], 'path' => $data['path'], 'icon' => $data['icon']];
$pid = self::add($data1); $parent_id = self::add($data1);
// 2.添加按钮 // 2.添加按钮
$data2 = ['pid' => $pid, 'title' => $data['title'] . '添加', 'account_type' => $data1['account_type'], 'type' => 1, 'flag' => $data['flag'] . ":add"]; $data2 = ['parent_id' => $parent_id, 'title' => $data['title'] . '添加', 'account_type' => $data1['account_type'], 'type' => 1, 'flag' => $data['flag'] . ":add"];
$pid2 = self::add($data2); $parent_id2 = self::add($data2);
// 3.添加接口 // 3.添加接口
$data3 = ['pid' => $pid2, 'title' => $data['title'] . '添加', 'account_type' => $data1['account_type'], 'type' => 2, 'flag' => $data['flag'] . ":add", 'method' => 'post']; $data3 = ['parent_id' => $parent_id2, 'title' => $data['title'] . '添加', 'account_type' => $data1['account_type'], 'type' => 2, 'flag' => $data['flag'] . ":add", 'method' => 'post'];
$pid3 = self::add($data3); $parent_id3 = self::add($data3);
// 4.修改按钮 // 4.修改按钮
$data2 = ['pid' => $pid, 'title' => $data['title'] . '修改', 'account_type' => $data1['account_type'], 'type' => 1, 'flag' => $data['flag'] . ":edit"]; $data2 = ['parent_id' => $parent_id, 'title' => $data['title'] . '修改', 'account_type' => $data1['account_type'], 'type' => 1, 'flag' => $data['flag'] . ":edit"];
$pid2 = self::add($data2); $parent_id2 = self::add($data2);
// 5.修改接口 // 5.修改接口
$data3 = ['pid' => $pid2, 'title' => $data['title'] . '修改', 'account_type' => $data1['account_type'], 'type' => 2, 'flag' => $data['flag'] . ":edit", 'method' => 'put']; $data3 = ['parent_id' => $parent_id2, 'title' => $data['title'] . '修改', 'account_type' => $data1['account_type'], 'type' => 2, 'flag' => $data['flag'] . ":edit", 'method' => 'put'];
$pid3 = self::add($data3); $parent_id3 = self::add($data3);
// 6.删除按钮 // 6.删除按钮
$data2 = ['pid' => $pid, 'title' => $data['title'] . '删除', 'account_type' => $data1['account_type'], 'type' => 1, 'flag' => $data['flag'] . ":del"]; $data2 = ['parent_id' => $parent_id, 'title' => $data['title'] . '删除', 'account_type' => $data1['account_type'], 'type' => 1, 'flag' => $data['flag'] . ":del"];
$pid2 = self::add($data2); $parent_id2 = self::add($data2);
// 7.删除接口 // 7.删除接口
$data3 = ['pid' => $pid2, 'title' => $data['title'] . '删除', 'account_type' => $data1['account_type'], 'type' => 2, 'flag' => $data['flag'] . ":del", 'method' => 'delete']; $data3 = ['parent_id' => $parent_id2, 'title' => $data['title'] . '删除', 'account_type' => $data1['account_type'], 'type' => 2, 'flag' => $data['flag'] . ":del", 'method' => 'delete'];
$pid3 = self::add($data3); $parent_id3 = self::add($data3);
// 8.列表接口 // 8.列表接口
$data3 = ['pid' => $pid, 'title' => $data['title'] . '列表', 'account_type' => $data1['account_type'], 'type' => 2, 'flag' => $data['flag'] . ":list", 'method' => 'get']; $data3 = ['parent_id' => $parent_id, 'title' => $data['title'] . '列表', 'account_type' => $data1['account_type'], 'type' => 2, 'flag' => $data['flag'] . ":list", 'method' => 'get'];
$pid3 = self::add($data3); $parent_id3 = self::add($data3);
// 9.选择接口 // 9.选择接口
$data3 = ['pid' => $pid, 'title' => $data['title'] . '选项', 'account_type' => $data1['account_type'], 'type' => 2, 'flag' => $data['flag'] . ":option", 'method' => 'get']; $data3 = ['parent_id' => $parent_id, 'title' => $data['title'] . '选项', 'account_type' => $data1['account_type'], 'type' => 2, 'flag' => $data['flag'] . ":option", 'method' => 'get'];
$pid3 = self::add($data3); $parent_id3 = self::add($data3);
Db::commit(); Db::commit();
return true; return true;
} }

View File

@ -7,8 +7,8 @@ use Hyperf\Validation\Request\FormRequest;
class AssetCategory extends FormRequest class AssetCategory extends FormRequest
{ {
protected array $scenes = [ protected array $scenes = [
'add' => ["category_name", "pid", "rank"], 'add' => ["category_name", "parent_id", "rank"],
'edit' => ["category_name", "pid", "rank", "category_id"], 'edit' => ["category_name", "parent_id", "rank", "category_id"],
]; ];
/** /**
@ -29,7 +29,7 @@ class AssetCategory extends FormRequest
'category_name' => 'required', 'category_name' => 'required',
'account_type' => 'required', 'account_type' => 'required',
'belong_id' => 'required', 'belong_id' => 'required',
'pid' => 'required', 'parent_id' => 'required',
'rank' => 'required', 'rank' => 'required',
'create_time' => 'required', 'create_time' => 'required',
'update_time' => 'required', 'update_time' => 'required',
@ -41,7 +41,7 @@ class AssetCategory extends FormRequest
{ {
return [ return [
'category_name.required' => '分类名称必传!', 'category_name.required' => '分类名称必传!',
'pid.required' => '上级分类必传!', 'parent_id.required' => '上级分类必传!',
'rank.required' => '排序必传!', 'rank.required' => '排序必传!',
]; ];
} }

View File

@ -10,8 +10,8 @@ use Hyperf\Validation\Request\FormRequest;
class Dept extends FormRequest class Dept extends FormRequest
{ {
protected array $scenes = [ protected array $scenes = [
'add' => ['pid', 'dept_name'], 'add' => ['parent_id', 'dept_name'],
'edit' => ['dept_id', 'pid', 'dept_name'], 'edit' => ['dept_id', 'parent_id', 'dept_name'],
]; ];
/** /**
@ -29,7 +29,7 @@ class Dept extends FormRequest
{ {
return [ return [
'dept_id' => 'required', 'dept_id' => 'required',
'pid' => 'required', 'parent_id' => 'required',
'dept_name' => 'required' 'dept_name' => 'required'
]; ];
} }
@ -38,7 +38,7 @@ class Dept extends FormRequest
{ {
return [ return [
'dept_id.required' => '部门ID必填', 'dept_id.required' => '部门ID必填',
'pid.required' => '上级ID必选', 'parent_id.required' => '上级ID必选',
'dept_name.required' => '部门名称必填!' 'dept_name.required' => '部门名称必填!'
]; ];
} }

View File

@ -10,9 +10,9 @@ use Hyperf\Validation\Request\FormRequest;
class Menu extends FormRequest class Menu extends FormRequest
{ {
protected array $scenes = [ protected array $scenes = [
'add' => ['pid', 'title', 'type'], 'add' => ['parent_id', 'title', 'type'],
'edit' => ['pid', 'title', 'type','menu_id'], 'edit' => ['parent_id', 'title', 'type','menu_id'],
'quick' => ['pid', 'title', 'name', 'flag', 'path', 'icon'] 'quick' => ['parent_id', 'title', 'name', 'flag', 'path', 'icon']
]; ];
/** /**
@ -30,7 +30,7 @@ class Menu extends FormRequest
{ {
return [ return [
'menu_id' => 'required', 'menu_id' => 'required',
'pid' => 'required', 'parent_id' => 'required',
'title' => 'required', 'title' => 'required',
'type' => 'required', 'type' => 'required',
'name' => 'required', 'name' => 'required',
@ -44,7 +44,7 @@ class Menu extends FormRequest
{ {
return [ return [
'menu_id.required' => '菜单ID必填', 'menu_id.required' => '菜单ID必填',
'pid.required' => '上级ID必选', 'parent_id.required' => '上级ID必选',
'title.required' => '菜单名称必填!', 'title.required' => '菜单名称必填!',
'type.required' => '菜单类型必填!' 'type.required' => '菜单类型必填!'
]; ];