Batch.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\BatchApi;
  5. /**
  6. * Description of Batch
  7. *
  8. * @author sgq
  9. */
  10. class Batch extends AdminController {
  11. /**
  12. * @auth {{/batch}}
  13. * @return type
  14. */
  15. public function index() {
  16. $declare_type_list = \app\common\api\DictApi::findChildDictByCode("declare_type");
  17. return view("", ["declare_type_list" => $declare_type_list]);
  18. }
  19. /**
  20. * @auth {{/batch/list}}
  21. * @return type
  22. */
  23. public function list() {
  24. return json(BatchApi::getList($this->request));
  25. }
  26. /**
  27. * @auth {{/batch/add}}
  28. * @return type
  29. */
  30. public function add() {
  31. if ($this->request->isPost()) {
  32. return json(BatchApi::create($this->request->param()));
  33. }
  34. return view("", ["source" => $this->user["type"]]);
  35. }
  36. /**
  37. * @auth {{/batch/update}}
  38. * @return type
  39. */
  40. public function edit() {
  41. if ($this->request->isPost()) {
  42. return json(BatchApi::update($this->request->param()));
  43. }
  44. $batch = BatchApi::getOne($this->request->param("id"));
  45. return view("", ["batch" => $batch]);
  46. }
  47. /**
  48. * @auth {{/batch/delete}}
  49. * @return type
  50. */
  51. public function delete() {
  52. if ($this->request->isPost()) {
  53. return json(BatchApi::delete($this->request->param("batchId")));
  54. }
  55. }
  56. /**
  57. * @auth {{/batch/setActive}}
  58. * @return type
  59. */
  60. public function setActive() {
  61. if ($this->request->isPost()) {
  62. return json(BatchApi::setActive($this->request->param("batchId"), 1));
  63. }
  64. }
  65. /**
  66. * @auth {{/batch/setNotActive}}
  67. * @return type
  68. */
  69. public function setNotActive() {
  70. if ($this->request->isPost()) {
  71. return json(BatchApi::setActive($this->request->param("batchId"), 2));
  72. }
  73. }
  74. /**
  75. * @auth {{/batch/detail}}
  76. * @return type
  77. */
  78. public function detail() {
  79. return view();
  80. }
  81. public function listBatchByType() {
  82. $type = $this->request["type"];
  83. $talentType = $this->user["type"];
  84. return json(BatchApi::getValidBatchs($type, $talentType));
  85. }
  86. }