CommonController.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace App\Http\Controllers\Web;
  3. use App\Services\Common\CategoryService;
  4. use App\Services\Common\HotWordService;
  5. use Illuminate\Http\Request;
  6. class CommonController extends WebBaseController
  7. {
  8. protected $categoryService;
  9. protected $hotWordService;
  10. /**
  11. * CommonController constructor.
  12. * @param $categoryService
  13. * @param $hotWordService
  14. */
  15. public function __construct(CategoryService $categoryService, HotWordService $hotWordService)
  16. {
  17. $this->categoryService = $categoryService;
  18. $this->hotWordService = $hotWordService;
  19. }
  20. /**
  21. * Show the application dashboard.
  22. *
  23. * @return \Illuminate\Http\Response
  24. */
  25. public function index()
  26. {
  27. return view('app.index');
  28. }
  29. /**
  30. * 职位分类对应描述及关联分类ajax返回
  31. */
  32. public function ajaxGetCategoryContent(Request $request)
  33. {
  34. $id = $request->id;
  35. !$id && response()->json(['status'=>0, 'msg'=>'请选择分类!']);
  36. $current_category = $this->categoryService->getCategoryJobs($id);
  37. $data = array();
  38. $data['show_relation'] = 0;
  39. $data['relation_data'][] = array('id'=>$id,'name'=>$current_category['name'],'desc'=>$current_category['content'],'current'=>1);
  40. if ($current_category['relation1']) {
  41. $idarr = explode(".", $current_category['relation1']);
  42. $relation_id = $idarr[2]==0?$idarr[1]:$idarr[2];
  43. $relation1 = $this->categoryService->getCategoryJobs($relation_id);
  44. if ($relation1['content']) {
  45. $data['show_relation'] = 1;
  46. $data['relation_data'][] = array('id'=>$relation1['id'],'name'=>$relation1['name'],'desc'=>$relation1['content'],'current'=>0);
  47. }
  48. }
  49. if ($current_category['relation2']) {
  50. $idarr = explode(".", $current_category['relation2']);
  51. $relation_id = $idarr[2]==0?$idarr[1]:$idarr[2];
  52. $relation2 = $this->categoryService->getCategoryJobs($relation_id);
  53. if ($relation2['content']) {
  54. $data['show_relation'] = 1;
  55. $data['relation_data'][] = array('id'=>$relation2['id'],'name'=>$relation2['name'],'desc'=>$relation2['content'],'current'=>0);
  56. }
  57. }
  58. return response()->json(['status'=>0, 'msg'=>'请选择分类!', 'data'=>$data]);
  59. }
  60. //关键字联想
  61. public function hotWord(Request $request)
  62. {
  63. $key = $request->input('query', '');
  64. $key = trim($key);
  65. $hotword_type = session('hotword_show_type', 1);
  66. if (!$key) {
  67. return response()->json(['status'=>0, 'msg'=>'请输入关健字!']);
  68. }
  69. //查询关键字
  70. $reg = $this->hotWordService->getHotWord($key, $hotword_type);
  71. $this->hotWordService->setMemberHotword($key, $hotword_type); //会员关键字记录表
  72. if ($reg) {
  73. return response()->json(['status'=>1, 'msg'=>'联想词获取成功!','data'=>array('query'=>$key,'suggestions'=>$reg)]);
  74. //$this->ajaxReturn(1,'联想词获取成功!',array('query'=>$key,'suggestions'=>$reg));
  75. } else {
  76. return response()->json(['status'=>0, 'msg'=>'']);
  77. }
  78. }
  79. //联系方式图形化
  80. public function getFontImg(Request $request)
  81. {
  82. $text = $request->input('text', '');
  83. $type = $request->input('type', 'phone');
  84. $pwdhash = config('aix.system.site_other.site_other.pwb_hash');
  85. $text = decrypt($text, $pwdhash);
  86. //$img=\Intervention\Image\Facades\Image::canvas(200, 30, '#FFFFFF');
  87. $img=\Intervention\Image\Facades\Image::canvas(200, 30);
  88. $img->text($text, 0, 20, function ($font) {
  89. //$font->file(public_path('themes/default/assets/app/fonts/Source-Sans-Pro-Semibold.ttf')); //引入字体
  90. $font->file(5);
  91. $font->size(14);
  92. $font->color('#643200');
  93. $font->align('left');
  94. //$font->valign('top');
  95. });
  96. $img->brightness(1);
  97. return $img->response('png');
  98. }
  99. public function listShowType(Request $request)
  100. {
  101. $action = $request->input('action');
  102. $type = $request->input('type', '');
  103. session([$action.'_show_type' => $type]);
  104. }
  105. }