Browse Source

完成b端企业管理:获取企业列表;添加企业;编辑企业;删除企业;的获取企业详情的接口搬到news服务上

15313670163 1 day ago
parent
commit
d710de740a
3 changed files with 2 additions and 227 deletions
  1. 1 193
      app/JsonRpc/PublicRpcService.php
  2. 1 7
      app/JsonRpc/PublicRpcServiceInterface.php
  3. 0 27
      app/Model/Company.php

+ 1 - 193
app/JsonRpc/PublicRpcService.php

@@ -31,8 +31,6 @@ use function Hyperf\Support\retry;
 use App\Model\Company;
 use Hyperf\Paginator\Paginator;
 use App\Model\User;
-// use Fukuball\Jieba\Jieba;
-// use Fukuball\Jieba\Finalseg;
 #[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class PublicRpcService implements PublicRpcServiceInterface
 {
@@ -1275,195 +1273,5 @@ class PublicRpcService implements PublicRpcServiceInterface
             return Result::success($template);
         }
     }
-    /**
-     * 企业管理
-     * @param array $data
-     * @return array
-     */
-    public function getCompanyList(array $data): array
-    {
-        $where = [];
-        $user = User::where('id', $data['user_id'])->first();
-        if(empty($user)){
-            return Result::error('用户不存在!');
-        }
-        if($user['type_id']!= 10000){
-            $where['user_id'] = $data['user_id'];
-        }
-        if(isset($data['title']) && $data['title']){
-            array_push($where, ['title', 'like', '%'. $data['title']. '%']);
-        }
-        if(isset($data['website_id']) && $data['website_id']){
-            $where['website_id'] = $data['website_id'];
-        }
-        // 状态:0:未审核 1:已审核 2:已拒绝
-        $pageSize = isset($data['pageSize']) ? (int)$data['pageSize'] : 10; // 默认每页 10 条记录
-        $page = isset($data['page']) ? (int)$data['page'] : 1; // 默认第 1 页
-        if(isset($data['ischeck']) && !empty($data['ischeck'])){
-            if($data['ischeck'] == 1){
-                $query =  Company::whereIn('status', [0,2]);
-            }else{
-                $query =  Company::where('status', 1);
-            }
-        }
-        $result = $query->where($where)
-        ->leftJoin('website_category', 'company.category_id', '=', 'website_category.category_id')
-        ->leftJoin('website', 'company.website_id', '=', 'website.id')
-        ->leftJoin('district', 'district.city_id', '=', 'district.id')
-        ->select('company.*', 'website.website_name', 'website_category.alias as category_name','district.name as city_name')
-        ->paginate($pageSize, ['*'], 'page', $page);
-        if(empty($result)){
-            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']) : '';
-        $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;
-        }
-        $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']) : '';
-        $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('企业不存在!');
-        }
-        // 状态: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);
-        }
-    }
+    
 }

+ 1 - 7
app/JsonRpc/PublicRpcServiceInterface.php

@@ -182,11 +182,5 @@ interface PublicRpcServiceInterface
     public function chooseWebsiteTemplate(array $data): array;
     public function saveWebsiteTemplate(array $data): array;
     
-    // --------------企业管理-----------
-    public function getCompanyList(array $data): array;
-    public function addCompany(array $data): array;
-    public function upCompany(array $data): array;
-    public function delCompany(array $data): array;
-    public function checkCompany(array $data): array;
-    public function getCompanyInfo(array $data): array;
+
 }

+ 0 - 27
app/Model/Company.php

@@ -1,27 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace App\Model;
-
-use Hyperf\DbConnection\Model\Model;
-
-/**
- */
-class Company extends Model
-{
-    /**
-     * The table associated with the model.
-     */
-    protected ?string $table = 'company';
-
-    /**
-     * The attributes that are mass assignable.
-     */
-    protected array $guarded = [];
-
-    /**
-     * The attributes that should be cast to native types.
-     */
-    protected array $casts = [];
-}