feat:代码块类目模块审核接口完善、各文件查询范围使用不生效Bug修复
This commit is contained in:
parent
97c5d18eae
commit
b741270bfa
@ -14,7 +14,8 @@ use app\common\arw\adjfut\src\UploadFile;
|
|||||||
use app\common\exception\Tool;
|
use app\common\exception\Tool;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use think\facade\Env;
|
use think\facade\Env;
|
||||||
|
use app\admin\logic\Code\CodeModuleCategory as LogicCodeModuleCategory;
|
||||||
|
use app\admin\logic\Code\CodeModuleCategoryAudit as LogicCodeModuleCategoryAudit;
|
||||||
|
|
||||||
class CodeModuleCategory extends BaseController
|
class CodeModuleCategory extends BaseController
|
||||||
{
|
{
|
||||||
@ -42,55 +43,12 @@ class CodeModuleCategory extends BaseController
|
|||||||
$con[] = ['cmc.code_module_category_global_mode', 'REGEXP', implode('|', $params['code_module_category_global_mode'])];
|
$con[] = ['cmc.code_module_category_global_mode', 'REGEXP', implode('|', $params['code_module_category_global_mode'])];
|
||||||
}
|
}
|
||||||
|
|
||||||
$tree_data = [];
|
//主级类目分页处理
|
||||||
//只针对主级类目进行的分页处理
|
$query = ModelCodeModuleCategory::alias('cmc')->leftjoin('customer cust', 'cmc.customer_guid = cust.customer_guid')->scope('master')->where($con);
|
||||||
$query = ModelCodeModuleCategory::alias('cmc')->leftjoin('customer cust', 'cmc.customer_guid = cust.customer_guid')
|
|
||||||
->scope('master')->where($con);
|
|
||||||
$module_category_guids = self::pageWrapper($query)->column('code_module_category_guid');
|
$module_category_guids = self::pageWrapper($query)->column('code_module_category_guid');
|
||||||
//分页后的主级类目开始构建树形结构(此时才会获取到各个父级类目所包含的子级类目)
|
|
||||||
if ($module_category_guids) {
|
|
||||||
$data = ModelCodeModuleCategory::alias('cmc')
|
|
||||||
->whereOr([
|
|
||||||
['cmc.code_module_category_guid', 'in', $module_category_guids],
|
|
||||||
['cmc.code_module_category_parent_guid', 'in', $module_category_guids],
|
|
||||||
])->field([
|
|
||||||
'cmc.code_module_category_id',
|
|
||||||
'cmc.code_module_category_guid',
|
|
||||||
'cmc.customer_guid',
|
|
||||||
'cmc.code_module_category_audit',
|
|
||||||
'cmc.code_module_category_sort',
|
|
||||||
'cmc.code_module_category_parent_guid',
|
|
||||||
'cmc.code_module_category_name',
|
|
||||||
'cmc.code_module_category_audit',
|
|
||||||
'cmc.code_module_category_global_mode',
|
|
||||||
'cmc.code_module_category_library_type',
|
|
||||||
'cmc.code_module_category_ps',
|
|
||||||
'cmcp.code_module_category_name' => "code_module_category_parent_name",
|
|
||||||
'cust.customer_name',
|
|
||||||
])
|
|
||||||
->leftjoin('code_module_category cmcp', 'cmc.code_module_category_parent_guid = cmcp.code_module_category_guid')
|
|
||||||
->leftjoin('customer cust', 'cmc.customer_guid = cust.customer_guid')
|
|
||||||
->order('code_module_category_sort')
|
|
||||||
->select()
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
$Traverse = new Traverse('code_module_category_guid', 'code_module_category_parent_guid');
|
//分页后的主级类目开始构建树形结构(此时才会获取到各个父级类目所包含的子级类目)
|
||||||
$tree_data = $Traverse->tree($data, ModelCodeModuleCategory::MASTER_DEFAULT, function ($v) {
|
$tree_data = LogicCodeModuleCategory::buildTreeData($module_category_guids);
|
||||||
return [
|
|
||||||
'code_module_category_name' => $v['code_module_category_name'],
|
|
||||||
'code_module_category_parent_name' => $v['code_module_category_parent_name'],
|
|
||||||
'code_module_category_guid' => $v['code_module_category_guid'],
|
|
||||||
'code_module_category_parent_guid' => $v['code_module_category_parent_guid'],
|
|
||||||
'code_module_category_sort' => $v['code_module_category_sort'],
|
|
||||||
'code_module_category_ps' => $v['code_module_category_ps'],
|
|
||||||
'code_module_category_global_mode' => $v['code_module_category_global_mode'],
|
|
||||||
'code_module_category_audit' => $v['code_module_category_audit'],
|
|
||||||
'code_module_category_library_type' => $v['code_module_category_library_type'],
|
|
||||||
'customer_guid' => $v['customer_guid'],
|
|
||||||
'customer_name' => $v['customer_name'],
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return msg(0, "获取代码块类目列表成功!", [
|
return msg(0, "获取代码块类目列表成功!", [
|
||||||
'count' => $query->count(),
|
'count' => $query->count(),
|
||||||
@ -217,7 +175,7 @@ class CodeModuleCategory extends BaseController
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return array
|
* @return array
|
||||||
* @date 2023-06-28
|
* @date 2023-07-05
|
||||||
* @author xjh
|
* @author xjh
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
@ -230,9 +188,7 @@ class CodeModuleCategory extends BaseController
|
|||||||
]);
|
]);
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
ModelCodeModuleCategory::where([
|
LogicCodeModuleCategoryAudit::handleAudit(explode(',', $params['code_module_category_guid']), $params['code_module_category_audit']);
|
||||||
'code_module_category_guid' => explode(',', $params['code_module_category_guid'])
|
|
||||||
])->select()->update(['code_module_category_audit' => $params['code_module_category_audit']]);
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return msg('审核成功!');
|
return msg('审核成功!');
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
73
app/admin/logic/Code/CodeModuleCategory.php
Normal file
73
app/admin/logic/Code/CodeModuleCategory.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\logic\Code;
|
||||||
|
|
||||||
|
use app\common\model\Code\CodeModuleCategory as ModelCodeModuleCategory;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use app\common\arw\adjfut\src\Traverse;
|
||||||
|
|
||||||
|
|
||||||
|
class CodeModuleCategory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 构建代码块类目树形结构数据
|
||||||
|
*
|
||||||
|
* @param array $module_category_guids 主类目guid数组
|
||||||
|
* @return array
|
||||||
|
* @date 2023-07-05
|
||||||
|
* @author xjh
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function buildTreeData(array $module_category_guids): array
|
||||||
|
{
|
||||||
|
if (!$module_category_guids) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tree_data = [];
|
||||||
|
$data = ModelCodeModuleCategory::alias('cmc')
|
||||||
|
->whereOr([
|
||||||
|
['cmc.code_module_category_guid', 'in', $module_category_guids],
|
||||||
|
['cmc.code_module_category_parent_guid', 'in', $module_category_guids],
|
||||||
|
])->field([
|
||||||
|
'cmc.code_module_category_id',
|
||||||
|
'cmc.code_module_category_guid',
|
||||||
|
'cmc.customer_guid',
|
||||||
|
'cmc.code_module_category_audit',
|
||||||
|
'cmc.code_module_category_sort',
|
||||||
|
'cmc.code_module_category_parent_guid',
|
||||||
|
'cmc.code_module_category_name',
|
||||||
|
'cmc.code_module_category_audit',
|
||||||
|
'cmc.code_module_category_global_mode',
|
||||||
|
'cmc.code_module_category_library_type',
|
||||||
|
'cmc.code_module_category_ps',
|
||||||
|
'cmcp.code_module_category_name' => "code_module_category_parent_name",
|
||||||
|
'cust.customer_name',
|
||||||
|
])
|
||||||
|
->leftjoin('code_module_category cmcp', 'cmc.code_module_category_parent_guid = cmcp.code_module_category_guid')
|
||||||
|
->leftjoin('customer cust', 'cmc.customer_guid = cust.customer_guid')
|
||||||
|
->order('code_module_category_sort')
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$Traverse = new Traverse('code_module_category_guid', 'code_module_category_parent_guid');
|
||||||
|
$tree_data = $Traverse->tree($data, ModelCodeModuleCategory::MASTER_DEFAULT, function ($v) {
|
||||||
|
return [
|
||||||
|
'code_module_category_name' => $v['code_module_category_name'],
|
||||||
|
'code_module_category_parent_name' => $v['code_module_category_parent_name'],
|
||||||
|
'code_module_category_guid' => $v['code_module_category_guid'],
|
||||||
|
'code_module_category_parent_guid' => $v['code_module_category_parent_guid'],
|
||||||
|
'code_module_category_sort' => $v['code_module_category_sort'],
|
||||||
|
'code_module_category_ps' => $v['code_module_category_ps'],
|
||||||
|
'code_module_category_global_mode' => $v['code_module_category_global_mode'],
|
||||||
|
'code_module_category_audit' => $v['code_module_category_audit'],
|
||||||
|
'code_module_category_library_type' => $v['code_module_category_library_type'],
|
||||||
|
'customer_guid' => $v['customer_guid'],
|
||||||
|
'customer_name' => $v['customer_name'],
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
return $tree_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
112
app/admin/logic/Code/CodeModuleCategoryAudit.php
Normal file
112
app/admin/logic/Code/CodeModuleCategoryAudit.php
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\logic\Code;
|
||||||
|
|
||||||
|
use app\common\model\Code\CodeModuleCategory as ModelCodeModuleCategory;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
|
||||||
|
|
||||||
|
class CodeModuleCategoryAudit
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 代码块类目审核处理
|
||||||
|
*
|
||||||
|
* @param array $code_module_category_guids 类目guid数组
|
||||||
|
* @param int $code_module_category_audit 审核状态
|
||||||
|
* @return void
|
||||||
|
* @date 2023-07-05
|
||||||
|
* @author xjh
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function handleAudit(array $code_module_category_guids, int $code_module_category_audit): void
|
||||||
|
{
|
||||||
|
foreach ($code_module_category_guids as $code_module_category_guid) {
|
||||||
|
$module_category = ModelCodeModuleCategory::find($code_module_category_guid);
|
||||||
|
if (!$module_category) {
|
||||||
|
throwErrorMsg("含有不存在的类目!");
|
||||||
|
}
|
||||||
|
//主类目审核处理
|
||||||
|
if ($module_category->code_module_category_parent_guid == ModelCodeModuleCategory::MASTER_DEFAULT) {
|
||||||
|
self::handleMainCategory($module_category, $code_module_category_audit);
|
||||||
|
}
|
||||||
|
//子类目审核处理
|
||||||
|
else {
|
||||||
|
self::handleSonCategory($module_category, $code_module_category_audit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码块主类目审核处理
|
||||||
|
*
|
||||||
|
* @param ModelCodeModuleCategory $module_category 模型实例
|
||||||
|
* @param int $code_module_category_audit 审核状态
|
||||||
|
* @return void
|
||||||
|
* @date 2023-07-05
|
||||||
|
* @author xjh
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function handleMainCategory(ModelCodeModuleCategory $module_category, int $code_module_category_audit): void
|
||||||
|
{
|
||||||
|
//主类目的审核将会直接将所属的子类目们审核状态连带修改
|
||||||
|
//(例: 主类目审核通过则子类目将会全员审核状态为通过)
|
||||||
|
//【主类目更新】
|
||||||
|
$module_category->code_module_category_audit = $code_module_category_audit;
|
||||||
|
$module_category->save();
|
||||||
|
|
||||||
|
//【所属子类目们的更新】
|
||||||
|
ModelCodeModuleCategory::where('code_module_category_parent_guid', $module_category->code_module_category_guid)->select()->update([
|
||||||
|
'code_module_category_audit' => $code_module_category_audit
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码块子类目审核处理
|
||||||
|
*
|
||||||
|
* @param ModelCodeModuleCategory $module_category 模型实例
|
||||||
|
* @param int $code_module_category_audit 审核状态
|
||||||
|
* @return void
|
||||||
|
* @date 2023-07-05
|
||||||
|
* @author xjh
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function handleSonCategory(ModelCodeModuleCategory $module_category, int $code_module_category_audit): void
|
||||||
|
{
|
||||||
|
//【当前子类目更新】
|
||||||
|
$module_category->code_module_category_audit = $code_module_category_audit;
|
||||||
|
$module_category->save();
|
||||||
|
|
||||||
|
//【所属主类目更新】
|
||||||
|
$module_category_parent_guid = $module_category->code_module_category_parent_guid;
|
||||||
|
//当前主类目含未审核子类目的数量
|
||||||
|
$count = ModelCodeModuleCategory::scope('auditUnaudited')->where([
|
||||||
|
['code_module_category_parent_guid', '=', $module_category_parent_guid],
|
||||||
|
['code_module_category_guid', '<>', $module_category->code_module_category_guid],
|
||||||
|
])->count();
|
||||||
|
//当未审核子类目的数量为0的时候
|
||||||
|
//【场景一】若此时所有的已审核子类目状态都为不通过,则自动将所属的主类目审核状态设置为不通过
|
||||||
|
//【场景二】若此时所有的已审核子类目状态包含着通过与不通过的状态,则自动将所属的主类目审核状态设置为通过
|
||||||
|
if ($count == 0) {
|
||||||
|
$son_category_audits = ModelCodeModuleCategory::scope('auditPass')->where('code_module_category_parent_guid', $module_category_parent_guid)
|
||||||
|
->column('code_module_category_audit');
|
||||||
|
$is_all_not_failed = true;
|
||||||
|
foreach ($son_category_audits as $son_category_audit) {
|
||||||
|
if ($son_category_audit != ModelCodeModuleCategory::AUDIT_FAILED) {
|
||||||
|
$is_all_not_failed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($is_all_not_failed) {
|
||||||
|
ModelCodeModuleCategory::update([
|
||||||
|
'code_module_category_guid' => $module_category_parent_guid,
|
||||||
|
'code_module_category_audit' => ModelCodeModuleCategory::AUDIT_FAILED,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
ModelCodeModuleCategory::update([
|
||||||
|
'code_module_category_guid' => $module_category_parent_guid,
|
||||||
|
'code_module_category_audit' => ModelCodeModuleCategory::AUDIT_PASS,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -51,7 +51,7 @@ class CodeModule extends BaseController
|
|||||||
'code_module_category.code_module_category_guid',
|
'code_module_category.code_module_category_guid',
|
||||||
])->leftJoin('code_module_category', 'code_module_category.code_module_category_guid = code_module.code_module_category_guid')
|
])->leftJoin('code_module_category', 'code_module_category.code_module_category_guid = code_module.code_module_category_guid')
|
||||||
->where('code_module.code_module_category_guid', $code_module_category_guid)
|
->where('code_module.code_module_category_guid', $code_module_category_guid)
|
||||||
->scope('audit_pass')
|
->scope('auditPass')
|
||||||
->order('code_module.code_module_sort')->select();
|
->order('code_module.code_module_sort')->select();
|
||||||
$data[] = $code_module_list;
|
$data[] = $code_module_list;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class CodeModuleCategory extends BaseController
|
|||||||
->append(['langHit', 'libraryType'])
|
->append(['langHit', 'libraryType'])
|
||||||
->hidden(['code_module_category_global_mode', 'code_module_category_library_type'])
|
->hidden(['code_module_category_global_mode', 'code_module_category_library_type'])
|
||||||
->leftjoin('customer c', 'a.customer_guid = c.customer_guid')
|
->leftjoin('customer c', 'a.customer_guid = c.customer_guid')
|
||||||
->scope('audit_pass')
|
->scope('auditPass')
|
||||||
->where('a.code_module_category_parent_guid', 0)->select();
|
->where('a.code_module_category_parent_guid', 0)->select();
|
||||||
|
|
||||||
return msg(0, "获取一级类目列表成功!", [
|
return msg(0, "获取一级类目列表成功!", [
|
||||||
@ -67,7 +67,7 @@ class CodeModuleCategory extends BaseController
|
|||||||
// ->append(['langHit', 'libraryType'])
|
// ->append(['langHit', 'libraryType'])
|
||||||
// ->hidden(['code_module_category_global_mode', 'code_module_category_library_type'])
|
// ->hidden(['code_module_category_global_mode', 'code_module_category_library_type'])
|
||||||
->leftjoin('customer c', 'a.customer_guid = c.customer_guid')
|
->leftjoin('customer c', 'a.customer_guid = c.customer_guid')
|
||||||
->scope('audit_pass')
|
->scope('auditPass')
|
||||||
->where('code_module_category_parent_guid', $params['code_module_category_guid'])
|
->where('code_module_category_parent_guid', $params['code_module_category_guid'])
|
||||||
->select();
|
->select();
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class CodeModuleCategory
|
|||||||
*/
|
*/
|
||||||
public static function isSonCategory(string $code_module_category_guid): void
|
public static function isSonCategory(string $code_module_category_guid): void
|
||||||
{
|
{
|
||||||
$module_category = ModelCodeModuleCategory::scope('not_master')->find($code_module_category_guid);
|
$module_category = ModelCodeModuleCategory::scope('notMaster')->find($code_module_category_guid);
|
||||||
if (!$module_category) {
|
if (!$module_category) {
|
||||||
throwErrorMsg("当前类目不为子类目!");
|
throwErrorMsg("当前类目不为子类目!");
|
||||||
}
|
}
|
||||||
|
@ -185,6 +185,20 @@ class CodeModuleCategory extends BaseModel
|
|||||||
$query->where('code_module_category.code_module_category_audit', self::AUDIT_PASS);
|
$query->where('code_module_category.code_module_category_audit', self::AUDIT_PASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询范围-未审核代码块类目
|
||||||
|
*
|
||||||
|
* @param $query
|
||||||
|
* @return void
|
||||||
|
* @date 2023-07-05
|
||||||
|
* @author xjh
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function scopeAuditUnaudited($query): void
|
||||||
|
{
|
||||||
|
$query->where('code_module_category.code_module_category_audit', self::AUDIT_UNAUDITED);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全局模式名称
|
* 获取全局模式名称
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user