|
@@ -30,7 +30,8 @@ use App\Model\JobHunting;
|
|
use App\Model\Notice;
|
|
use App\Model\Notice;
|
|
use App\Model\Complaint;
|
|
use App\Model\Complaint;
|
|
use App\Model\Order;
|
|
use App\Model\Order;
|
|
-
|
|
|
|
|
|
+use App\Model\WebsiteImg;
|
|
|
|
+use Hyperf\HttpServer\Contract\RequestInterface;
|
|
|
|
|
|
use Hyperf\DbConnection\Db;
|
|
use Hyperf\DbConnection\Db;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
@@ -2526,4 +2527,118 @@ class WebsiteService implements WebsiteServiceInterface
|
|
return Result::error("更新失败", 0);
|
|
return Result::error("更新失败", 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // --自助建站-----------20250522fr----------------------start
|
|
|
|
+ /**
|
|
|
|
+ * 获取网站模板下的板块信息
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getStaticResourceList(array $data): array
|
|
|
|
+ {
|
|
|
|
+ // return Result::success($data);
|
|
|
|
+ $where = [];
|
|
|
|
+ if(isset($data['keyword']) &&!empty($data['keyword'])){
|
|
|
|
+ $where = ['img_alias' => $data['keyword'],'name' => ['like', '%'. $data['keyword']. '%']];
|
|
|
|
+ }
|
|
|
|
+ if(isset($data['type']) &&!empty($data['type'])){
|
|
|
|
+ $where = ['type' => $data['type']];
|
|
|
|
+ }
|
|
|
|
+ if(isset($data['website_id']) &&!empty($data['website_id'])){
|
|
|
|
+ $where = ['website_id' => $data['website_id']];
|
|
|
|
+ }
|
|
|
|
+ // return Result::success($where);
|
|
|
|
+ $query = WebsiteImg::when(!empty($where), function ($query) use ($where) {
|
|
|
|
+ $query->where($where);
|
|
|
|
+ })
|
|
|
|
+ ->orderBy('updated_at', 'desc');
|
|
|
|
+ $count = $query->count();
|
|
|
|
+ $row = $query->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->get();
|
|
|
|
+ if (empty($row)) {
|
|
|
|
+ return Result::error("没有查找到相关数据", 0);
|
|
|
|
+ } else {
|
|
|
|
+ $result = [
|
|
|
|
+ 'row' => $row,
|
|
|
|
+ 'count' => $count,
|
|
|
|
+ ];}
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 添加网站模板下的板块信息
|
|
|
|
+ * @param array $data
|
|
|
|
+ */
|
|
|
|
+ public function addStaticResource(array $data): array
|
|
|
|
+ {
|
|
|
|
+ // $file = $data['img_url']->file('image');
|
|
|
|
+ // $size = $file->getSize();
|
|
|
|
+ $img_data = [
|
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
|
+ 'img_alias' => $data['img_alias'],
|
|
|
|
+ 'img_url' => $data['img_url'],
|
|
|
|
+ 'img_size' => $data['img_size'],
|
|
|
|
+ ];
|
|
|
|
+ $img = WebsiteImg::insertGetId($img_data);
|
|
|
|
+ if (empty($img)) {
|
|
|
|
+ return Result::error("添加失败", 0);
|
|
|
|
+ }
|
|
|
|
+ $img_id['id'] = $img;
|
|
|
|
+ $url = WebsiteImg::where($img_id)->value('img_url');
|
|
|
|
+
|
|
|
|
+ // 1. 分割路径部分(以 / 为分隔符)
|
|
|
|
+ $pathSegments = explode('/', parse_url($url, PHP_URL_PATH));
|
|
|
|
+
|
|
|
|
+ // 2. 取最后一个元素作为文件名
|
|
|
|
+ $fileName = end($pathSegments); // 1743041040714597.jpg
|
|
|
|
+
|
|
|
|
+ // 3. 分割文件名获取扩展名
|
|
|
|
+ $fileParts = explode('.', $fileName);
|
|
|
|
+ $fileType = end($fileParts); // jpg
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $img_datas = [
|
|
|
|
+ 'img_type' => $fileType,
|
|
|
|
+ 'name' => $fileName
|
|
|
|
+ ];
|
|
|
|
+ $up_img = WebsiteImg::where($img_id)->update($img_datas);
|
|
|
|
+ if (empty($up_img)) {
|
|
|
|
+ return Result::error("修改失败", 0);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($up_img);
|
|
|
|
+ // 将字节转换为更友好的单位
|
|
|
|
+ // $friendlySize = $this->formatFileSize($size);
|
|
|
|
+ // $data['img_size'] = $friendlySize;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 修改网站模板下的板块信息
|
|
|
|
+ * @param array $data
|
|
|
|
+ */
|
|
|
|
+ public function delStaticResource(array $data): array
|
|
|
|
+ {
|
|
|
|
+ $where = [
|
|
|
|
+ 'id' => $data['id'],
|
|
|
|
+ ];
|
|
|
|
+ $result = WebsiteImg::where($where)->delete();
|
|
|
|
+ if (empty($result)) {
|
|
|
|
+
|
|
|
|
+ return Result::error("修改失败", 0);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 获取网站模板下的板块信息
|
|
|
|
+ * @param array $data
|
|
|
|
+ */
|
|
|
|
+ public function getStaticResourceInfo(array $data): array
|
|
|
|
+ {
|
|
|
|
+ $where = [
|
|
|
|
+ 'id' => $data['id'],
|
|
|
|
+ ];
|
|
|
|
+ $result = WebsiteImg::where($where)->first();
|
|
|
|
+ if (empty($result)) {
|
|
|
|
+ return Result::error("没有查找到相关数据", 0);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ }
|
|
|
|
+ // --自助建站-----------20250522fr----------------------end
|
|
}
|
|
}
|