Compare commits
No commits in common. "1e8b6fe77d9592ff5db450576bc1500183d606b3" and "c389fec971c730be0ce9307be9e72d2fce42e1f8" have entirely different histories.
1e8b6fe77d
...
c389fec971
@ -35,7 +35,6 @@ class OrganizationController extends BaseController
|
||||
{
|
||||
$detail = Organization::where('id', $id)->where('delete_time', null)->find()->toArray();
|
||||
$detail['leader_name'] = AdminUser::where('id', $detail['leader_id'])->value('name');
|
||||
$detail['parent_name'] = Organization::where('id', $detail['parent_id'])->value('org_name');
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
|
||||
@ -1,147 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller\Tenant;
|
||||
|
||||
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 think\Request;
|
||||
use app\model\Tenant\Tenant;
|
||||
use app\model\AdminUser;
|
||||
|
||||
class TenantController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 获取租户列表
|
||||
*/
|
||||
public function getTenant(Request $request)
|
||||
{
|
||||
// 获取参数
|
||||
$page = $request->param('page', 1, 'int');
|
||||
$pageSize = $request->param('pageSize', 10, 'int');
|
||||
$tenantName = $request->param('tenant_name', '');
|
||||
$tenantCode = $request->param('tenant_code', '');
|
||||
$contactPerson = $request->param('contact_person', '');
|
||||
$contactPhone = $request->param('contact_phone', '');
|
||||
|
||||
$where = [['delete_time', '=', null]];
|
||||
|
||||
// 动态增加模糊搜索条件
|
||||
if ($tenantName) $where[] = ['tenant_name', 'like', "%$tenantName%"];
|
||||
if ($tenantCode) $where[] = ['tenant_code', 'like', "%$tenantCode%"];
|
||||
if ($contactPerson) $where[] = ['contact_person', 'like', "%$contactPerson%"];
|
||||
if ($contactPhone) $where[] = ['contact_phone', 'like', "%$contactPhone%"];
|
||||
|
||||
$list = Tenant::where($where)->page($page, $pageSize)->select()->toArray();
|
||||
$total = Tenant::where($where)->count();
|
||||
|
||||
return json(['code' => 200, 'data' => ['list' => $list, 'total' => $total]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户详情
|
||||
*/
|
||||
public function getTenantDetail($id)
|
||||
{
|
||||
$detail = Tenant::where('id', $id)->where('delete_time', null)->find()->toArray();
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
'data' => $detail
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建租户
|
||||
*/
|
||||
public function createTenant()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$tenant = Tenant::create($data);
|
||||
if ($tenant) {
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '创建成功',
|
||||
'data' => $tenant
|
||||
]);
|
||||
} else {
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '创建失败',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑租户
|
||||
*/
|
||||
public function editTenant($id)
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$tenant = Tenant::where('id', $id)->update($data);
|
||||
if ($tenant) {
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '编辑成功',
|
||||
'data' => $tenant
|
||||
]);
|
||||
} else {
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '编辑失败',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除租户
|
||||
*/
|
||||
public function deleteTenant($id)
|
||||
{
|
||||
$tenant = Tenant::where('id', $id)->update(['delete_time' => date('Y-m-d H:i:s')]);
|
||||
if ($tenant) {
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '删除成功',
|
||||
]);
|
||||
} else {
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '删除失败',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户编码重复(不筛选删除数据)
|
||||
*/
|
||||
public function findTenantCode(Request $request)
|
||||
{
|
||||
$tenantCode = $request->param('tenant_code', '');
|
||||
|
||||
if (!$tenantCode) {
|
||||
return json(['code' => 400, 'msg' => '缺少编码参数']);
|
||||
}
|
||||
|
||||
// 直接去表里查,只要有一条一样的就返回重复
|
||||
$hasOne = Tenant::where('tenant_code', $tenantCode)->find();
|
||||
|
||||
if ($hasOne) {
|
||||
return json([
|
||||
'code' => 201,
|
||||
'msg' => '编码已存在',
|
||||
'data' => $hasOne
|
||||
]);
|
||||
}
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '编码可用'
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -3,9 +3,9 @@ use think\facade\Route;
|
||||
|
||||
// 组织机构管理路由
|
||||
Route::group('erp', function() {
|
||||
Route::get('getOrganization', 'app\admin\controller\Erp\OrganizationController/getOrganization');
|
||||
Route::get('organization', 'app\admin\controller\Erp\OrganizationController/getOrganization');
|
||||
Route::get('getOrganizationDetail/:id', 'app\admin\controller\Erp\OrganizationController/getOrganizationDetail');
|
||||
Route::post('createOrganization', 'app\admin\controller\Erp\OrganizationController/createOrganization');
|
||||
Route::post('editOrganization/:id', 'app\admin\controller\Erp\OrganizationController/editOrganization');
|
||||
Route::delete('deleteOrganization/:id', 'app\admin\controller\Erp\OrganizationController/deleteOrganization');
|
||||
Route::post('organization', 'app\admin\controller\Erp\OrganizationController/createOrganization');
|
||||
Route::post('organization/:id', 'app\admin\controller\Erp\OrganizationController/editOrganization');
|
||||
Route::delete('organization/:id', 'app\admin\controller\Erp\OrganizationController/deleteOrganization');
|
||||
});
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
use think\facade\Route;
|
||||
|
||||
// 租户管理路由
|
||||
Route::group('tenant', function() {
|
||||
Route::get('getTenant', 'app\admin\controller\Tenant\TenantController/getTenant');
|
||||
Route::get('getTenantDetail/:id', 'app\admin\controller\Tenant\TenantController/getTenantDetail');
|
||||
Route::post('createTenant', 'app\admin\controller\Tenant\TenantController/createTenant');
|
||||
Route::post('editTenant/:id', 'app\admin\controller\Tenant\TenantController/editTenant');
|
||||
Route::delete('deleteTenant/:id', 'app\admin\controller\Tenant\TenantController/deleteTenant');
|
||||
Route::get('findTenantCode', 'app\admin\controller\Tenant\TenantController/findTenantCode');
|
||||
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user