chore: 重写初始提交(清空历史,整理后全量提交)

This commit is contained in:
ywxapp
2026-08-16 16:54:14 +08:00
commit 6c1a106bc1
1808 changed files with 238144 additions and 0 deletions
+91
View File
@@ -0,0 +1,91 @@
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ywxapp<admin@ywxapp.cn>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace addon\docs\model;
use think\Model;
/**
* 文档正文模型
*
* @author ywxapp <admin@ywxapp.cn>
*/
class DocsDoc extends Model
{
protected $name = 'docs_doc';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_at';
protected $updateTime = 'update_at';
protected $type = [
'id' => 'integer',
'project_id' => 'integer',
'version_id' => 'integer',
'pid' => 'integer',
'editor_type' => 'integer',
'is_dir' => 'integer',
'views' => 'integer',
'uid' => 'integer',
'editor_uid' => 'integer',
'audit_status' => 'integer',
'sort' => 'integer',
'status' => 'integer',
];
/**
* 关联所属项目
*/
public function project()
{
return $this->belongsTo(DocsProject::class, 'project_id', 'id');
}
/**
* 关联所属版本
*/
public function version()
{
return $this->belongsTo(DocsVersion::class, 'version_id', 'id');
}
/**
* 按项目 + 版本 + 标识查找已发布文档
*
* @param int $projectId 项目ID
* @param int $versionId 版本ID
* @param string $name 文档标识
* @return static|null
*/
public static function findByName(int $projectId, int $versionId, string $name)
{
if ($name === '') {
return null;
}
return static::where('project_id', $projectId)
->where('version_id', $versionId)
->where('name', $name)
->where('status', 1)
->find();
}
/**
* 阅读量自增
*
* @param int $id 文档ID
* @return void
*/
public static function addViews(int $id): void
{
if ($id > 0) {
static::where('id', $id)->inc('views')->update();
}
}
}
+71
View File
@@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ywxapp<admin@ywxapp.cn>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace addon\docs\model;
use think\Model;
/**
* 文档项目模型
*
* @author ywxapp <admin@ywxapp.cn>
*/
class DocsProject extends Model
{
protected $name = 'docs_project';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_at';
protected $updateTime = 'update_at';
protected $type = [
'id' => 'integer',
'owner_uid' => 'integer',
'sort' => 'integer',
'status' => 'integer',
];
/**
* 关联版本列表
*/
public function versions()
{
return $this->hasMany(DocsVersion::class, 'project_id', 'id')
->order('sort', 'asc')
->order('id', 'asc');
}
/**
* 按 URL 标识获取启用中的项目
*
* @param string $name 项目标识
* @return static|null
*/
public static function findByName(string $name)
{
if ($name === '') {
return null;
}
return static::where('name', $name)->where('status', 1)->find();
}
/**
* 获取全部启用项目(按排序)
*
* @return \think\Collection
*/
public static function enabledList()
{
return static::where('status', 1)
->order('sort', 'asc')
->order('id', 'asc')
->select();
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ywxapp<admin@ywxapp.cn>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace addon\docs\model;
use think\Model;
/**
* 文档搜索索引模型
*
* @author ywxapp <admin@ywxapp.cn>
*/
class DocsSearch extends Model
{
protected $name = 'docs_search';
protected $autoWriteTimestamp = true;
protected $createTime = false;
protected $updateTime = 'update_at';
protected $type = [
'id' => 'integer',
'doc_id' => 'integer',
'project_id' => 'integer',
'version_id' => 'integer',
];
/**
* 关联文档
*/
public function doc()
{
return $this->belongsTo(DocsDoc::class, 'doc_id', 'id');
}
}
+94
View File
@@ -0,0 +1,94 @@
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ywxapp<admin@ywxapp.cn>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace addon\docs\model;
use think\Model;
/**
* 文档版本模型
*
* @author ywxapp <admin@ywxapp.cn>
*/
class DocsVersion extends Model
{
protected $name = 'docs_version';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_at';
protected $updateTime = 'update_at';
protected $type = [
'id' => 'integer',
'project_id' => 'integer',
'is_default' => 'integer',
'sort' => 'integer',
'status' => 'integer',
];
/**
* 关联所属项目
*/
public function project()
{
return $this->belongsTo(DocsProject::class, 'project_id', 'id');
}
/**
* 获取项目下的启用版本列表
*
* @param int $projectId 项目ID
* @return \think\Collection
*/
public static function listByProject(int $projectId)
{
return static::where('project_id', $projectId)
->where('status', 1)
->order('sort', 'asc')
->order('id', 'asc')
->select();
}
/**
* 解析项目的目标版本
*
* 优先按名称精确匹配,其次取默认版本,最后退回第一个版本。
*
* @param int $projectId 项目ID
* @param string $name 版本标识,为空表示取默认
* @return static|null
*/
public static function resolve(int $projectId, string $name = '')
{
if ($name !== '') {
$version = static::where('project_id', $projectId)
->where('name', $name)
->where('status', 1)
->find();
if ($version) {
return $version;
}
}
$default = static::where('project_id', $projectId)
->where('status', 1)
->where('is_default', 1)
->find();
if ($default) {
return $default;
}
return static::where('project_id', $projectId)
->where('status', 1)
->order('sort', 'asc')
->order('id', 'asc')
->find();
}
}