批量更新租户规则
This commit is contained in:
@@ -11,7 +11,7 @@ use think\facade\Session;
|
||||
use think\response\Json;
|
||||
use think\db\exception\DbException;
|
||||
use app\model\Erp\Organization;
|
||||
use app\model\AdminUser;
|
||||
use app\model\System\AdminUser;
|
||||
|
||||
class OrganizationController extends BaseController
|
||||
{
|
||||
@@ -20,13 +20,13 @@ class OrganizationController extends BaseController
|
||||
*/
|
||||
public function getOrganization()
|
||||
{
|
||||
$tenantId = $this->getTenantId();
|
||||
if (!$tenantId) {
|
||||
$tid = $this->getTenantId();
|
||||
if (!$tid) {
|
||||
return json(['code' => 403, 'msg' => '无法获取租户信息']);
|
||||
}
|
||||
|
||||
$list = Organization::where('delete_time', null)
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('tid', $tid)
|
||||
->select()
|
||||
->toArray();
|
||||
return json([
|
||||
@@ -41,14 +41,14 @@ class OrganizationController extends BaseController
|
||||
*/
|
||||
public function getOrganizationDetail($id)
|
||||
{
|
||||
$tenantId = $this->getTenantId();
|
||||
if (!$tenantId) {
|
||||
$tid = $this->getTenantId();
|
||||
if (!$tid) {
|
||||
return json(['code' => 403, 'msg' => '无法获取租户信息']);
|
||||
}
|
||||
|
||||
$detail = Organization::where('id', $id)
|
||||
->where('delete_time', null)
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('tid', $tid)
|
||||
->find()
|
||||
->toArray();
|
||||
$detail['leader_name'] = AdminUser::where('id', $detail['leader_id'])->value('name');
|
||||
@@ -65,13 +65,13 @@ class OrganizationController extends BaseController
|
||||
*/
|
||||
public function createOrganization()
|
||||
{
|
||||
$tenantId = $this->getTenantId();
|
||||
if (!$tenantId) {
|
||||
$tid = $this->getTenantId();
|
||||
if (!$tid) {
|
||||
return json(['code' => 403, 'msg' => '无法获取租户信息']);
|
||||
}
|
||||
|
||||
$data = $this->request->post();
|
||||
$data['tenant_id'] = $tenantId;
|
||||
$data['tid'] = $tid;
|
||||
|
||||
$organization = Organization::create($data);
|
||||
if ($organization) {
|
||||
@@ -93,16 +93,16 @@ class OrganizationController extends BaseController
|
||||
*/
|
||||
public function editOrganization($id)
|
||||
{
|
||||
$tenantId = $this->getTenantId();
|
||||
if (!$tenantId) {
|
||||
$tid = $this->getTenantId();
|
||||
if (!$tid) {
|
||||
return json(['code' => 403, 'msg' => '无法获取租户信息']);
|
||||
}
|
||||
|
||||
$data = $this->request->post();
|
||||
unset($data['tenant_id']); // 不允许修改租户ID
|
||||
unset($data['tid']); // 不允许修改租户ID
|
||||
|
||||
$organization = Organization::where('id', $id)
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('tid', $tid)
|
||||
->update($data);
|
||||
if ($organization !== false) {
|
||||
return json([
|
||||
@@ -123,13 +123,13 @@ class OrganizationController extends BaseController
|
||||
*/
|
||||
public function deleteOrganization($id)
|
||||
{
|
||||
$tenantId = $this->getTenantId();
|
||||
if (!$tenantId) {
|
||||
$tid = $this->getTenantId();
|
||||
if (!$tid) {
|
||||
return json(['code' => 403, 'msg' => '无法获取租户信息']);
|
||||
}
|
||||
|
||||
$organization = Organization::where('id', $id)
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('tid', $tid)
|
||||
->update(['delete_time' => date('Y-m-d H:i:s')]);
|
||||
if ($organization) {
|
||||
return json([
|
||||
@@ -149,12 +149,12 @@ class OrganizationController extends BaseController
|
||||
*/
|
||||
public function getCompanys()
|
||||
{
|
||||
$tenantId = $this->getTenantId();
|
||||
if (!$tenantId) {
|
||||
$tid = $this->getTenantId();
|
||||
if (!$tid) {
|
||||
return json(['code' => 403, 'msg' => '无法获取租户信息']);
|
||||
}
|
||||
|
||||
$where = [['delete_time', '=', null], ['is_company', '=', 1], ['tenant_id', '=', $tenantId]];
|
||||
$where = [['delete_time', '=', null], ['is_company', '=', 1], ['tid', '=', $tid]];
|
||||
|
||||
$list = Organization::where($where)->select()->toArray();
|
||||
return json([
|
||||
@@ -169,14 +169,14 @@ class OrganizationController extends BaseController
|
||||
*/
|
||||
public function getDepartments()
|
||||
{
|
||||
$tenantId = $this->getTenantId();
|
||||
if (!$tenantId) {
|
||||
$tid = $this->getTenantId();
|
||||
if (!$tid) {
|
||||
return json(['code' => 403, 'msg' => '无法获取租户信息']);
|
||||
}
|
||||
|
||||
$parentId = input('parent_id/d', 0);
|
||||
|
||||
$where = [['delete_time', '=', null], ['is_company', '=', 0], ['tenant_id', '=', $tenantId]];
|
||||
$where = [['delete_time', '=', null], ['is_company', '=', 0], ['tid', '=', $tid]];
|
||||
|
||||
if ($parentId > 0) {
|
||||
$where[] = ['parent_id', '=', $parentId];
|
||||
|
||||
Reference in New Issue
Block a user