jobhuntingmodel.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2021-09-27 08:46:31
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2021-11-20 16:39:49
  7. */
  8. namespace app\index\model;
  9. use think\Model;
  10. class jobhuntingmodel extends Model
  11. {
  12. protected $table = 't_jobhunting';
  13. public function insertData($data)
  14. {
  15. $id = $this->insertGetId($data);
  16. return empty($id) ? false : $id;
  17. }
  18. public function getInfo($where, $field = "*", $row = true)
  19. {
  20. $info = $this->field($field)->where($where);
  21. if ($row) {
  22. $info = $info->find();
  23. } else {
  24. $info = $info->select();
  25. }
  26. return empty($info) ? false : $info;
  27. }
  28. public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
  29. {
  30. $sqlObj = $this->where($where);
  31. if ("count" != $field) {
  32. $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
  33. if ($row) {
  34. $data = $sqlObj->find();
  35. } else {
  36. $data = $sqlObj->select();
  37. }
  38. } else {
  39. $data = $sqlObj = $sqlObj->count();
  40. }
  41. return $data;
  42. }
  43. public function updateinfo($where, $updateData)
  44. {
  45. $row = $this->where($where)->update($updateData);
  46. return empty($row) ? false : $row;
  47. }
  48. public function deleteinfo($where)
  49. {
  50. $row = $this->where($where)->delete();
  51. return empty($row) ? false : $row;
  52. }
  53. public function incField($where, $field, $step = 1)
  54. {
  55. $row = $this->where($where)->setInc($field, $step);
  56. return empty($row) ? false : $row;
  57. }
  58. /*
  59. * 20211002
  60. * 根据发布者ID获取清单
  61. * 应用于发布者查看本人发布的消息
  62. */
  63. public function sellistbyuid($uid)
  64. {
  65. $where_arr['createuid'] = $uid;
  66. $rlist = $this->where($where_arr)->order('id', 'desc')->select();
  67. $rlist = collection($rlist)->toArray();
  68. return $rlist;
  69. }
  70. /**
  71. * 获取总数
  72. * 20211117
  73. * wj
  74. */
  75. public function getcount()
  76. {
  77. $count = $this->where([])->count();
  78. return $count;
  79. }
  80. /**
  81. * 获取分析数据
  82. * 20211117
  83. * wj
  84. */
  85. public function statistics()
  86. {
  87. $sql = "select isactive,ispass,count(*) as count from " . $this->table . " group by isactive,ispass";
  88. $list = $this->query("select * from (" . $sql . ") as t");
  89. return $list;
  90. }
  91. /**
  92. * 根据条件查询
  93. * 未加组关联 20211119 wj
  94. */
  95. public function getlistjoinuser($where, $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
  96. {
  97. $sql = $this->alias('i')->join('t_userinfo u', 'i.createuid=u.id');
  98. $whereUse = [];
  99. if (isset($where['wname']) && !empty($where['wname'])) {
  100. $whereUse['u.wname'] = ['like', '%' . $where['wname'] . '%'];
  101. }
  102. if (isset($where['telno']) && !empty($where['telno'])) {
  103. $whereUse['u.telno'] = ['like', '%' . $where['telno'] . '%'];
  104. }
  105. if (isset($where['isactive']) && is_numeric($where['isactive'])) {
  106. $whereUse['i.isactive'] = $where['isactive'];
  107. }
  108. if (isset($where['userstyle']) && is_numeric($where['userstyle'])) {
  109. $whereUse['i.userstyle'] = $where['userstyle'];
  110. }
  111. if (isset($where['ispass']) && is_numeric($where['ispass'])) {
  112. $whereUse['i.ispass'] = $where['ispass'];
  113. }
  114. if (isset($where['worktype']) && !empty($where['worktype'])) {
  115. $whereUse['i.worktype'] = $where['worktype'];
  116. }
  117. if (isset($where['createdate']) && is_array($where['createdate'])) {
  118. $whereUse['createdate'] = ['between', $where['createdate']];
  119. }
  120. if ($field == 'count') {
  121. $data = $sql->where($whereUse)->count();
  122. } else {
  123. $field = ['u.wname', 'u.telno', 'u.isactive', 'i.*'];
  124. if ($row) {
  125. $data = $sql->where($whereUse)->field($field)->page($page, $size)->order($order)->find();
  126. } else {
  127. $data = $sql->where($whereUse)->field($field)->page($page, $size)->order($order)->group($group)->select();
  128. }
  129. }
  130. return empty($data) ? false : $data;
  131. }
  132. /*
  133. * 20211130
  134. * steelxu
  135. */
  136. public function selinfobyid($id)
  137. {
  138. $where_arr['id'] = $id;
  139. $rec = $this->where($where_arr)->find();
  140. return $rec;
  141. }
  142. }