|
@@ -5899,170 +5899,176 @@ class NewsService implements NewsServiceInterface
|
|
|
->orderBy('company.updated_at', 'desc')
|
|
|
->paginate($data['pageSize'], ['*'], 'page', $data['page']);
|
|
|
|
|
|
- if ($result->isEmpty()) {
|
|
|
- return Result::error("暂无企业", 0);
|
|
|
- }
|
|
|
- return Result::success($result);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 添加企业
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function addCompany(array $data): array
|
|
|
- {
|
|
|
- $data['category_id'] = isset($data['cat_arr_id']) ? end($data['cat_arr_id']) : '';
|
|
|
- if (isset($data['cat_arr_id']) && !empty($data['cat_arr_id']) && is_array($data['cat_arr_id'])) {
|
|
|
- $car_arr_id = array_values(array_unique(array_map('intval', $data['cat_arr_id'])));
|
|
|
- $data['cat_arr_id'] = json_encode($car_arr_id);
|
|
|
- } else {
|
|
|
- $data['cat_arr_id'] = '';
|
|
|
- }
|
|
|
- if ($data['imgurl'] == '') {
|
|
|
- //content中提取图片第一个图,正则提取
|
|
|
- $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
|
|
|
- preg_match_all($reg, $data['content'], $matches);
|
|
|
- if (isset($matches[1][0])) {
|
|
|
- //截取varchar240
|
|
|
- $data['imgurl'] = substr($matches[1][0], 0, 240);
|
|
|
+ if($result->isEmpty()){
|
|
|
+ return Result::error("暂无企业", 0);
|
|
|
}
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
- 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['introduce'] == '') {
|
|
|
- //提取内容中的描述
|
|
|
- $data['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
|
|
|
- }
|
|
|
- $user = User::where('id', $data['user_id'])->first();
|
|
|
- if (empty($user)) {
|
|
|
- return Result::error('用户不存在!');
|
|
|
- }
|
|
|
- if ($user['type_id'] == 10000) {
|
|
|
- $data['status'] = 1;
|
|
|
- }
|
|
|
- $result = Company::insertGetId($data);
|
|
|
- if ($result) {
|
|
|
- return Result::success($result);
|
|
|
- } else {
|
|
|
- return Result::error('添加失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 更新企业
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function upCompany(array $data): array
|
|
|
- {
|
|
|
- $data['category_id'] = isset($data['cat_arr_id']) ? end($data['cat_arr_id']) : '';
|
|
|
- if (isset($data['cat_arr_id']) && !empty($data['cat_arr_id']) && is_array($data['cat_arr_id'])) {
|
|
|
- $car_arr_id = array_values(array_unique(array_map('intval', $data['cat_arr_id'])));
|
|
|
- $data['cat_arr_id'] = json_encode($car_arr_id);
|
|
|
- } else {
|
|
|
- $data['cat_arr_id'] = '';
|
|
|
+ /**
|
|
|
+ * 添加企业
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function addCompany(array $data): array
|
|
|
+ {
|
|
|
+ $data['category_id'] = isset($data['cat_arr_id']) ? end($data['cat_arr_id']) : '';
|
|
|
+ if(isset($data['cat_arr_id']) &&!empty($data['cat_arr_id']) && is_array($data['cat_arr_id'])){
|
|
|
+ $car_arr_id = array_values(array_unique(array_map('intval', $data['cat_arr_id'])));
|
|
|
+ $data['cat_arr_id'] = json_encode($car_arr_id);
|
|
|
+ }else{
|
|
|
+ $data['cat_arr_id'] = '';
|
|
|
+ }
|
|
|
+ if ($data['imgurl'] == '') {
|
|
|
+ //content中提取图片第一个图,正则提取
|
|
|
+ $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
|
|
|
+ preg_match_all($reg, $data['content'], $matches);
|
|
|
+ if (isset($matches[1][0])) {
|
|
|
+ //截取varchar240
|
|
|
+ $data['imgurl'] = substr($matches[1][0], 0, 240);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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['introduce'] == '' || empty($data['introduce'])) {
|
|
|
+ //提取内容中的描述
|
|
|
+ $data['introduce'] = mb_substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100) ?? '';
|
|
|
+ }
|
|
|
+ $user = User::where('id', $data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error('用户不存在!');
|
|
|
+ }
|
|
|
+ if($user['type_id']== 10000){
|
|
|
+ $data['status'] = 1;
|
|
|
+ }
|
|
|
+ $result = Company::insertGetId($data);
|
|
|
+ if ($result) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error('添加失败');
|
|
|
+ }
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 更新企业
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function upCompany(array $data): array
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ if(isset($data['cat_arr_id']) &&!empty($data['cat_arr_id']) && is_array($data['cat_arr_id'])){
|
|
|
+ $car_arr_id = array_values(array_unique(array_map('intval', $data['cat_arr_id'])));
|
|
|
+ $data['cat_arr_id'] = json_encode($car_arr_id);
|
|
|
+ $data['category_id'] = isset($data['cat_arr_id']) ? end($car_arr_id) : '';
|
|
|
+ }else{
|
|
|
+ $data['cat_arr_id'] = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ // $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
|
|
|
+ if ($data['imgurl'] == '') {
|
|
|
+ //content中提取图片第一个图,正则提取
|
|
|
+ $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
|
|
|
+ preg_match_all($reg, $data['content'], $matches);
|
|
|
+ if (isset($matches[1][0])) {
|
|
|
+ //截取varchar240
|
|
|
+ $data['imgurl'] = substr($matches[1][0], 0, 240);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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['introduce'] == '') {
|
|
|
+ //提取内容中的描述
|
|
|
+ // var_dump(11111);
|
|
|
+ $data['introduce'] = mb_substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
|
|
|
+ // var_dump($data['introduce']);
|
|
|
+ }
|
|
|
+ // return Result::success($data);
|
|
|
|
|
|
- // $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
|
|
|
- if ($data['imgurl'] == '') {
|
|
|
- //content中提取图片第一个图,正则提取
|
|
|
- $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
|
|
|
- preg_match_all($reg, $data['content'], $matches);
|
|
|
- if (isset($matches[1][0])) {
|
|
|
- //截取varchar240
|
|
|
- $data['imgurl'] = substr($matches[1][0], 0, 240);
|
|
|
- }
|
|
|
- }
|
|
|
- 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['introduce'] == '') {
|
|
|
- //提取内容中的描述
|
|
|
- $data['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
|
|
|
- }
|
|
|
- $user = User::where('id', $data['user_id'])->first();
|
|
|
- if (empty($user)) {
|
|
|
- return Result::error('用户不存在!');
|
|
|
- }
|
|
|
- if ($user['type_id'] == 10000) {
|
|
|
- $data['status'] = 1;
|
|
|
- } else {
|
|
|
- $data['status'] = 0;
|
|
|
- }
|
|
|
- $result = Company::where('id', $data['id'])->update($data);
|
|
|
- if ($result) {
|
|
|
- return Result::success($result);
|
|
|
- } else {
|
|
|
- return Result::error('修改失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 删除企业
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function delCompany(array $data): array
|
|
|
- {
|
|
|
- $result = Company::where('id', $data['id'])->delete();
|
|
|
- if ($result) {
|
|
|
- return Result::success($result);
|
|
|
- } else {
|
|
|
- return Result::error('删除失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 审核企业
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function checkCompany(array $data): array
|
|
|
- {
|
|
|
- $user = User::where('id', $data['user_id'])->first();
|
|
|
- if (empty($user)) {
|
|
|
- return Result::error('用户不存在!');
|
|
|
- }
|
|
|
- $company = Company::where('id', $data['id'])->first();
|
|
|
- if (empty($company)) {
|
|
|
- return Result::error('企业不存在!');
|
|
|
+ $user = User::where('id', $data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error('用户不存在!');
|
|
|
+ }
|
|
|
+ if($user['type_id']== 10000){
|
|
|
+ $data['status'] = 1;
|
|
|
+ }else{
|
|
|
+ $data['status'] = 0;
|
|
|
+ }
|
|
|
+ $result = Company::where('id', $data['id'])->update($data);
|
|
|
+ if ($result) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error('修改失败');
|
|
|
+ }
|
|
|
}
|
|
|
- // 状态:0:未审核 1:已审核 2:已拒绝
|
|
|
- if ($company['status'] == 0 || $company['status'] == 1) {
|
|
|
- $result = Company::where('id', $data['id'])->update(['status' => $data['status']]);
|
|
|
- } else {
|
|
|
- $result = Company::where('id', $data['id'])->update(['status' => $data['status'], 'reject_reason' => $data['reject_reason']]);
|
|
|
+ /**
|
|
|
+ * 删除企业
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function delCompany(array $data): array
|
|
|
+ {
|
|
|
+ $result = Company::where('id', $data['id'])->delete();
|
|
|
+ if ($result) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error('删除失败');
|
|
|
+ }
|
|
|
}
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error('审核失败!');
|
|
|
- } else {
|
|
|
- return Result::success($result);
|
|
|
+ /**
|
|
|
+ * 审核企业
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function checkCompany(array $data): array
|
|
|
+ {
|
|
|
+ $user = User::where('id', $data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error('用户不存在!');
|
|
|
+ }
|
|
|
+ $company = Company::where('id', $data['id'])->first();
|
|
|
+ if(empty($company)){
|
|
|
+ return Result::error('企业不存在!');
|
|
|
+ }
|
|
|
+ // 状态:0:未审核 1:已审核 2:已拒绝
|
|
|
+ if($company['status'] == 0 || $company['status'] == 1){
|
|
|
+ $result = Company::where('id', $data['id'])->update(['status' => $data['status']]);
|
|
|
+ }else{
|
|
|
+ $result = Company::where('id', $data['id'])->update(['status' => $data['status'],'reject_reason'=> $data['reject_reason']]);
|
|
|
+ }
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error('审核失败!');
|
|
|
+ }else{
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取企业信息
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getCompanyInfo(array $data): array
|
|
|
- {
|
|
|
- $result = Company::where('id', $data['id'])->first();
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error('企业不存在!');
|
|
|
- } else {
|
|
|
- return Result::success($result);
|
|
|
+ /**
|
|
|
+ * 获取企业信息
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getCompanyInfo(array $data): array
|
|
|
+ {
|
|
|
+ $result = Company::where('id', $data['id'])->first();
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error('企业不存在!');
|
|
|
+ }else{
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
}
|