feat : site

This commit is contained in:
2024-11-12 15:40:33 +08:00
parent 82dd7450af
commit 900d98234b
7 changed files with 169 additions and 5 deletions

View File

@@ -74,4 +74,25 @@ class AdminUser extends Model
{
return $this->where('id', $id)->where('is_del',UserCode::IS_NO_DEL)->first();
}
/**
* 获取所有数据
* @param array $ids
* @return array
*/
public function getDataByIds(array $ids): array
{
$data = $this->whereIn('id',$ids)->get();
if (empty($data)){
return [];
}
$res = [];
foreach ($data->toArray() as $one)
{
$res[$one['id']] = $one;
}
return $res;
}
}

View File

@@ -60,4 +60,25 @@ class Kitchen extends Model
{
return $this->where('id',$id)->where('is_del',SiteCode::KITCHEN_NO_DEL)->first();
}
/**
* 获取所有数据
* @param array $ids
* @return array
*/
public function getDataByIds(array $ids): array
{
$data = $this->whereIn('id',$ids)->get();
if (empty($data)){
return [];
}
$res = [];
foreach ($data->toArray() as $one)
{
$res[$one['id']] = $one;
}
return $res;
}
}

View File

@@ -6,6 +6,7 @@ namespace App\Model;
use App\Constants\Common\OssObjectCode;
use Hyperf\Collection\Collection;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
use function Hyperf\Config\config;
@@ -93,6 +94,15 @@ class OssObject extends Model
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

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Model;
use App\Constants\Common\SiteCode;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
/**
@@ -62,4 +63,22 @@ class Site extends Model
->where('is_del',SiteCode::SITE_NO_DEL)
->update(['status' => SiteCode::SITE_DISABLE]);
}
/**
* @param string $name
* @return Builder|\Hyperf\Database\Model\Model|null
*/
public function getInfoByName(string $name): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('name',$name)->where('is_del',SiteCode::SITE_NO_DEL)->first();
}
/**
* @param int $id
* @return \Hyperf\Database\Model\Model|Builder|null
*/
public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('id',$id)->where('is_del',SiteCode::SITE_NO_DEL)->first();
}
}

View File

@@ -67,4 +67,25 @@ class SystemCity extends Model
{
return $this->whereIn('id',$ids)->pluck('title','id')->toArray();
}
/**
* 获取所有数据
* @param array $ids
* @return array
*/
public function getDataByIds(array $ids): array
{
$data = $this->whereIn('id',$ids)->get();
if (empty($data)){
return [];
}
$res = [];
foreach ($data->toArray() as $one)
{
$res[$one['id']] = $one;
}
return $res;
}
}