|
@@ -66,6 +66,8 @@ use App\Model\Company;
|
|
|
use Hyperf\Paginator\Paginator;
|
|
|
use App\Model\Project;
|
|
|
|
|
|
+use App\Model\Project;
|
|
|
+
|
|
|
#[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class NewsService implements NewsServiceInterface
|
|
|
{
|
|
@@ -6774,4 +6776,162 @@ class NewsService implements NewsServiceInterface
|
|
|
var_dump($type_id, '-----------------test---------');
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * @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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|