init
This commit is contained in:
84
app/admin/model/Bulk.php
Executable file
84
app/admin/model/Bulk.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Bulk extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getBulkLists($where = null, $order = null, $field = null, $limit = null, $level = 0, array &$alldata = array()) {
|
||||
if ($level > 5) {
|
||||
return;
|
||||
}
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
$alldata[] = $row;
|
||||
|
||||
}
|
||||
}
|
||||
return $alldata;
|
||||
}
|
||||
|
||||
public function getBulkList($where = null, $order = null, $field = null, $limit = null) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$data = $this->select();
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setContentAttr($content, $data) {
|
||||
if (!empty($content)) {
|
||||
$config = \HTMLPurifier_Config::createDefault();
|
||||
$purifier = new \HTMLPurifier($config);
|
||||
$content = $purifier->purify($content);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user