linwu 3 ani în urmă
părinte
comite
ceb7f537fb

+ 202 - 0
app/Admin/Controllers/System/ShortUrlController.php

@@ -0,0 +1,202 @@
+<?php
+
+namespace App\Admin\Controllers\System;
+
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Http\Controllers\Controller;
+use App\Models\ShortUrl;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Illuminate\Validation\Rule;
+
+class ShortUrlController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('短链接列表')
+            ->description('')
+            ->body($this->grid());
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('短链接列表')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('短链接列表')
+            ->description('创建')
+            ->body($this->createForm());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new ShortUrl);
+
+        $grid->id('ID');
+        $grid->name('名称')->width(400);
+        $grid->key('短链接')->width(200);
+        $grid->column('短链接带域名')->display(function(){
+            return route('short_url',['url'=>$this->key]);
+        })->width(200);
+        $grid->url('原链接')->width(400);
+        $grid->actions(function ($actions) use ($grid) {
+            $actions->disableEdit(false);
+            $actions->disableDelete(false);
+        });
+        $grid->disableCreateButton(false);
+
+        $grid->filter(function ($filter) {
+            $filter->where(function ($query) {
+                $query->where('name', 'like', "%{$this->input}%");
+            }, '名称');
+            $filter->where(function ($query) {
+                $query->where('key', 'like', "%{$this->input}%")->orWhere('url', 'like', "%{$this->input}%");
+            }, '链接');
+        });
+
+        return $grid;
+    }
+
+    protected function form()
+    {
+        $grid = new ValidateForm(new ShortUrl);
+
+        return $grid;
+    }
+
+    protected function editForm($id)
+    {
+        $form = new Form(new ShortUrl);
+        $form->text('name', '名称')->rules([
+            'required',
+        ])->setWidth(3)->setMustMark();
+        $form->text('key', '短链接')->rules([
+            'required',
+            Rule::unique('short_url')->ignore($id),
+        ])->setWidth(3)->setMustMark();
+        $form->text('url', '原始链接')->rules([
+            'required',
+        ])->setWidth(8)->setMustMark();
+
+        return $form;
+    }
+
+    protected function createForm()
+    {
+        $form = new Form(new ShortUrl);
+        $form->text('name', '名称')->rules([
+            'required',
+        ])->setWidth(3)->setMustMark();
+        $form->text('key', '短链接')->rules([
+            'required',
+            'unique:short_url',
+        ])->setWidth(3)->setMustMark()->value($this->_getShortUrl());
+        $form->text('url', '原始链接')->rules([
+            'required',
+        ])->setWidth(8)->setMustMark();
+
+        return $form;
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @return mixed
+     */
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param int $id
+     *
+     * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
+     */
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+
+    public function destroy($id)
+    {
+        if ($this->form()->destroy($id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+
+    /**
+     * 生成短链接
+     */
+    private function _getShortUrl()
+    {
+        return $this->_base62();
+    }
+    private function _base62()
+    {
+        $base32 = [
+            "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
+            "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+            "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
+            "u", "v", "w", "x", "y", "z",
+            "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
+            "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
+            "U", "V", "W", "X", "Y", "Z",
+        ];
+
+        $output = '';
+        $len    = count($base32);
+        for ($i = 0; $i < 6; $i++) {
+            $num    = mt_rand(0, $len - 1);
+            $output .= $base32[$num];
+        }
+
+        return $output;
+    }
+}

+ 1 - 0
app/Admin/routes.php

@@ -398,6 +398,7 @@ Route::group([
         $router->get('sms/test', 'SmsController@test');
         $router->post('sms/test', 'SmsController@testPost');
         $router->resource('user/log', UserLogController::class);
+        $router->resource('short_url/index', ShortUrlController::class)->names('admin.sys.short_url');
     });
 
     //工具管理

+ 133 - 118
app/Http/Controllers/Web/HomeController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Web;
 use App\Models\Recruit;
 use App\Models\Recuperate;
 use App\Models\RecuperateCategory;
+use App\Models\ShortUrl;
 use App\Services\Content\LinkService;
 use App\Services\HomeService;
 use App\Services\Company\JobsService;
@@ -77,32 +78,32 @@ class HomeController extends WebBaseController
      * @param $articleService
      * @param $subsiteService
      */
-    public function __construct(LinkService $LinkService, HomeService $homeService, JobsService $jobsService, CategoryService $categoryService, CompanyDownResumeService $companyDownResumeService, SearchService $searchService, ResumeService $resumeService, CompanyService $companyService, JobfairService $jobfairService, NoticeServer $noticeServer, ArticleService $articleService, SubsiteService $subsiteService, PersonalJobsApplyRepository $personalJobsApplyRepository, ViewJobRepository $viewJobRepository, PmsRepository $pmsRepository, ResumeRepository $resumeRepository, CompanyInterviewRepository $companyInterviewRepository, companyFavoriteRepository $companyFavoriteRepository, ViewResumeRepository $viewResumeRepository, TaskLogRepository $taskLogRepository, PersonFocusComRepository $personFocusComRepository, MemberSetmealRepository $memberSetmealRepository, JobsRepository $jobsRepository,PolicyService $policyService)
+    public function __construct(LinkService $LinkService, HomeService $homeService, JobsService $jobsService, CategoryService $categoryService, CompanyDownResumeService $companyDownResumeService, SearchService $searchService, ResumeService $resumeService, CompanyService $companyService, JobfairService $jobfairService, NoticeServer $noticeServer, ArticleService $articleService, SubsiteService $subsiteService, PersonalJobsApplyRepository $personalJobsApplyRepository, ViewJobRepository $viewJobRepository, PmsRepository $pmsRepository, ResumeRepository $resumeRepository, CompanyInterviewRepository $companyInterviewRepository, companyFavoriteRepository $companyFavoriteRepository, ViewResumeRepository $viewResumeRepository, TaskLogRepository $taskLogRepository, PersonFocusComRepository $personFocusComRepository, MemberSetmealRepository $memberSetmealRepository, JobsRepository $jobsRepository, PolicyService $policyService)
     {
-        $this->LinkService = $LinkService;
-        $this->homeService = $homeService;
-        $this->jobsService = $jobsService;
-        $this->categoryService = $categoryService;
-        $this->companyDownResumeService = $companyDownResumeService;
-        $this->searchService = $searchService;
-        $this->resumeService = $resumeService;
-        $this->companyService = $companyService;
-        $this->jobfairService = $jobfairService;
-        $this->noticeServer = $noticeServer;
-        $this->articleService = $articleService;
-        $this->subsiteService = $subsiteService;
+        $this->LinkService                 = $LinkService;
+        $this->homeService                 = $homeService;
+        $this->jobsService                 = $jobsService;
+        $this->categoryService             = $categoryService;
+        $this->companyDownResumeService    = $companyDownResumeService;
+        $this->searchService               = $searchService;
+        $this->resumeService               = $resumeService;
+        $this->companyService              = $companyService;
+        $this->jobfairService              = $jobfairService;
+        $this->noticeServer                = $noticeServer;
+        $this->articleService              = $articleService;
+        $this->subsiteService              = $subsiteService;
         $this->personalJobsApplyRepository = $personalJobsApplyRepository;
-        $this->viewJobRepository = $viewJobRepository;
-        $this->pmsRepository = $pmsRepository;
-        $this->resumeRepository = $resumeRepository;
-        $this->companyInterviewRepository = $companyInterviewRepository;
-        $this->companyFavoriteRepository = $companyFavoriteRepository;
-        $this->viewResumeRepository = $viewResumeRepository;
-        $this->taskLogRepository = $taskLogRepository;
-        $this->personFocusComRepository = $personFocusComRepository;
-        $this->memberSetmealRepository = $memberSetmealRepository;
-        $this->jobsRepository = $jobsRepository;
-        $this->policyService   = $policyService;
+        $this->viewJobRepository           = $viewJobRepository;
+        $this->pmsRepository               = $pmsRepository;
+        $this->resumeRepository            = $resumeRepository;
+        $this->companyInterviewRepository  = $companyInterviewRepository;
+        $this->companyFavoriteRepository   = $companyFavoriteRepository;
+        $this->viewResumeRepository        = $viewResumeRepository;
+        $this->taskLogRepository           = $taskLogRepository;
+        $this->personFocusComRepository    = $personFocusComRepository;
+        $this->memberSetmealRepository     = $memberSetmealRepository;
+        $this->jobsRepository              = $jobsRepository;
+        $this->policyService               = $policyService;
     }
 
 
@@ -113,12 +114,12 @@ class HomeController extends WebBaseController
      */
     public function index()
     {
-        $filter_data = array(
-            'AIX_indexfocus' => 6, //首页轮播广告
-            'AIX_indextopimg' => 6, //首页上方横幅
+        $filter_data = [
+            'AIX_indexfocus'   => 6, //首页轮播广告
+            'AIX_indextopimg'  => 6, //首页上方横幅
             'AIX_index_center' => 8, //首页中部横幅
 
-            'index_famous' => 8, //首页中部名企推荐广告 - 六栏格子广告
+            'index_famous'  => 8, //首页中部名企推荐广告 - 六栏格子广告
             'index_famous1' => 8, //首页中部横幅
             'index_famous2' => 8, //首页两栏广告
             'index_famous3' => 8, //首页三栏广告
@@ -126,8 +127,8 @@ class HomeController extends WebBaseController
             'index_famous5' => 8, //首页浮窗广告
             'index_famous6' => 8, //首页浮窗广告
             'index_famous7' => 8, //首页浮窗广告
-        );
-        $ads = $this->homeService->getAds($filter_data);
+        ];
+        $ads         = $this->homeService->getAds($filter_data);
 
 //        $seatmeal_companies = [];
 //        $seatmeal_arr = array(
@@ -145,7 +146,7 @@ class HomeController extends WebBaseController
 
 
         $links_logo = $this->getLinks('AIX_index', '2', '18');
-        $links_url = $this->getLinks('AIX_index', '1', '50');
+        $links_url  = $this->getLinks('AIX_index', '1', '50');
         if ($user = auth('web-member')->user()) {
             $userInfo = $this->homeService->getUserInfo($user);
         } elseif ($user = auth('web-company')->user()) {
@@ -155,21 +156,21 @@ class HomeController extends WebBaseController
         }
         $time = $this->homeService->getTime();
         //公告公示
-        $notice_filter = array(
+        $notice_filter = [
             'titlelen' => 14,
-            'dot' => '...',
-            'size' => 9
-        );
-        $notices = $this->noticeServer->getNotices($notice_filter);
+            'dot'      => '...',
+            'size'     => 9,
+        ];
+        $notices       = $this->noticeServer->getNotices($notice_filter);
 
         //获取工作动态、校园招聘、重要通知的数据
-        $article_map = array(
-            'type_id' => array(48,2, 3, 30, 31, 13, 14, 15, 16, 17, 18, 19, 25, 26, 27, 28, 29),
-            'limit' => 12,
+        $article_map = [
+            'type_id'  => [48, 2, 3, 30, 31, 13, 14, 15, 16, 17, 18, 19, 25, 26, 27, 28, 29],
+            'limit'    => 12,
             'titlelen' => 25,
-            'dot' => '...'
-        );
-        $articles = $this->articleService->getArticleCache($article_map, 'home');
+            'dot'      => '...',
+        ];
+        $articles    = $this->articleService->getArticleCache($article_map, 'home');
 
         $articles_img = $this->articleService->getArticlesByType(3, 5);
 
@@ -217,37 +218,37 @@ class HomeController extends WebBaseController
                 //是否已签到
                 $isSign = $this->taskLogRepository->getTaskLogCount($user->id, 18, $user->utype);
                 //待处理简历
-                $condition1 = [
-                    'is_reply' => 0,
+                $condition1   = [
+                    'is_reply'   => 0,
                     'company_id' => $this->getUser()->id,
                 ];
                 $resumesCount = $this->personalJobsApplyRepository->resumesCount($condition1);
                 //谁看过我
 
                 $map['company_id'] = auth('web-company')->user()->id;
-                $concern = $this->personFocusComRepository->getFansCount($map);
+                $concern           = $this->personFocusComRepository->getFansCount($map);
 
                 //我的消息
                 $where['msgtouid'] = $this->getUser()->id;
-                $where['utype'] = $this->getUser()->utype;
-                $where['new'] = 1;
+                $where['utype']    = $this->getUser()->utype;
+                $where['new']      = 1;
 
                 $pms = $this->pmsRepository->getPmsCount($where);
 
-                $company_setmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, $user->utype);//会员套餐
-                $jobs_meanwhile = $company_setmeal->jobs_meanwhile;
+                $company_setmeal  = $this->memberSetmealRepository->getSetmealByUid($user->id, $user->utype);//会员套餐
+                $jobs_meanwhile   = $company_setmeal->jobs_meanwhile;
                 $jobsCountwhere[] = ['company_id', '=', $user->id];
-                $jobsCount = $this->jobsRepository->getJobCount($jobsCountwhere);
+                $jobsCount        = $this->jobsRepository->getJobCount($jobsCountwhere);
             } else {
                 //是否已签到
                 $isSign = $this->taskLogRepository->getTaskLogCount($user->id, 3, $user->utype);
                 $resume = $this->resumeRepository->getPersonInfo($this->getUser()->id);
                 if ($resume) {
-                    $interview = $this->companyInterviewRepository->getInterview($this->getUser()->id, getJobsStatus());
+                    $interview  = $this->companyInterviewRepository->getInterview($this->getUser()->id, getJobsStatus());
                     $viewResume = $this->companyFavoriteRepository->getAttentionByResume($resume->id);
-                    $resumeid = $resume->id;
+                    $resumeid   = $resume->id;
                 } else {
-                    $interview = 0;
+                    $interview  = 0;
                     $viewResume = 0;
                 }
                 $mypms = $this->pmsRepository->getPmsCount(['msgtype' => 1, 'new' => 1, 'utype' => 2, 'msgtouid' => $this->getUser()->id]);
@@ -255,61 +256,61 @@ class HomeController extends WebBaseController
         }
 
         //人才新闻
-        $ad_pic_where1[] = array('type_id', '=',3);
-        $ad_pic_where1[] = array('small_img', '<>','');
-        $ad_pic1 = Article::where($ad_pic_where1)->orderBy('list_order', 'asc')->orderBy('id', 'desc')->limit(1)->get();
+        $ad_pic_where1[] = ['type_id', '=', 3];
+        $ad_pic_where1[] = ['small_img', '<>', ''];
+        $ad_pic1         = Article::where($ad_pic_where1)->orderBy('list_order', 'asc')->orderBy('id', 'desc')->limit(1)->get();
 
         //人才疗休养活动
-        $ad_pic_where2[] =array('r_c_id', '!=',0);
-        $ad_pic_where2[] =array('deleted_at', '=',null);
-        $ad_pic_where2[] = array('small_img', '<>','');
-        $ad_pic2 = Recuperate::where($ad_pic_where2)->orderBy('list_order', 'asc')->orderBy('id', 'desc')->limit(4)->get();
+        $ad_pic_where2[] = ['r_c_id', '!=', 0];
+        $ad_pic_where2[] = ['deleted_at', '=', null];
+        $ad_pic_where2[] = ['small_img', '<>', ''];
+        $ad_pic2         = Recuperate::where($ad_pic_where2)->orderBy('list_order', 'asc')->orderBy('id', 'desc')->limit(4)->get();
         //人才疗休养分类
-        $Recuperatecategory_arr=RecuperateCategory::where('deleted_at',null)->select('id','name')->get()->toArray();
+        $Recuperatecategory_arr = RecuperateCategory::where('deleted_at', null)->select('id', 'name')->get()->toArray();
 
         //人才新闻
-        $ad_pic_where3[] = array('type_id', '=',51);
-        $ad_pic_where3[] = array('small_img', '<>','');
-        $ad_pic3 = Article::where($ad_pic_where3)->orderBy('list_order', 'asc')->orderBy('id', 'desc')->limit(4)->get();
+        $ad_pic_where3[] = ['type_id', '=', 51];
+        $ad_pic_where3[] = ['small_img', '<>', ''];
+        $ad_pic3         = Article::where($ad_pic_where3)->orderBy('list_order', 'asc')->orderBy('id', 'desc')->limit(4)->get();
 
-        $rcinfos=$this->policyService->getRcInfosByIndex();
+        $rcinfos = $this->policyService->getRcInfosByIndex();
 
         //招考系统
-        $recruit = Recruit::where([['status','=',1]])->orderBy('ordid','desc')->orderBy('updated_at','desc')->limit(4)->get();
+        $recruit = Recruit::where([['status', '=', 1]])->orderBy('ordid', 'desc')->orderBy('updated_at', 'desc')->limit(4)->get();
         if (!$recruit->isEmpty()) {
             foreach ($recruit as $k => $v) {
                 $recruit[$k] = Recruit::parse_index($v);
             }
         }
 
-        $return_data = array(
-            'links_logo' => $links_logo,
-            'links_url' => $links_url,
-            'ads' => $ads,
-            'userInfo' => $userInfo,
-            'time' => $time,
-            'notices' => $notices,
-            'articles' => $articles,
+        $return_data = [
+            'links_logo'              => $links_logo,
+            'links_url'               => $links_url,
+            'ads'                     => $ads,
+            'userInfo'                => $userInfo,
+            'time'                    => $time,
+            'notices'                 => $notices,
+            'articles'                => $articles,
             //'seatmeal_companies' => $seatmeal_companies,
-            'am_pm' => $am_pm,
-            'isSign' => $isSign,
-            'jobs_meanwhile' => $jobs_meanwhile,
-            'jobsCount' => $jobsCount,
-            'resumesCount' => $resumesCount,
-            'concern' => $concern,
-            'pms' => $pms,
-            'resumeid' => $resumeid,
-            'interview' => $interview,
-            'viewResume' => $viewResume,
-            'mypms' => $mypms,
-            'articles_img' => $articles_img,
-            'ad_pic1' => $ad_pic1,
-            'ad_pic2' => $ad_pic2,
-            'ad_pic3' => $ad_pic3,
-            'rcinfos' => $rcinfos,
+            'am_pm'                   => $am_pm,
+            'isSign'                  => $isSign,
+            'jobs_meanwhile'          => $jobs_meanwhile,
+            'jobsCount'               => $jobsCount,
+            'resumesCount'            => $resumesCount,
+            'concern'                 => $concern,
+            'pms'                     => $pms,
+            'resumeid'                => $resumeid,
+            'interview'               => $interview,
+            'viewResume'              => $viewResume,
+            'mypms'                   => $mypms,
+            'articles_img'            => $articles_img,
+            'ad_pic1'                 => $ad_pic1,
+            'ad_pic2'                 => $ad_pic2,
+            'ad_pic3'                 => $ad_pic3,
+            'rcinfos'                 => $rcinfos,
             'recuperate_category_arr' => $Recuperatecategory_arr,
-            'recruit' => $recruit,
-        );
+            'recruit'                 => $recruit,
+        ];
         //获取分站模板信息
         if (get_subsite_id() > 0) {
             $tpl_name = $this->subsiteService->getSubsiteTpl(get_subsite_id());
@@ -336,18 +337,18 @@ class HomeController extends WebBaseController
 
     public function getLinks($alias, $type = '', $limit = 18)
     {
-        $where = array(
+        $where = [
             'alias' => $alias,
-            'type' => $type,
-            'limit' => $limit
-        );
+            'type'  => $type,
+            'limit' => $limit,
+        ];
         $links = $this->LinkService->getLinks($where);
         return $links;
     }
 
     public function getUser()
     {
-        $user = array();
+        $user = [];
         if (auth('web-member')->check()) {
             $user = auth('web-member')->user();
         } elseif (auth('web-company')->check()) {
@@ -364,35 +365,49 @@ class HomeController extends WebBaseController
     }
 
     /*优秀人才申请*/
-    public function  declare(Request $request){
+    public function  declare(Request $request)
+    {
 
-        if($this->getUser()){
-            if(!$user=auth('web-company')->user()){
-                return $this->showMessage('个人未开放申请优秀人才申报系统功能!', route('home'), true,'','1');
+        if ($this->getUser()) {
+            if (!$user = auth('web-company')->user()) {
+                return $this->showMessage('个人未开放申请优秀人才申报系统功能!', route('home'), true, '', '1');
             }
-            $url='http://rc.jucai.gov.cn/api/jucaiInterface/login';
-            $data=array(
-                'username'=>$user->username,
-                'userType'=>1,
-                'timestr'=>time(),
-/*                'name'=>$user->companyname,
-                'idCard'=>$user->organization_code,
-                'type'=>1*/
+            $url  = 'http://rc.jucai.gov.cn/api/jucaiInterface/login';
+            $data = [
+                'username' => $user->username,
+                'userType' => 1,
+                'timestr'  => time(),
+                /*                'name'=>$user->companyname,
+                                'idCard'=>$user->organization_code,
+                                'type'=>1*/
 
-            );
+            ];
 
             ksort($data);
-            $sign_arr=array_merge($data,array( 'key'=>'rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi'));
-            $sign=strtoupper(md5(http_build_query($sign_arr)));
-            $data['sign']=$sign;
-            $data['name']=htmlspecialchars($user->companyname);
-            $data['idCard']=$user->organization_code;
-            $data['type']=1;
-            return redirect()->away('http://rc.jucai.gov.cn/api/jucaiInterface/login?timestr='.time().'&userType=1&username='.$user->username.'&sign='.$sign.'&name='.$user->companyname.'&idCard='.$user->organization_code.'&type=1&id='.$user->id);
-        }else{
+            $sign_arr       = array_merge($data, ['key' => 'rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi']);
+            $sign           = strtoupper(md5(http_build_query($sign_arr)));
+            $data['sign']   = $sign;
+            $data['name']   = htmlspecialchars($user->companyname);
+            $data['idCard'] = $user->organization_code;
+            $data['type']   = 1;
+            return redirect()->away('http://rc.jucai.gov.cn/api/jucaiInterface/login?timestr=' . time() . '&userType=1&username=' . $user->username . '&sign=' . $sign . '&name=' . $user->companyname . '&idCard=' . $user->organization_code . '&type=1&id=' . $user->id);
+        } else {
             return redirect()->away('http://rc.jucai.gov.cn/login');
 
         }
 
     }
+
+    /**
+     * 短链接生成
+     */
+    public function short_url($url)
+    {
+        $short_url = ShortUrl::where('key', $url)->first();
+        if (empty($short_url)) {
+            return redirect(route('home'));
+        } else {
+            return redirect($short_url['url']);
+        }
+    }
 }

+ 12 - 0
app/Models/ShortUrl.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class ShortUrl extends Model
+{
+    public $timestamps = false;
+    protected $table = 'short_url';
+}

+ 2 - 2
libs/repositories/laravel-admin/src/Console/ExtendCommand.php

@@ -114,7 +114,7 @@ class ExtendCommand extends Command
     ├── resources
     │   ├── assets
     │   └── views
-    │       └── index.blade.php
+    │       └── create.blade.php
     ├── routes
     │   └── web.php
     └── src
@@ -139,7 +139,7 @@ TREE;
 
         // copy files
         $this->copy([
-            __DIR__.'/stubs/extension/view.stub'       => 'resources/views/index.blade.php',
+            __DIR__.'/stubs/extension/view.stub'       => 'resources/views/create.blade.php',
             __DIR__.'/stubs/extension/.gitignore.stub' => '.gitignore',
             __DIR__.'/stubs/extension/README.md.stub'  => 'README.md',
             __DIR__.'/stubs/extension/LICENSE.stub'    => 'LICENSE',

+ 190 - 0
resources/views/admin/system/short_url/create.blade.php

@@ -0,0 +1,190 @@
+{!! $grid !!}
+<link rel="stylesheet" href="{{ theme_asset('app/css/viewer.min.css') }}">
+<script type="text/javascript" src="{{ theme_asset('app/js/viewer-jquery.min.js') }}"></script>
+<script>
+    //报名审核必选
+    $("input[name='flow_path[]']").eq(0).attr("disabled", true);
+    $("input[name='flow_path[]']").eq(1).attr("disabled", true);
+
+
+    var admin = null;
+    var paper = null;
+    var post = null;
+    var id = {{$id}}
+
+    $(function () {
+        getAdmin();
+    });
+
+    function getAdmin() {
+        if (id !== 0) {
+            getPost()
+        } else {
+            getView()
+
+        }
+    }
+
+    function getPost() {
+        if (this.post === null) {
+            $.ajax({
+                url: "{{route('recruit.getRecruitPost')}}",
+                data: {id: id,_token:'{{csrf_token()}}'},
+                success: function ($data) {
+                    post = $data.post;
+                    editView()
+                },
+            });
+        }
+    }
+
+    function getView() {
+        var job_base = '<div style=" font-weight:700;padding-left:20px;border-bottom:1px  #DFEDF7 solid;border-top:1px #DFEDF7 solid;background-color:#F0F8FD;height:30px;line-height:30px;margin-bottom:15px;"><span style="color:#f00">*<\/span>招考岗位<\/div>'
+        job_base += '<div style="margin-left:20px;margin-bottom:15px;"><input type="button" id="add_post" onclick="addPost()" class="btn btn-warning"  value="增行"><span>&nbsp;(注:岗位编号为一位或两位数字)<\/span><\/div>';
+        job_base += '<div style="background:#F5F7F8;padding:20px;margin-left:20px; "><table id="post_table"  border="0" cellpadding="15" cellspacing="3"  >' +
+            ' <tr >' +
+            '              <th  style="text-align: center;">岗位编号<\/th>' +
+            '              <th  style="text-align: center;">岗位名称<\/th>' +
+            '              <th  style="text-align: center;">招聘人数<\/th>' +
+            '              <th  style="text-align: center;">岗位限制条件(JSON格式)<\/th>' +
+            '              <th  style="text-align: center;"><\/th>' +
+            '         <\/tr>' +
+            '<tr>' +
+            '              <td  style="padding:8px 15px;"><input type="text"  name="postcode[]" value="" class="form-control postcode"  style="width:100px; " onkeyup="value=value.replace(/[^\\d.]/g,\'\')"  ><\/td>' +
+            '              <td  style="padding:8px 15px;"><input type="text"  name="postname[]" value="" class="form-control postname"   style="width:400px;" maxlength="80" ><\/td>' +
+            '              <td  style="padding:8px 15px;"><input type="text"  name="postnumber[]" value="1" class="form-control postname"   style="width:100px;" maxlength="80" ><\/td>' +
+            '              <td  style="padding:8px 15px;"><input type="text"  name="postlimit[]" value="" class="form-control limit"   style="width:400px;" ><\/td>'
+        ;
+
+        job_base += '                    <\/select>' +
+            '              <\/td>' +
+            '              <td>' +
+            '              <\/td>' +
+            '        <\/tr>' +
+            '    <\/table><\/div>';
+        $("form .box-body .fields-group").append(job_base);
+    }
+
+    function editView() {
+        var job_base = '<div style=" font-weight:700;padding-left:20px;border-bottom:1px  #DFEDF7 solid;border-top:1px #DFEDF7 solid;background-color:#F0F8FD;height:30px;line-height:30px;margin-bottom:15px;"><span style="color:#f00">*<\/span>招考岗位<\/div>'
+        job_base += '<div style="margin-left:20px;margin-bottom:15px;"><input type="button" id="add_post" onclick="addPost()" class="btn btn-warning"  value="增行"><span>&nbsp;(注:岗位编号为一位或两位数字)<\/span><\/div>';
+        job_base += '<div style="background:#F5F7F8;padding:20px;margin-left:20px; "><table id="post_table"  border="0" cellpadding="15" cellspacing="3"  >' +
+            ' <tr >' +
+            '              <th  style="text-align: center;">岗位编号<\/th>' +
+            '              <th  style="text-align: center;">岗位名称<\/th>' +
+            '              <th  style="text-align: center;">限制条件<\/th>' +
+            '              <th  style="text-align: center;"><\/th>' +
+            '         <\/tr>';
+        for (var c = 0; c < post.length; c++) {
+            job_base += '<tr>' +
+                '              <td  style="padding:8px 15px;"><input type="text"  name="postcode[]" value="' + post[c].code + '" class="form-control postcode"  style="width:100px; " onkeyup="value=value.replace(/[^\\d.]/g,\'\')"  ><\/td>' +
+                '              <td  style="padding:8px 15px;"><input type="text"  name="postname[]" value="' + post[c].name + '" class="form-control postname"   style="width:400px;"  maxlength="80" ><\/td>' +
+                '              <td  style="padding:8px 15px;"><input type="text"  name="postnumber[]" value="' + post[c].number + '" class="form-control postnumber"   style="width:100px;"  maxlength="80" ><\/td>' +
+                '              <td  style="padding:8px 15px;"><input type="text" id="post_' + post[c].id + '"  name="postlimit[]" value="" class="form-control limit"   style="width:400px;" ><\/td>'
+            ;
+            job_base += '                    <\/select>' +
+                '              <\/td>' +
+                '              <td>' +
+                ' <input type="button" onclick="deltr(this)"class="btn btn-danger" value="删除">' +
+                ' <input  type="hidden" class="btn btn-danger" name="postid_arr[]" value="' + post[c].id + '">' +
+                '              <\/td>' +
+                '        <\/tr>';
+        }
+        job_base += '    <\/table><\/div>';
+        $("form .box-body .fields-group").append(job_base);
+        for (var c = 0; c < post.length; c++) {
+            $("#post_" + post[c].id).val(post[c].limit);
+        }
+    }
+
+    function addPost() {
+        var trtd = '<tr>' +
+            '              <td  style="padding:8px 15px;"><input type="text"  name="postcode[]" value="" class="form-control postcode"  style="width:100px; " onkeyup="value=value.replace(/[^\\d.]/g,\'\')"  ><\/td>' +
+            '              <td  style="padding:8px 15px;"><input type="text"  name="postname[]" value="" class="form-control postname"   style="width:400px;"  maxlength="80" ><\/td>' +
+            '              <td  style="padding:8px 15px;"><input type="text"  name="postnumber[]" value="1" class="form-control postnumber"  style="width:100px; "  ><\/td>' +
+            '              <td  style="padding:8px 15px;"><input type="text"  name="postlimit[]" value="" class="form-control limit"   style="width:400px;"  ><\/td>'
+        ;
+
+        trtd += '                    <\/select>' +
+            '              <\/td>' +
+            '              <td><input type="button" onclick="deltr(this)"class="btn btn-danger" value="删除"><\/td>' +
+            '        <\/tr>';
+
+        var tables = $('#post_table');
+        tables.append(trtd);
+    }
+
+    function deltr(obj) {
+        $(obj).parent().parent().remove();
+    }
+
+    checkFlowPath();
+    setInterval(function () {
+        checkFlowPath();
+    }, 250);
+
+    //判断时间是否显示
+    function checkFlowPath() {
+        $('input[name="flow_path[]"]').each(function () {
+            //笔试时间
+            if ($(this).val() == 3) {
+                if ($(this).is(":checked")) {
+                    $("input[name='preliminary_start']").parents(".form-group").css("display", "block");
+                } else {
+                    $("input[name='preliminary_start']").parents(".form-group").css("display", "none");
+                }
+            }
+            //上机时间
+            if ($(this).val() == 4) {
+                if ($(this).is(":checked")) {
+                    $("input[name='computer_start']").parents(".form-group").css("display", "block");
+                } else {
+                    $("input[name='computer_start']").parents(".form-group").css("display", "none");
+                }
+            }
+            //面试时间
+            if ($(this).val() == 5) {
+                if ($(this).is(":checked")) {
+                    $("input[name='interview_start']").parents(".form-group").css("display", "block");
+                    $("textarea[name='expand_id']").parents(".form-group").css("display", "block");
+                } else {
+                    $("input[name='interview_start']").parents(".form-group").css("display", "none");
+                    $("textarea[name='expand_id']").parents(".form-group").css("display", "none");
+                }
+            }
+            //复试时间
+            if ($(this).val() == 6) {
+                if ($(this).is(":checked")) {
+                    $("input[name='reexamine_start']").parents(".form-group").css("display", "block");
+                } else {
+                    $("input[name='reexamine_start']").parents(".form-group").css("display", "none");
+                }
+            }
+            //体检时间
+            if ($(this).val() == 7) {
+                if ($(this).is(":checked")) {
+                    $("input[name='health_start']").parents(".form-group").css("display", "block");
+                } else {
+                    $("input[name='health_start']").parents(".form-group").css("display", "none");
+                }
+            }
+        })
+    }
+
+
+    function getCookie(name) {
+        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
+        if (arr = document.cookie.match(reg)) {
+            return unescape(arr[2]);
+        } else
+            return null;
+    }
+
+    function setCookie(name, value) {
+        var Days = 60000;
+        var exp = new Date();
+        exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
+        document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
+    }
+
+</script>

+ 3 - 0
routes/web.php

@@ -12,6 +12,9 @@ use Illuminate\Routing\Router;
 |
 */
 
+/*短链接*/
+Route::get('/u/{url}', 'Web\HomeController@short_url')->name('short_url');
+
 /*首页*/
 Route::get('/', 'Web\HomeController@index')->name('home');
 Route::get('home/declare', 'Web\HomeController@declare')->name('declare'); //优秀人才申报