'integer', 'size' => 'integer','height' => 'integer', 'width' => 'integer', 'audio_second' => 'integer', 'video_duration' => 'integer', 'is_enabled' => 'integer', 'type' => 'integer']; const CREATED_AT = 'create_time'; const UPDATED_AT = null; /** * url访问器 * @param $value * @return string */ public function getUrlAttribute($value) { return config('ali.oss_url').$value; } /** * 根据ids获取资源id列表 * @param array $ids * @return Collection */ public function getIdListByIds(array $ids): Collection { return $this->whereIn('id', $ids)->pluck('id'); } /** * 根据ids更新oss Enable状态 */ public function updateEnabledByIds(array $ids): int { return $this->whereIn('id', $ids)->update(['is_enabled' => OssObjectCode::ENABLE]); } /** * 根据ids 更新oss Disable状态 * @param array $ids * @return int */ public function updateDisableByIds(array $ids): int { return $this->whereIn('id', $ids)->update(['is_enabled' => OssObjectCode::DISABLE]); } /** * 根据id获取信息 * @param array $ids * @return Collection */ public function getInfoByOssIds(array $ids): Collection { return $this->whereIn('id', $ids)->get(); } /** * @param int $id * @return Builder|\Hyperf\Database\Model\Model|null */ public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null { return $this->where('id', $id)->first(); } /** * 根据is_enabled获取传入时间前无效资源id * @param $time * @return Collection|false */ public function getOssIdListByIsEnabled($time): Collection|false { return $this->where([ ['is_enabled', '=', OssObjectCode::DISABLE], ['create_time', '<',$time] ])->pluck('id') ?? false; } }