|
@@ -28,6 +28,8 @@ use Hyperf\Redis\Redis;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use App\Model\Company;
|
|
use App\Model\Company;
|
|
use Hyperf\Paginator\Paginator;
|
|
use Hyperf\Paginator\Paginator;
|
|
|
|
+use App\Model\Project;
|
|
|
|
+
|
|
#[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
#[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
class NewsService implements NewsServiceInterface
|
|
class NewsService implements NewsServiceInterface
|
|
{
|
|
{
|
|
@@ -1041,7 +1043,7 @@ class NewsService implements NewsServiceInterface
|
|
foreach ($img_article as $k => $v) {
|
|
foreach ($img_article as $k => $v) {
|
|
$img_article[$k]->category_name = $catiall[$v->catid]['alias'];
|
|
$img_article[$k]->category_name = $catiall[$v->catid]['alias'];
|
|
$img_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
$img_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}else{
|
|
}else{
|
|
$img_article = [];
|
|
$img_article = [];
|
|
@@ -2816,28 +2818,38 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
|
|
}
|
|
}
|
|
// return Result::success($where);
|
|
// return Result::success($where);
|
|
$query = Company::where($where);
|
|
$query = Company::where($where);
|
|
- $result['img'] = $this->processArticle(
|
|
|
|
- $query->clone()
|
|
|
|
|
|
+ $result['text'] = $query->clone()
|
|
|
|
+ ->select('id','title','introduce','description','content','category_id','cat_arr_id','category_id')
|
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
|
+ ->limit($data['textnum'])
|
|
|
|
+ ->get();
|
|
|
|
+ $result['img'] = $query->clone()
|
|
->where('imgurl','!=', '')
|
|
->where('imgurl','!=', '')
|
|
->whereNotNull('imgurl')
|
|
->whereNotNull('imgurl')
|
|
- ->select('id','imgurl','title','introduce','description','content','category_id','cat_arr_id')
|
|
|
|
|
|
+ ->select('id','imgurl as imgs','title','introduce','description','content','category_id','cat_arr_id')
|
|
->orderBy('updated_at', 'desc')
|
|
->orderBy('updated_at', 'desc')
|
|
->limit($data['imgnum'])
|
|
->limit($data['imgnum'])
|
|
- ->get(),
|
|
|
|
- $data
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- $result['text'] = $this->processArticle(
|
|
|
|
- $query->clone()
|
|
|
|
- ->select('id','title','introduce','description','content','category_id','cat_arr_id')
|
|
|
|
- ->orderBy('updated_at', 'desc')
|
|
|
|
- ->limit($data['textnum'])
|
|
|
|
- ->get(),
|
|
|
|
- $data
|
|
|
|
- );
|
|
|
|
|
|
+ ->get();
|
|
|
|
+
|
|
if(empty($result)){
|
|
if(empty($result)){
|
|
return Result::error("暂无相关公司信息", 0);
|
|
return Result::error("暂无相关公司信息", 0);
|
|
}
|
|
}
|
|
|
|
+ $category_arr = $this->processArticlePro($data['website_id']);
|
|
|
|
+ $catiall = $category_arr['catiall'];
|
|
|
|
+ if(!empty($result['img'])){
|
|
|
|
+ foreach($result['img'] as $key => $val){
|
|
|
|
+ $result['img'][$key]->category_name = $catiall[$val->category_id]['alias'];
|
|
|
|
+ $result['img'][$key]->pinyin = $catiall[$val->category_id]['pinyin'];
|
|
|
|
+ $imgurl = json_decode($val['imgs'], true);
|
|
|
|
+ if(!empty($imgurl)){
|
|
|
|
+ $result['img'][$key]->imgurl = $imgurl[0];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // if(!empty($result['text'])){
|
|
|
|
+ // $result['text'] = $this->processArticlePro($result['text'], $catiall);
|
|
|
|
+ // }
|
|
|
|
+
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
@@ -2888,6 +2900,161 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
|
|
}
|
|
}
|
|
return Result::success($company);
|
|
return Result::success($company);
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getWebsiteProject(array $data): array
|
|
|
|
+ {
|
|
|
|
+ $categorys = json_decode($data['id'], true);
|
|
|
|
+ if(!empty($categorys)){
|
|
|
|
+ $category_arr = $this->processArticlePro($data['website_id']);
|
|
|
|
+ $cat_1st_arr = $category_arr['cat_1st_arr'];
|
|
|
|
+ $catiall = $category_arr['catiall'];
|
|
|
|
+ // return Result::success($catiall);
|
|
|
|
+ foreach($categorys as $key => $val){
|
|
|
|
+ if(isset($val['level'][0]) && !empty($val['level'][0])){
|
|
|
|
+ $level = $val['level'][0];
|
|
|
|
+ $imgnum = $val['level'][1] ?? null;
|
|
|
|
+ $textnum = $val['level'][2] ?? null;
|
|
|
|
+ if(!empty($textnum)){
|
|
|
|
+ $text_num = Project::where('level', $level)
|
|
|
|
+ ->where('website_id',$data['website_id'])
|
|
|
|
+ ->where('status',1)
|
|
|
|
+ ->select('project.id','project.title','project.description','project.updated_at',
|
|
|
|
+ 'project.category_id','project.cat_arr_id')
|
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
|
+ ->limit($textnum)
|
|
|
|
+ ->get()->all();
|
|
|
|
+ }
|
|
|
|
+ if(!empty($imgnum)){
|
|
|
|
+ $img_num = Project::where('level', $level)
|
|
|
|
+ ->where('website_id',$data['website_id'])
|
|
|
|
+ ->where('status',1)
|
|
|
|
+ ->where('imgurl','!=', '')
|
|
|
|
+ ->whereNotNull('imgurl')
|
|
|
|
+ ->select('project.id','project.title','project.description','project.updated_at',
|
|
|
|
+ 'project.imgurl as imgs','project.category_id','project.cat_arr_id')
|
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
|
+ ->limit($imgnum)
|
|
|
|
+ ->get()->all();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(isset($val['id'][0]) && !empty($val['id'][0])){
|
|
|
|
+ $category_ids = explode(',', $val['id'])[0];
|
|
|
|
+ $cat_imgnum = explode(',', $val['id'])[1] ?? null;
|
|
|
|
+ $cat_textnum = explode(',', $val['id'])[2] ?? null;
|
|
|
|
+ if(!empty($cat_textnum)){
|
|
|
|
+ $text_num = Project::where('category_id', $category_ids)
|
|
|
|
+ ->where('website_id',$data['website_id'])
|
|
|
|
+ ->where('status',1)
|
|
|
|
+ ->select('project.id','project.title','project.description','project.updated_at',
|
|
|
|
+ 'project.category_id','project.cat_arr_id')
|
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
|
+ ->limit($cat_textnum)
|
|
|
|
+ ->get()->all();
|
|
|
|
+ }
|
|
|
|
+ if(!empty($cat_imgnum)){
|
|
|
|
+ $img_num = Project::where('category_id', $category_ids)
|
|
|
|
+ ->where('website_id',$data['website_id'])
|
|
|
|
+ ->where('status',1)
|
|
|
|
+ ->where('imgurl','!=', '')
|
|
|
|
+ ->whereNotNull('imgurl')
|
|
|
|
+ ->select('project.id','project.title','project.description','project.updated_at',
|
|
|
|
+ 'project.imgurl as imgs','project.category_id','project.cat_arr_id')
|
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
|
+ ->limit($cat_imgnum)
|
|
|
|
+ ->get()->all();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(!empty($img_num)){
|
|
|
|
+ foreach ($img_num as $k => $v) {
|
|
|
|
+ $img_num[$k]->category_name = $catiall[$v->category_id]['alias'];
|
|
|
|
+ $imgurl = json_decode($v['imgs'], true);
|
|
|
|
+ if(!empty($imgurl)){
|
|
|
|
+ $img_num[$k]->imgurl = $imgurl[0];
|
|
|
|
+ }
|
|
|
|
+ $img_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
|
|
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(!empty($text_num)){
|
|
|
|
+ foreach ($text_num as $k => $v) {
|
|
|
|
+ $text_num[$k]->category_name = $catiall[$v->category_id]['alias'];
|
|
|
|
+ $text_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $project[$key]['img_num'] = $img_num ?? [];
|
|
|
|
+ $project[$key]['text_num'] = $text_num ?? [];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(empty($project)){
|
|
|
|
+ return Result::error("暂无相关项目信息", 0);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($project);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getWebsiteProjectInfo(array $data): array
|
|
|
|
+ {
|
|
|
|
+ $project = Project::where('id', $data['id'])
|
|
|
|
+ ->where('status', 1)
|
|
|
|
+ ->where('website_id', $data['website_id'])
|
|
|
|
+ ->select('project.*')
|
|
|
|
+ ->first();
|
|
|
|
+ if(empty($project)){
|
|
|
|
+ return Result::error("暂无相关项目信息", 0);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($project);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getWebsiteProjectList(array $data): array
|
|
|
|
+ {
|
|
|
|
+ $where = [];
|
|
|
|
+ if(isset($data['category_id']) && !empty($data['category_id'])){
|
|
|
|
+ $where['category_id'] = $data['category_id'];
|
|
|
|
+ }
|
|
|
|
+ if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
|
|
+ $where[] = ['title','like', '%' . $data['keyword'] . '%'];
|
|
|
|
+ }
|
|
|
|
+ $query = Project::where($where)
|
|
|
|
+ ->where('status', 1)
|
|
|
|
+ ->where('website_id', $data['website_id'])
|
|
|
|
+ ->select('project.id','project.title','project.introduce','project.imgurl as imgs',
|
|
|
|
+ 'project.category_id','project.cat_arr_id')
|
|
|
|
+ ->orderBy('updated_at', 'desc');
|
|
|
|
+ $count = $query->count();
|
|
|
|
+ $project = $query->clone()
|
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
|
+ ->limit($data['pageSize'])
|
|
|
|
+ ->get()->all();
|
|
|
|
+ if(empty($project)){
|
|
|
|
+ return Result::error("暂无相关项目信息", 0);
|
|
|
|
+ }
|
|
|
|
+ $categorys = $this->processArticlePro($data['website_id']);
|
|
|
|
+ $catiall = $categorys['catiall'];
|
|
|
|
+ foreach($project as $key => $val){
|
|
|
|
+ $project[$key]->category_name = $catiall[$val->category_id]['alias'];
|
|
|
|
+ if(!empty($val['imgs'])){
|
|
|
|
+ $imgurl = json_decode($val['imgs'], true);
|
|
|
|
+ if(!empty($imgurl)){
|
|
|
|
+ $project[$key]->imgurl = $imgurl[0];
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ $project[$key]->imgurl = '';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $project[$key]->pinyin = $catiall[$val->category_id]['pinyin'];
|
|
|
|
+ }
|
|
|
|
+ $result = [
|
|
|
|
+ 'rows' => $project,
|
|
|
|
+ 'count' => $count,
|
|
|
|
+ ];
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ }
|
|
}
|
|
}
|