src/Biz/Course/Sync/CourseChapter.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\Course\Sync;
use Biz\Course\Dao\CourseChapterDao;
use Biz\Course\Dao\CourseDao;
use Biz\Sync\Service\AbstractSychronizer;
class CourseChapter extends AbstractSychronizer
{
public function syncWhenCreate($sourceId)
{
$sourceChapter = $this->getCourseChapterDao()->get($sourceId);
$copiedCourses = $this->getCourseDao()->findCoursesByParentIdAndLocked($sourceChapter['courseId'], 1);
if (empty($copiedCourses)) {
return;
}
$helper = $this->getBatchHelper(self::BATCH_CREATE_HELPER, $this->getCourseChapterDao());
foreach ($copiedCourses as $copyCourse) {
$copyChapter = $sourceChapter;
$copyChapter['courseId'] = $copyCourse['id'];
$copyChapter['copyId'] = $sourceChapter['id'];
unset($copyChapter['id']);
$helper->add($copyChapter);
unset($copyChapter);
}
unset($copiedCourses);
}
public function syncWhenUpdate($sourceId)
{
$sourceChapter = $this->getCourseChapterDao()->get($sourceId);
$copiedChapters = $this->getCourseChapterDao()->findByCopyId($sourceId);
if (empty($copiedChapters)) {
return;
}
$helper = $this->getBatchHelper(self::BATCH_UPDATE_HELPER, $this->getCourseChapterDao());
foreach ($copiedChapters as $copiedChapter) {
$newFields = $sourceChapter;
unset($newFields['id']);
unset($newFields['courseId']);
unset($newFields['copyId']);
$helper->add('id', $copiedChapter['id'], $newFields);
unset($newFields);
}
unset($copiedChapters);
}
public function syncWhenDelete($sourceId)
{
$this->getCourseChapterDao()->batchDelete(array('copyId' => $sourceId));
}
/**
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。