# FAST云课堂 **Repository Path**: iizue/fast ## Basic Information - **Project Name**: FAST云课堂 - **Description**: fastadmin + thinkphp + swoole - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-08-02 - **Last Updated**: 2024-08-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Thinkphp5.0(MVC框架) + FastAdmin(二次开发系统) MVC M:model(模型) 数据模型,对数据库的操作 V:view(视图) 视图 == 页面 C:Controller(控制器) 书写我们业务逻辑 validate:验证器 验证数据 访问流程:Url(访问地址) -> index.php -> 控制器Controller -> 加载模型,查询数据 -> 视图页面显示 Thinkphp5 纯裸框架 MVC 架构 FastAdmin(二次开发系统) -> 自带一些表 系统配置 管理员 权限功能 插件系统(免费,收费) 会员系统 文件附件管理 FastAdmin官网:https://www.fastadmin.net/ FastAdmin框架文档:https://doc.fastadmin.net/doc 云课堂项目:规范 Fast云服务 域名、目录、数据库、表前缀、gitee仓库 www.fast.com 编码:utf8mb4_general_ci 完整项目: 前台 后台 Thinkphp + FastAdmin 目录结构 -> 文档、手册中文 addons 插件目录 extend 拓展第三方组件 runtime 运行时所产生文件目录 thinkphp 这个框架的源代码目录 vendor node_modules包 框架所需要依赖的包管理文件夹 think 框架的命令行执行文件 public/ <- 虚拟主机指向的目录 /assets/ 静态文件 css js font images /uploads/ 上传文件 /template/ 模板文件 index.php -> 框架的入口文件 admin.php -> 后台入口文件 application/ MVC 应用程序目录 config.php 整个框架和系统的配置文件 database.php 数据库的配置文件 home/ 前台模块 Controller 控制器 Model 模型 View 视图 admin/ 后台模块 小型的MVC Controller/ Model/ View/ common/ 公共模块 Controller/ Model/ UserModel.php View/ 采集图片和小说 php不是一个内部和外部变量 添加php的环境变量 php --version 一定要在 项目的根目录下去执行 创建前台模块 php think build --module 模块名称 php think build --module home 更改默认访问的模块地址 config.php -> default_module www.fast.com -> fast/public/ 目录 public/index.php -> 入口程序 www.fast.com/index.php/模块/控制器/控制器方法/ URL地址:www.fast.com/index.php/home/index/index 控制器文件:application/home/controller/Index.php -> Class Index -> public function index 开启错误的调试模式:application/config.php -> APP_DEBUG -> FALSE 修改为 TRUE 在模板当中如何去进行跳转:框架的函数 在模板中输出:{} 不要吧所有的程序都写到一个控制器里面 要按照模块的概念去分离 跟用户有关:user 跟商户有关:business 跟课程有关:subject 跟订单有关:order 跟商品有关:product 跟支付有关:pay 创建一个控制器 会自动将这个文件放到 application/home/controller/Business.php php think make:controller 模块/Business 清除缓存 php think clear 当前模块的配置信息: application/home/config.php 更改全局配置信息:application/config.php 创建模型的命令 php think make:model common/Business/Business php think make:model common/Business/Source common(模块)/Business(二级目录)/Business(模型的名字) 数据表的表前缀 pre_ fa_ fa_business fa_business_address fa_business_record fa_order_address password=123123 salt=hudfihgg md5(password.salt) 调试期间如何打印SQL语句 sql=model(′Business.Business′)−>where([′mobile′=> mobile])->getLastSql(); echo $sql; //看数据结构 //查询一条数据 一维数组 business=model(′Business.Business′)−>where([′mobile′=> mobile])->find(); //将模型数据转换为数组 var_dump($business->toArray()); //查询多条数据 二维数组 business=model(′Business.Business′)−>where([′mobile′=> mobile])->select(); //将集合转换为数组 var_dump(collection($business)->toArray()); PHP单继承面相对象 判断登录功能封装 Business => Home(公共控制器) => Controller 创建一个公共的控制器 php think make:controller common/Home 创建一个地区表的模型 php think make:model common/Region save方法:新增插入、更新语句 数据中是否有 主建ID 字段 save 方法 专门给模型使用的 我们之所以去使用 save方法 他可以去使用 validate 验证码 用户:qq邮箱 后台:服务方 163 使用协议SMTP fa_business -> auth 0未认证 1已认证 fa_ems 邮件验证表 发送验证码 1 2 3 我们要始终保持 每个人只有一条验证码 fa_ems 删除 fa_ems 插入语句 验证邮箱验证码 fa_ems 删除语句 fa_business auth 1 更新语句 事务:保证我们sql语句能够统一的执行完毕 cart 购物车 order 订单 business 用户表 事务的作用 如果在其中的某一条执行失败了的话,就会执行回滚动作 order 插入语句 business 扣钱 更新语句 cart 删除语句 点击发送按钮 -> 发送ajax请求 -> 控制器接收 -> 开启事务 -> 删除过期的验证码记录 -> 插入最新的验证码 -> 发送验证码 关于邮件发送 -> 不能频繁发送 不能发送一些敏感关键词 第三方邮件服务器 条数限制:看服务器的要求 1.域名 需要备案 2.服务器 php think make:controller Home/Team https://packagist.org/packages/dh2y/think-qrcode 安装生成二维码的 插件库 通过 composer 来进行安装 添加安装信息 到 composer.json 里面 "dh2y/think-qrcode":"1.*" 执行安装命令 composer install composer === npm 国外镜像源 php think make:model common/Subject/Subject php think make:model common/Subject/Teacher php think make:controller home/Coupon php think make:model common/Coupon/Coupon php think make:model common/Coupon/Receive php think make:validate common/Coupon/Coupon php think make:validate common/Coupon/Receive php think make:controller home/Subject php think make:controller home/Teacher 老师:粉丝 1:N 粉丝(会员):老师 1:N 互为:1:N == N:M 新建第三张表(关系表) 将两张表的主建放到第三张表做外键 老师表:fa_teacher 新增老师的粉丝表 fa_teacher_follow id teacherid 老师id busid 用户id createtime 关注时间 CREATE TABLE fast.fa_teacher_follow ( id int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', teacherid int UNSIGNED NULL COMMENT '老师外键ID', busid int UNSIGNED NULL COMMENT '客户外键ID', createtime int UNSIGNED NULL COMMENT '关注时间', PRIMARY KEY (id), INDEX key_teacher_follow_teacherid(teacherid) USING BTREE, INDEX key_teacher_follow_busid(busid) USING BTREE, CONSTRAINT fk_teacher_follow_teacherid FOREIGN KEY (teacherid) REFERENCES fast.fa_teacher (id) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT fk_teacher_follow_busid FOREIGN KEY (busid) REFERENCES fast.fa_business (id) ON DELETE CASCADE ON UPDATE NO ACTION ) ENGINE = InnoDB COMMENT = '老师的粉丝关注表'; ALTER TABLE fast.fa_teacher DROP COLUMN follows; 创建一个老师粉丝关注模型 php think make:model common/Teacher/Follow 创建一个验证器 php think make:validate common/Teacher/Follow fa_business_commission php think make:model common/Business/Commission ---------------------------------后台部分-------------------- 我们在后台中做功能的话,一定要先列出来功能的菜单 客户中心 -> business 一级菜单 客户来源 -> 二级菜单 business/source 目录结构:application/admin/business/Source.php business/source/index business/source/add business/source/edit business/source/del 客户公海 -> 二级菜单 business/highsea business/highsea/index 列表 business/highsea/apply 领取 business/highsea/allot 分配 business/highsea/del 软删除 php think crud -t business -c business/Highsea -u 1 客户私海 -> 二级菜单 business/privatesea business/privatesea/index 私海列表 business/privatesea/add 添加资源 business/privatesea/edit 编辑资源 business/privatesea/del 软删除 business/privatesea/recovery 客户回收 business/info/index 客户详情 php think crud -t business -c business/Privatesea -u 1 回收站 -> 二级菜单 business/recyclebin business/recyclebin/index 回收站列表 云课堂 subject 分类管理 subject/category 列表 subject/category/index 添加 subject/category/add 编辑 subject/category/edit 删除 subject/category/del PHP控制器:application/admin/subject/Category.php 视图:application/admin/subject/category/ html JS控制器:public/assets/js/backend/subject/category.js //生成fa_test表的CRUD且对应的模型名为testmodel php think crud -t subject_category -m Category -l 0 php think crud -t subject_category -c subject/Category -u 1 客户来源:一定要根据url地址来找东西 PHP控制器:application/admin/business/Source.php 视图:application/admin/view/business/source/index.html add.html edit.html del.html 模型:application/common/model/business/Source.php JS控制器(模块化):public/assets/js/backend/business/source.js PHP当中的控制器方法 === JS当中的控制器方法 创建PHP的控制器 php think make:controller admin/business/Source https://gitee.com/karson/fastadmin 客户私海 添加一个客户详情的界面 php think crud -t business -c Business/Info -u 1 构建菜单 business/info/index 详情界面 business/info/receive 申请记录 business/info/visit 回访记录 business/info/record 消费记录 business/info/subject 课程订单 business/recyclebin composer 下载工具 搜索包 composer search select2 初始化 包管理器的配置文件 composer init 安装 composer require select2/select2 项目上线:域名备案 服务器的IP:192.168.103.56 你的域名:www.demo.com 域名解析: @ 解析记录 demo.com www 解析记录 www.demo.com * 解析记录 泛域名解析 *.demo.com * 任意二级域名都可以访问 fast.demo.com 云课堂项目地址 shop.demo.com 商城项目地址 ping www.demo.com https://www.bt.cn/new/index.html 克隆完项目后 给目录设置权限 chmod -R 777 fast目录 chown -R www:www fast目录 站点目录:public 伪静态:选择thinkphp 服务器:nginx 导入数据库到线上 并修改 databases.php 文件账号密码 home前台当中 axios.js 异步请求 request.js baseURL = 'www.fast.com' 修改为 baseURL = 'http://fast.demo.com' axios.defaults.baseURL = 'http://www.fast.com/home' apache 和 nginx 都是服务器软件 nginx 对于大小写规范要求的非常严格 Vue商城项目 vite.config.js 修改反向代理的请求地址 然后重新打包 将打包的代码放到服务器上 给站点设置反向代理 让你的接口可以正常访问