代码提交

This commit is contained in:
wong
2026-01-06 10:58:29 +08:00
parent efcbb06eb2
commit ea2dd8cab2
23 changed files with 1848 additions and 722 deletions

View File

@@ -47,7 +47,7 @@ class Workbench extends Validate
'wechatGroups' => 'checkGroupPushTarget|array|min:1', // 当targetType=1时必填
'wechatFriends' => 'checkFriendPushTarget|array', // 当targetType=2时可选可以为空
'ownerWechatId' => 'checkFriendPushService', // 当targetType=2且未选择好友/流量池时必填
'contentGroups' => 'requireIf:type,3|array|min:1',
'contentGroups' => 'checkContentGroups|array', // 群推送时必填,但群公告时可以为空
// 群公告特有参数
'announcementContent' => 'checkAnnouncementContent|max:5000', // 群公告内容当groupPushSubType=2时必填
'enableAiRewrite' => 'checkEnableAiRewrite|in:0,1', // 是否启用AI智能话术改写
@@ -106,7 +106,7 @@ class Workbench extends Validate
'endTime.dateFormat' => '发布结束时间格式错误',
'accountGroups.requireIf' => '请选择账号类型',
'accountGroups.in' => '账号类型错误',
'contentGroups.requireIf' => '选择内容库',
'contentGroups.checkContentGroups' => '群群发时必须选择内容库',
'contentGroups.array' => '内容库格式错误',
// 群消息推送相关提示
'pushType.requireIf' => '请选择推送方式',
@@ -383,4 +383,31 @@ class Workbench extends Validate
}
return true;
}
/**
* 验证内容库(群推送时必填,但群公告时可以为空)
*/
protected function checkContentGroups($value, $rule, $data)
{
// 如果是群消息推送类型
if (isset($data['type']) && $data['type'] == self::TYPE_GROUP_PUSH) {
$targetType = isset($data['targetType']) ? intval($data['targetType']) : 1; // 默认1
$groupPushSubType = isset($data['groupPushSubType']) ? intval($data['groupPushSubType']) : 1; // 默认1
// 群公告groupPushSubType=2内容库可以为空不需要验证
if ($targetType == 1 && $groupPushSubType == 2) {
// 群公告时允许为空,不进行验证
return true;
}
// 其他情况(群群发、好友推送),内容库必填
if (!isset($value) || $value === null || $value === '') {
return false;
}
if (!is_array($value) || count($value) < 1) {
return false;
}
}
return true;
}
}