V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  xiaochong0302  ›  全部回复第 6 页 / 共 13 页
回复总数  255
1  2  3  4  5  6  7  8  9  10 ... 13  
只能看前 N 页就好了,简单粗暴

```
public function getPage()
{
$page = $this->request->getQuery('page', ['trim', 'int'], 1);

return $page > 100 ? 100 : $page;
}

public function getLimit()
{
$limit = $this->request->getQuery('limit', ['trim', 'int'], 12);

return $limit > 100 ? 100 : $limit;
}
```
哥们,看看我的开源在线教育项目: https://gitee.com/koogua/course-tencent-cloud 不能再用爱发电,以后也会搞代理商
2021-05-30 14:15:57 +08:00
回复了 GrowingGit 创建的主题 推广 ★3W+! GitHub 中文排行榜,帮助你发现高分优秀中文项目
edusoho 这种假开源也在其中?
2021-05-27 10:08:41 +08:00
回复了 coolworker 创建的主题 问与答 去实习还是专升本,纠结中
@LamProductionS 全日制本科,35岁以下

我已经不合条件了,年龄超了,日了狗了,当然没买房深户也没卵用
2021-05-21 09:20:09 +08:00
回复了 puduhe1 创建的主题 程序员 阿里抄袭自记账之三,博君一笑,希望大家不要烦
https://www.v2ex.com/t/777798 搞个链接,希望有后文
2021-05-19 12:18:56 +08:00
回复了 Rxianbei 创建的主题 广州 在广东生活能够自然而然的学会广东话吗?
听懂不难,要说就不简单了,我江西人在,起初刚到深圳住的地方没有网络,只能看电视,电视也就几个台,选了几个讲白话的频道看(新闻,电视剧),几个月下来,白话不看字幕也能听懂,说的话就舌头打结,发音困难
2021-05-14 09:07:28 +08:00
回复了 tctc4869 创建的主题 程序员 除了开源中国,还有哪些网站有软件更新资讯的版块?
@ragnaroks 我举报了几个所谓开源项目刷 star 的,证据扎实,我还特意发个帖问了一下有没有人管,他们官方说会有人管,事实上毫无作为,就这样吧...
2021-05-06 09:14:29 +08:00
回复了 dujiangbo 创建的主题 PHP 为什么 PHP .ini 设置中的 error_reporting 在 cmd 命令行下不起作用?
有 fpm 和 cli 两个配置的
商家的尺码不标准有鬼用啊
我懒鬼订单号:$this->sn = date('YmdHis') . rand(1000, 9999);

没有大量用户高并发,这样又不是不能用,大不了后面再加一段随机数。
2021-04-26 15:39:51 +08:00
回复了 iminto 创建的主题 Linux 有什么自带显示屏的 mini Linux 主机成品吗
树莓派不复杂吧,那么多外设可插拔,小巧方便
@iyaozhen 估计是这么个意思
2021-04-23 19:34:01 +08:00
回复了 Renco 创建的主题 程序员 数据库设计太拉跨被喷了。
参考一下我的模型文件:[app/Models/Course.php]( https://gitee.com/koogua/course-tencent-cloud/blob/master/app/Models/Course.php)

我个人觉得不用写注释都能看得一清二楚

```
<?php

namespace App\Models;

use App\Caches\MaxCourseId as MaxCourseIdCache;
use App\Services\Sync\CourseIndex as CourseIndexSync;
use App\Services\Sync\CourseScore as CourseScoreSync;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
use Phalcon\Text;

class Course extends Model
{

/**
* 模型
*/
const MODEL_VOD = 1; // 点播
const MODEL_LIVE = 2; // 直播
const MODEL_READ = 3; // 图文
const MODEL_OFFLINE = 4; // 面授

/**
* 级别
*/
const LEVEL_ENTRY = 1; // 入门
const LEVEL_JUNIOR = 2; // 初级
const LEVEL_MEDIUM = 3; // 中级
const LEVEL_SENIOR = 4; // 高级

/**
* @var array
*
* 点播扩展属性
*/
protected $_vod_attrs = [
'duration' => 0,
];

/**
* @var array
*
* 直播扩展属性
*/
protected $_live_attrs = [
'start_date' => '',
'end_date' => '',
];

/**
* @var array
*
* 图文扩展属性
*/
protected $_read_attrs = [
'duration' => 0,
'word_count' => 0,
];

/**
* @var array
*
* 面授扩展属性
*/
protected $_offline_attrs = [
'start_date' => '',
'end_date' => '',
'user_limit' => 30,
'location' => '',
];

/**
* 主键编号
*
* @var int
*/
public $id = 0;

/**
* 标题
*
* @var string
*/
public $title = '';

/**
* 封面
*
* @var string
*/
public $cover = '';

/**
* 简介
*
* @var string
*/
public $summary = '';

/**
* 关键字
*
* @var string
*/
public $keywords = '';

/**
* 详情
*
* @var string
*/
public $details = '';

/**
* 主分类编号
*
* @var int
*/
public $category_id = 0;

/**
* 主教师编号
*
* @var int
*/
public $teacher_id = 0;

/**
* 原始价格
*
* @var float
*/
public $origin_price;

/**
* 优惠价格
*
* @var float
*/
public $market_price = 0.00;

/**
* 会员价格
*
* @var float
*/
public $vip_price = 0.00;

/**
* 学习期限(月)
*
* @var int
*/
public $study_expiry = 12;

/**
* 退款期限(天)
*
* @var int
*/
public $refund_expiry = 7;

/**
* 用户评价
*
* @var float
*/
public $rating = 5.00;

/**
* 综合得分
*
* @var float
*/
public $score = 0.00;

/**
* 模式类型
*
* @var int
*/
public $model = self::MODEL_VOD;

/**
* 难度级别
*
* @var int
*/
public $level = self::LEVEL_JUNIOR;

/**
* 扩展属性
*
* @var array|string
*/
public $attrs = [];

/**
* 推荐标识
*
* @var int
*/
public $featured = 0;

/**
* 发布标识
*
* @var int
*/
public $published = 0;

/**
* 删除标识
*
* @var int
*/
public $deleted = 0;

/**
* 资源数
*
* @var int
*/
public $resource_count = 0;

/**
* 学员数
*
* @var int
*/
public $user_count = 0;

/**
* 课时数
*
* @var int
*/
public $lesson_count = 0;

/**
* 套餐数
*
* @var int
*/
public $package_count = 0;

/**
* 咨询数
*
* @var int
*/
public $consult_count = 0;

/**
* 评价数
*
* @var int
*/
public $review_count = 0;

/**
* 收藏数
*
* @var int
*/
public $favorite_count = 0;

/**
* 创建时间
*
* @var int
*/
public $create_time = 0;

/**
* 更新时间
*
* @var int
*/
public $update_time = 0;

public function getSource(): string
{
return 'kg_course';
}

public function initialize()
{
parent::initialize();

$this->keepSnapshots(true);

$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}

public function beforeCreate()
{
if (empty($this->attrs)) {
if ($this->model == self::MODEL_VOD) {
$this->attrs = $this->_vod_attrs;
} elseif ($this->model == self::MODEL_LIVE) {
$this->attrs = $this->_live_attrs;
} elseif ($this->model == self::MODEL_READ) {
$this->attrs = $this->_read_attrs;
} elseif ($this->model == self::MODEL_OFFLINE) {
$this->attrs = $this->_offline_attrs;
}
}

if (is_array($this->attrs)) {
$this->attrs = kg_json_encode($this->attrs);
}

if (empty($this->cover)) {
$this->cover = kg_default_course_cover_path();
} elseif (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover);
}

$this->create_time = time();
}

public function beforeUpdate()
{
if (time() - $this->update_time > 3 * 3600) {
$sync = new CourseIndexSync();
$sync->addItem($this->id);

$sync = new CourseScoreSync();
$sync->addItem($this->id);
}

if (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover);
}

if (empty($this->summary)) {
$this->summary = kg_parse_summary($this->details);
}

if (is_array($this->attrs)) {
$this->attrs = kg_json_encode($this->attrs);
}

if (empty($this->origin_price)) {
$this->origin_price = 1.5 * $this->market_price;
}

if ($this->deleted == 1) {
$this->published = 0;
}

$this->update_time = time();
}

public function afterCreate()
{
$cache = new MaxCourseIdCache();

$cache->rebuild();
}

public function afterFetch()
{
$this->origin_price = (float)$this->origin_price;
$this->market_price = (float)$this->market_price;
$this->vip_price = (float)$this->vip_price;
$this->rating = (float)$this->rating;
$this->score = (float)$this->score;

if (!Text::startsWith($this->cover, 'http')) {
$this->cover = kg_cos_course_cover_url($this->cover);
}

if (is_string($this->attrs)) {
$this->attrs = json_decode($this->attrs, true);
}
}

public static function getCoverPath($url)
{
if (Text::startsWith($url, 'http')) {
return parse_url($url, PHP_URL_PATH);
}

return $url;
}

public static function modelTypes()
{
return [
self::MODEL_VOD => '点播',
self::MODEL_LIVE => '直播',
self::MODEL_READ => '图文',
self::MODEL_OFFLINE => '面授',
];
}

public static function levelTypes()
{
return [
self::LEVEL_ENTRY => '入门',
self::LEVEL_JUNIOR => '初级',
self::LEVEL_MEDIUM => '中级',
self::LEVEL_SENIOR => '高级',
];
}

public static function sortTypes()
{
return [
'score' => '综合',
'rating' => '好评',
'latest' => '最新',
'popular' => '最热',
'featured' => '推荐',
'free' => '免费',
];
}

public static function studyExpiryOptions()
{
return [
1 => '1 个月',
3 => '3 个月',
6 => '6 个月',
12 => '12 个月',
36 => '36 个月',
];
}

public static function refundExpiryOptions()
{
return [
0 => '0 天',
7 => '7 天',
14 => '14 天',
30 => '30 天',
90 => '90 天',
180 => '180 天',
];
}

}
```
2021-04-22 12:38:37 +08:00
回复了 005008 创建的主题 问与答 准备做个前端学习的公众号,起个什么名字好呢
你学废了吗?
好像 oschina 现在发言相关的功能都关闭了
1  2  3  4  5  6  7  8  9  10 ... 13  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1023 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 36ms · UTC 23:39 · PVG 07:39 · LAX 16:39 · JFK 19:39
Developed with CodeLauncher
♥ Do have faith in what you're doing.