Recruit.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Recruit extends Model
  5. {
  6. public $page_info;
  7. /**
  8. * 获取单个招聘岗位
  9. */
  10. public function getOneRecruit($condition, $field = '*')
  11. {
  12. return db('recruit')->field($field)->where($condition)->find();
  13. }
  14. /**
  15. * 招聘岗位列表
  16. */
  17. public function getRecruit($condition, $field = '*', $page = 0, $order = 'sort', $limit = '')
  18. {
  19. if ($limit) {
  20. return db('recruit')->where($condition)->field($field)->order($order,'desc')->page($page)->limit($limit)->select();
  21. } else {
  22. $res = db('recruit')->where($condition)->field($field)->order($order,'desc')->paginate($page);
  23. $this->page_info = $res;
  24. return $res->items();
  25. }
  26. }
  27. /**
  28. * 新增招聘岗位
  29. */
  30. public function addRecruit($param)
  31. {
  32. return db('recruit')->insertGetId($param);
  33. }
  34. /**
  35. * 修改招聘岗位
  36. */
  37. public function edit($condition, $update)
  38. {
  39. return db('recruit')->where($condition)->update($update);
  40. }
  41. /**
  42. * 删除招聘岗位
  43. * @param unknown $condition
  44. * @return boolean
  45. */
  46. public function deleteRecruit($condition)
  47. {
  48. $recruit_array = $this->getRecruit($condition, 'id');
  49. $id_array = array();
  50. foreach ($recruit_array as $value) {
  51. $id_array[] = $value['id'];
  52. // @unlink(BASE_UPLOAD_PATH . DS . ATTACH_PRODUCT . DS . $value['product_img']);
  53. }
  54. return db('recruit')->where(array('id' => array('in', $id_array)))->delete();
  55. }
  56. }
  57. ?>