Recruit.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Lang;
  4. class Recruit extends AdminControl
  5. {
  6. public function _initialize()
  7. {
  8. parent::_initialize();
  9. Lang::load(APP_PATH . 'admin/lang/' . config('default_lang') . '/product.lang.php');
  10. }
  11. /**
  12. * 招聘岗位列表
  13. */
  14. public function index(){
  15. $model_recruit = Model('Recruit');
  16. $recruit_keywords = input('post.product_keywords');
  17. $recruit_type = input('post.product_type');
  18. $condition = array();
  19. if($recruit_keywords){
  20. $condition['product_keywords'] = $recruit_keywords;
  21. }
  22. if($recruit_type){
  23. $condition['product_type'] = $recruit_type;
  24. }
  25. $recruit_list = $model_recruit->getRecruit($condition,'*',10);
  26. for($i=0;$i<count($recruit_list);$i++){
  27. $recruit_list[$i]['add_time'] = date("Y-m-d h:i:s",$recruit_list[$i]['add_time']);
  28. $recruit_list[$i]['update_time'] = date("Y-m-d h:i:s",$recruit_list[$i]['update_time']);
  29. }
  30. $allpower = $this->qxhans();
  31. $this->assign('allpower',$allpower);
  32. $this->assign('recruit_list', $recruit_list);
  33. $this->assign('show_page', $model_recruit->page_info->render());
  34. $this->setAdminCurItem('index');
  35. return $this->fetch();
  36. }
  37. /**
  38. * 添加招聘岗位
  39. * @return mixed
  40. */
  41. public function add()
  42. {
  43. $allpower = $this->qxhans();
  44. $this->assign('allpower',$allpower);
  45. if (request()->isPost()) {
  46. if(input('post.status') == ""){
  47. $data = array(
  48. 'name' => input('post.name'),
  49. 'sort' => input('post.sort'),
  50. 'detail' => input('post.detail'),
  51. 'address' => input('post.address'),
  52. 'add_time' => time(),
  53. 'update_time' => time(),
  54. 'status' => '0',
  55. );
  56. }else{
  57. $data = array(
  58. 'name' => input('post.name'),
  59. 'sort' => input('post.sort'),
  60. 'detail' => input('post.detail'),
  61. 'address' => input('post.address'),
  62. 'add_time' => time(),
  63. 'update_time' => time(),
  64. 'status' => input('post.status'),
  65. );
  66. }
  67. $result = model('Recruit')->addRecruit($data);
  68. if ($result){
  69. $this->success(lang('add_succ'), url('Recruit/index'));
  70. }
  71. $this->error(lang('add_fail'));
  72. } else {
  73. $recruit = array('status'=>1);
  74. $this->assign('recruit', $recruit);
  75. $this->setAdminCurItem('add');
  76. return $this->fetch('form');
  77. }
  78. }
  79. /**
  80. * 修改招聘职位
  81. * @return mixed
  82. */
  83. public function edit()
  84. {
  85. $allpower = $this->qxhans();
  86. $this->assign('allpower',$allpower);
  87. $id = input('param.id');
  88. if ($id <= 0) {
  89. $this->error('系统错误');
  90. }
  91. $condition['id'] = $id;
  92. if (request()->isPost()) {
  93. $data = array(
  94. 'name' => input('post.name'),
  95. 'sort' => input('post.sort'),
  96. 'detail' => input('post.detail'),
  97. 'address' => input('post.address'),
  98. 'update_time' => time(),
  99. 'status' => input('post.status'),
  100. );
  101. $result = model('Recruit')->edit(['id' => $id], $data);
  102. if ($result >= 0) {
  103. $this->success(lang('edit_succ'), 'Recruit/index');
  104. } else {
  105. $this->error(lang('edit_fail'));
  106. }
  107. } else {
  108. $recruit = model('Recruit')->getOneRecruit(['id' => $id]);
  109. $this->assign('recruit', $recruit);
  110. $this->setAdminCurItem('edit');
  111. return $this->fetch('form');
  112. }
  113. }
  114. /**
  115. * 删除招聘职位
  116. * @return mixed
  117. */
  118. function del()
  119. {
  120. $id = intval(input('param.id'));
  121. if ($id) {
  122. $condition['id'] = $id;
  123. $result = model('Recruit')->deleteRecruit($condition);
  124. if ($result) {
  125. ds_json_encode(10000, lang('del_succ'));
  126. } else {
  127. ds_json_encode(10001, lang('del_fail'));
  128. }
  129. } else {
  130. ds_json_encode(10001, lang('param_error'));
  131. }
  132. }
  133. }