1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace app\common\model;
- use think\Model;
- /**
- * 接收信息队列
- *
- * @author wj
- * @date 2023-08-14
- */
- class ShoneReceiveQueueModel extends Model
- {
- protected $table = "t_shouhuan_one_receive_queue";
- public function insertData($data)
- {
- $data = $this->formatData($data);
- if (empty($data)) {
- return false;
- }
- $id = $this->insertGetId($data);
- return $id ? $id : false;
- }
- public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
- {
- $sqlObj = $this->where($where);
- if ("count" != $field) {
- if (empty($size)) {
- $sqlObj = $sqlObj->field($field)->order($order)->group($group);
- } else {
- $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
- }
- if ($row) {
- $data = $sqlObj->find();
- } else {
- $data = $sqlObj->select();
- }
- } else {
- $data = $sqlObj->count();
- }
- return $data;
- }
- /**
- * 根据id删除信息
- *
- * @param [type] $id
- * @return void
- * @author wj
- * @date 2023-08-14
- */
- public function deleteinfobyid($id)
- {
- $where = ['id' => $id];
- $row = $this->where($where)->delete();
- return empty($row) ? false : $row;
- }
- public function updateinfo($where, $updateData)
- {
- $row = $this->where($where)->update($updateData);
- return empty($row) ? false : $row;
- }
- private function formatData($data)
- {
- $useData = [];
- $fields = $this->getTableFields();
- foreach ($data as $key => $value) {
- if (in_array($key, $fields)) {
- $useData[$key] = $value;
- }
- }
- return $useData;
- }
- }
|