This commit is contained in:
JaguarJack 2023-03-10 17:08:35 +08:00
commit 3ca5de717c
16 changed files with 0 additions and 659 deletions

View File

@ -1,67 +0,0 @@
<?php
declare(strict_types=1);
namespace Modules\Cms\Http\Controllers;
use Catch\Base\CatchController as Controller;
use Modules\Cms\Models\Category;
use Illuminate\Http\Request;
class CategoryController extends Controller
{
public function __construct(
protected readonly Category $model
){}
/**
* @return mixed
*/
public function index(): mixed
{
return $this->model->getList();
}
/**
* store
*
* @param Request $request
* @return mixed
*/
public function store(Request $request): mixed
{
return $this->model->storeBy($request->all());
}
/**
* show
*
* @param $id
* @return mixed
*/
public function show($id): mixed
{
return $this->model->firstBy($id);
}
/**
*
* @param $id
* @param Request $request
* @return mixed
*/
public function update($id, Request $request): mixed
{
return $this->model->updateBy($id, $request->all());
}
/**
*
* @param $id
* @return bool|null
*/
public function destroy($id): ?bool
{
return $this->model->deleteBy($id);
}
}

View File

@ -1,43 +0,0 @@
<?php
declare(strict_types=1);
namespace Modules\Cms\Models;
use Catch\Base\CatchModel as Model;
/**
* @property $id
* @property $parent_id
* @property $name
* @property $slug
* @property $order
* @property $post_count
* @property $creator_id
* @property $created_at
* @property $updated_at
* @property $deleted_at
*/
class Category extends Model
{
protected $table = 'cms_category';
protected $fillable = [ 'id', 'parent_id', 'name', 'slug', 'order', 'post_count', 'creator_id', 'created_at', 'updated_at', 'deleted_at' ];
/**
* @var array
*/
protected array $fields = ['id','parent_id','name','slug','order','post_count','created_at','updated_at'];
/**
* @var array
*/
protected array $form = ['parent_id','name','slug','order'];
/**
* @var array
*/
public array $searchable = [
'name' => 'like'
];
}

View File

@ -1,20 +0,0 @@
<?php
namespace Modules\Cms\Providers;
use Catch\CatchAdmin;
use Catch\Providers\CatchModuleServiceProvider;
class CmsServiceProvider extends CatchModuleServiceProvider
{
/**
* route path
*
* @return string
*/
public function moduleName(): string
{
// TODO: Implement path() method.
return 'Cms';
}
}

View File

@ -1,43 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cms_user', function (Blueprint $table) {
$table->id();
$table->string('nickname', 50)->comment('昵称');
$table->string('password')->comment('密码');
$table->string('email', 100)->comment('邮箱');
$table->string('homepage')->comment('主页地址');
$table->string('active_key')->comment('激活码');
$table->tinyInteger('status')->default(0)->comment('状态 0 无需激活 1 未激活 2 激活');
$table->creatorId();
$table->createdAt();
$table->updatedAt();
$table->deletedAt();
$table->engine='InnoDB';
$table->comment('用户管理表');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_user');
}
};

View File

@ -1,39 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cms_user_meta', function (Blueprint $table) {
$table->id();
$table->integer('user_id')->nullable()->comment('用户ID');
$table->string('key')->nullable()->comment('元数据的 key');
$table->string('value')->nullable()->comment('元数据的值');
$table->createdAt();
$table->updatedAt();
$table->deletedAt();
$table->engine='InnoDB';
$table->comment('用户关联的元数据表');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_user_meta');
}
};

View File

@ -1,48 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cms_comment', function (Blueprint $table) {
$table->id();
$table->integer('parent_id')->comment('父级ID');
$table->integer('user_id')->default(0)->comment('用户ID不一定存在');
$table->integer('post_id')->default(0)->comment('文章ID');
$table->string('author')->nullable()->comment('作者');
$table->string('author_email')->comment('作者邮箱');
$table->string('author_homepage')->comment('作者的主页');
$table->string('author_ip')->comment('ip地址');
$table->text('content')->comment('评论内容');
$table->tinyInteger('is_approved')->default(1)->comment('1 未批准 2 批准');
$table->string('user_agent')->comment('评论者的USER AGENT');
$table->string('type')->default(1)->comment('评论类型 1 普通 2 回复');
$table->creatorId();
$table->createdAt();
$table->updatedAt();
$table->deletedAt();
$table->engine='InnoDB';
$table->comment('评论表');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_comment');
}
};

View File

@ -1,39 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cms_comment_mata', function (Blueprint $table) {
$table->id();
$table->integer('comment_id')->comment('评论ID');
$table->string('key')->comment('评论元数据 KEY');
$table->string('value')->comment('评论元数据 Value');
$table->createdAt();
$table->updatedAt();
$table->deletedAt();
$table->engine='InnoDB';
$table->comment('评论元数据表');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_comment_mata');
}
};

View File

@ -1,47 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cms_links', function (Blueprint $table) {
$table->id();
$table->string('name')->comment('链接名称');
$table->string('url')->comment('链接的 URL');
$table->string('image')->comment('链接图片');
$table->tinyInteger('is_target')->default(1)->comment('打开方式 1 本窗口打开 2 新窗口打开');
$table->tinyText('description')->comment('描述');
$table->tinyInteger('is_visible')->default(1)->comment('是否可见 1 不可见 2 可见');
$table->integer('rating')->comment('评分等级');
$table->string('rel')->comment('友情链接');
$table->string('rel_notes', 1000)->comment('友情链接注释');
$table->string('rss')->comment('rss 链接地址');
$table->creatorId();
$table->createdAt();
$table->updatedAt();
$table->deletedAt();
$table->engine='InnoDB';
$table->comment('链接表');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_links');
}
};

View File

@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cms_options', function (Blueprint $table) {
$table->id();
$table->string('key')->comment('key');
$table->text('value')->comment('value 值');
$table->tinyInteger('autoload')->default(1)->comment('是否自动载入 1 是 2 否');
$table->creatorId();
$table->createdAt();
$table->updatedAt();
$table->deletedAt();
$table->engine='InnoDB';
$table->comment('选项, key value');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_options');
}
};

View File

@ -1,48 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cms_posts', function (Blueprint $table) {
$table->id();
$table->string('author')->comment('作者');
$table->string('title')->comment('标题');
$table->longText('content')->comment('内容');
$table->tinyText('excerpt')->comment('摘录');
$table->tinyInteger('status')->default(1)->comment('文章状态 1 草稿 2 发布');
$table->tinyInteger('is_can_comment')->default(1)->comment('是否可以评论 1 可以 2 不可以');
$table->string('password')->comment('文章查看密码');
$table->integer('order')->default(1)->comment('排序 默认 1');
$table->integer('user_id')->default(0)->comment('用户ID 0 未知');
$table->tinyInteger('type')->default(1)->comment('文章类型 1 文章 2 页面');
$table->integer('comment_count')->default(0)->comment('评论总数');
$table->creatorId();
$table->createdAt();
$table->updatedAt();
$table->deletedAt();
$table->engine='InnoDB';
$table->comment('文章内容表');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_posts');
}
};

View File

@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cms_category_meta', function (Blueprint $table) {
$table->id();
$table->integer('category_id')->comment('分类ID');
$table->string('key')->comment('元数据key');
$table->string('value')->comment('元数据的值');
$table->creatorId();
$table->createdAt();
$table->updatedAt();
$table->deletedAt();
$table->engine='InnoDB';
$table->comment('分类元数据');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_category_meta');
}
};

View File

@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cms_catetory_relationships', function (Blueprint $table) {
$table->id();
$table->integer('category_id')->comment('分类ID');
$table->integer('object_id')->comment('文章ID/链接ID');
$table->tinyInteger('type')->default(1)->comment('类型 1 文章 2 链接');
$table->creatorId();
$table->createdAt();
$table->updatedAt();
$table->deletedAt();
$table->engine='InnoDB';
$table->comment('分类关系');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_catetory_relationships');
}
};

View File

@ -1,42 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cms_category', function (Blueprint $table) {
$table->id();
$table->integer('parent_id')->default(0)->comment('父级ID');
$table->string('name')->comment('名称');
$table->string('slug')->comment('缩略名');
$table->integer('order')->default(1)->comment('排序 默认 1');
$table->integer('post_count')->default(0)->comment('文章数量');
$table->creatorId();
$table->createdAt();
$table->updatedAt();
$table->deletedAt();
$table->engine='InnoDB';
$table->comment('分类');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cms_category');
}
};

View File

@ -1,10 +0,0 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Cms\Http\Controllers\CategoryController;
Route::prefix('cms')->group(function(){
Route::apiResource('category', CategoryController::class);
//next
});

View File

@ -1,43 +0,0 @@
<template>
<el-form :model="formData" label-width="120px" ref="form" v-loading="loading" class="pr-4">
<el-form-item label="父级分类" prop="parent_id">
<el-select v-model="formData.parent_id" placeholder="请选择" clearable multiple>
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="分类名称" prop="name">
<el-input v-model="formData.name" name="name" clearable />
</el-form-item>
<el-form-item label="缩略名" prop="slug">
<el-input v-model="formData.slug" name="slug" clearable />
</el-form-item>
<el-form-item label="排序" prop="order">
<el-input-number v-model="formData.order" name="order" :min="1" />
</el-form-item>
<div class="flex justify-end">
<el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
</div>
</el-form>
</template>
<script lang="ts" setup>
import { useCreate } from '/admin/composables/curd/useCreate'
import { useShow } from '/admin/composables/curd/useShow'
import { onMounted } from 'vue'
const props = defineProps({
primary: String | Number,
api: String,
})
const { formData, form, loading, submitForm, close } = useCreate(props.api, props.primary)
if (props.primary) {
useShow(props.api, props.primary, formData)
}
const emit = defineEmits(['close'])
onMounted(() => {
close(() => emit('close'))
})
</script>

View File

@ -1,50 +0,0 @@
<template>
<div>
<Search :search="search" :reset="reset">
<template v-slot:body> </template>
</Search>
<div class="table-default">
<Operate :show="open" />
<el-table :data="tableData" class="mt-3" v-loading="loading" row-key="id" default-expand-all :tree-props="{ children: 'children' }">
<el-table-column prop="id" label="ID" />
<el-table-column prop="parent_id" label="父级分类" />
<el-table-column prop="name" label="分类名称" />
<el-table-column prop="slug" label="缩略名" />
<el-table-column prop="order" label="排序" />
<el-table-column prop="post_count" label="文章数量" />
<el-table-column prop="created_at" label="创建时间" />
<el-table-column prop="updated_at" label="更新时间" />
<el-table-column label="操作" width="200">
<template #default="scope">
<Update @click="open(scope.row.id)" />
<Destroy @click="destroy(api, scope.row.id)" />
</template>
</el-table-column>
</el-table>
<Paginate />
</div>
<Dialog v-model="visible" :title="title" destroy-on-close>
<Create @close="close(reset)" :primary="id" :api="api" />
</Dialog>
</div>
</template>
<script lang="ts" setup>
import { computed, onMounted } from 'vue'
import Create from './create.vue'
import { useGetList } from '/admin/composables/curd/useGetList'
import { useDestroy } from '/admin/composables/curd/useDestroy'
import { useOpen } from '/admin/composables/curd/useOpen'
const api = 'cms/category'
const { data, query, search, reset, loading } = useGetList(api)
const { destroy, deleted } = useDestroy()
const { open, close, title, visible, id } = useOpen()
const tableData = computed(() => data.value?.data)
onMounted(() => {
search()
deleted(reset)
})
</script>