feat: add note module and route fixes

This commit is contained in:
nepiedg
2026-04-17 07:48:44 +00:00
parent 866ddb046b
commit 84e1c0daac
25 changed files with 2196 additions and 38 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace app\note\model;
use think\Model;
/**
* note 模块 AI 总结模型
*/
class NoteAiSummary extends Model
{
protected $connection = 'dbnote';
protected $name = 'note_ai_summary';
protected $pk = 'id';
protected $autoWriteTimestamp = false;
/**
* 获取笔记最新总结
*
* @param int $noteId
* @return self|null
*/
public static function findLatestByNoteId(int $noteId): ?self
{
return self::where('note_id', $noteId)
->order('id', 'desc')
->find();
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace app\note\model;
use think\Model;
use think\db\Query;
/**
* note 模块笔记主表模型
*/
class NoteItem extends Model
{
protected $connection = 'dbnote';
protected $name = 'note_item';
protected $pk = 'id';
protected $autoWriteTimestamp = false;
/**
* 创建当前用户的基础查询
*
* @param int $noteUserId
* @return Query
*/
public static function buildUserQuery(int $noteUserId): Query
{
return self::where('note_user_id', $noteUserId)
->where('deleted_at', 0);
}
/**
* 查询当前用户拥有的笔记
*
* @param int $noteUserId
* @param int $id
* @return self|null
*/
public static function findOwnedNote(int $noteUserId, int $id): ?self
{
return self::buildUserQuery($noteUserId)
->where('id', $id)
->find();
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace app\note\model;
use think\Model;
/**
* note 模块实时转写模型
*/
class NoteTranscript extends Model
{
protected $connection = 'dbnote';
protected $name = 'note_transcript';
protected $pk = 'id';
protected $autoWriteTimestamp = false;
/**
* 查找某条笔记的指定分片
*
* @param int $noteId
* @param int $segmentNo
* @return self|null
*/
public static function findByNoteAndSegment(int $noteId, int $segmentNo): ?self
{
return self::where('note_id', $noteId)
->where('segment_no', $segmentNo)
->find();
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace app\note\model;
use think\Model;
/**
* note 模块小程序用户模型
*/
class NoteUser extends Model
{
protected $connection = 'dbnote';
protected $name = 'note_user';
protected $pk = 'id';
protected $autoWriteTimestamp = false;
/**
* 根据 openid 查找用户
*
* @param string $openid
* @return self|null
*/
public static function findByOpenid(string $openid): ?self
{
return self::where('openid', $openid)
->where('deleted_at', 0)
->find();
}
/**
* 根据主键查找用户
*
* @param int $id
* @return self|null
*/
public static function findActiveById(int $id): ?self
{
return self::where('id', $id)
->where('deleted_at', 0)
->find();
}
}