|
@@ -64,6 +64,7 @@ use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
use App\Model\Company;
|
|
|
use Hyperf\Paginator\Paginator;
|
|
|
+use App\Model\Project;
|
|
|
|
|
|
#[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class NewsService implements NewsServiceInterface
|
|
@@ -286,13 +287,14 @@ class NewsService implements NewsServiceInterface
|
|
|
$result = Category::where($data)->delete();
|
|
|
WebsiteCategory::where(['category_id' => $data['id']])->delete();
|
|
|
if (!$result) {
|
|
|
- return Result::error("删除失败");
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error("删除失败");
|
|
|
}
|
|
|
- return Result::success($result);
|
|
|
Db::commit();
|
|
|
+ return Result::success($result);
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
- return Result::error("删除失败");
|
|
|
+ return Result::error("删除失败".$e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -5977,8 +5979,48 @@ class NewsService implements NewsServiceInterface
|
|
|
} else {
|
|
|
$query = Company::whereIn('company.status', [0, 2]);
|
|
|
}
|
|
|
- } else {
|
|
|
- $query = Company::where('company.status', 1);
|
|
|
+ if($user['type_id']!= 10000){
|
|
|
+ $where['user_id'] = $data['user_id'];
|
|
|
+ }
|
|
|
+ if(isset($data['title']) && !empty($data['title'])){
|
|
|
+ array_push($where, ['company.title', 'like', '%'. $data['title']. '%']);
|
|
|
+ }
|
|
|
+ if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
+ array_push($where, ['website.id', $data['website_id']]);
|
|
|
+ }
|
|
|
+ if(isset($data['ischeck']) && !empty($data['ischeck'])){
|
|
|
+ if($data['ischeck'] == 1){
|
|
|
+ if(isset($data['status']) && $data['status'] != ''){
|
|
|
+ array_push($where, ['company.status', $data['status']]);
|
|
|
+ $query = Company::where($where);
|
|
|
+ }else{
|
|
|
+ $query = Company::whereIn('company.status', [0,2]);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $query = Company::where('company.status', 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $result = $query->where($where)
|
|
|
+ ->leftJoin('website_category', function ($query) {
|
|
|
+ $query->on('website_category.category_id', '=', 'company.category_id')
|
|
|
+ ->on('website_category.website_id', '=', 'company.website_id');
|
|
|
+ })
|
|
|
+ ->leftJoin('website', 'company.website_id', '=', 'website.id')
|
|
|
+ ->select(
|
|
|
+ 'company.id',
|
|
|
+ 'company.title',
|
|
|
+ 'company.website_id',
|
|
|
+ 'company.category_id',
|
|
|
+ 'website.website_name',
|
|
|
+ 'website_category.alias as category_name',
|
|
|
+ 'company.status',
|
|
|
+ 'company.updated_at',
|
|
|
+ )
|
|
|
+ ->orderBy('company.updated_at', 'desc')
|
|
|
+ ->paginate($data['pageSize'], ['*'], 'page', $data['page']);
|
|
|
+
|
|
|
+ if($result->isEmpty()){
|
|
|
+ return Result::error("暂无企业", 0);
|
|
|
}
|
|
|
}
|
|
|
$result = $query->where($where)
|
|
@@ -6228,8 +6270,7 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
if (isset($data['keyword']) && !empty($data['keyword'])) {
|
|
|
array_push($where, ['title', 'like', '%' . $data['keyword'] . '%']);
|
|
|
- }
|
|
|
- $query = Company::where($where);
|
|
|
+ } $query = Company::where($where);
|
|
|
$company = $this->processArticle(
|
|
|
$query->select('id', 'title', 'introduce', 'description', 'content', 'category_id', 'cat_arr_id')
|
|
|
->orderBy('updated_at', 'desc')
|
|
@@ -6247,20 +6288,204 @@ class NewsService implements NewsServiceInterface
|
|
|
];
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
- /**
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getWebsiteCompanyInfo(array $data): array
|
|
|
- {
|
|
|
- $company = Company::where('id', $data['id'])
|
|
|
- ->where('status', 1)
|
|
|
- ->where('website_id', $data['website_id'])
|
|
|
- ->select('company.*')
|
|
|
- ->first();
|
|
|
- if (empty($company)) {
|
|
|
- return Result::error("暂无相关公司信息", 0);
|
|
|
+ /**
|
|
|
+ * 获取项目列表
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getProjectList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ $user = User::where('id',$data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error('用户不存在!');
|
|
|
+ }
|
|
|
+ if($user->type_id != 10000){
|
|
|
+ array_push($where, ['project.user_id', $data['user_id']]);
|
|
|
+ }
|
|
|
+ $query = Project::query();
|
|
|
+ if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
+ array_push($where, ['project.website_id', $data['website_id']]);
|
|
|
+ }
|
|
|
+ if(isset($data['title']) && !empty($data['title'])){
|
|
|
+ array_push($where, ['project.title', 'like', '%' . $data['title'] . '%']);
|
|
|
+ }
|
|
|
+ if($data['status'] != 3){
|
|
|
+ array_push($where, ['project.status', $data['status']]);
|
|
|
+ }
|
|
|
+ $query = Project::where($where)
|
|
|
+ ->when($data['status'] == 3, function($query){
|
|
|
+ $query->whereIn('project.status', [0, 2]);
|
|
|
+ });
|
|
|
+ $count = $query->clone()
|
|
|
+ ->count();
|
|
|
+ $rows = $query->clone()
|
|
|
+ ->leftJoin('website', 'project.website_id','website.id' )
|
|
|
+ ->leftJoin('website_category', function ($join) {
|
|
|
+ $join->on('project.website_id', '=', 'website_category.website_id')
|
|
|
+ ->on('project.category_id', '=', 'website_category.category_id');
|
|
|
+ })
|
|
|
+ ->select('project.id','project.title','project.updated_at','project.status','website.website_name',
|
|
|
+ 'website_category.alias as category_name')
|
|
|
+ ->orderBy('project.updated_at', 'desc')
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->get();
|
|
|
+ if($rows->isEmpty()){
|
|
|
+ return Result::error("暂无相关项目信息", 0);
|
|
|
+ }
|
|
|
+ $result = [
|
|
|
+ 'count' => $count,
|
|
|
+ 'rows' => $rows,
|
|
|
+ ];
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 添加项目
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function addProject(array $data): array
|
|
|
+ {
|
|
|
+ $user = User::where('id',$data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error("暂无相关用户信息", 0);
|
|
|
+ }
|
|
|
+ if($user->type_id == 10000){
|
|
|
+ $data['status'] = 1;
|
|
|
+ }else{
|
|
|
+ $data['status'] = 0;
|
|
|
+ }
|
|
|
+ if ($data['keyword'] == '') {
|
|
|
+ //提取标题+内容中的关键词
|
|
|
+ $data['keyword'] = $data['title'];
|
|
|
+ // . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
|
|
|
+ Jieba::init(); // 初始化 jieba-php
|
|
|
+ Finalseg::init();
|
|
|
+ $segList = Jieba::cut($data['keyword']);
|
|
|
+ $segList1 = array_slice($segList, 0, 8);
|
|
|
+ $data['keyword'] = implode(',', $segList1);
|
|
|
+ }
|
|
|
+ if ($data['description'] == '') {
|
|
|
+ //提取内容中的描述
|
|
|
+ // var_dump(11111);
|
|
|
+ $data['description'] = mb_substr(str_replace(' ', '', strip_tags($data['introduce'])), 0, 100);
|
|
|
+ }
|
|
|
+ $project = Project::insertGetId($data);
|
|
|
+ if(empty($project)){
|
|
|
+ return Result::error("暂无相关项目信息", 0);
|
|
|
+ }
|
|
|
+ return Result::success($project);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 更新项目
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function upProject(array $data): array
|
|
|
+ {
|
|
|
+ $project = Project::where('id', $data['id'])->first();
|
|
|
+ if(empty($project)){
|
|
|
+ return Result::error("暂无相关项目信息", 0);
|
|
|
+ }
|
|
|
+ $id = $data['id'];
|
|
|
+ unset($data['id']);
|
|
|
+ $user = User::where('id',$data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error("暂无相关用户信息", 0);
|
|
|
+ }
|
|
|
+ if($user->type_id == 10000){
|
|
|
+ $data['status'] = 1;
|
|
|
+ }else{
|
|
|
+ $data['status'] = 0;
|
|
|
+ }
|
|
|
+ unset($data['user_id']);
|
|
|
+ if ($data['keyword'] == '') {
|
|
|
+ //提取标题+内容中的关键词
|
|
|
+ $data['keyword'] = $data['title'];
|
|
|
+ // . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
|
|
|
+ Jieba::init(); // 初始化 jieba-php
|
|
|
+ Finalseg::init();
|
|
|
+ $segList = Jieba::cut($data['keyword']);
|
|
|
+ $segList1 = array_slice($segList, 0, 8);
|
|
|
+ $data['keyword'] = implode(',', $segList1);
|
|
|
+ }
|
|
|
+ if ($data['description'] == '') {
|
|
|
+ //提取内容中的描述
|
|
|
+ // var_dump(11111);
|
|
|
+ $data['description'] = mb_substr(str_replace(' ', '', strip_tags($data['introduce'])), 0, 100);
|
|
|
+ }
|
|
|
+ $result = Project::where('id', $id)->update($data);
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("更新失败", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 删除项目
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+
|
|
|
+ public function delProject(array $data): array
|
|
|
+ {
|
|
|
+ $user = User::where('id',$data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error("暂无相关用户信息", 0);
|
|
|
+ }
|
|
|
+ $project = Project::where('id', $data['id'])->first();
|
|
|
+ if(empty($project)){
|
|
|
+ return Result::error("暂无相关项目信息", 0);
|
|
|
+ }
|
|
|
+ $result = Project::where('id',$data['id'])->delete();
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("删除失败", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 审核项目
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function checkProject(array $data): array
|
|
|
+ {
|
|
|
+ $user = User::where('id',$data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error("暂无相关用户信息", 0);
|
|
|
+ }
|
|
|
+ // 0:未审核; 1:已审核; 2:已拒绝;
|
|
|
+ if($user->type_id != 10000){
|
|
|
+ if($data['status'] == 1 || $data['status'] == 2){
|
|
|
+ return Result::error("此用户权限不足", 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $project = Project::where('id', $data['id'])->first();
|
|
|
+ if(empty($project)){
|
|
|
+ return Result::error("暂无相关项目信息", 0);
|
|
|
+ }
|
|
|
+ if($data['status'] == 2){
|
|
|
+ $result = Project::where('id', $data['id'])->update(['status' => $data['status'],'refuse_reason' => $data['refuse_reason']]);
|
|
|
+ }else{
|
|
|
+ $result = Project::where('id',$data['id'])->update(['status' => $data['status']]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("审核失败", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取项目详情
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getProjectInfo(array $data): array
|
|
|
+ {
|
|
|
+ $project = Project::where('id', $data['id'])->first();
|
|
|
+ if(empty($project)){
|
|
|
+ return Result::error("暂无相关项目信息", 0);
|
|
|
+ }
|
|
|
+ return Result::success($project);
|
|
|
}
|
|
|
- return Result::success($company);
|
|
|
- }
|
|
|
}
|