Commit 928bfbe8 authored by wangzhengwen's avatar wangzhengwen

学习资料

parent 1da2424d
凡骄网络科技
\ No newline at end of file
# 文档预览系统
这是一个简单的文档预览系统,支持PDF和Word文档的在线预览。
## 功能特性
* PDF文档在线预览(使用PDF.js)
* Word文档在线预览(使用Google Docs Viewer)
* 拖拽上传文件
* 响应式设计,适合各种设备
* 简洁现代的用户界面
## 安装与使用
### 系统要求
* 支持PHP 7.0+的Web服务器(Apache/Nginx)
* 启用mod_rewrite模块(Apache)
* 启用文件上传功能
### 安装步骤
1. 将所有文件上传到Web服务器目录
2. 确保`uploads`目录可写(权限设为755或777)
3. 确保PHP文件上传配置正确(php.ini中的upload_max_filesize和post_max_size)
### 配置说明
系统主要包含以下文件:
* `cs.html` - 主页面,包含文档预览功能
* `upload_word.php` - 处理Word文档上传的PHP脚本
* `.htaccess` - Apache服务器配置文件
* `uploads/` - 上传文件存储目录(会自动创建)
## 使用方法
1. 访问`cs.html`页面
2. 选择要预览的文档类型(PDF或Word)
3. 点击上传区域或拖拽文件到上传区域
4. 等待文件上传并预览
## 注意事项
* PDF预览完全在客户端进行,无需服务器端处理
* Word预览需要上传文件到服务器,然后使用Google Docs Viewer进行预览
* 由于Google Docs Viewer安全限制,预览的文件URL必须是公开可访问的
* 在实际应用中,可能需要考虑文件访问权限、存储限制等问题
## 技术实现
* 前端:HTML5、CSS3、JavaScript
* PDF预览:PDF.js库
* Word预览:Google Docs Viewer
* 后端:PHP
* 服务器:Apache(带mod_rewrite)
\ No newline at end of file
......@@ -240,4 +240,9 @@ class Search extends BaseController
Cache::tag('search_plus')->clear();
return $this->returnMsg('缓存清除成功', 1);
}
public function addSearchKey()
{
}
}
\ No newline at end of file
<?php
namespace app\api\controller\study;
use app\api\validate\StudyInformationValidate;
use app\BaseController;
use app\model\Project as ProjectModel;
use app\model\StudyCategory;
use app\model\StudyInformation;
use think\Request;
class Study extends BaseController
{
public function getStudyList(Request $request)
{
$vo = (new StudyInformationValidate())->goCheck(['category_id']);
if ($vo !== true) {
return $vo;
}
$data = $request->param();
$page = $request->param('page/d', 1);
$pageSize = $request->param('pageSize/d', 10);
$list = (new StudyInformation())->studyList($data['category_id'],$page,$pageSize);
return $this->returnMsg('success',1,$list);
}
public function getStudyDetail(Request $request)
{
$vo = (new StudyInformationValidate())->goCheck(['study_information_id']);
if ($vo !== true) {
return $vo;
}
$data = $request->param();
$data = (new StudyInformation())->studyDetail($data['study_information_id']);
return $this->returnMsg('success',1,$data);
}
public function getStudyCategoryList(Request $request)
{
$vo = (new StudyInformationValidate())->goCheck(['pid']);
if ($vo !== true) {
return $vo;
}
$data = $request->param();
$list = (new StudyCategory())->getStudyCategoryList($data['pid']);
return $this->returnMsg('success',1,$list);
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ class StudyInformationValidate extends BaseValidate
'content' => 'requireCallback:contentcheck',
'updateField' => 'require|in:is_sell',
'updateValue' => 'require',
'pid' => 'require',
];
protected $message = [
......
......@@ -135,13 +135,18 @@ class Course extends Model
if ($searchKeyWords) {
$query->where('title', 'like', '%' . $searchKeyWords . '%');
}
return $query->field('id,thumb,title,createtime,description,price,content')
->with(['thumb'])
$list = $query->field('id,thumb,title,createtime,description,price,content,teacher_id,tag_ids')
->with(['getTeacher'=>['thumb'],'thumb'])
->paginate([
'page' => $page,
'list_rows' => $pageSize
]);
if ($list->isEmpty()) {
return $list;
}
$list = UtilService::listWithTags($list, CourseTag::class, 'tag_ids');
return $list;
}
//获取课程详情
......
......@@ -83,4 +83,43 @@ class StudyInformation extends Model
->where('isdel',0);
}
public static function studyList($category_id,$page,$pageSize)
{
$where = ['is_sell'=>1,'status'=>2];
$query = self::where($where);
$query->with(['getuserdata', 'filepath']);
if ($category_id != 0) {
$query->where('cate_id', $category_id);
}
$query->where(['is_sell'=>1,'status'=>2]);
$query->field('id,user_id,title,type,thumb,updatetime,createtime,file_id');
$list = $query->paginate([
'page' => $page,
'list_rows' => $pageSize
]);
return $list;
}
public function studyDetail($id)
{
$where = ['is_sell'=>1,'status'=>2];
$query = self::where($where);
$query->with(['getuserdata', 'filepath']);
if ($id != 0) {
$query->where('id', $id);
}
$query->where(['is_sell'=>1,'status'=>2]);
$query->field('id,user_id,title,type,thumb,updatetime,createtime,file_id');
return $query->find();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment