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
+44
View File
@@ -0,0 +1,44 @@
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
declare(strict_types=1);
namespace addon\forum\model;
use think\Model;
class ForumBoard extends Model
{
protected $name = 'forum_board';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_at';
protected $updateTime = 'update_at';
/**
* 启用的版块列表
*/
public static function enabledList()
{
return self::where('status', 1)->order('sort asc,id asc')->select();
}
/**
* 按 slug 解析版块
*/
public static function findBySlug(string $slug)
{
return self::where('slug', $slug)->where('status', 1)->find();
}
/**
* 增加帖子/回复计数
*/
public static function incr(int $boardId, string $field, int $step = 1)
{
if ($boardId < 1) {
return;
}
self::where('id', $boardId)->inc($field, $step)->update();
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
declare(strict_types=1);
namespace addon\forum\model;
use think\Model;
class ForumMessage extends Model
{
protected $name = 'forum_message';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_at';
protected $updateTime = 'update_at';
public static function unreadCount(int $userId): int
{
return self::where('user_id', $userId)->where('is_read', 0)->count();
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
declare(strict_types=1);
namespace addon\forum\model;
use think\Model;
class ForumReply extends Model
{
protected $name = 'forum_reply';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_at';
protected $updateTime = 'update_at';
public static function listByTopic(int $topicId)
{
return self::where('topic_id', $topicId)
->where('status', 1)
->order('floor asc, id asc')
->select();
}
public static function countByTopic(int $topicId): int
{
return self::where('topic_id', $topicId)->where('status', 1)->count();
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
declare(strict_types=1);
namespace addon\forum\model;
use think\Model;
class ForumTag extends Model
{
protected $name = 'forum_tag';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_at';
protected $updateTime = 'update_at';
}
+68
View File
@@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
declare(strict_types=1);
namespace addon\forum\model;
use think\Model;
class ForumTopic extends Model
{
protected $name = 'forum_topic';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_at';
protected $updateTime = 'update_at';
// 帖子类型(对应 Fly 专栏 class 值)
const TYPE_ASK = 0; // 提问
const TYPE_SHARE = 99; // 分享
const TYPE_DISCUSS = 100; // 讨论
const TYPE_SUGGEST = 101; // 建议
const TYPE_NOTICE = 168; // 公告
const TYPE_DYNAMIC = 169; // 动态
public static $typeMap = [
self::TYPE_ASK => '提问',
self::TYPE_SHARE => '分享',
self::TYPE_DISCUSS => '讨论',
self::TYPE_SUGGEST => '建议',
self::TYPE_NOTICE => '公告',
self::TYPE_DYNAMIC => '动态',
];
/**
* 前台列表查询(返回普通集合,便于模板直接 volist)
* @param int $boardId
* @param string $type 空=全部
* @param string $order hot|new
* @param int $size 返回条数
*/
public static function listFront(int $boardId = 0, string $type = '', string $order = 'new', int $page = 1, int $size = 20)
{
$q = self::where('status', 1);
if ($boardId > 0) {
$q->where('board_id', $boardId);
}
if ($type !== '' && isset(self::$typeMap[(int) $type])) {
$q->where('type', (int) $type);
}
if ($order === 'hot') {
$q->order('reply_count desc, views desc');
} else {
$q->order('is_top desc, id desc');
}
return $q->limit($size)->select();
}
public static function findById(int $id)
{
return self::where('id', $id)->where('status', '>=', 0)->find();
}
public static function addViews(int $id)
{
self::where('id', $id)->inc('views', 1)->update();
}
}