src/Biz/Content/Service/Impl/CommentServiceImpl.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\Content\Service\Impl;
use Biz\BaseService;
use Biz\Content\CommentException;
use Biz\Content\Dao\CommentDao;
use Biz\Content\Service\CommentService;
use Biz\Course\CourseException;
use Biz\Course\Service\CourseService;
use AppBundle\Common\TimeMachine;
use Biz\User\UserException;
class CommentServiceImpl extends BaseService implements CommentService
{
public function createComment(array $comment)
{
$this->checkCommentObjectFields($comment['objectType']);
$this->checkCommentObjectValue($comment);
$fields = array();
$fields['objectType'] = $comment['objectType'];
$fields['objectId'] = $comment['objectId'];
$fields['content'] = $comment['content'];
$fields['userId'] = $this->getCurrentUser()->id;
$fields['createdTime'] = TimeMachine::time();
return $this->getCommentDao()->create($fields);
}
public function getComment($id)
{
return $this->getCommentDao()->get($id);
}
public function findComments($objectType, $objectId, $start, $limit)
{
$this->checkCommentObjectFields($objectType);
$this->checkCommentObjectValue(array('objectType' => $objectType, 'objectId' => $objectId));
return $this->getCommentDao()->findByObjectTypeAndObjectId($objectType, $objectId, $start, $limit);
}
public function deleteComment($id)
{
$user = $this->getCurrentUser();
$comment = $this->getComment($id);
if (empty($comment)) {
$this->createNewException(CommentException::NOTFOUND_COMMENT());
}
if (empty($user)) {
$this->createNewException(UserException::UN_LOGIN());
}
if ($comment['userId'] != $user['id'] && !$user->isAdmin()) {
$this->createNewException(CommentException::FORBIDDEN_DELETE());
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。