批量更新租户规则

This commit is contained in:
2026-03-09 23:00:20 +08:00
parent e09b4c639c
commit e27cc8f457
45 changed files with 579 additions and 314 deletions
+17 -17
View File
@@ -11,7 +11,7 @@ use think\facade\Session;
use think\response\Json;
use think\db\exception\DbException;
use app\model\Erp\Employee;
use app\model\AdminUser;
use app\model\System\AdminUser;
class EmployeeController extends BaseController
{
@@ -20,13 +20,13 @@ class EmployeeController extends BaseController
*/
public function getEmployee()
{
$tenantId = $this->getTenantId();
if (!$tenantId) {
$tid = $this->getTenantId();
if (!$tid) {
return json(['code' => 403, 'msg' => '无法获取租户信息']);
}
$list = Employee::where('delete_time', null)
->where('tenant_id', $tenantId)
->where('tid', $tid)
->select()
->toArray();
return json([
@@ -41,14 +41,14 @@ class EmployeeController extends BaseController
*/
public function getEmployeeDetail($id)
{
$tenantId = $this->getTenantId();
if (!$tenantId) {
$tid = $this->getTenantId();
if (!$tid) {
return json(['code' => 403, 'msg' => '无法获取租户信息']);
}
$detail = Employee::where('id', $id)
->where('delete_time', null)
->where('tenant_id', $tenantId)
->where('tid', $tid)
->find()
->toArray();
return json([
@@ -63,13 +63,13 @@ class EmployeeController extends BaseController
*/
public function createEmployee()
{
$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;
$employee = Employee::create($data);
if ($employee) {
@@ -91,16 +91,16 @@ class EmployeeController extends BaseController
*/
public function editEmployee($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
$employee = Employee::where('id', $id)
->where('tenant_id', $tenantId)
->where('tid', $tid)
->update($data);
if ($employee !== false) {
return json([
@@ -121,13 +121,13 @@ class EmployeeController extends BaseController
*/
public function deleteEmployee($id)
{
$tenantId = $this->getTenantId();
if (!$tenantId) {
$tid = $this->getTenantId();
if (!$tid) {
return json(['code' => 403, 'msg' => '无法获取租户信息']);
}
$employee = Employee::where('id', $id)
->where('tenant_id', $tenantId)
->where('tid', $tid)
->update(['delete_time' => date('Y-m-d H:i:s')]);
if ($employee) {
return json([