DictController.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace App\Web\Controllers;
  3. use App\Http\Controllers\BaseController;
  4. use App\Web\Services\BlogService;
  5. use App\Web\Services\DictService;
  6. use Illuminate\Http\Request;
  7. class DictController extends BaseController
  8. {
  9. protected $service = null;
  10. /**
  11. * 构造函数
  12. * BlogController constructor.
  13. * @param BlogService $service
  14. */
  15. public function __construct(DictService $service)
  16. {
  17. $this->service = $service;
  18. }
  19. /**
  20. * 获取功能列表
  21. * */
  22. public function getDictFunctionList(Request $request){
  23. $params=$request->only(['page_size','page','status','keyword']);
  24. $ret=$this->service->getDictFunctionList($params);
  25. return $this->jsonResponse(
  26. 'ok',
  27. $ret
  28. );
  29. }
  30. /**
  31. * 功能保存
  32. * */
  33. public function saveDictFunction(Request $request){
  34. $this->validate($request, [
  35. 'name' => 'required',
  36. ], [
  37. 'name.required' => '功能名称不能为空',
  38. ]);
  39. $params=$request->only(['id','name','remark','status']);
  40. $ret=$this->service->saveDictFunction($params);
  41. return $this->jsonResponse(
  42. 'ok',
  43. $ret
  44. );
  45. }
  46. /**
  47. * 变更功能状态
  48. * */
  49. public function changeDictFunctionStatus(Request $request){
  50. $this->validate($request, [
  51. 'id' => 'required',
  52. ], [
  53. 'id.required' => 'id不能为空',
  54. ]);
  55. $params=$request->only(['id','status']);
  56. $ret=$this->service->saveDictFunction($params);
  57. return $this->jsonResponse(
  58. 'ok',
  59. $ret
  60. );
  61. }
  62. /**
  63. * 获取行业列表
  64. * */
  65. public function getDictIndustryList(Request $request){
  66. $params=$request->only(['page_size','page','status','keyword']);
  67. $ret=$this->service->getDictIndustryList($params);
  68. return $this->jsonResponse(
  69. 'ok',
  70. $ret
  71. );
  72. }
  73. /**
  74. * 行业保存
  75. * */
  76. public function saveDictIndustry(Request $request){
  77. $this->validate($request, [
  78. 'name' => 'required',
  79. ], [
  80. 'name.required' => '行业名称不能为空',
  81. ]);
  82. $params=$request->only(['id','name','pid','status','remark']);
  83. $ret=$this->service->saveDictIndustry($params);
  84. return $this->jsonResponse(
  85. 'ok',
  86. $ret
  87. );
  88. }
  89. /**
  90. * 变更行业状态
  91. * */
  92. public function changeDictIndustryStatus(Request $request){
  93. $this->validate($request, [
  94. 'id' => 'required',
  95. ], [
  96. 'id.required' => 'id不能为空',
  97. ]);
  98. $params=$request->only(['id','status']);
  99. $ret=$this->service->saveDictIndustry($params);
  100. return $this->jsonResponse(
  101. 'ok',
  102. $ret
  103. );
  104. }
  105. }