123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-09-27 08:46:31
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-11-20 16:39:49
- */
- namespace app\index\model;
- use think\Model;
- class jobhuntingmodel extends Model
- {
- protected $table = 't_jobhunting';
- public function insertData($data)
- {
- $id = $this->insertGetId($data);
- return empty($id) ? false : $id;
- }
- public function getInfo($where, $field = "*", $row = true)
- {
- $info = $this->field($field)->where($where);
- if ($row) {
- $info = $info->find();
- } else {
- $info = $info->select();
- }
- return empty($info) ? false : $info;
- }
- public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
- {
- $sqlObj = $this->where($where);
- if ("count" != $field) {
- $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
- if ($row) {
- $data = $sqlObj->find();
- } else {
- $data = $sqlObj->select();
- }
- } else {
- $data = $sqlObj = $sqlObj->count();
- }
- return $data;
- }
- public function updateinfo($where, $updateData)
- {
- $row = $this->where($where)->update($updateData);
- return empty($row) ? false : $row;
- }
- public function deleteinfo($where)
- {
- $row = $this->where($where)->delete();
- return empty($row) ? false : $row;
- }
- public function incField($where, $field, $step = 1)
- {
- $row = $this->where($where)->setInc($field, $step);
- return empty($row) ? false : $row;
- }
- /*
- * 20211002
- * 根据发布者ID获取清单
- * 应用于发布者查看本人发布的消息
- */
- public function sellistbyuid($uid)
- {
- $where_arr['createuid'] = $uid;
- $rlist = $this->where($where_arr)->order('id', 'desc')->select();
- $rlist = collection($rlist)->toArray();
- return $rlist;
- }
- /**
- * 获取总数
- * 20211117
- * wj
- */
- public function getcount()
- {
- $count = $this->where([])->count();
- return $count;
- }
- /**
- * 获取分析数据
- * 20211117
- * wj
- */
- public function statistics()
- {
- $sql = "select isactive,ispass,count(*) as count from " . $this->table . " group by isactive,ispass";
- $list = $this->query("select * from (" . $sql . ") as t");
- return $list;
- }
- /**
- * 根据条件查询
- * 未加组关联 20211119 wj
- */
- public function getlistjoinuser($where, $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
- {
- $sql = $this->alias('i')->join('t_userinfo u', 'i.createuid=u.id');
- $whereUse = [];
- if (isset($where['wname']) && !empty($where['wname'])) {
- $whereUse['u.wname'] = ['like', '%' . $where['wname'] . '%'];
- }
- if (isset($where['telno']) && !empty($where['telno'])) {
- $whereUse['u.telno'] = ['like', '%' . $where['telno'] . '%'];
- }
- if (isset($where['isactive']) && is_numeric($where['isactive'])) {
- $whereUse['i.isactive'] = $where['isactive'];
- }
- if (isset($where['userstyle']) && is_numeric($where['userstyle'])) {
- $whereUse['i.userstyle'] = $where['userstyle'];
- }
- if (isset($where['ispass']) && is_numeric($where['ispass'])) {
- $whereUse['i.ispass'] = $where['ispass'];
- }
- if (isset($where['worktype']) && !empty($where['worktype'])) {
- $whereUse['i.worktype'] = $where['worktype'];
- }
- if (isset($where['createdate']) && is_array($where['createdate'])) {
- $whereUse['createdate'] = ['between', $where['createdate']];
- }
- if ($field == 'count') {
- $data = $sql->where($whereUse)->count();
- } else {
- $field = ['u.wname', 'u.telno', 'u.isactive', 'i.*'];
- if ($row) {
- $data = $sql->where($whereUse)->field($field)->page($page, $size)->order($order)->find();
- } else {
- $data = $sql->where($whereUse)->field($field)->page($page, $size)->order($order)->group($group)->select();
- }
- }
- return empty($data) ? false : $data;
- }
- /*
- * 20211130
- * steelxu
- */
- public function selinfobyid($id)
- {
- $where_arr['id'] = $id;
- $rec = $this->where($where_arr)->find();
- return $rec;
- }
- }
|