增加erp组织架构
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller\Erp;
|
||||
|
||||
use app\admin\BaseController;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\Session;
|
||||
use think\response\Json;
|
||||
use think\db\exception\DbException;
|
||||
use app\model\Erp\Organization;
|
||||
use app\model\AdminUser;
|
||||
|
||||
class OrganizationController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 获取组织机构列表
|
||||
*/
|
||||
public function getOrganization()
|
||||
{
|
||||
$list = Organization::where('delete_time', null)->select()->toArray();
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
'data' => $list
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组织机构详情
|
||||
*/
|
||||
public function getOrganizationDetail($id)
|
||||
{
|
||||
$detail = Organization::where('id', $id)->where('delete_time', null)->find()->toArray();
|
||||
$detail['leader_name'] = AdminUser::where('id', $detail['leader_id'])->value('name');
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
'data' => $detail
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建组织机构
|
||||
*/
|
||||
public function createOrganization()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$organization = Organization::create($data);
|
||||
if ($organization) {
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '创建成功',
|
||||
'data' => $organization
|
||||
]);
|
||||
} else {
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '创建失败',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑组织机构
|
||||
*/
|
||||
public function editOrganization($id)
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$organization = Organization::where('id', $id)->update($data);
|
||||
if ($organization) {
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '编辑成功',
|
||||
'data' => $organization
|
||||
]);
|
||||
} else {
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '编辑失败',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除组织机构
|
||||
*/
|
||||
public function deleteOrganization($id)
|
||||
{
|
||||
$organization = Organization::where('id', $id)->update(['delete_time' => date('Y-m-d H:i:s')]);
|
||||
if ($organization) {
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '删除成功',
|
||||
]);
|
||||
} else {
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '删除失败',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,23 @@ class UserController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户用户
|
||||
* @return Json
|
||||
*/
|
||||
public function getTenantUsers(int $tenantId)
|
||||
{
|
||||
$users = AdminUser::where('delete_time', null)->where('tenant_id', $tenantId)->field('id, account, name, phone, birth, email, qq, sex, group_id, status, last_login_ip, login_count, create_time, update_time')->select()->toArray();
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'list' => $users,
|
||||
'total' => count($users)
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @return Json
|
||||
|
||||
Reference in New Issue
Block a user