1.将部门修改为渠道,并且所有dice_表关联渠道表
2.将所有配置表,记录表设置关联渠道 3.优化后台页面设置
This commit is contained in:
@@ -6,13 +6,15 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\logic\ante_config;
|
||||
|
||||
use app\dice\helper\AdminScopeHelper;
|
||||
use app\dice\helper\ConfigScopeEditHelper;
|
||||
use app\dice\model\ante_config\DiceAnteConfig;
|
||||
use plugin\saiadmin\basic\think\BaseLogic;
|
||||
use app\dice\basic\DiceBaseLogic;
|
||||
|
||||
/**
|
||||
* 底注配置逻辑层
|
||||
*/
|
||||
class DiceAnteConfigLogic extends BaseLogic
|
||||
class DiceAnteConfigLogic extends DiceBaseLogic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
@@ -23,21 +25,32 @@ class DiceAnteConfigLogic extends BaseLogic
|
||||
{
|
||||
return $this->transaction(function () use ($data) {
|
||||
$this->normalizeDefaultField($data);
|
||||
$deptId = AdminScopeHelper::resolveConfigDeptId(null, $data['dept_id'] ?? AdminScopeHelper::DEFAULT_TEMPLATE_DEPT);
|
||||
if ((int) ($data['is_default'] ?? 0) === 1) {
|
||||
$this->clearOtherDefaults();
|
||||
$this->clearOtherDefaults(null, $deptId);
|
||||
}
|
||||
return parent::add($data);
|
||||
});
|
||||
}
|
||||
|
||||
public function edit($id, array $data): mixed
|
||||
public function edit($id, array $data, ?array $adminInfo = null, $requestDeptId = null): mixed
|
||||
{
|
||||
return $this->transaction(function () use ($id, $data) {
|
||||
$pickedDeptId = AdminScopeHelper::pickRequestDeptId($requestDeptId, $data);
|
||||
$deptId = AdminScopeHelper::resolveConfigDeptId($adminInfo, $pickedDeptId);
|
||||
return $this->transaction(function () use ($id, $data, $deptId, $adminInfo, $pickedDeptId) {
|
||||
$this->normalizeDefaultField($data);
|
||||
if ((int) ($data['is_default'] ?? 0) === 1) {
|
||||
$this->clearOtherDefaults((int) $id);
|
||||
$this->clearOtherDefaults((int) $id, $deptId);
|
||||
}
|
||||
return parent::edit($id, $data);
|
||||
return ConfigScopeEditHelper::updateByPkAndDept(
|
||||
$this->model,
|
||||
$id,
|
||||
$deptId,
|
||||
$data,
|
||||
['id', 'dept_id', 'create_time', 'update_time', 'delete_time', 'row_id'],
|
||||
$adminInfo,
|
||||
$pickedDeptId
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,9 +92,10 @@ class DiceAnteConfigLogic extends BaseLogic
|
||||
$data['is_default'] = ((int) $data['is_default']) === 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
private function clearOtherDefaults(?int $excludeId = null): void
|
||||
private function clearOtherDefaults(?int $excludeId = null, int $deptId = AdminScopeHelper::DEFAULT_TEMPLATE_DEPT): void
|
||||
{
|
||||
$query = $this->model->where('is_default', 1);
|
||||
ConfigScopeEditHelper::applyDeptIdWhere($query, $deptId);
|
||||
if ($excludeId !== null && $excludeId > 0) {
|
||||
$query->where('id', '<>', $excludeId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user