mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-29 11:22:22 +08:00
Compare commits
354 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2c9f3b7577 | ||
|
13b3327b2f | ||
|
247050f4ef | ||
|
57409cb630 | ||
|
4e1e8340b9 | ||
|
2ab6ae71cd | ||
|
303442f446 | ||
|
7281029dd0 | ||
|
f5ed2ce239 | ||
|
2a1b4b69fd | ||
|
123e1ec97f | ||
|
b2f795eb3b | ||
|
12db90d9c1 | ||
|
59bfe4a765 | ||
|
fb0b760e2e | ||
|
e31b86580d | ||
|
f2a446a876 | ||
|
27440fe679 | ||
|
7a9fee5545 | ||
|
d927e619e8 | ||
|
77cdc594ff | ||
|
0d8b07033a | ||
|
9ad15b72cf | ||
|
12f0f6dc87 | ||
|
3efa081e81 | ||
|
47a6c5cce1 | ||
|
328aea1e2d | ||
|
e5869e1e8f | ||
|
9fcea65989 | ||
|
08d3859e38 | ||
|
02983a27c9 | ||
|
72deb17daa | ||
|
76edeef591 | ||
|
9c737c7241 | ||
|
21f9bdd4b1 | ||
|
9b0700e5c1 | ||
|
054ab77f08 | ||
|
90ab9bc018 | ||
|
77b7224901 | ||
|
f5665bc94a | ||
|
2b08bf737d | ||
|
fce99c2472 | ||
|
5854d86875 | ||
|
e22f3b4bdc | ||
|
3070231ca8 | ||
|
38f8e27c9c | ||
|
fb7301de4c | ||
|
9206166910 | ||
|
97af1081d3 | ||
|
2d26c2659b | ||
|
f273e874e7 | ||
|
b919239308 | ||
|
9d210deedf | ||
|
09723a9d34 | ||
|
9d8ed0f863 | ||
|
e27a203ac8 | ||
|
c3887845a9 | ||
|
4d810eae98 | ||
|
601c71b8a4 | ||
|
3a6d295aa1 | ||
|
6614cdc8d2 | ||
|
0f38ce7d62 | ||
|
6f005f741c | ||
|
9a51f95d26 | ||
|
41cb93d6d5 | ||
|
978b77a184 | ||
|
98cc8da285 | ||
|
a0e7bce18b | ||
|
9811186434 | ||
|
cdc8074f88 | ||
|
0f446fef10 | ||
|
7ff6f470aa | ||
|
5b30d5d880 | ||
|
f482a8ec9e | ||
|
2302f44c03 | ||
|
4ec6f60b06 | ||
|
fa8d27d668 | ||
|
a24ea6149e | ||
|
978f064e2b | ||
|
a360ce0f83 | ||
|
9b37570a78 | ||
|
86efc64651 | ||
|
d5353ff5d2 | ||
|
3a703dd0e1 | ||
|
7c5ea7fe34 | ||
|
17691a6a1b | ||
|
759253cfc5 | ||
|
0f5ed61158 | ||
|
e39c140d35 | ||
|
91a878ba98 | ||
|
56f94d3ea8 | ||
|
36ee91c1cf | ||
|
8aaed108b9 | ||
|
4a5cc68915 | ||
|
f0470c027d | ||
|
703d5cbc3d | ||
|
f04c23e90f | ||
|
b55350a9a4 | ||
|
0aa07da41b | ||
|
f66dab48ec | ||
|
2014d99c7e | ||
|
3efdc0698e | ||
|
675ee63674 | ||
|
14534b8461 | ||
|
30d9b80ca8 | ||
|
17b7f64de7 | ||
|
8e618b5bc7 | ||
|
4467f8748f | ||
|
45125453e0 | ||
|
200a0b0d16 | ||
|
272a3255d2 | ||
|
dfb88ee09e | ||
|
0c962920de | ||
|
b0b28117f5 | ||
|
e22a716aa5 | ||
|
dd469752e1 | ||
|
f5ba565f99 | ||
|
d0921a8afd | ||
|
fba681a4b5 | ||
|
56f66c01bd | ||
|
8a5aa01d1c | ||
|
a31c991b1c | ||
|
b2eb5d56d3 | ||
|
0c30cda0c3 | ||
|
a0e8e932e1 | ||
|
bd14979e9b | ||
|
4e80f3938a | ||
|
9addc3debe | ||
|
e24cf1bd1c | ||
|
c355709d03 | ||
|
2b3372c8e8 | ||
|
a790cf878b | ||
|
4171039f16 | ||
|
9a29e21441 | ||
|
502bd8588d | ||
|
621123ee3d | ||
|
0d6420ef16 | ||
|
547bb72910 | ||
|
046db8877c | ||
|
c968a3a69f | ||
|
d31ae5b7be | ||
|
65b0bf1678 | ||
|
af4b570681 | ||
|
d95b218812 | ||
|
d3623b2654 | ||
|
b96c711a6f | ||
|
89145284aa | ||
|
00cb8bf963 | ||
|
c304fbd423 | ||
|
2506ea4078 | ||
|
542e96846f | ||
|
3b18267c6f | ||
|
c4259d78f3 | ||
|
6a5c4845dc | ||
|
9b7a244fa3 | ||
|
d0091f4695 | ||
|
01587189cb | ||
|
45dfa0d269 | ||
|
56e04fc3a3 | ||
|
3079a9855a | ||
|
ebc609ac19 | ||
|
486ac7bd69 | ||
|
5e1ca229ec | ||
|
680f1cf1bc | ||
|
b67011c041 | ||
|
fd2e8d2aee | ||
|
78d538c816 | ||
|
5ce45971e6 | ||
|
33fc75b9f8 | ||
|
59e27e1443 | ||
|
ce9f0eade0 | ||
|
411ffe8f1c | ||
|
decf80273a | ||
|
db82de6f35 | ||
|
52aa85b2ae | ||
|
6c33dbc724 | ||
|
2714a048f8 | ||
|
dd0c26d6ad | ||
|
8e40019939 | ||
|
fb01e61332 | ||
|
da0cc73c12 | ||
|
b192760deb | ||
|
e0da7b71b3 | ||
|
56f909b5d2 | ||
|
c859deec44 | ||
|
435bc12035 | ||
|
dca1ccf79a | ||
|
817b32b067 | ||
|
51428ac97a | ||
|
8f22cab282 | ||
|
982b1d5ca7 | ||
|
f3fcb6956a | ||
|
3dd5490bdb | ||
|
5268e6370c | ||
|
79a678fa54 | ||
|
0072b4f5fe | ||
|
51de0ed94b | ||
|
26e3e94881 | ||
|
0a86fc3f05 | ||
|
e905e7cb96 | ||
|
2c881547b4 | ||
|
7d54f0e933 | ||
|
1bef24f217 | ||
|
0dec52806b | ||
|
241d802fe1 | ||
|
66bd0965d6 | ||
|
40380132a2 | ||
|
ebd310caa6 | ||
|
138b9d45ce | ||
|
504bf6d8e6 | ||
|
65b5190a05 | ||
|
f284a8ef92 | ||
|
c584f25455 | ||
|
85ba7911ac | ||
|
190117146f | ||
|
c0e44a76d0 | ||
|
0c9256751d | ||
|
1c0af6fa1e | ||
|
4f18d78356 | ||
|
621b921862 | ||
|
e48d831ce3 | ||
|
30ece511df | ||
|
b519fd4d6d | ||
|
fca03feb35 | ||
|
71898bf5ec | ||
|
cf80b3c878 | ||
|
44b5633f23 | ||
|
f0fdd6ebbb | ||
|
c9ddb0abab | ||
|
13ff32343d | ||
|
41c4fc45b2 | ||
|
9159e28b51 | ||
|
36ef6ca37b | ||
|
a72f44225f | ||
|
f7a3c0d736 | ||
|
fb5feb0759 | ||
|
ce2329a71c | ||
|
5985576065 | ||
|
cced354b2a | ||
|
f094f10011 | ||
|
2a055d9ad4 | ||
|
e3e5d20a7c | ||
|
7322d1fc0d | ||
|
84d21d80da | ||
|
772380adcd | ||
|
5405e1652e | ||
|
259859fae6 | ||
|
251c1348fa | ||
|
a581b0d493 | ||
|
464527fe67 | ||
|
1b1c048cca | ||
|
d59a63079a | ||
|
5ca47be92c | ||
|
a343b3c5f5 | ||
|
c639f89c7b | ||
|
bba2842967 | ||
|
14b2e1df20 | ||
|
56bbb7d6fe | ||
|
5a061ad9fb | ||
|
fcd15c1a5f | ||
|
df9d77cad2 | ||
|
d65e4cab43 | ||
|
7355e8c625 | ||
|
59b3edc1c0 | ||
|
f5753da68b | ||
|
d560e62405 | ||
|
2bc5cbf1a9 | ||
|
ecb20a14f4 | ||
|
74c08316f1 | ||
|
a3d62c71bf | ||
|
254a78f246 | ||
|
2a20d1eb2e | ||
|
db077346e1 | ||
|
8b501d8757 | ||
|
1f996ab384 | ||
|
2145316913 | ||
|
77228b99f0 | ||
|
1b25ccc30d | ||
|
3d42389012 | ||
|
46beccb67a | ||
|
7f9a63886f | ||
|
bd4d340f53 | ||
|
05837d6c5f | ||
|
46176071b8 | ||
|
a941d1129a | ||
|
301557abbc | ||
|
372b996365 | ||
|
3c5310b5bd | ||
|
6edbcc4638 | ||
|
3e7082b251 | ||
|
1825f2346f | ||
|
dd2c3009a4 | ||
|
6b6ccea185 | ||
|
fd1c209a1d | ||
|
04c0ac186f | ||
|
5032c0b432 | ||
|
d8c5a3d0a2 | ||
|
a3cb6d757a | ||
|
7153d4e5ef | ||
|
63a1f6eb1d | ||
|
810956cf36 | ||
|
2ece258a67 | ||
|
fc4ee4cf49 | ||
|
de38cc756d | ||
|
d840f5fe71 | ||
|
1c42df299e | ||
|
370ffa4250 | ||
|
c17447784c | ||
|
79cc6b9c9e | ||
|
06607e7f2e | ||
|
9ebbf2cecc | ||
|
79a2253918 | ||
|
c801559b62 | ||
|
3854a082d3 | ||
|
8d64969040 | ||
|
b79d6e5588 | ||
|
42f591173d | ||
|
93ec72faf6 | ||
|
fbcc721828 | ||
|
bf3b84638a | ||
|
1093f52350 | ||
|
a47e63340e | ||
|
73d04e3c63 | ||
|
ea78fd3c5c | ||
|
6870380091 | ||
|
13873dcb0b | ||
|
b60f8fe485 | ||
|
21f79dad80 | ||
|
923095700f | ||
|
290fda610b | ||
|
9b55b04e5f | ||
|
4c9557c5c8 | ||
|
2628f6b7d7 | ||
|
20fb468f0d | ||
|
cd9422afc1 | ||
|
107c54dba9 | ||
|
5d2a4b8b11 | ||
|
cd3922e3dd | ||
|
0b161d52bb | ||
|
dc85029241 | ||
|
f5719c2ee7 | ||
|
175737f274 | ||
|
34da1deae6 | ||
|
d1917781fb | ||
|
21f92166d2 | ||
|
35a8785177 | ||
|
7945644f3a | ||
|
7f9314a111 | ||
|
b5ceb155f3 | ||
|
83a39e5648 | ||
|
d86ee20ced | ||
|
23305e1738 | ||
|
f1ceae2301 | ||
|
e272bfc585 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,12 +5,11 @@
|
||||
/config/xs.course.ini
|
||||
/config/xs.article.ini
|
||||
/config/xs.question.ini
|
||||
/config/xs.group.ini
|
||||
/config/xs.user.ini
|
||||
/config/alipay/*.crt
|
||||
/config/wxpay/*.pem
|
||||
/db/migrations/schema.php
|
||||
/public/robots.txt
|
||||
/public/sitemap.xml
|
||||
/public/h5
|
||||
/storage/cache/purifier
|
||||
*KgTest*
|
||||
|
308
CHANGELOG.md
308
CHANGELOG.md
@ -1,3 +1,311 @@
|
||||
### [v1.7.8](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.8)(2025-06-20)
|
||||
|
||||
- 移除ThrottleLimit
|
||||
- 增加CloseLiveTask
|
||||
- 增加搜索页图片alt属性striptags过滤
|
||||
- 后台增加返回顶部快捷方式
|
||||
- 前台fixbar增加联系电话
|
||||
- 优化安装脚本
|
||||
- 优化课时列表直播提示
|
||||
- 优化后台返回链接
|
||||
- 优化统计分析代码位置
|
||||
- 直播回调后更新课时缓存
|
||||
- 后台清空头像->上传头像
|
||||
- sitemap.xml直接写入网站根目录
|
||||
|
||||
### [v1.7.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.7)(2025-04-20)
|
||||
|
||||
- 优化索引管理工具
|
||||
- 优化章节等页面UI
|
||||
- 修正workerman中onMessage问题
|
||||
- 修正非免费课程试听问题
|
||||
- 优化layer窗口中的表单跳转
|
||||
- 文件清理以及命名优化
|
||||
- 优化倒计时
|
||||
|
||||
### [v1.7.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.6)(2025-03-22)
|
||||
|
||||
- 升级layui-v2.9.25
|
||||
- 去除发货中不必要的异常抛出
|
||||
- 去除文章和问题缓存重建
|
||||
- 去除多余的文件引用
|
||||
- 修正每日访问站点积分问题
|
||||
- 限制全文搜索关键字长度
|
||||
- 统一规划二维码样式
|
||||
|
||||
### [v1.7.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.5)(2025-02-22)
|
||||
|
||||
- 优化后台统计图表
|
||||
- 优化图片放大查看
|
||||
- 优化错误处理机制
|
||||
- 优化前台编辑器页面
|
||||
- 去除一些过度的设计
|
||||
- 精简属性空判断
|
||||
- 规整redirect
|
||||
- 优化bootstrap
|
||||
- 优化logger
|
||||
- 优化contact
|
||||
- 优化logo
|
||||
- 优化nav
|
||||
|
||||
### [v1.7.4](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.4)(2024-12-10)
|
||||
|
||||
- 更新layui-v2.9.20
|
||||
- 优化编辑器内容自动提交
|
||||
- 修正课时详情页目录高亮问题
|
||||
- 修正CommentInfo中点赞判断
|
||||
- 精简AccountSearchTrait
|
||||
- 优化kg_h5_index_url()
|
||||
- 优化CourseUserTrait
|
||||
- 优化kg_setting()
|
||||
- 优化CsrfToken
|
||||
|
||||
### [v1.7.3](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.3)(2024-10-10)
|
||||
|
||||
- 更新layui-v2.9.16
|
||||
- 增加编辑器内容自动提交
|
||||
- 修改文章和提问可用tag数量
|
||||
- 优化findUserActiveSessions
|
||||
- 优化findUserActiveTokens
|
||||
- 优化上传文件失败抛出异常
|
||||
- 优化默认文件上传
|
||||
- 优化用户锁定相关
|
||||
|
||||
### [v1.7.2](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.2)(2024-07-31)
|
||||
|
||||
- 更新layui-v2.9.14
|
||||
- 优化docker自动化脚本
|
||||
- 修正教师直播通知
|
||||
- 修正课程分类删选问题
|
||||
- 后台增加客户服务入口
|
||||
- redis增加expire方法
|
||||
- 日志记录增加log.trace参数
|
||||
- 精简代码
|
||||
|
||||
### [v1.7.1](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.1)(2024-06-31)
|
||||
|
||||
- 更新layui-v2.9.10
|
||||
- 更新docker国内镜像地址
|
||||
- 增加导入镜像构建容器的方式
|
||||
- 调整微信公众号模板消息
|
||||
- 移除加载富文本编辑器初始化的语言文件
|
||||
- 移除consult中多余的chapter_id属性
|
||||
- 修正课程列表顶部过滤条件区块不能收缩问题
|
||||
- 用户中心第三方登录列表增加过滤条件
|
||||
- 后台增加打开/关闭左侧菜单提示
|
||||
- 优化整理文件mimeType
|
||||
- iconfont资源本地化
|
||||
- 优化UploadController
|
||||
- 优化富文本内容显示样式
|
||||
- 简化内容图片放大监听
|
||||
- 去除课程打赏相关内容
|
||||
- 课程增加能否发布检查
|
||||
|
||||
### [v1.7.0](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.0)(2024-05-15)
|
||||
|
||||
- 升级layui-2.9.8
|
||||
- 调整html编辑器属性
|
||||
- 增加代码块内容复制
|
||||
- 清理无用的Captcha配置
|
||||
- 联系人QQ改为上传二维码图片
|
||||
- 修正logo,favicon上传路径
|
||||
- 登录后台同时登录前台
|
||||
- 移动端修正评论发表
|
||||
|
||||
### [v1.6.9](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.9)(2024-04-15)
|
||||
|
||||
- 增加用户删除和还原功能
|
||||
- 增加unauthorized响应
|
||||
- 增加post方式传递csrf_token
|
||||
- 删除chapter中resource_count,consult_count属性
|
||||
- 精简csrf_token白名单
|
||||
- 拆解优化migrations创建表脚本
|
||||
- 修正chapter_user时长重复计数问题
|
||||
- 修正后台刷新首页缓存问题
|
||||
- 修正home模块中编辑器图片上传
|
||||
- 优化文章和提问搜索条件
|
||||
- 优化课程详情页排版
|
||||
- 优化storage上传
|
||||
- 优化CategoryTreeList
|
||||
- 优化CourseUserTrait
|
||||
- 更新layui-v2.9.7
|
||||
|
||||
### [v1.6.8](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.8)(2024-01-30)
|
||||
|
||||
- 修正course_user中active_time未更新问题
|
||||
- 修正主页simple模式免费课程模块样式问题
|
||||
- 修正chapter_user中plan_id=0问题
|
||||
- 修正课时评论管理链接
|
||||
- 修正用户active_time搜索条件
|
||||
- 修正课时发布switch开关
|
||||
- 精简chapter/lessons.volt
|
||||
- 去除league/commonmark包
|
||||
- 去除分类等必选判断
|
||||
- 更新layui-v2.9.3
|
||||
- 使用ServiceTrait精简代码
|
||||
- 优化AccountTrait
|
||||
- 优化错误处理
|
||||
|
||||
### [v1.6.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.7)(2023-12-15)
|
||||
|
||||
- 增加文章分类功能
|
||||
- 增加问题分类功能
|
||||
- 增加审核等批量功能
|
||||
- 增加若干业务插件埋点
|
||||
- 精简重构大量业务逻辑
|
||||
- 移除秒杀营销功能
|
||||
- 已发现的问题修复
|
||||
|
||||
### [v1.6.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.6)(2023-08-30)
|
||||
|
||||
- 还原意外删除的AnswerList.php文件
|
||||
- 修正邮箱注册提交按钮不可用问题
|
||||
- 去除删除远程课件逻辑
|
||||
- 增加课程课件资料总览
|
||||
- 优化cleanDemoDataTask脚本
|
||||
- 优化tag表migration脚本
|
||||
- 命名结构等常规优化
|
||||
|
||||
### [v1.6.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.5)(2023-07-15)
|
||||
|
||||
- 升级layui-v2.8.8
|
||||
- 使用本地图像验证码
|
||||
- 优化计划任务脚本
|
||||
- 优化日志清理脚本
|
||||
- 优化钉钉webhook
|
||||
- 修正图文分享参数问题
|
||||
|
||||
### [v1.6.4](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.4)(2023-06-15)
|
||||
|
||||
- 增加推荐课程等Widget
|
||||
- 更新Composer包
|
||||
- 修正验证空口令问题
|
||||
- 优化订单确认页样式
|
||||
- 优化课程等Me相关信息
|
||||
- 优化分享URL
|
||||
- 优化用户课程查找
|
||||
- 优化通知相关
|
||||
- 优化Providers
|
||||
- 优化课程章节权限
|
||||
- 优化钉钉机器人
|
||||
|
||||
### [v1.6.3](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.3)(2023-05-08)
|
||||
|
||||
- 强化文章|提问|课程列表参数检查
|
||||
- 优化HtmlPurifier内容过滤
|
||||
- 优化排序条件和分页重复问题
|
||||
- 优化课程搜索分组条件样式
|
||||
- 优化课程学习时长同步
|
||||
- 优化程序语法层面
|
||||
- 更新Layui-v2.8.2
|
||||
- 替换ip2region包
|
||||
- 去除未支付“新鲜”订单检查
|
||||
- 修正手续费率设置为0无效问题
|
||||
|
||||
### [v1.6.2](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.2)(2023-02-12)
|
||||
|
||||
- 增加ServerMonitor监控指标配置
|
||||
- 同步更新腾讯云短信内容规则
|
||||
- 文章和问答增加评论开关属性
|
||||
- 修正视频记忆播放无效问题
|
||||
- 升级composer包版本
|
||||
- 优化Repo查询默认排序
|
||||
- 优化管理后台细节
|
||||
- 优化二维码输出
|
||||
- 优化评分检查
|
||||
|
||||
### [v1.6.1](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.1)(2022-12-12)
|
||||
|
||||
- 富文本编辑器增加粘贴图片和远程图片本地化
|
||||
- 修正用户通知标记为已读,计数不归零问题
|
||||
- 修正播放器中央按钮显示问题
|
||||
- 优化腾讯云播放地址鉴权参数
|
||||
- 优化热门作者,答主和问题
|
||||
- 优化学员学习记录显示
|
||||
- 优化表单数据提交体验
|
||||
- 优化单章节层级显示
|
||||
- 优化ServerInfo类
|
||||
|
||||
### [v1.6.0](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.0)(2022-10-26)
|
||||
|
||||
- 播放器中间增加大号播放按钮
|
||||
- 单页和帮助增加浏览计数属性
|
||||
- logo上增加首页链接
|
||||
- 修正分类默认图标问题
|
||||
- 修正layui-main样式更新带来的问题
|
||||
- 更新composer包
|
||||
- 调整退款手续费范围
|
||||
- 导航部分,教师->师资
|
||||
- 优化分页组件参数
|
||||
- 优化内容表格样式
|
||||
- 优化热门问题和热门答主
|
||||
- 优化通知计数方式
|
||||
|
||||
### [v1.5.9](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.9)(2022-09-20)
|
||||
|
||||
- 修正内容图片上传问题
|
||||
- 去除user全文索引
|
||||
- 调整notice目录结构
|
||||
- 更新默认图片
|
||||
- 更新直播名格式化
|
||||
- 更新微博分享链接
|
||||
- 文章单页等增加SEO关键字
|
||||
- 专题增加封面上传
|
||||
- 优化router扫描规则
|
||||
- 升级layui至v2.7.6
|
||||
- 增加用户协议和隐私政策
|
||||
- 优化错误日志
|
||||
|
||||
### [v1.5.8](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.8)(2022-08-28)
|
||||
|
||||
- 整理migrations
|
||||
- 更新自动安装脚本
|
||||
- 优化登录/注册/忘记密码页
|
||||
- 修复移动端首页课程缓存刷新
|
||||
- sitemap条目增加过滤条件
|
||||
|
||||
### [v1.5.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.7)(2022-08-18)
|
||||
|
||||
- 清理群组残留
|
||||
- 升级腾讯云存储SDK到v2.5.6
|
||||
- GuzzleHttp升级到v6.5.7
|
||||
- 优化HtmlPurifier缓存目录自动创建
|
||||
- 优化问题回答排序问题
|
||||
- 优化腾讯云短信错误日志
|
||||
- 整理查询构建语句
|
||||
- 整理优化CSS
|
||||
|
||||
### [v1.5.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.6)(2022-08-08)
|
||||
|
||||
- 增加应用内命令行migrations
|
||||
- 移除群组和微聊模块
|
||||
- kindeditor替换vditor
|
||||
- markdown转html
|
||||
|
||||
### [v1.5.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.5)(2022-07-27)
|
||||
|
||||
- 修正获分类查询条件
|
||||
- 修正锁定账户还能登录的问题
|
||||
- 发货增加noMatchedHandler
|
||||
- 增加demo数据清理脚本
|
||||
- 用户课程列表增加角色限定条件
|
||||
- 精简模块加载和路由扫描
|
||||
- 优化CsrfToken
|
||||
- 去除无实质作用的数据表优化
|
||||
|
||||
### [v1.5.4](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.4)(2022-06-15)
|
||||
|
||||
- 增加migration助手SettingTrait
|
||||
- 增加积分兑换会员
|
||||
- 增加ISP备案和电子执照配置
|
||||
- 增加获取视频时长补偿机制
|
||||
- 优化课程和套餐发货
|
||||
- 优化验证码
|
||||
- 优化视频点播回调处理任务
|
||||
- 优化章节排序初始值和步长
|
||||
- 优化后台视频上传和转码
|
||||
- 修正获取子分类查询条件
|
||||
|
||||
### [v1.5.3](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.3)(2022-05-30)
|
||||
|
||||
- 优化章节排序初始值和步长
|
||||
|
42
README.md
42
README.md
@ -1,23 +1,23 @@
|
||||
## 酷瓜云课堂
|
||||
|
||||

|
||||
[](https://www.koogua.com)
|
||||
|
||||
### 系统介绍
|
||||
|
||||
酷瓜云课堂,依托腾讯云基础服务架构,采用C扩展框架Phalcon开发,GPL-2.0开源协议,致力开源网课系统,开源网校系统,开源知识付费系统,开源在线教育系统。
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
### 系统功能
|
||||
|
||||
实现了点播、直播、专栏、面授、问答、会员、群组、微聊、积分、秒杀等。
|
||||
实现了点播、直播、专栏、问答、会员、积分等。
|
||||
|
||||
友情提示:
|
||||
|
||||
- 演示系统配置低(1Core,1G,1M 跑多个容器)切莫压测
|
||||
- 演示系统配置低(2核,2G,1M 跑多个容器)切莫压测
|
||||
- 课程数据来源于网络(无实质内容)切莫购买
|
||||
- 管理后台已禁止数据提交,私密配置已过滤
|
||||
|
||||
@ -34,12 +34,6 @@ H5手机端演示:
|
||||
|
||||
演示账号:13507083515 / 123456
|
||||
|
||||
微信公众号演示:
|
||||
|
||||

|
||||
|
||||
演示账号:13507083515 / 123456
|
||||
|
||||
支付流程演示:
|
||||
|
||||
- [MySQL提升课程全面讲解MySQL架构设计(0.01元)](https://ctc.koogua.com/order/confirm?item_id=1390&item_type=1)
|
||||
@ -48,33 +42,25 @@ H5手机端演示:
|
||||
|
||||
Tips: 测试支付请用手机号注册一个新账户,以便接收订单通知,以及避免课程无法购买
|
||||
|
||||
即时通讯演示:
|
||||
|
||||
请使用以下两个账号在不同终端或者浏览器登录,打开微聊界面
|
||||
|
||||
- 帐号A:100015@163.com / 123456
|
||||
- 帐号B:100065@163.com / 123456
|
||||
|
||||
微信推送演示:
|
||||
|
||||
Tips: 请用手机注册一个新账号,用户中心 -> 关注订阅,扫码关注公众号。之后的登录、购买、退款、直播、咨询等会有消息推送。
|
||||
|
||||
### 项目组件
|
||||
|
||||
- 后台框架:[phalcon 3.4.5](https://phalcon.io)
|
||||
- 前端框架:[layui 2.6.8](https://layui.com), [layim 3.9.8](https://www.layui.com/layim)(已授权)
|
||||
- 全文检索:[xunsearch 1.4.9](http://www.xunsearch.com)
|
||||
- 即时通讯:[workerman 3.5.22](https://workerman.net)
|
||||
- 后台框架:[phalcon 3.4](https://phalcon.io)
|
||||
- 前端框架:[layui 2.9](https://layui.dev)
|
||||
- 全文检索:[xunsearch 1.4](http://www.xunsearch.com)
|
||||
- 基础依赖:[php7.3](https://php.net), [mysql5.7](https://mysql.com), [redis5.0](https://redis.io)
|
||||
|
||||
### 项目文档
|
||||
|
||||
- [运行环境搭建](https://koogua.com/page/wiki)
|
||||
- [系统服务配置](https://koogua.com/page/wiki)
|
||||
- [客户终端配置](https://koogua.com/page/wiki)
|
||||
- [运行环境搭建](https://www.koogua.com/page/wiki)
|
||||
- [系统服务配置](https://www.koogua.com/page/wiki)
|
||||
- [客户终端配置](https://www.koogua.com/page/wiki)
|
||||
|
||||
### 意见反馈
|
||||
|
||||
- [码云平台](https://gitee.com/koogua/course-tencent-cloud/issues)
|
||||
- [官方社区](https://koogua.com/community)
|
||||
- [官方社区](https://www.koogua.com/community)
|
||||
- QQ交流群: 787363898
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Question as QuestionRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class AnswerList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class AnswerList extends Builder
|
||||
$questions = $this->getQuestions($answers);
|
||||
|
||||
foreach ($answers as $key => $answer) {
|
||||
$answers[$key]['question'] = $questions[$answer['question_id']] ?? new \stdClass();
|
||||
$answers[$key]['question'] = $questions[$answer['question_id']] ?? null;
|
||||
}
|
||||
|
||||
return $answers;
|
||||
@ -29,7 +28,7 @@ class AnswerList extends Builder
|
||||
$users = $this->getUsers($answers);
|
||||
|
||||
foreach ($answers as $key => $answer) {
|
||||
$answers[$key]['owner'] = $users[$answer['owner_id']] ?? new \stdClass();
|
||||
$answers[$key]['owner'] = $users[$answer['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $answers;
|
||||
@ -56,20 +55,7 @@ class AnswerList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($answers, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Article as ArticleRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
use Phalcon\Text;
|
||||
|
||||
class ArticleFavoriteList extends Builder
|
||||
@ -19,7 +18,7 @@ class ArticleFavoriteList extends Builder
|
||||
$articles = $this->getArticles($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['article'] = $articles[$value['article_id']] ?? new \stdClass();
|
||||
$relations[$key]['article'] = $articles[$value['article_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -30,7 +29,7 @@ class ArticleFavoriteList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -70,20 +69,7 @@ class ArticleFavoriteList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,8 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Caches\CategoryList as CategoryListCache;
|
||||
use App\Caches\CategoryAllList as CategoryAllListCache;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ArticleList extends Builder
|
||||
{
|
||||
@ -28,7 +27,7 @@ class ArticleList extends Builder
|
||||
$categories = $this->getCategories();
|
||||
|
||||
foreach ($articles as $key => $article) {
|
||||
$articles[$key]['category'] = $categories[$article['category_id']] ?? new \stdClass();
|
||||
$articles[$key]['category'] = $categories[$article['category_id']] ?? null;
|
||||
}
|
||||
|
||||
return $articles;
|
||||
@ -39,7 +38,7 @@ class ArticleList extends Builder
|
||||
$users = $this->getUsers($articles);
|
||||
|
||||
foreach ($articles as $key => $article) {
|
||||
$articles[$key]['owner'] = $users[$article['owner_id']] ?? new \stdClass();
|
||||
$articles[$key]['owner'] = $users[$article['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $articles;
|
||||
@ -47,7 +46,7 @@ class ArticleList extends Builder
|
||||
|
||||
public function getCategories()
|
||||
{
|
||||
$cache = new CategoryListCache();
|
||||
$cache = new CategoryAllListCache();
|
||||
|
||||
$items = $cache->get(CategoryModel::TYPE_ARTICLE);
|
||||
|
||||
@ -69,20 +68,7 @@ class ArticleList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($articles, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\User as UserRepo;
|
||||
use Phalcon\Di\Injectable;
|
||||
|
||||
class Builder extends Injectable
|
||||
@ -17,4 +18,22 @@ class Builder extends Injectable
|
||||
return kg_array_object($items);
|
||||
}
|
||||
|
||||
protected function getShallowUserByIds(array $ids)
|
||||
{
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,15 +8,16 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Models\Category as CategoryModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
use App\Repos\Category as CategoryRepo;
|
||||
|
||||
class CategoryTreeList extends Builder
|
||||
{
|
||||
|
||||
public function handle($type)
|
||||
{
|
||||
$topCategories = $this->findTopCategories($type);
|
||||
$categoryRepo = new CategoryRepo();
|
||||
|
||||
$topCategories = $categoryRepo->findTopCategories($type);
|
||||
|
||||
if ($topCategories->count() == 0) {
|
||||
return [];
|
||||
@ -39,7 +40,9 @@ class CategoryTreeList extends Builder
|
||||
|
||||
protected function handleChildren(CategoryModel $category)
|
||||
{
|
||||
$subCategories = $this->findChildCategories($category->id);
|
||||
$categoryRepo = new CategoryRepo();
|
||||
|
||||
$subCategories = $categoryRepo->findChildCategories($category->id);
|
||||
|
||||
if ($subCategories->count() == 0) {
|
||||
return [];
|
||||
@ -59,37 +62,4 @@ class CategoryTreeList extends Builder
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $type
|
||||
* @return ResultsetInterface|Resultset|CategoryModel[]
|
||||
*/
|
||||
protected function findTopCategories($type)
|
||||
{
|
||||
$query = CategoryModel::query();
|
||||
|
||||
$query->where('parent_id = 0');
|
||||
$query->andWhere('published = 1');
|
||||
$query->andWhere('deleted = 0');
|
||||
$query->andWhere('type = :type:', ['type' => $type]);
|
||||
$query->orderBy('priority ASC');
|
||||
|
||||
return $query->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $parentId
|
||||
* @return ResultsetInterface|Resultset|CategoryModel[]
|
||||
*/
|
||||
protected function findChildCategories($parentId)
|
||||
{
|
||||
$query = CategoryModel::query();
|
||||
|
||||
$query->where('published = 1');
|
||||
$query->where('deleted = 0');
|
||||
$query->andWhere('parent_id = :parent_id:', ['parent_id' => $parentId]);
|
||||
$query->orderBy('priority ASC');
|
||||
|
||||
return $query->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class CommentList extends Builder
|
||||
{
|
||||
|
||||
@ -17,8 +15,8 @@ class CommentList extends Builder
|
||||
$users = $this->getUsers($comments);
|
||||
|
||||
foreach ($comments as $key => $comment) {
|
||||
$comments[$key]['owner'] = $users[$comment['owner_id']] ?? new \stdClass();
|
||||
$comments[$key]['to_user'] = $users[$comment['to_user_id']] ?? new \stdClass();
|
||||
$comments[$key]['owner'] = $users[$comment['owner_id']] ?? null;
|
||||
$comments[$key]['to_user'] = $users[$comment['to_user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $comments;
|
||||
@ -30,20 +28,7 @@ class CommentList extends Builder
|
||||
$toUserIds = kg_array_column($comments, 'to_user_id');
|
||||
$ids = array_merge($ownerIds, $toUserIds);
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,7 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Chapter as ChapterRepo;
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ConsultList extends Builder
|
||||
{
|
||||
@ -19,7 +17,7 @@ class ConsultList extends Builder
|
||||
$courses = $this->getCourses($consults);
|
||||
|
||||
foreach ($consults as $key => $consult) {
|
||||
$consults[$key]['course'] = $courses[$consult['course_id']] ?? new \stdClass();
|
||||
$consults[$key]['course'] = $courses[$consult['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $consults;
|
||||
@ -30,8 +28,8 @@ class ConsultList extends Builder
|
||||
$users = $this->getUsers($consults);
|
||||
|
||||
foreach ($consults as $key => $consult) {
|
||||
$consults[$key]['owner'] = $users[$consult['owner_id']] ?? new \stdClass();
|
||||
$consults[$key]['replier'] = $users[$consult['replier_id']] ?? new \stdClass();
|
||||
$consults[$key]['owner'] = $users[$consult['owner_id']] ?? null;
|
||||
$consults[$key]['replier'] = $users[$consult['replier_id']] ?? null;
|
||||
}
|
||||
|
||||
return $consults;
|
||||
@ -54,43 +52,13 @@ class ConsultList extends Builder
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getChapters(array $consults)
|
||||
{
|
||||
$ids = kg_array_column($consults, 'chapter_id');
|
||||
|
||||
$chapterRepo = new ChapterRepo();
|
||||
|
||||
$chapters = $chapterRepo->findByIds($ids, ['id', 'title']);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($chapters->toArray() as $chapter) {
|
||||
$result[$chapter['id']] = $chapter;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getUsers(array $consults)
|
||||
{
|
||||
$ownerIds = kg_array_column($consults, 'owner_id');
|
||||
$replierIds = kg_array_column($consults, 'replier_id');
|
||||
$ids = array_merge($ownerIds, $replierIds);
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class CourseFavoriteList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class CourseFavoriteList extends Builder
|
||||
$courses = $this->getCourses($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -29,7 +28,7 @@ class CourseFavoriteList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -70,20 +69,7 @@ class CourseFavoriteList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,8 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Caches\CategoryList as CategoryListCache;
|
||||
use App\Caches\CategoryAllList as CategoryAllListCache;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class CourseList extends Builder
|
||||
{
|
||||
@ -19,7 +18,7 @@ class CourseList extends Builder
|
||||
$categories = $this->getCategories();
|
||||
|
||||
foreach ($courses as $key => $course) {
|
||||
$courses[$key]['category'] = $categories[$course['category_id']] ?? new \stdClass();
|
||||
$courses[$key]['category'] = $categories[$course['category_id']] ?? null;
|
||||
}
|
||||
|
||||
return $courses;
|
||||
@ -30,7 +29,7 @@ class CourseList extends Builder
|
||||
$teachers = $this->getTeachers($courses);
|
||||
|
||||
foreach ($courses as $key => $course) {
|
||||
$courses[$key]['teacher'] = $teachers[$course['teacher_id']] ?? new \stdClass();
|
||||
$courses[$key]['teacher'] = $teachers[$course['teacher_id']] ?? null;
|
||||
}
|
||||
|
||||
return $courses;
|
||||
@ -38,7 +37,7 @@ class CourseList extends Builder
|
||||
|
||||
public function getCategories()
|
||||
{
|
||||
$cache = new CategoryListCache();
|
||||
$cache = new CategoryAllListCache();
|
||||
|
||||
$items = $cache->get(CategoryModel::TYPE_COURSE);
|
||||
|
||||
@ -60,20 +59,7 @@ class CourseList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($courses, 'teacher_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class CourseTopicList extends Builder
|
||||
$courses = $this->getCourses($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -29,7 +29,7 @@ class CourseTopicList extends Builder
|
||||
$topics = $this->getTopics($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['topic'] = $topics[$value['topic_id']] ?? new \stdClass();
|
||||
$relations[$key]['topic'] = $topics[$value['topic_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class CourseUserList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class CourseUserList extends Builder
|
||||
$courses = $this->getCourses($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -29,7 +28,7 @@ class CourseUserList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -74,20 +73,7 @@ class CourseUserList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,104 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Chapter as ChapterRepo;
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class DanmuList extends Builder
|
||||
{
|
||||
|
||||
public function handleCourses(array $danmus)
|
||||
{
|
||||
$courses = $this->getCourses($danmus);
|
||||
|
||||
foreach ($danmus as $key => $danmu) {
|
||||
$danmus[$key]['course'] = $courses[$danmu['course_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $danmus;
|
||||
}
|
||||
|
||||
public function handleChapters(array $danmus)
|
||||
{
|
||||
$chapters = $this->getChapters($danmus);
|
||||
|
||||
foreach ($danmus as $key => $danmu) {
|
||||
$danmus[$key]['chapter'] = $chapters[$danmu['chapter_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $danmus;
|
||||
}
|
||||
|
||||
public function handleUsers(array $danmus)
|
||||
{
|
||||
$users = $this->getUsers($danmus);
|
||||
|
||||
foreach ($danmus as $key => $danmu) {
|
||||
$danmus[$key]['owner'] = $users[$danmu['owner_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $danmus;
|
||||
}
|
||||
|
||||
public function getCourses(array $danmus)
|
||||
{
|
||||
$ids = kg_array_column($danmus, 'course_id');
|
||||
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$courses = $courseRepo->findByIds($ids, ['id', 'title']);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($courses->toArray() as $course) {
|
||||
$result[$course['id']] = $course;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getChapters(array $danmus)
|
||||
{
|
||||
$ids = kg_array_column($danmus, 'chapter_id');
|
||||
|
||||
$chapterRepo = new ChapterRepo();
|
||||
|
||||
$chapters = $chapterRepo->findByIds($ids, ['id', 'title']);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($chapters->toArray() as $chapter) {
|
||||
$result[$chapter['id']] = $chapter;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getUsers(array $danmus)
|
||||
{
|
||||
$ids = kg_array_column($danmus, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Caches\CategoryList as CategoryListCache;
|
||||
use App\Caches\CategoryAllList as CategoryAllListCache;
|
||||
use App\Models\Category as CategoryModel;
|
||||
|
||||
class HelpList extends Builder
|
||||
@ -18,7 +18,7 @@ class HelpList extends Builder
|
||||
$categories = $this->getCategories();
|
||||
|
||||
foreach ($helps as $key => $help) {
|
||||
$helps[$key]['category'] = $categories[$help['category_id']] ?? new \stdClass();
|
||||
$helps[$key]['category'] = $categories[$help['category_id']] ?? null;
|
||||
}
|
||||
|
||||
return $helps;
|
||||
@ -26,7 +26,7 @@ class HelpList extends Builder
|
||||
|
||||
public function getCategories()
|
||||
{
|
||||
$cache = new CategoryListCache();
|
||||
$cache = new CategoryAllListCache();
|
||||
|
||||
$items = $cache->get(CategoryModel::TYPE_HELP);
|
||||
|
||||
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ImFriendUserList extends Builder
|
||||
{
|
||||
|
||||
public function handleFriends(array $relations)
|
||||
{
|
||||
$users = $this->getFriends($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['friend'] = $users[$value['friend_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $relations;
|
||||
}
|
||||
|
||||
public function getFriends(array $relations)
|
||||
{
|
||||
$ids = kg_array_column($relations, 'friend_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$columns = [
|
||||
'id', 'name', 'avatar', 'title', 'about', 'vip',
|
||||
'gender', 'area', 'active_time',
|
||||
];
|
||||
|
||||
$users = $userRepo->findByIds($ids, $columns);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ImGroupList extends Builder
|
||||
{
|
||||
|
||||
public function handleGroups(array $groups)
|
||||
{
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
foreach ($groups as $key => $group) {
|
||||
$groups[$key]['avatar'] = $baseUrl . $group['avatar'];
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
public function handleCourses(array $groups)
|
||||
{
|
||||
$courses = $this->getCourses($groups);
|
||||
|
||||
foreach ($groups as $key => $group) {
|
||||
$groups[$key]['course'] = $courses[$group['course_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
public function handleUsers(array $groups)
|
||||
{
|
||||
$users = $this->getUsers($groups);
|
||||
|
||||
foreach ($groups as $key => $group) {
|
||||
$groups[$key]['owner'] = $users[$group['owner_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
public function getCourses(array $groups)
|
||||
{
|
||||
$ids = kg_array_column($groups, 'course_id');
|
||||
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$courses = $courseRepo->findByIds($ids, ['id', 'title']);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($courses->toArray() as $course) {
|
||||
$result[$course['id']] = $course;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getUsers(array $groups)
|
||||
{
|
||||
$ids = kg_array_column($groups, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\ImGroup as ImGroupRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ImGroupUserList extends Builder
|
||||
{
|
||||
|
||||
public function handleGroups(array $relations)
|
||||
{
|
||||
$groups = $this->getGroups($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['group'] = $groups[$value['group_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $relations;
|
||||
}
|
||||
|
||||
public function handleUsers(array $relations)
|
||||
{
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $relations;
|
||||
}
|
||||
|
||||
public function getUsers(array $relations)
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$columns = ['id', 'name', 'avatar', 'title', 'about', 'vip', 'gender', 'area'];
|
||||
|
||||
$users = $userRepo->findByIds($ids, $columns);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getGroups(array $relations)
|
||||
{
|
||||
$ids = kg_array_column($relations, 'group_id');
|
||||
|
||||
$groupRepo = new ImGroupRepo();
|
||||
|
||||
$columns = ['id', 'type', 'name', 'avatar', 'about', 'owner_id', 'user_count', 'msg_count'];
|
||||
|
||||
$groups = $groupRepo->findByIds($ids, $columns);
|
||||
|
||||
$users = $this->getGroupOwners($groups->toArray());
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($groups->toArray() as $group) {
|
||||
$group['avatar'] = $baseUrl . $group['avatar'];
|
||||
$group['owner'] = $users[$group['owner_id']] ?? new \stdClass();
|
||||
unset($group['owner_id']);
|
||||
$result[$group['id']] = $group;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getGroupOwners(array $groups)
|
||||
{
|
||||
$ids = kg_array_column($groups, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name']);
|
||||
|
||||
$result = [];
|
||||
|
||||
if ($users->count() > 0) {
|
||||
foreach ($users->toArray() as $user) {
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ImMessageList extends Builder
|
||||
{
|
||||
|
||||
public function handleSenders(array $messages)
|
||||
{
|
||||
$users = $this->getSenders($messages);
|
||||
|
||||
foreach ($messages as $key => $message) {
|
||||
$messages[$key]['sender'] = $users[$message['sender_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function getSenders(array $messages)
|
||||
{
|
||||
$ids = kg_array_column($messages, 'sender_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ namespace App\Builders;
|
||||
|
||||
use App\Repos\Chapter as ChapterRepo;
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class LearningList extends Builder
|
||||
{
|
||||
@ -19,7 +18,7 @@ class LearningList extends Builder
|
||||
$courses = $this->getCourses($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -30,7 +29,7 @@ class LearningList extends Builder
|
||||
$chapters = $this->getChapters($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['chapter'] = $chapters[$value['chapter_id']] ?? new \stdClass();
|
||||
$relations[$key]['chapter'] = $chapters[$value['chapter_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -41,7 +40,7 @@ class LearningList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -85,17 +84,7 @@ class LearningList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name']);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class LiveList extends Builder
|
||||
$courses = $this->getCourses($lives);
|
||||
|
||||
foreach ($lives as $key => $live) {
|
||||
$lives[$key]['course'] = $courses[$live['course_id']] ?? new \stdClass();
|
||||
$lives[$key]['course'] = $courses[$live['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $lives;
|
||||
@ -30,7 +30,7 @@ class LiveList extends Builder
|
||||
$chapters = $this->getChapters($lives);
|
||||
|
||||
foreach ($lives as $key => $live) {
|
||||
$lives[$key]['chapter'] = $chapters[$live['chapter_id']] ?? new \stdClass();
|
||||
$lives[$key]['chapter'] = $chapters[$live['chapter_id']] ?? null;
|
||||
}
|
||||
|
||||
return $lives;
|
||||
@ -63,7 +63,7 @@ class LiveList extends Builder
|
||||
|
||||
foreach ($courses->toArray() as $course) {
|
||||
$course['cover'] = $baseUrl . $course['cover'];
|
||||
$course['teacher'] = $teachers[$course['teacher_id']] ?? new \stdClass();
|
||||
$course['teacher'] = $teachers[$course['teacher_id']] ?? null;
|
||||
$result[$course['id']] = [
|
||||
'id' => $course['id'],
|
||||
'title' => $course['title'],
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class NotificationList extends Builder
|
||||
{
|
||||
|
||||
@ -17,8 +15,8 @@ class NotificationList extends Builder
|
||||
$users = $this->getUsers($notifications);
|
||||
|
||||
foreach ($notifications as $key => $notification) {
|
||||
$notifications[$key]['sender'] = $users[$notification['sender_id']] ?? new \stdClass();
|
||||
$notifications[$key]['receiver'] = $users[$notification['receiver_id']] ?? new \stdClass();
|
||||
$notifications[$key]['sender'] = $users[$notification['sender_id']] ?? null;
|
||||
$notifications[$key]['receiver'] = $users[$notification['receiver_id']] ?? null;
|
||||
}
|
||||
|
||||
return $notifications;
|
||||
@ -30,20 +28,7 @@ class NotificationList extends Builder
|
||||
$receiverIds = kg_array_column($notifications, 'receiver_id');
|
||||
$ids = array_merge($senderIds, $receiverIds);
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace App\Builders;
|
||||
|
||||
use App\Models\Course as CourseModel;
|
||||
use App\Models\Order as OrderModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class OrderList extends Builder
|
||||
{
|
||||
@ -30,7 +29,7 @@ class OrderList extends Builder
|
||||
$users = $this->getUsers($orders);
|
||||
|
||||
foreach ($orders as $key => $order) {
|
||||
$orders[$key]['owner'] = $users[$order['owner_id']] ?? new \stdClass();
|
||||
$orders[$key]['owner'] = $users[$order['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $orders;
|
||||
@ -113,8 +112,13 @@ class OrderList extends Builder
|
||||
$me['allow_refund'] = $refundStatusOk && $refundTimeOk ? 1 : 0;
|
||||
}
|
||||
|
||||
$me['allow_pay'] = $payStatusOk;
|
||||
$me['allow_cancel'] = $cancelStatusOk;
|
||||
if ($payStatusOk == 1) {
|
||||
$me['allow_pay'] = 1;
|
||||
}
|
||||
|
||||
if ($cancelStatusOk == 1) {
|
||||
$me['allow_cancel'] = 1;
|
||||
}
|
||||
|
||||
return $me;
|
||||
}
|
||||
@ -149,20 +153,6 @@ class OrderList extends Builder
|
||||
return $itemInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $itemInfo
|
||||
* @return mixed
|
||||
*/
|
||||
protected function handleRewardInfo($itemInfo)
|
||||
{
|
||||
if (!empty($itemInfo) && is_string($itemInfo)) {
|
||||
$itemInfo = json_decode($itemInfo, true);
|
||||
$itemInfo['course']['cover'] = $this->imgBaseUrl . $itemInfo['course']['cover'];
|
||||
}
|
||||
|
||||
return $itemInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $itemInfo
|
||||
* @return mixed
|
||||
@ -184,17 +174,7 @@ class OrderList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($orders, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Question as QuestionRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
use Phalcon\Text;
|
||||
|
||||
class QuestionFavoriteList extends Builder
|
||||
@ -19,7 +18,7 @@ class QuestionFavoriteList extends Builder
|
||||
$questions = $this->getQuestions($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['question'] = $questions[$value['question_id']] ?? new \stdClass();
|
||||
$relations[$key]['question'] = $questions[$value['question_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -30,7 +29,7 @@ class QuestionFavoriteList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -70,20 +69,7 @@ class QuestionFavoriteList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,8 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Caches\CategoryList as CategoryListCache;
|
||||
use App\Caches\CategoryAllList as CategoryAllListCache;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class QuestionList extends Builder
|
||||
{
|
||||
@ -23,15 +22,15 @@ class QuestionList extends Builder
|
||||
return $questions;
|
||||
}
|
||||
|
||||
public function handleCategories(array $articles)
|
||||
public function handleCategories(array $questions)
|
||||
{
|
||||
$categories = $this->getCategories();
|
||||
|
||||
foreach ($articles as $key => $article) {
|
||||
$articles[$key]['category'] = $categories[$article['category_id']] ?? new \stdClass();
|
||||
foreach ($questions as $key => $question) {
|
||||
$questions[$key]['category'] = $categories[$question['category_id']] ?? null;
|
||||
}
|
||||
|
||||
return $articles;
|
||||
return $questions;
|
||||
}
|
||||
|
||||
public function handleUsers(array $questions)
|
||||
@ -39,8 +38,8 @@ class QuestionList extends Builder
|
||||
$users = $this->getUsers($questions);
|
||||
|
||||
foreach ($questions as $key => $question) {
|
||||
$questions[$key]['owner'] = $users[$question['owner_id']] ?? new \stdClass();
|
||||
$questions[$key]['last_replier'] = $users[$question['last_replier_id']] ?? new \stdClass();
|
||||
$questions[$key]['owner'] = $users[$question['owner_id']] ?? null;
|
||||
$questions[$key]['last_replier'] = $users[$question['last_replier_id']] ?? null;
|
||||
}
|
||||
|
||||
return $questions;
|
||||
@ -48,7 +47,7 @@ class QuestionList extends Builder
|
||||
|
||||
public function getCategories()
|
||||
{
|
||||
$cache = new CategoryListCache();
|
||||
$cache = new CategoryAllListCache();
|
||||
|
||||
$items = $cache->get(CategoryModel::TYPE_QUESTION);
|
||||
|
||||
@ -72,20 +71,7 @@ class QuestionList extends Builder
|
||||
$lastReplierIds = kg_array_column($questions, 'last_replier_id');
|
||||
$ids = array_merge($ownerIds, $lastReplierIds);
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace App\Builders;
|
||||
|
||||
use App\Models\Refund as RefundModel;
|
||||
use App\Repos\Order as OrderRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class RefundList extends Builder
|
||||
{
|
||||
@ -19,7 +18,7 @@ class RefundList extends Builder
|
||||
$orders = $this->getOrders($trades);
|
||||
|
||||
foreach ($trades as $key => $trade) {
|
||||
$trades[$key]['order'] = $orders[$trade['order_id']] ?? new \stdClass();
|
||||
$trades[$key]['order'] = $orders[$trade['order_id']] ?? null;
|
||||
}
|
||||
|
||||
return $trades;
|
||||
@ -30,7 +29,7 @@ class RefundList extends Builder
|
||||
$users = $this->getUsers($refunds);
|
||||
|
||||
foreach ($refunds as $key => $refund) {
|
||||
$refunds[$key]['owner'] = $users[$refund['owner_id']] ?? new \stdClass();
|
||||
$refunds[$key]['owner'] = $users[$refund['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $refunds;
|
||||
@ -75,20 +74,7 @@ class RefundList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($refunds, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ReportList extends Builder
|
||||
{
|
||||
|
||||
@ -17,7 +15,7 @@ class ReportList extends Builder
|
||||
$users = $this->getUsers($reports);
|
||||
|
||||
foreach ($reports as $key => $report) {
|
||||
$reports[$key]['owner'] = $users[$report['owner_id']] ?? new \stdClass();
|
||||
$reports[$key]['owner'] = $users[$report['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $reports;
|
||||
@ -27,20 +25,7 @@ class ReportList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($reports, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class ResourceList extends Builder
|
||||
$uploads = $this->getUploads($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['upload'] = $uploads[$value['upload_id']] ?? new \stdClass();
|
||||
$relations[$key]['upload'] = $uploads[$value['upload_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ReviewList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class ReviewList extends Builder
|
||||
$courses = $this->getCourses($reviews);
|
||||
|
||||
foreach ($reviews as $key => $review) {
|
||||
$reviews[$key]['course'] = $courses[$review['course_id']] ?? new \stdClass();
|
||||
$reviews[$key]['course'] = $courses[$review['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $reviews;
|
||||
@ -29,7 +28,7 @@ class ReviewList extends Builder
|
||||
$users = $this->getUsers($reviews);
|
||||
|
||||
foreach ($reviews as $key => $review) {
|
||||
$reviews[$key]['owner'] = $users[$review['owner_id']] ?? new \stdClass();
|
||||
$reviews[$key]['owner'] = $users[$review['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $reviews;
|
||||
@ -56,20 +55,7 @@ class ReviewList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($reviews, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Tag as TagRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class TagFollowList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class TagFollowList extends Builder
|
||||
$tags = $this->getTags($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['tag'] = $tags[$value['tag_id']] ?? new \stdClass();
|
||||
$relations[$key]['tag'] = $tags[$value['tag_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -29,7 +28,7 @@ class TagFollowList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -61,20 +60,7 @@ class TagFollowList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Order as OrderRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class TradeList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class TradeList extends Builder
|
||||
$orders = $this->getOrders($trades);
|
||||
|
||||
foreach ($trades as $key => $trade) {
|
||||
$trades[$key]['order'] = $orders[$trade['order_id']] ?? new \stdClass();
|
||||
$trades[$key]['order'] = $orders[$trade['order_id']] ?? null;
|
||||
}
|
||||
|
||||
return $trades;
|
||||
@ -29,7 +28,7 @@ class TradeList extends Builder
|
||||
$users = $this->getUsers($trades);
|
||||
|
||||
foreach ($trades as $key => $trade) {
|
||||
$trades[$key]['owner'] = $users[$trade['owner_id']] ?? new \stdClass();
|
||||
$trades[$key]['owner'] = $users[$trade['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $trades;
|
||||
@ -56,20 +55,7 @@ class TradeList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($trades, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\Account as AccountRepo;
|
||||
use App\Repos\Role as RoleRepo;
|
||||
|
||||
class UserList extends Builder
|
||||
@ -24,6 +25,17 @@ class UserList extends Builder
|
||||
return $users;
|
||||
}
|
||||
|
||||
public function handleAccounts(array $users)
|
||||
{
|
||||
$accounts = $this->getAccounts($users);
|
||||
|
||||
foreach ($users as $key => $user) {
|
||||
$users[$key]['account'] = $accounts[$user['id']] ?? null;
|
||||
}
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
public function handleAdminRoles(array $users)
|
||||
{
|
||||
$roles = $this->getAdminRoles($users);
|
||||
@ -46,6 +58,26 @@ class UserList extends Builder
|
||||
return $users;
|
||||
}
|
||||
|
||||
protected function getAccounts(array $users)
|
||||
{
|
||||
$ids = kg_array_column($users, 'id');
|
||||
|
||||
$accountRepo = new AccountRepo();
|
||||
|
||||
$accounts = $accountRepo->findByIds($ids);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$result[$account->id] = [
|
||||
'phone' => $account->phone,
|
||||
'email' => $account->email,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getAdminRoles(array $users)
|
||||
{
|
||||
$ids = kg_array_column($users, 'admin_role');
|
||||
|
@ -27,10 +27,10 @@ class AppInfo extends Cache
|
||||
$appInfo = new \App\Library\AppInfo();
|
||||
|
||||
return [
|
||||
'name' => $appInfo->name,
|
||||
'alias' => $appInfo->alias,
|
||||
'link' => $appInfo->link,
|
||||
'version' => $appInfo->version,
|
||||
'name' => $appInfo->get('name'),
|
||||
'alias' => $appInfo->get('alias'),
|
||||
'link' => $appInfo->get('link'),
|
||||
'version' => $appInfo->get('version'),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\Article as ArticleRepo;
|
||||
|
||||
class Article extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "article:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$articleRepo = new ArticleRepo();
|
||||
|
||||
$article = $articleRepo->findById($id);
|
||||
|
||||
return $article ?: null;
|
||||
}
|
||||
|
||||
}
|
46
app/Caches/CategoryAllList.php
Normal file
46
app/Caches/CategoryAllList.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Category as CategoryModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
|
||||
class CategoryAllList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "category_all_list:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
/**
|
||||
* @var Resultset $categories
|
||||
*/
|
||||
$categories = CategoryModel::query()
|
||||
->columns(['id', 'parent_id', 'name', 'priority', 'level', 'path'])
|
||||
->where('type = :type:', ['type' => $id])
|
||||
->orderBy('level ASC, priority ASC')
|
||||
->execute();
|
||||
|
||||
if ($categories->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $categories->toArray();
|
||||
}
|
||||
|
||||
}
|
@ -20,23 +20,19 @@ class CategoryList extends Cache
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($type = null)
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "category_list:{$type}";
|
||||
return "category_list:{$id}";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $type
|
||||
* @return array
|
||||
*/
|
||||
public function getContent($type = null)
|
||||
public function getContent($id = null)
|
||||
{
|
||||
/**
|
||||
* @var Resultset $categories
|
||||
*/
|
||||
$categories = CategoryModel::query()
|
||||
->columns(['id', 'parent_id', 'name', 'priority', 'level', 'path'])
|
||||
->where('type = :type:', ['type' => $type])
|
||||
->where('type = :type:', ['type' => $id])
|
||||
->andWhere('published = 1')
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('level ASC, priority ASC')
|
||||
|
@ -19,16 +19,16 @@ class CategoryTreeList extends Cache
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($type = null)
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "category_tree_list:{$type}";
|
||||
return "category_tree_list:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($type = null)
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$builder = new CategoryTreeListBuilder();
|
||||
|
||||
$list = $builder->handle($type);
|
||||
$list = $builder->handle($id);
|
||||
|
||||
return $list ?: [];
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ use App\Repos\Chapter as ChapterRepo;
|
||||
class Chapter extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ namespace App\Caches;
|
||||
|
||||
use App\Library\Cache\Backend\Redis as RedisCache;
|
||||
use Phalcon\Di\Injectable;
|
||||
use Redis;
|
||||
|
||||
abstract class Counter extends Injectable
|
||||
{
|
||||
@ -19,7 +20,7 @@ abstract class Counter extends Injectable
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @var \Redis
|
||||
* @var Redis
|
||||
*/
|
||||
protected $redis;
|
||||
|
||||
@ -30,19 +31,13 @@ abstract class Counter extends Injectable
|
||||
$this->redis = $this->cache->getRedis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存内容
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return array
|
||||
*/
|
||||
public function get($id = null)
|
||||
{
|
||||
$key = $this->getKey($id);
|
||||
|
||||
$content = $this->redis->hGetAll($key);
|
||||
|
||||
if (!$this->cache->exists($key)) {
|
||||
if (!$this->redis->exists($key)) {
|
||||
|
||||
$content = $this->getContent($id);
|
||||
$lifetime = $this->getLifetime();
|
||||
@ -54,23 +49,13 @@ abstract class Counter extends Injectable
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存内容
|
||||
*
|
||||
* @param mixed $id
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
$key = $this->getKey($id);
|
||||
|
||||
$this->cache->delete($key);
|
||||
$this->redis->del($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重建缓存内容
|
||||
*
|
||||
* @param mixed $id
|
||||
*/
|
||||
public function rebuild($id = null)
|
||||
{
|
||||
$this->delete($id);
|
||||
|
@ -12,7 +12,7 @@ use App\Repos\Course as CourseRepo;
|
||||
class Course extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Repos\Course as CourseRepo;
|
||||
|
||||
class CourseCategoryList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "course_category_list:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$categories = $courseRepo->findCategories($id);
|
||||
|
||||
if ($categories->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->handleContent($categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CategoryModel[] $categories
|
||||
* @return array
|
||||
*/
|
||||
public function handleContent($categories)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$result[] = [
|
||||
'id' => $category->id,
|
||||
'name' => $category->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo;
|
||||
class CoursePackageList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo;
|
||||
class CourseRelatedList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\Course as CourseRepo;
|
||||
|
||||
class CourseTeacherList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "course_teacher_list:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$users = $courseRepo->findTeachers($id);
|
||||
|
||||
if ($users->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->handleContent($users);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserModel[] $users
|
||||
* @return array
|
||||
*/
|
||||
public function handleContent($users)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($users as $user) {
|
||||
$result[] = [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'avatar' => $user->avatar,
|
||||
'vip' => $user->vip,
|
||||
'title' => $user->title,
|
||||
'about' => $user->about,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class CourseTopicList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
71
app/Caches/FeaturedArticleList.php
Normal file
71
app/Caches/FeaturedArticleList.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Article as ArticleModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class FeaturedArticleList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 3600;
|
||||
|
||||
protected $limit = 5;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'featured_article_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$articles = $this->findArticles($this->limit);
|
||||
|
||||
if ($articles->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($articles as $article) {
|
||||
$result[] = [
|
||||
'id' => $article->id,
|
||||
'title' => $article->title,
|
||||
'cover' => $article->cover,
|
||||
'favorite_count' => $article->favorite_count,
|
||||
'comment_count' => $article->comment_count,
|
||||
'view_count' => $article->view_count,
|
||||
'like_count' => $article->like_count,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|ArticleModel[]
|
||||
*/
|
||||
protected function findArticles($limit = 5)
|
||||
{
|
||||
return ArticleModel::query()
|
||||
->where('featured = 1')
|
||||
->andWhere('published = :published:', ['published' => ArticleModel::PUBLISH_APPROVED])
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('RAND()')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
@ -11,10 +11,12 @@ use App\Models\Course as CourseModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class CourseRecommendedList extends Cache
|
||||
class FeaturedCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
protected $limit = 5;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
@ -23,26 +25,17 @@ class CourseRecommendedList extends Cache
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "course_recommended_list:{$id}";
|
||||
return 'featured_course_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$courses = $this->findCourses(5);
|
||||
$courses = $this->findCourses($this->limit);
|
||||
|
||||
if ($courses->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->handleContent($courses);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CourseModel[] $courses
|
||||
* @return array
|
||||
*/
|
||||
public function handleContent($courses)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($courses as $course) {
|
||||
@ -76,10 +69,10 @@ class CourseRecommendedList extends Cache
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|CourseModel[]
|
||||
*/
|
||||
public function findCourses($limit = 5)
|
||||
protected function findCourses($limit = 5)
|
||||
{
|
||||
return CourseModel::query()
|
||||
->where('market_price > 0')
|
||||
->where('featured = 1')
|
||||
->andWhere('published = 1')
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('RAND()')
|
72
app/Caches/FeaturedQuestionList.php
Normal file
72
app/Caches/FeaturedQuestionList.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Question as QuestionModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class FeaturedQuestionList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 3600;
|
||||
|
||||
protected $limit = 5;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'featured_question_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$questions = $this->findQuestions($this->limit);
|
||||
|
||||
if ($questions->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($questions as $question) {
|
||||
|
||||
$result[] = [
|
||||
'id' => $question->id,
|
||||
'title' => $question->title,
|
||||
'cover' => $question->cover,
|
||||
'favorite_count' => $question->favorite_count,
|
||||
'answer_count' => $question->answer_count,
|
||||
'view_count' => $question->view_count,
|
||||
'like_count' => $question->like_count,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|QuestionModel[]
|
||||
*/
|
||||
protected function findQuestions($limit = 5)
|
||||
{
|
||||
return QuestionModel::query()
|
||||
->where('featured = 1')
|
||||
->andWhere('published = :published:', ['published' => QuestionModel::PUBLISH_APPROVED])
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('RAND()')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\FlashSale as FlashSaleRepo;
|
||||
|
||||
class FlashSale extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "flash_sale:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$saleRepo = new FlashSaleRepo();
|
||||
|
||||
$sale = $saleRepo->findById($id);
|
||||
|
||||
return $sale ?: null;
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\Help as HelpRepo;
|
||||
|
||||
class Help extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 7 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "help:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$helpRepo = new HelpRepo();
|
||||
|
||||
$help = $helpRepo->findById($id);
|
||||
|
||||
return $help ?: null;
|
||||
}
|
||||
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Models\Help as HelpModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class HelpList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'help_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
|
||||
$categories = $this->findCategories();
|
||||
|
||||
if ($categories->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
$item = [];
|
||||
|
||||
$item['category'] = [
|
||||
'id' => $category->id,
|
||||
'name' => $category->name,
|
||||
];
|
||||
|
||||
$item['helps'] = [];
|
||||
|
||||
$helps = $this->findHelps($category->id);
|
||||
|
||||
if ($helps->count() > 0) {
|
||||
foreach ($helps as $help) {
|
||||
$item['helps'][] = [
|
||||
'id' => $help->id,
|
||||
'title' => $help->title,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$result[] = $item;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResultsetInterface|Resultset|CategoryModel[]
|
||||
*/
|
||||
protected function findCategories()
|
||||
{
|
||||
return CategoryModel::query()
|
||||
->where('type = :type:', ['type' => CategoryModel::TYPE_HELP])
|
||||
->andWhere('level = 1')
|
||||
->andWhere('published = 1')
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('priority ASC')
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $categoryId
|
||||
* @return ResultsetInterface|Resultset|CategoryModel[]
|
||||
*/
|
||||
protected function findHelps($categoryId)
|
||||
{
|
||||
return HelpModel::query()
|
||||
->where('category_id = :category_id:', ['category_id' => $categoryId])
|
||||
->andWhere('published = 1')
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('priority ASC')
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
@ -14,13 +14,11 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class HotQuestionList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
$tomorrow = strtotime('tomorrow');
|
||||
|
||||
return $tomorrow - time();
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
@ -48,6 +46,12 @@ class HotQuestionList extends Cache
|
||||
return $this->handleQuestions($questions);
|
||||
}
|
||||
|
||||
$questions = $this->findFullyHotQuestions();
|
||||
|
||||
if ($questions->count() > 0) {
|
||||
return $this->handleQuestions($questions);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -102,6 +106,17 @@ class HotQuestionList extends Cache
|
||||
return $this->findHotQuestions($createTime, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|QuestionModel[]
|
||||
*/
|
||||
protected function findFullyHotQuestions($limit = 10)
|
||||
{
|
||||
$createTime = 0;
|
||||
|
||||
return $this->findHotQuestions($createTime, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $createTime
|
||||
* @param int $limit
|
||||
|
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\ImMessage;
|
||||
use App\Models\ImMessage as ImMessageModel;
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\ImGroup as ImGroupRepo;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class ImActiveGroupList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'im_active_group_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$groups = $this->findGroups();
|
||||
|
||||
if (empty($groups)) return [];
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$result[] = [
|
||||
'id' => $group->id,
|
||||
'type' => $group->type,
|
||||
'name' => $group->name,
|
||||
'avatar' => $group->avatar,
|
||||
'about' => $group->about,
|
||||
'user_count' => $group->user_count,
|
||||
'msg_count' => $group->msg_count,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $days
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|UserModel[]
|
||||
*/
|
||||
protected function findGroups($days = 7, $limit = 12)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$startTime = strtotime("-{$days} days");
|
||||
$endTime = time();
|
||||
|
||||
$rows = ImMessageModel::query()
|
||||
->columns(['receiver_id', 'total_count' => 'count(receiver_id)'])
|
||||
->groupBy('receiver_id')
|
||||
->orderBy('total_count DESC')
|
||||
->where('receiver_type = :type:', ['type' => ImMessageModel::TYPE_GROUP])
|
||||
->betweenWhere('create_time', $startTime, $endTime)
|
||||
->andWhere('deleted = 0')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
|
||||
if ($rows->count() > 0) {
|
||||
|
||||
$ids = kg_array_column($rows->toArray(), 'receiver_id');
|
||||
|
||||
$groupRepo = new ImGroupRepo();
|
||||
|
||||
$result = $groupRepo->findByIds($ids);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\ImMessage as ImMessageModel;
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class ImActiveUserList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'im_active_user_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$users = $this->findUsers($id);
|
||||
|
||||
if (empty($users)) return [];
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users as $user) {
|
||||
$result[] = [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'avatar' => $user->avatar,
|
||||
'title' => $user->title,
|
||||
'about' => $user->about,
|
||||
'vip' => $user->vip,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $days
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|UserModel[]
|
||||
*/
|
||||
protected function findUsers($days = 7, $limit = 12)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$startTime = strtotime("-{$days} days");
|
||||
$endTime = time();
|
||||
|
||||
$rows = ImMessageModel::query()
|
||||
->columns(['sender_id', 'total_count' => 'count(sender_id)'])
|
||||
->groupBy('sender_id')
|
||||
->orderBy('total_count DESC')
|
||||
->betweenWhere('create_time', $startTime, $endTime)
|
||||
->limit($limit)
|
||||
->execute();
|
||||
|
||||
if ($rows->count() > 0) {
|
||||
|
||||
$ids = kg_array_column($rows->toArray(), 'sender_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$result = $userRepo->findByIds($ids);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\ImGroup as ImGroupRepo;
|
||||
|
||||
class ImGroup extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "im_group:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$groupRepo = new ImGroupRepo();
|
||||
|
||||
$group = $groupRepo->findById($id);
|
||||
|
||||
return $group ?: null;
|
||||
}
|
||||
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\ImMessage as ImMessageModel;
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class ImGroupActiveUserList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "im_group_active_user_list:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$users = $this->findUsers($id);
|
||||
|
||||
if (empty($users)) return [];
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users as $user) {
|
||||
$result[] = [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'avatar' => $user->avatar,
|
||||
'title' => $user->title,
|
||||
'about' => $user->about,
|
||||
'vip' => $user->vip,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $groupId
|
||||
* @param int $days
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|UserModel[]
|
||||
*/
|
||||
protected function findUsers($groupId, $days = 7, $limit = 5)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$startTime = strtotime("-{$days} days");
|
||||
$endTime = time();
|
||||
|
||||
$rows = ImMessageModel::query()
|
||||
->columns(['sender_id', 'total_count' => 'count(sender_id)'])
|
||||
->groupBy('sender_id')
|
||||
->orderBy('total_count DESC')
|
||||
->where('receiver_id = :group_id:', ['group_id' => $groupId])
|
||||
->andWhere('receiver_type = :type:', ['type' => ImMessageModel::TYPE_GROUP])
|
||||
->betweenWhere('create_time', $startTime, $endTime)
|
||||
->limit($limit)
|
||||
->execute();
|
||||
|
||||
if ($rows->count() > 0) {
|
||||
|
||||
$ids = kg_array_column($rows->toArray(), 'sender_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$result = $userRepo->findByIds($ids);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\ImGroup as ImGroupModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class ImNewGroupList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'im_new_group_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$limit = 12;
|
||||
|
||||
$groups = $this->findGroups($limit);
|
||||
|
||||
if ($groups->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->handleContent($groups);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImGroupModel[] $groups
|
||||
* @return array
|
||||
*/
|
||||
protected function handleContent($groups)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$result[] = [
|
||||
'id' => $group->id,
|
||||
'type' => $group->type,
|
||||
'name' => $group->name,
|
||||
'avatar' => $group->avatar,
|
||||
'about' => $group->about,
|
||||
'user_count' => $group->user_count,
|
||||
'msg_count' => $group->msg_count,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|ImGroupModel[]
|
||||
*/
|
||||
public function findGroups($limit = 12)
|
||||
{
|
||||
return ImGroupModel::query()
|
||||
->where('published = 1')
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('id DESC')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\User as UserModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class ImNewUserList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'im_new_user_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$limit = 12;
|
||||
|
||||
$users = $this->findUsers($limit);
|
||||
|
||||
if ($users->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->handleContent($users);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserModel[] $users
|
||||
* @return array
|
||||
*/
|
||||
protected function handleContent($users)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($users as $user) {
|
||||
$result[] = [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'avatar' => $user->avatar,
|
||||
'title' => $user->title,
|
||||
'about' => $user->about,
|
||||
'vip' => $user->vip,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|UserModel[]
|
||||
*/
|
||||
public function findUsers($limit = 12)
|
||||
{
|
||||
return UserModel::query()
|
||||
->where('deleted = 0')
|
||||
->orderBy('id DESC')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
@ -14,7 +14,7 @@ use App\Services\Logic\Article\ArticleList as ArticleListService;
|
||||
class IndexArticleList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 15 * 60;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexFeaturedCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Services\Logic\FlashSale\SaleList;
|
||||
|
||||
class IndexFlashSaleList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return strtotime('tomorrow') - time();
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'index_flash_sale_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$service = new SaleList();
|
||||
|
||||
$sales = $service->handle();
|
||||
|
||||
return $sales[0]['items'] ?? [];
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexFreeCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexLiveList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexNewCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ use App\Services\Logic\Question\QuestionList as QuestionListService;
|
||||
class IndexQuestionList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 15 * 60;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexSimpleFeaturedCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexSimpleFreeCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexSimpleNewCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexSimpleVipCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexSlideList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexTeacherList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 3600;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexVipCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Answer as AnswerModel;
|
||||
|
||||
class MaxAnswerId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_answer_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$answer = AnswerModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $answer->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Article as ArticleModel;
|
||||
|
||||
class MaxArticleId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_article_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$article = ArticleModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $article->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Comment as CommentModel;
|
||||
|
||||
class MaxCommentId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_comment_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$comment = CommentModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $comment->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\FlashSale as FlashSaleModel;
|
||||
|
||||
class MaxFlashSaleId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_flash_sale_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$sale = FlashSaleModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $sale->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Help as HelpModel;
|
||||
|
||||
class MaxHelpId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_help_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$help = HelpModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $help->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\ImGroup as ImGroupModel;
|
||||
|
||||
class MaxImGroupId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_im_group_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$group = ImGroupModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $group->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Page as PageModel;
|
||||
|
||||
class MaxPageId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_page_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$page = PageModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $page->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\PointGift as PointGiftModel;
|
||||
|
||||
class MaxPointGiftId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_point_gift_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$gift = PointGiftModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $gift->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Question as QuestionModel;
|
||||
|
||||
class MaxQuestionId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_question_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$question = QuestionModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $question->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Upload as UploadModel;
|
||||
|
||||
class MaxUploadId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_upload_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$upload = UploadModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $upload->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\Stat as StatRepo;
|
||||
|
||||
class ModerationStat extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 15 * 60;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'moderation_stat';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$statRepo = new StatRepo();
|
||||
|
||||
$articleCount = $statRepo->countPendingArticles();
|
||||
$questionCount = $statRepo->countPendingQuestions();
|
||||
$answerCount = $statRepo->countPendingAnswers();
|
||||
$commentCount = $statRepo->countPendingComments();
|
||||
|
||||
return [
|
||||
'article_count' => $articleCount,
|
||||
'question_count' => $questionCount,
|
||||
'answer_count' => $answerCount,
|
||||
'comment_count' => $commentCount,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -13,7 +13,7 @@ use App\Repos\Package as PackageRepo;
|
||||
class PackageCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\Page as PageRepo;
|
||||
|
||||
class Page extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 7 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "page:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$pageRepo = new PageRepo();
|
||||
|
||||
$page = $pageRepo->findById($id);
|
||||
|
||||
return $page ?: null;
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\PointGift as PointGiftRepo;
|
||||
|
||||
class PointGift extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "point_gift:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$giftRepo = new PointGiftRepo();
|
||||
|
||||
$gift = $giftRepo->findById($id);
|
||||
|
||||
return $gift ?: null;
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ class PointHotGiftList extends Cache
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
/**
|
||||
* 显示个数
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\Question as QuestionRepo;
|
||||
|
||||
class Question extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "question:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$questionRepo = new QuestionRepo();
|
||||
|
||||
$question = $questionRepo->findById($id);
|
||||
|
||||
return $question ?: null;
|
||||
}
|
||||
|
||||
}
|
@ -12,7 +12,6 @@ use App\Repos\Article as ArticleRepo;
|
||||
use App\Repos\Comment as CommentRepo;
|
||||
use App\Repos\Consult as ConsultRepo;
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\ImGroup as GroupRepo;
|
||||
use App\Repos\Package as PackageRepo;
|
||||
use App\Repos\Question as QuestionRepo;
|
||||
use App\Repos\Review as ReviewRepo;
|
||||
@ -42,7 +41,6 @@ class SiteGlobalStat extends Cache
|
||||
$answerRepo = new AnswerRepo();
|
||||
$commentRepo = new CommentRepo();
|
||||
$consultRepo = new ConsultRepo();
|
||||
$groupRepo = new GroupRepo();
|
||||
$packageRepo = new PackageRepo();
|
||||
$reviewRepo = new ReviewRepo();
|
||||
$topicRepo = new TopicRepo();
|
||||
@ -55,7 +53,6 @@ class SiteGlobalStat extends Cache
|
||||
'answer_count' => $answerRepo->countAnswers(),
|
||||
'comment_count' => $commentRepo->countComments(),
|
||||
'consult_count' => $consultRepo->countConsults(),
|
||||
'group_count' => $groupRepo->countGroups(),
|
||||
'vip_count' => $userRepo->countVipUsers(),
|
||||
'package_count' => $packageRepo->countPackages(),
|
||||
'review_count' => $reviewRepo->countReviews(),
|
||||
|
@ -13,9 +13,9 @@ use App\Repos\Article as ArticleRepo;
|
||||
class TaggedArticleList extends Cache
|
||||
{
|
||||
|
||||
protected $limit = 5;
|
||||
protected $limit = 15;
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -13,9 +13,9 @@ use App\Repos\Question as QuestionRepo;
|
||||
class TaggedQuestionList extends Cache
|
||||
{
|
||||
|
||||
protected $limit = 5;
|
||||
protected $limit = 15;
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Article as ArticleModel;
|
||||
use App\Models\ArticleLike as ArticleLikeModel;
|
||||
use App\Models\Answer as AnswerModel;
|
||||
use App\Models\AnswerLike as AnswerLikeModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
@ -16,7 +16,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class TopAnswererList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
@ -37,10 +37,24 @@ class TopAnswererList extends Cache
|
||||
return $this->handleUsers($userIds);
|
||||
}
|
||||
|
||||
$randOwners = $this->findRandArticleOwners();
|
||||
$rankings = $this->findMonthlyAuthorRankings();
|
||||
|
||||
if ($randOwners->count() > 0) {
|
||||
$userIds = kg_array_column($randOwners->toArray(), 'owner_id');
|
||||
if ($rankings->count() > 0) {
|
||||
$userIds = kg_array_column($rankings->toArray(), 'author_id');
|
||||
return $this->handleUsers($userIds);
|
||||
}
|
||||
|
||||
$rankings = $this->findYearlyAuthorRankings();
|
||||
|
||||
if ($rankings->count() > 0) {
|
||||
$userIds = kg_array_column($rankings->toArray(), 'author_id');
|
||||
return $this->handleUsers($userIds);
|
||||
}
|
||||
|
||||
$rankings = $this->findFullyAuthorRankings();
|
||||
|
||||
if ($rankings->count() > 0) {
|
||||
$userIds = kg_array_column($rankings->toArray(), 'author_id');
|
||||
return $this->handleUsers($userIds);
|
||||
}
|
||||
|
||||
@ -73,23 +87,53 @@ class TopAnswererList extends Cache
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset
|
||||
*/
|
||||
protected function findRandArticleOwners($limit = 10)
|
||||
protected function findWeeklyAuthorRankings($limit = 10)
|
||||
{
|
||||
return ArticleModel::query()
|
||||
->columns(['owner_id'])
|
||||
->orderBy('RAND()')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
$createTime = strtotime('monday this week');
|
||||
|
||||
return $this->findAuthorRankings($createTime, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset
|
||||
*/
|
||||
protected function findWeeklyAuthorRankings($limit = 10)
|
||||
protected function findMonthlyAuthorRankings($limit = 10)
|
||||
{
|
||||
$createTime = strtotime('monday this week');
|
||||
$createTime = strtotime(date('Y-m-01'));
|
||||
|
||||
return $this->findAuthorRankings($createTime, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset
|
||||
*/
|
||||
protected function findYearlyAuthorRankings($limit = 10)
|
||||
{
|
||||
$createTime = strtotime(date('Y-01-01'));
|
||||
|
||||
return $this->findAuthorRankings($createTime, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset
|
||||
*/
|
||||
protected function findFullyAuthorRankings($limit = 10)
|
||||
{
|
||||
$createTime = 0;
|
||||
|
||||
return $this->findAuthorRankings($createTime, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $createTime
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset
|
||||
*/
|
||||
protected function findAuthorRankings($createTime, $limit = 10)
|
||||
{
|
||||
$columns = [
|
||||
'author_id' => 'a.owner_id',
|
||||
'like_count' => 'count(al.user_id)',
|
||||
@ -97,8 +141,8 @@ class TopAnswererList extends Cache
|
||||
|
||||
return $this->modelsManager->createBuilder()
|
||||
->columns($columns)
|
||||
->addFrom(ArticleLikeModel::class, 'al')
|
||||
->join(ArticleModel::class, 'al.article_id = a.id', 'a')
|
||||
->addFrom(AnswerLikeModel::class, 'al')
|
||||
->join(AnswerModel::class, 'al.answer_id = a.id', 'a')
|
||||
->where('al.create_time > :create_time:', ['create_time' => $createTime])
|
||||
->groupBy('author_id')
|
||||
->orderBy('like_count DESC')
|
||||
|
@ -16,7 +16,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class TopAuthorList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ use App\Repos\User as UserRepo;
|
||||
class User extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -10,8 +10,6 @@ namespace App\Caches;
|
||||
class UserDailyCounter extends Counter
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
$tomorrow = strtotime('tomorrow');
|
||||
|
42
app/Console/Migrations/Migration.php
Normal file
42
app/Console/Migrations/Migration.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2022 深圳市酷瓜软件有限公司
|
||||
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Console\Migrations;
|
||||
|
||||
use App\Models\Setting as SettingModel;
|
||||
use App\Repos\Setting as SettingRepo;
|
||||
use App\Traits\Service as ServiceTrait;
|
||||
|
||||
abstract class Migration
|
||||
{
|
||||
|
||||
use ServiceTrait;
|
||||
|
||||
abstract public function run();
|
||||
|
||||
protected function saveSettings(array $settings)
|
||||
{
|
||||
foreach ($settings as $setting) {
|
||||
$this->saveSetting($setting);
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveSetting(array $setting)
|
||||
{
|
||||
$settingRepo = new SettingRepo();
|
||||
|
||||
$item = $settingRepo->findItem($setting['section'], $setting['item_key']);
|
||||
|
||||
if (!$item) {
|
||||
$item = new SettingModel();
|
||||
$item->create($setting);
|
||||
} else {
|
||||
$item->update($setting);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
48
app/Console/Migrations/V20240608145810.php
Normal file
48
app/Console/Migrations/V20240608145810.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2024 深圳市酷瓜软件有限公司
|
||||
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Console\Migrations;
|
||||
|
||||
use App\Models\Chapter as ChapterModel;
|
||||
use App\Models\Course as CourseModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
|
||||
class V20240608145810 extends Migration
|
||||
{
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->handleReadChapters();
|
||||
}
|
||||
|
||||
protected function handleReadChapters()
|
||||
{
|
||||
/**
|
||||
* @var $chapters Resultset|ChapterModel[]
|
||||
*/
|
||||
$chapters = ChapterModel::query()
|
||||
->where('model = :model:', ['model' => CourseModel::MODEL_READ])
|
||||
->andWhere('parent_id > 0')
|
||||
->execute();
|
||||
|
||||
if ($chapters->count() == 0) return;
|
||||
|
||||
foreach ($chapters as $chapter) {
|
||||
|
||||
$attrs = $chapter->attrs;
|
||||
|
||||
if (isset($attrs['format'])) continue;
|
||||
|
||||
$attrs['format'] = 'html';
|
||||
|
||||
$chapter->attrs = $attrs;
|
||||
|
||||
$chapter->update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
29
app/Console/Migrations/V20241110191316.php
Normal file
29
app/Console/Migrations/V20241110191316.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2024 深圳市酷瓜软件有限公司
|
||||
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Console\Migrations;
|
||||
|
||||
class V20241110191316 extends Migration
|
||||
{
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->handleContactSettings();
|
||||
}
|
||||
|
||||
protected function handleContactSettings()
|
||||
{
|
||||
$setting = [
|
||||
'section' => 'contact',
|
||||
'item_key' => 'douyin',
|
||||
'item_value' => '',
|
||||
];
|
||||
|
||||
$this->saveSetting($setting);
|
||||
}
|
||||
|
||||
}
|
41
app/Console/Migrations/V20250110191618.php
Normal file
41
app/Console/Migrations/V20250110191618.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2025 深圳市酷瓜软件有限公司
|
||||
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Console\Migrations;
|
||||
|
||||
use App\Models\UserBalance;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class V20250110191618 extends Migration
|
||||
{
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->handleRootUserBalance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 之前migration初始化root账号缺少user_balance数据
|
||||
*/
|
||||
protected function handleRootUserBalance()
|
||||
{
|
||||
$userId = 10000;
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$userBalance = $userRepo->findUserBalance($userId);
|
||||
|
||||
if ($userBalance) return;
|
||||
|
||||
$userBalance = new UserBalance();
|
||||
|
||||
$userBalance->user_id = $userId;
|
||||
|
||||
$userBalance->create();
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user