// +---------------------------------------------------------------------- declare (strict_types = 1); namespace addon\articles\model; use ywxapp\model\BaseModel; /** * 点赞记录模型 * * 唯一键 (uid, target_id, type) 保证同一用户对同一目标只能点一次赞; * 计数冗余在 articles_article.like_count / articles_comment.like_count。 */ class ArticleLike extends BaseModel { /** 文章点赞 */ const TYPE_ARTICLE = 1; /** 评论点赞 */ const TYPE_COMMENT = 2; protected $name = 'articles_like'; // 只需记录创建时间,且不自动维护时间戳(由 service 显式写入) protected $autoWriteTimestamp = false; protected $type = [ 'uid' => 'integer', 'target_id' => 'integer', 'type' => 'integer', ]; public static function ensureSchema(): void { \addon\articles\library\ArticleSchema::ensure(); } }