|
|
@@ -29,7 +29,7 @@ use Hyperf\Di\Annotation\Inject;
|
|
|
use App\Model\Company;
|
|
|
use Hyperf\Paginator\Paginator;
|
|
|
use App\Model\Project;
|
|
|
-use App\Model\WhiteRouter;
|
|
|
+use App\Model\WhiteRouter;
|
|
|
#[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class NewsService implements NewsServiceInterface
|
|
|
{
|
|
|
@@ -317,7 +317,7 @@ class NewsService implements NewsServiceInterface
|
|
|
$where = [
|
|
|
'status' => 1
|
|
|
];
|
|
|
- $website_id = $data['website_id'];
|
|
|
+ // $website_id = $data['website_id'];
|
|
|
$month = date("Y-m-d H:i:s", strtotime("-30 day"));
|
|
|
//如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
|
|
|
// 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
|
|
|
@@ -437,37 +437,36 @@ class NewsService implements NewsServiceInterface
|
|
|
$category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $catid)->select('category_id')->get();
|
|
|
$category = $category->toArray();
|
|
|
if (!empty($category)) {
|
|
|
- $where = [
|
|
|
- 'status' => 1,
|
|
|
- 'catid' => $catid,
|
|
|
- ];
|
|
|
- $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
|
|
|
- // 1:文字新闻;2:轮播图;3:图文;
|
|
|
- // 级别:0:未分类
|
|
|
- // 3:推荐图片
|
|
|
- if ($data['level'] == 1) {
|
|
|
- $data['level'] = 0;
|
|
|
- }
|
|
|
- $result = Article::where($where)
|
|
|
- ->where(function ($query) use ($data) {
|
|
|
- $query->whereRaw("JSON_CONTAINS(level, '" . intval($data['level']) . "') = 1")
|
|
|
- ->orWhereNull("level")
|
|
|
- ->orWhereRaw("level = '[]'");
|
|
|
- })
|
|
|
- ->where(function ($query) use ($data) {
|
|
|
- $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
|
|
|
- ->orWhereNull("ignore_ids");
|
|
|
- })
|
|
|
- ->orderBy("updated_at", "desc")
|
|
|
- ->offset($placeid)
|
|
|
- ->limit($data['pagesize'])
|
|
|
- ->get();
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("此栏目暂无相关新闻", 0);
|
|
|
- }
|
|
|
+ $where = [
|
|
|
+ 'status' => 1,
|
|
|
+ 'catid' => $catid,
|
|
|
+ ];
|
|
|
+ $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
|
|
|
+ // 1:文字新闻;2:轮播图;3:图文;
|
|
|
+ // 级别:0:未分类
|
|
|
+ // 3:推荐图片
|
|
|
+ if ($data['level'] == 1) {
|
|
|
+ $data['level'] = 0;
|
|
|
+ }
|
|
|
+ $result = Article::where($where)
|
|
|
+ ->where(function ($query) use ($data) {
|
|
|
+ $query->whereRaw("JSON_CONTAINS(level, '" . intval($data['level']) . "') = 1")
|
|
|
+ ->orWhereNull("level")
|
|
|
+ ->orWhereRaw("level = '[]'");
|
|
|
+ })
|
|
|
+ ->where(function ($query) use ($data) {
|
|
|
+ $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
|
|
|
+ ->orWhereNull("ignore_ids");
|
|
|
+ })
|
|
|
+ ->orderBy("updated_at", "desc")
|
|
|
+ ->offset($placeid)
|
|
|
+ ->limit($data['pagesize'])
|
|
|
+ ->get();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("此栏目暂无相关新闻", 0);
|
|
|
+ }
|
|
|
} else {
|
|
|
- return Result::error("此网站暂无此栏目", 0);
|
|
|
-
|
|
|
+ return Result::error("此网站暂无此栏目", 0);
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
@@ -2915,6 +2914,8 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
|
|
|
$category_arr = $this->processArticlePro($data['website_id']);
|
|
|
$cat_1st_arr = $category_arr['cat_1st_arr'];
|
|
|
$catiall = $category_arr['catiall'];
|
|
|
+ $categoryIds = $category_arr['categoryIds'];
|
|
|
+ // return Result::success($category_arr);
|
|
|
foreach($categorys as $key => $value){
|
|
|
if(array_key_exists('level',$value)){
|
|
|
$parts = explode(',', $value['level']);
|
|
|
@@ -2923,7 +2924,7 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
|
|
|
$textnum = $parts[2] ?? null;
|
|
|
if(!empty($textnum) && $textnum > 0){
|
|
|
$text_num = Company::where('level', $level)
|
|
|
- ->where('website_id',$data['website_id'])
|
|
|
+ ->whereIn('category_id', $categoryIds)
|
|
|
->where('status',1)
|
|
|
->select('company.id','company.title','company.description','company.updated_at',
|
|
|
'company.category_id','company.cat_arr_id')
|
|
|
@@ -2933,7 +2934,7 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
|
|
|
}
|
|
|
if(!empty($imgnum) && $imgnum > 0){
|
|
|
$img_num = Company::where('level', $level)
|
|
|
- ->where('website_id',$data['website_id'])
|
|
|
+ ->whereIn('category_id', $categoryIds)
|
|
|
->where('status',1)
|
|
|
->where('imgurl','!=', '')
|
|
|
->whereNotNull('imgurl')
|
|
|
@@ -2953,7 +2954,7 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
|
|
|
$category_arr = array_merge([$category_id], $cat_1st_arr[$category_id] ?? [0]);
|
|
|
if(!empty($textnum) && $textnum > 0){
|
|
|
$text_num = Company::whereIn('category_id', $category_arr)
|
|
|
- ->where('website_id',$data['website_id'])
|
|
|
+ // ->where('website_id',$data['website_id'])
|
|
|
->where('status',1)
|
|
|
->select('company.id','company.title','company.description','company.updated_at',
|
|
|
'company.category_id','company.cat_arr_id')
|
|
|
@@ -2964,7 +2965,7 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
|
|
|
if(!empty($imgnum) && $imgnum > 0){
|
|
|
|
|
|
$img_num = Company::whereIn('category_id', $category_arr)
|
|
|
- ->where('website_id',$data['website_id'])
|
|
|
+ // ->where('website_id',$data['website_id'])
|
|
|
->where('status',1)
|
|
|
->where('imgurl','!=', '')
|
|
|
->whereNotNull('imgurl')
|
|
|
@@ -3012,27 +3013,32 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
|
|
|
{
|
|
|
$where['website_id'] = $data['website_id'];
|
|
|
$where['status'] = 1;
|
|
|
+ $categoryIds = [];
|
|
|
if(isset($data['category_id']) && !empty($data['category_id'])){
|
|
|
- $where['category_id'] = $data['category_id'];
|
|
|
- }
|
|
|
- if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
|
- array_push($where, ['title', 'like', '%' . $data['keyword'] . '%']);
|
|
|
+
|
|
|
+ $category_id = $data['category_id'];
|
|
|
}
|
|
|
- $query = Company::where($where);
|
|
|
- $company = $this->processArticle(
|
|
|
- $query->select('id','title','introduce','description','content','category_id','cat_arr_id','updated_at')
|
|
|
- ->orderBy('updated_at', 'desc')
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->limit($data['pageSize'])
|
|
|
- ->get(),
|
|
|
- $data
|
|
|
- );
|
|
|
+ $category_arr = $this->processArticlePro($data['website_id']);
|
|
|
+ $categoryIds = $category_arr['categoryIds'];
|
|
|
+ // return Result::success($cat_1st_arr);
|
|
|
+ $company = Company::when(isset($data['keyword']) && !empty($data['keyword']), function($query) use ($data){
|
|
|
+ $query->where('title', 'like', '%' . $data['keyword'] . '%');
|
|
|
+ })
|
|
|
+ ->when(!isset($category_id) || empty($category_id), function($query) use ($categoryIds){
|
|
|
+ $query->whereIn('category_id', $categoryIds);
|
|
|
+ })
|
|
|
+ ->when(isset($data['category_id']) && !empty($data['category_id']), function($query) use ($category_id){
|
|
|
+ $query->where('category_id', $category_id);
|
|
|
+ })
|
|
|
+ ->select('id','title','introduce','description','content','category_id','cat_arr_id','updated_at')
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->paginate($data['pageSize'], ['*'], 'page', $data['page']);
|
|
|
if(empty($company)){
|
|
|
return Result::error("暂无相关公司信息", 0);
|
|
|
}
|
|
|
$result = [
|
|
|
- 'count' => $query->clone()->count(),
|
|
|
- 'data' => $company,
|
|
|
+ 'count' => $company->total(),
|
|
|
+ 'data' => $company->items(), // 使用 items() 方法替代不存在的 data() 方法
|
|
|
];
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
@@ -3045,7 +3051,7 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
|
|
|
$company = Company::where('id', $data['id'])
|
|
|
->leftJoin('job_industry','job_industry.hyid','company.hy_id')
|
|
|
->where('status', 1)
|
|
|
- ->where('website_id', $data['website_id'])
|
|
|
+ // ->where('website_id', $data['website_id'])
|
|
|
->select('company.*','job_industry.hyname as hy_name')
|
|
|
->first();
|
|
|
// 企业性质:0:市场监管;1:信访纪检;2:公检法司;3:高关注机构
|