You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.5 KiB
92 lines
2.5 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\adminapi\controller\departments;
|
|
|
|
use core\base\BaseAdminController;
|
|
use app\service\admin\departments\DepartmentsService;
|
|
|
|
|
|
/**
|
|
* 部门控制器
|
|
* Class Departments
|
|
* @package app\adminapi\controller\departments
|
|
*/
|
|
class Departments extends BaseAdminController
|
|
{
|
|
/**
|
|
* 获取部门列表
|
|
* @return \think\Response
|
|
*/
|
|
public function lists(){
|
|
$data = $this->request->params([
|
|
["department_name",""],
|
|
["parent_department_id",""]
|
|
]);
|
|
return success((new DepartmentsService())->getPage($data));
|
|
}
|
|
|
|
/**
|
|
* 部门详情
|
|
* @param int $id
|
|
* @return \think\Response
|
|
*/
|
|
public function info(int $id){
|
|
return success((new DepartmentsService())->getInfo($id));
|
|
}
|
|
|
|
/**
|
|
* 添加部门
|
|
* @return \think\Response
|
|
*/
|
|
public function add(){
|
|
$data = $this->request->params([
|
|
["department_name",""],
|
|
["parent_department_id",0],
|
|
|
|
]);
|
|
$this->validate($data, 'app\validate\departments\Departments.add');
|
|
$id = (new DepartmentsService())->add($data);
|
|
return success('ADD_SUCCESS', ['id' => $id]);
|
|
}
|
|
|
|
/**
|
|
* 部门编辑
|
|
* @param $id 部门id
|
|
* @return \think\Response
|
|
*/
|
|
public function edit(int $id){
|
|
$data = $this->request->params([
|
|
["department_name",""],
|
|
["parent_department_id",0],
|
|
|
|
]);
|
|
$this->validate($data, 'app\validate\departments\Departments.edit');
|
|
(new DepartmentsService())->edit($id, $data);
|
|
return success('EDIT_SUCCESS');
|
|
}
|
|
|
|
/**
|
|
* 部门删除
|
|
* @param $id 部门id
|
|
* @return \think\Response
|
|
*/
|
|
public function del(int $id){
|
|
(new DepartmentsService())->del($id);
|
|
return success('DELETE_SUCCESS');
|
|
}
|
|
|
|
|
|
public function getDepartmentsAll(){
|
|
return success(( new DepartmentsService())->getDepartmentsAll());
|
|
}
|
|
|
|
}
|
|
|