|
@@ -30,7 +30,8 @@ use App\Model\JobHunting;
|
|
|
use App\Model\Notice;
|
|
|
use App\Model\Complaint;
|
|
|
use App\Model\Order;
|
|
|
-
|
|
|
+use App\Model\WebsiteImg;
|
|
|
+use Hyperf\HttpServer\Contract\RequestInterface;
|
|
|
|
|
|
use Hyperf\DbConnection\Db;
|
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
@@ -2526,4 +2527,118 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::error("更新失败", 0);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 获取网站模板下的板块信息
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getStaticResourceList(array $data): array
|
|
|
+ {
|
|
|
+
|
|
|
+ $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']];
|
|
|
+ }
|
|
|
+
|
|
|
+ $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
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ $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');
|
|
|
+
|
|
|
+
|
|
|
+ $pathSegments = explode('/', parse_url($url, PHP_URL_PATH));
|
|
|
+
|
|
|
+
|
|
|
+ $fileName = end($pathSegments);
|
|
|
+
|
|
|
+
|
|
|
+ $fileParts = explode('.', $fileName);
|
|
|
+ $fileType = end($fileParts);
|
|
|
+
|
|
|
+
|
|
|
+ $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);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ * 修改网站模板下的板块信息
|
|
|
+ * @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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|