init
This commit is contained in:
31
app/admin/model/ActionLog.php
Executable file
31
app/admin/model/ActionLog.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class ActionLog extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
public function getPageLists($where = null, $order = null, $field = null, $limit = null, $level = 0) {
|
||||
$this->alias('al')->join('user u', 'al.user_id=u.id', 'LEFT');
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
$object = $this->paginate($limit);
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
||||
46
app/admin/model/Ad.php
Executable file
46
app/admin/model/Ad.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Ad extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
protected $update = [];
|
||||
|
||||
public function getAdLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('b')->join('ad_type bt', 'b.typeid=bt.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['b.stat' => 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');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
109
app/admin/model/AdType.php
Executable file
109
app/admin/model/AdType.php
Executable file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class AdType extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
public function getChildIDArray($id) {
|
||||
$list = $this->where(['pid' => $id])->field('id')->select();
|
||||
$childIDArray = array((int) $id);
|
||||
if ($list) {
|
||||
foreach ($list as $val) {
|
||||
$childArray = self::getChildIDArray($val['id']);
|
||||
$childIDArray = array_merge($childIDArray, $childArray);
|
||||
}
|
||||
}
|
||||
return $childIDArray;
|
||||
}
|
||||
|
||||
public function getTopParentID($id, $where = null) {
|
||||
$data = $this::get(function($query)use($id, $where) {
|
||||
$query->where(['id' => $id]);
|
||||
if ($where) {
|
||||
$query->where($where);
|
||||
}
|
||||
$query->field(['id', 'pid']);
|
||||
});
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
$topid = self::getTopParentID($data['pid'], $where);
|
||||
} else {
|
||||
$topid = $id;
|
||||
}
|
||||
return $topid;
|
||||
}
|
||||
|
||||
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = 20) {
|
||||
$options = '';
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
|
||||
$options = '';
|
||||
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) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
$where['pid'] = $row['id'];
|
||||
$options.=self::getOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
84
app/admin/model/Agents.php
Executable file
84
app/admin/model/Agents.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Agents extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getAgentLists($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 getAgentList($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;
|
||||
}
|
||||
|
||||
}
|
||||
147
app/admin/model/Article.php
Executable file
147
app/admin/model/Article.php
Executable file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Article extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['updatetime'];
|
||||
protected $update = ['updatetime'];
|
||||
|
||||
public function getCategoryArticleList($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('article_category c', 'a.cid=c.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['eq', '0'], 'c.stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$data = $this->select();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getArticleLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('article_category c', 'a.cid=c.id', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['eq', '0'], 'c.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');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getRecycleLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')
|
||||
->join('article_category c', 'a.cid=c.id', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getExportSearchArticleLists($where = null, $order = 'id', $limit = null, $count = false, $field = '*') {
|
||||
$this->alias('a')->join('article_category c', 'a.cid=c.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
//$object->fetchsql(true);
|
||||
if ($count) {
|
||||
$result = $this->count();
|
||||
return $result;
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
if (is_array($limit)) {
|
||||
//$limit = ['offset' => 1, 'length' => 1];
|
||||
$limit = array_values($limit);
|
||||
$this->limit($limit[0], $limit[1]);
|
||||
} else {
|
||||
$this->limit($limit);
|
||||
}
|
||||
}
|
||||
$result = $this->select();
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($result);
|
||||
// exit;
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
if (empty($value)) {
|
||||
return time();
|
||||
} else {
|
||||
return strtotime($value);
|
||||
}
|
||||
}
|
||||
|
||||
// 属性修改器 更新时间
|
||||
protected function setUpdatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
// 属性修改器 设置注册ip
|
||||
protected function setIpAttr() {
|
||||
return Request::instance()->ip();
|
||||
}
|
||||
|
||||
protected function setContentAttr($content, $data) {
|
||||
if (!empty($content)) {
|
||||
$config = \HTMLPurifier_Config::createDefault();
|
||||
$purifier = new \HTMLPurifier($config);
|
||||
// $content = $purifier->purify($content);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
240
app/admin/model/ArticleCategory.php
Executable file
240
app/admin/model/ArticleCategory.php
Executable file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class ArticleCategory extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getCategoryLists($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) {
|
||||
$row['level'] = $level;
|
||||
$alldata[] = $row;
|
||||
$where['pid'] = $row['id'];
|
||||
//self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
!$row['haschild'] ? '' : self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
}
|
||||
}
|
||||
return $alldata;
|
||||
}
|
||||
|
||||
public function getCategoryList($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;
|
||||
}
|
||||
|
||||
public function getChildIDArray($id) {
|
||||
$list = $this->where(['pid' => $id, 'stat' => 0])->field(['id', 'haschild'])->select();
|
||||
$childIDArray = array((int) $id);
|
||||
if ($list) {
|
||||
foreach ($list as $val) {
|
||||
$childArray = $val['haschild'] ? self::getChildIDArray($val['id']) : array((int) $val['id']);
|
||||
$childIDArray = array_merge($childIDArray, $childArray);
|
||||
}
|
||||
}
|
||||
return $childIDArray;
|
||||
}
|
||||
|
||||
public function getTopParentID($id, $where = null) {
|
||||
$data = $this::get(function($query)use($id, $where) {
|
||||
$query->where(['id' => $id]);
|
||||
if ($where) {
|
||||
$query->where($where);
|
||||
}
|
||||
$query->field(['id', 'pid']);
|
||||
});
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
$topid = self::getTopParentID($data['pid'], $where);
|
||||
} else {
|
||||
$topid = $id;
|
||||
}
|
||||
return $topid;
|
||||
}
|
||||
|
||||
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
|
||||
if (!$id) {
|
||||
return array();
|
||||
}
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
$data = $this->field(['id', 'name', 'pid'])->get($id);
|
||||
$catarr[] = $data;
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
self::getBreadCrumb($data['pid'], $where, $catarr);
|
||||
} else {
|
||||
return array_reverse($catarr);
|
||||
}
|
||||
return $catarr;
|
||||
}
|
||||
|
||||
public function getCategoryOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
|
||||
$options = '';
|
||||
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 ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getCategoryOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
|
||||
$options = '';
|
||||
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) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
$where['pid'] = $row['id'];
|
||||
//$options.=self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
$options.=!$row['haschild'] ? '' : self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getCategoryTree($where = null, $order = null, $field = null, $limit = 50, $level = 0) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
$result = array();
|
||||
if ($level > 5) {
|
||||
return $result;
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select(); // 获取
|
||||
if ($list) {
|
||||
foreach ($list as $row) {
|
||||
$row['level'] = $level;
|
||||
$where['pid'] = $row['id'];
|
||||
//$row['child'] = self::getCategoryTree($where, $order, $field, $limit, $level + 1);
|
||||
$row['child'] = !$row['haschild'] ? array() : self::getCategoryTree($where, $order, $field, $limit, $level + 1);
|
||||
$result[] = $row;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function deleteRow($id, $stat = -1) {
|
||||
//$result = $this::destroy($id);
|
||||
$data = ['id' => $id, 'pid' => 0, 'haschild' => 0, 'stat' => $stat,];
|
||||
$object = $this::update($data);
|
||||
return $object;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
133
app/admin/model/ArticleComment.php
Executable file
133
app/admin/model/ArticleComment.php
Executable file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class ArticleComment extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
|
||||
public function getRemarkList($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('article c', 'a.article_id=c.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['in','0,1'], 'c.stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$data = $this->select();
|
||||
//echo $this->getLastsql(); die;
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getRemarkLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('article c', 'a.article_id=c.id', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['in','0,1']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getRecycleLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('article c', 'a.article_id=c.id', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getExportSearchArticleLists($where = null, $order = 'id', $limit = null, $count = false, $field = '*') {
|
||||
$this->alias('a')->join('article c', 'a.article_id=c.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
//$object->fetchsql(true);
|
||||
if ($count) {
|
||||
$result = $this->count();
|
||||
return $result;
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
if (is_array($limit)) {
|
||||
//$limit = ['offset' => 1, 'length' => 1];
|
||||
$limit = array_values($limit);
|
||||
$this->limit($limit[0], $limit[1]);
|
||||
} else {
|
||||
$this->limit($limit);
|
||||
}
|
||||
}
|
||||
$result = $this->select();
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($result);
|
||||
// exit;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 属性修改器 设置注册ip
|
||||
protected function setIpAttr() {
|
||||
return Request::instance()->ip();
|
||||
}
|
||||
|
||||
protected function setContentAttr($content, $data) {
|
||||
if (!empty($content)) {
|
||||
$config = \HTMLPurifier_Config::createDefault();
|
||||
$purifier = new \HTMLPurifier($config);
|
||||
$content = $purifier->purify($content);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
80
app/admin/model/Ask.php
Executable file
80
app/admin/model/Ask.php
Executable file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Ask extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['create_time'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getAskLists($where = null, $order = null, $field = null, $limit = null, $level = 0, array &$alldata = array()) {
|
||||
if ($level > 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
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 getAskList($where = null, $order = null, $field = null, $limit = null) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
38
app/admin/model/AuthAccess.php
Executable file
38
app/admin/model/AuthAccess.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class AuthAccess extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
public function getAuthAccessLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('aa')->join('auth_group ag', 'aa.gid=ag.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['aa.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');
|
||||
}
|
||||
$object = $this->paginate($limit);
|
||||
return $object;
|
||||
}
|
||||
|
||||
protected function setNameAttr($value) {
|
||||
return htmlspecialchars($value);
|
||||
}
|
||||
|
||||
}
|
||||
45
app/admin/model/AuthGroup.php
Executable file
45
app/admin/model/AuthGroup.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class AuthGroup extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
|
||||
$options = '';
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
//$options = '<option value="0">请选择...</option>' . "\n";
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
protected function setNameAttr($value) {
|
||||
return htmlspecialchars($value);
|
||||
}
|
||||
|
||||
}
|
||||
46
app/admin/model/Banner.php
Executable file
46
app/admin/model/Banner.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Banner extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
protected $update = [];
|
||||
|
||||
public function getBannerLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('b')->join('banner_type bt', 'b.typeid=bt.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['b.stat' => 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');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
109
app/admin/model/BannerType.php
Executable file
109
app/admin/model/BannerType.php
Executable file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class BannerType extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
public function getChildIDArray($id) {
|
||||
$list = $this->where(['pid' => $id])->field('id')->select();
|
||||
$childIDArray = array((int) $id);
|
||||
if ($list) {
|
||||
foreach ($list as $val) {
|
||||
$childArray = self::getChildIDArray($val['id']);
|
||||
$childIDArray = array_merge($childIDArray, $childArray);
|
||||
}
|
||||
}
|
||||
return $childIDArray;
|
||||
}
|
||||
|
||||
public function getTopParentID($id, $where = null) {
|
||||
$data = $this::get(function($query)use($id, $where) {
|
||||
$query->where(['id' => $id]);
|
||||
if ($where) {
|
||||
$query->where($where);
|
||||
}
|
||||
$query->field(['id', 'pid']);
|
||||
});
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
$topid = self::getTopParentID($data['pid'], $where);
|
||||
} else {
|
||||
$topid = $id;
|
||||
}
|
||||
return $topid;
|
||||
}
|
||||
|
||||
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = 20) {
|
||||
$options = '';
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
|
||||
$options = '';
|
||||
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) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
$where['pid'] = $row['id'];
|
||||
$options.=self::getOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
84
app/admin/model/Blog.php
Executable file
84
app/admin/model/Blog.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Blog extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['add_time'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getBlotLists($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 getBlogList($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;
|
||||
}
|
||||
|
||||
}
|
||||
133
app/admin/model/BlogRemark.php
Executable file
133
app/admin/model/BlogRemark.php
Executable file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class BlogRemark extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
|
||||
public function getRemarkList($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('blog c', 'a.b_id=c.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['in','0,1'], 'c.stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$data = $this->select();
|
||||
//echo $this->getLastsql(); die;
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getRemarkLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('blog c', 'a.b_id=c.id', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['in','0,1']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getRecycleLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('blog c', 'a.b_id=c.id', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getExportSearchArticleLists($where = null, $order = 'id', $limit = null, $count = false, $field = '*') {
|
||||
$this->alias('a')->join('blog c', 'a.b_id=c.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
//$object->fetchsql(true);
|
||||
if ($count) {
|
||||
$result = $this->count();
|
||||
return $result;
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
if (is_array($limit)) {
|
||||
//$limit = ['offset' => 1, 'length' => 1];
|
||||
$limit = array_values($limit);
|
||||
$this->limit($limit[0], $limit[1]);
|
||||
} else {
|
||||
$this->limit($limit);
|
||||
}
|
||||
}
|
||||
$result = $this->select();
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($result);
|
||||
// exit;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 属性修改器 设置注册ip
|
||||
protected function setIpAttr() {
|
||||
return Request::instance()->ip();
|
||||
}
|
||||
|
||||
protected function setContentAttr($content, $data) {
|
||||
if (!empty($content)) {
|
||||
$config = \HTMLPurifier_Config::createDefault();
|
||||
$purifier = new \HTMLPurifier($config);
|
||||
$content = $purifier->purify($content);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
84
app/admin/model/BulkInquiry.php
Executable file
84
app/admin/model/BulkInquiry.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class BulkInquiry extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getBulkInquiryLists($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 getBulkInquiryList($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;
|
||||
}
|
||||
|
||||
}
|
||||
34
app/admin/model/Country.php
Executable file
34
app/admin/model/Country.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
use think\Session;
|
||||
|
||||
class Country extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
public function getLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => 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');
|
||||
}
|
||||
$object = $this->paginate($limit);
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
||||
224
app/admin/model/Customer.php
Executable file
224
app/admin/model/Customer.php
Executable file
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
use think\Session;
|
||||
|
||||
class Customer extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
public function getLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('u')
|
||||
->join('customer_dept ud', 'u.id=ud.id', 'LEFT')
|
||||
->join('dept d', 'ud.dept_id=d.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['neq', '-1']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
$object = $this->paginate($limit);
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getRoleCustomers($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('u')->join('auth_role ar', 'u.role_id=ar.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge([], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
$this->group('u.id');
|
||||
//$this->having('max(ud.dept_id)');
|
||||
$object = $this->paginate($limit);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库中的配置列表
|
||||
* @return array
|
||||
*/
|
||||
public function getCustomerLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('c')->join('customer_group cg', 'c.group_id=cg.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['c.stat' => 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');
|
||||
}
|
||||
$object = $this->paginate($limit);
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = 20) {
|
||||
$options = '';
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['customername'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['customername'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/*
|
||||
public function insertRow($data, $siteid = 32267) {
|
||||
if (isset($data['password'])) {
|
||||
//$salt = getstr_random();
|
||||
//$row['password'] = md5($data['password'] . $salt);
|
||||
$row['salt'] = $data['password'];
|
||||
$row['password'] = md5($data['password']);
|
||||
}
|
||||
$row['siteid'] = $siteid;
|
||||
$object = $this::create($row);
|
||||
return $object;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* 更新用户密码
|
||||
*/
|
||||
public function updatePassword($data) {
|
||||
//$salt = getstr_random();
|
||||
$row = array(
|
||||
'id' => $data['id'],
|
||||
'password' => md5($data['newpassword']),
|
||||
'salt' => $data['newpassword'],
|
||||
);
|
||||
$object = $this::update($row);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录认证
|
||||
* @param string $condition 验证条件如用户名邮箱手机号ID
|
||||
* @param string $password 用户密码
|
||||
* @param integer $type 用户名类型 (1-用户名,2-邮箱,3-手机,4-UID)
|
||||
* @return integer 登录成功-用户ID,登录失败-错误编号
|
||||
*/
|
||||
public function login($condition, $password, $type = 1) {
|
||||
$where = [];
|
||||
switch ($type) {
|
||||
case 1:$where['customername'] = $condition;
|
||||
break;
|
||||
case 2:$where['email'] = $condition;
|
||||
break;
|
||||
case 3:$where['mobile'] = $condition;
|
||||
break;
|
||||
case 4:$where['id'] = $condition;
|
||||
break;
|
||||
default:
|
||||
return ['status' => false, 'msg' => '参数错误', 'id' => 0]; //参数错误
|
||||
}
|
||||
/* 获取用户数据 */
|
||||
$row = $this->where($where)->field('id,customername,password,salt,picture,position,role_id,stat,last_login_time')->find();
|
||||
if (empty($row) || (int) $row->stat !== 1) {
|
||||
return ['status' => false, 'msg' => '用户不存在或被禁用', 'id' => 0];
|
||||
}
|
||||
/* 验证用户密码 */
|
||||
if (md5($password) !== $row->password) {
|
||||
return ['status' => false, 'msg' => '密码错误', 'id' => 0];
|
||||
}
|
||||
unset($row->password);
|
||||
unset($row->salt);
|
||||
/* 登录用户 */
|
||||
$this->autoLogin($row->toArray());
|
||||
return ['status' => false, 'msg' => '登录成功', 'id' => $row->id]; //登录成功,返回用户ID
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动登录用户
|
||||
* @param integer $row 用户信息数组
|
||||
*/
|
||||
private function autoLogin($row) {
|
||||
/* 更新登录信息 */
|
||||
$data = [
|
||||
'id' => $row['id'],
|
||||
//'login' => \think\Db::raw('`login`+1'),
|
||||
'last_login_time' => Request::instance()->time(),
|
||||
'last_login_ip' => Request::instance()->ip()
|
||||
];
|
||||
$this::update($data);
|
||||
/* 记录登录SESSION和COOKIES */
|
||||
Session::set('customer_auth', $row);
|
||||
Session::set('customer_auth_sign', data_auth_sign($row));
|
||||
unset($row);
|
||||
//记录行为
|
||||
// $param = ['action' => 'customer_login', 'model' => 'member', 'record_id' => $row['id']];
|
||||
// Hook::listen('customer_behavior', $param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销当前用户
|
||||
* @return void
|
||||
*/
|
||||
public function logout() {
|
||||
Session::delete('customer_auth', null);
|
||||
Session::delete('customer_auth_sign', null);
|
||||
}
|
||||
|
||||
protected function setRegisterTimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setLastLoginTimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setLastUpdateTimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setRegisterIpAttr() {
|
||||
return Request::instance()->ip();
|
||||
}
|
||||
|
||||
}
|
||||
47
app/admin/model/CustomerGroup.php
Executable file
47
app/admin/model/CustomerGroup.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class CustomerGroup extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = 20) {
|
||||
$options = '';
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['gt', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
protected function setNameAttr($value) {
|
||||
return htmlspecialchars($value);
|
||||
}
|
||||
|
||||
}
|
||||
214
app/admin/model/Dept.php
Executable file
214
app/admin/model/Dept.php
Executable file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
use think\Session;
|
||||
|
||||
class Dept extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
public function getDeptLists($where = null, $order = null, $field = null, $limit = null, $level = 0, array &$alldata = array()) {
|
||||
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) {
|
||||
$row['level'] = $level;
|
||||
$alldata[] = $row;
|
||||
$where['pid'] = $row['id'];
|
||||
!$row['haschild'] ? '' : self::getDeptLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
}
|
||||
}
|
||||
return $alldata;
|
||||
}
|
||||
|
||||
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
|
||||
$options = '';
|
||||
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 ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options .= '<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
$options = '';
|
||||
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) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('    ', $level) . '⌊' : '' ) . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('    ', $level) . '⌊' : '' ) . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
$where['pid'] = $row['id'];
|
||||
$options.=!$row['haschild'] ? '' : self::getOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getDeptTree($where = null, $order = null, $field = null, $limit = 50, $level = 0) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
$result = array();
|
||||
if ($level > 5) {
|
||||
return $result;
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select(); // 获取
|
||||
if ($list) {
|
||||
foreach ($list as $row) {
|
||||
$row['level'] = $level;
|
||||
$where['pid'] = $row['id'];
|
||||
$row['child'] = !$row['haschild'] ? [] : self:: getDeptTree($where, $order, $field, $limit, $level + 1);
|
||||
$result[] = $row->toArray();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getMenu($where = null, $order = null, $field = null, $limit = 50, $level = 0) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
$result = array();
|
||||
if ($level > 5) {
|
||||
return $result;
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select(); // 获取
|
||||
if ($list) {
|
||||
foreach ($list as $row) {
|
||||
$row['level'] = $level;
|
||||
$where['pid'] = $row['id'];
|
||||
$row['child'] = !$row['haschild'] ? [] : self::getMenu($where, $order, $field, $limit, $level + 1);
|
||||
$result[] = $row->toArray();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getChildIDArray($id) {
|
||||
$list = $this->where([ 'pid' => $id, 'stat' => 0])->field(['id', 'haschild'])->select();
|
||||
$childIDArray = array((int) $id);
|
||||
if ($list) {
|
||||
foreach ($list as $val) {
|
||||
$childArray = $val['haschild'] ? self::getChildIDArray($val['id']) : array((int)
|
||||
$val['id']);
|
||||
$childIDArray = array_merge($childIDArray, $childArray);
|
||||
}
|
||||
}
|
||||
return $childIDArray;
|
||||
}
|
||||
|
||||
public function getTopParentID($id, $where = null) {
|
||||
$data = $this::get(function($query)use($id, $where) {
|
||||
$query->where(['id' => $id]);
|
||||
if ($where) {
|
||||
$query->where($where);
|
||||
}
|
||||
$query->field(['id', 'pid']);
|
||||
});
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
$topid = self::getTopParentID($data['pid'], $where);
|
||||
} else {
|
||||
$topid = $id;
|
||||
}
|
||||
return $topid;
|
||||
}
|
||||
|
||||
public function deleteRow($id, $stat = -1) {
|
||||
//$result = $this::destroy($id);
|
||||
$data = ['id' => $id, 'pid' => 0, 'haschild' => 0, 'stat' => $stat,];
|
||||
$object = $this::update($data);
|
||||
return $object;
|
||||
}
|
||||
|
||||
protected function setUrlAttr($value, $data) {
|
||||
return trim($value, '/');
|
||||
}
|
||||
|
||||
}
|
||||
113
app/admin/model/Download.php
Executable file
113
app/admin/model/Download.php
Executable file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Download extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime', 'updatetime'];
|
||||
protected $update = ['updatetime'];
|
||||
|
||||
public function getCategoryDownloadList($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('download_category c', 'a.cid=c.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['eq', '0'], 'c.stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$data = $this->select();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getCategoryDownloadLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')
|
||||
->join('download_category c', 'a.cid=c.id', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
//$this->where('c.stat', ['eq', '0'], ['null', ''], 'or');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['eq', '0'], 'c.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');
|
||||
}
|
||||
// $this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getRecycleLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')
|
||||
->join('download_category c', 'a.cid=c.id', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
// 属性修改器 更新时间
|
||||
protected function setUpdatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
// 属性修改器 设置注册ip
|
||||
protected function setIpAttr() {
|
||||
return Request::instance()->ip();
|
||||
}
|
||||
|
||||
protected function setContentAttr($content, $data) {
|
||||
if (!empty($content)) {
|
||||
$config = \HTMLPurifier_Config::createDefault();
|
||||
$purifier = new \HTMLPurifier($config);
|
||||
$content = $purifier->purify($content);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
220
app/admin/model/DownloadCategory.php
Executable file
220
app/admin/model/DownloadCategory.php
Executable file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class DownloadCategory extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getCategoryLists($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) {
|
||||
$row['level'] = $level;
|
||||
$alldata[] = $row;
|
||||
$where['pid'] = $row['id'];
|
||||
//self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
!$row['haschild'] ? '' : self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
}
|
||||
}
|
||||
return $alldata;
|
||||
}
|
||||
|
||||
public function getChildIDArray($id) {
|
||||
$list = $this->where(['pid' => $id, 'stat' => 0])->field(['id', 'haschild'])->select();
|
||||
$childIDArray = array((int) $id);
|
||||
if ($list) {
|
||||
foreach ($list as $val) {
|
||||
$childArray = $val['haschild'] ? self::getChildIDArray($val['id']) : array((int) $val['id']);
|
||||
$childIDArray = array_merge($childIDArray, $childArray);
|
||||
}
|
||||
}
|
||||
return $childIDArray;
|
||||
}
|
||||
|
||||
public function getTopParentID($id, $where = null) {
|
||||
$data = $this::get(function($query)use($id, $where) {
|
||||
$query->where(['id' => $id]);
|
||||
if ($where) {
|
||||
$query->where($where);
|
||||
}
|
||||
$query->field(['id', 'pid']);
|
||||
});
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
$topid = self::getTopParentID($data['pid'], $where);
|
||||
} else {
|
||||
$topid = $id;
|
||||
}
|
||||
return $topid;
|
||||
}
|
||||
|
||||
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
|
||||
if (!$id) {
|
||||
return array();
|
||||
}
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
$data = $this->field(['id', 'name', 'pid'])->get($id);
|
||||
$catarr[] = $data;
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
self::getBreadCrumb($data['pid'], $where, $catarr);
|
||||
} else {
|
||||
return array_reverse($catarr);
|
||||
}
|
||||
return $catarr;
|
||||
}
|
||||
|
||||
public function getCategoryOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
|
||||
$options = '';
|
||||
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 ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getCategoryOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
|
||||
$options = '';
|
||||
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) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
$where['pid'] = $row['id'];
|
||||
//$options.=self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
$options.=!$row['haschild'] ? '' : self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getCategoryTree($where = null, $order = null, $field = null, $limit = 50, $level = 0) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
$result = array();
|
||||
if ($level > 5) {
|
||||
return $result;
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select(); // 获取
|
||||
if ($list) {
|
||||
foreach ($list as $row) {
|
||||
$row['level'] = $level;
|
||||
$where['pid'] = $row['id'];
|
||||
//$row['child'] = self::getCategoryTree($where, $order, $field, $limit, $level + 1);
|
||||
$row['child'] = !$row['haschild'] ? array() : self::getCategoryTree($where, $order, $field, $limit, $level + 1);
|
||||
$result[] = $row;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function deleteRow($id, $stat = -1) {
|
||||
//$result = $this::destroy($id);
|
||||
$data = ['id' => $id, 'pid' => 0, 'haschild' => 0, 'stat' => $stat,];
|
||||
$object = $this::update($data);
|
||||
return $object;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
46
app/admin/model/Flink.php
Executable file
46
app/admin/model/Flink.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Flink extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
protected $update = [];
|
||||
|
||||
public function getFlinkLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('b')->join('flink_type bt', 'b.typeid=bt.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['b.stat' => 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');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
137
app/admin/model/FlinkType.php
Executable file
137
app/admin/model/FlinkType.php
Executable file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class FlinkType extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
public function getFlinkTypeLists($where = null, $order = null, $field = null, $limit = null, $level = 0, array &$alldata = array()) {
|
||||
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);
|
||||
}
|
||||
$flinktypes = $this->select();
|
||||
if ($flinktypes) {
|
||||
foreach ($flinktypes as $k => $flinktype) {
|
||||
$flinktype['level'] = $level;
|
||||
$alldata[] = $flinktype;
|
||||
$where['pid'] = $flinktype['id'];
|
||||
self::getFlinkTypeLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
}
|
||||
}
|
||||
return $alldata;
|
||||
}
|
||||
|
||||
public function getChildIDArray($id) {
|
||||
$list = $this->where(['pid' => $id])->field('id')->select();
|
||||
$childIDArray = array((int) $id);
|
||||
if ($list) {
|
||||
foreach ($list as $val) {
|
||||
$childArray = self::getChildIDArray($val['id']);
|
||||
$childIDArray = array_merge($childIDArray, $childArray);
|
||||
}
|
||||
}
|
||||
return $childIDArray;
|
||||
}
|
||||
|
||||
public function getTopParentID($id, $where = null) {
|
||||
$data = $this::get(function($query)use($id, $where) {
|
||||
$query->where(['id' => $id]);
|
||||
if ($where) {
|
||||
$query->where($where);
|
||||
}
|
||||
$query->field(['id', 'pid']);
|
||||
});
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
$topid = self::getTopParentID($data['pid'], $where);
|
||||
} else {
|
||||
$topid = $id;
|
||||
}
|
||||
return $topid;
|
||||
}
|
||||
|
||||
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = 20) {
|
||||
$options = '';
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getOptions($id = 0, $where = null, $order = null, $field = null, $limit = 20, $level = 0) {
|
||||
$options = '';
|
||||
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) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
$where['pid'] = $row['id'];
|
||||
$options.=self::getOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
12
app/admin/model/Fq.php
Executable file
12
app/admin/model/Fq.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Fq extends Model {
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
}
|
||||
84
app/admin/model/Inquiry.php
Executable file
84
app/admin/model/Inquiry.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Inquiry extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getInquiryLists($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 getInquiryList($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;
|
||||
}
|
||||
|
||||
}
|
||||
36
app/admin/model/Job.php
Executable file
36
app/admin/model/Job.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
|
||||
class Job extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
|
||||
public function getJobLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
||||
32
app/admin/model/Msgform.php
Executable file
32
app/admin/model/Msgform.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Msgform extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['stat' => 0, 'ip', 'createtime'];
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
if (empty($value)) {
|
||||
return time();
|
||||
} else {
|
||||
return strtotime($value);
|
||||
}
|
||||
}
|
||||
|
||||
protected function setContentAttr($value) {
|
||||
return htmlspecialchars($value);
|
||||
}
|
||||
|
||||
protected function setIpAttr() {
|
||||
return Request::instance()->ip();
|
||||
}
|
||||
|
||||
}
|
||||
71
app/admin/model/Navigation.php
Executable file
71
app/admin/model/Navigation.php
Executable file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Navigation extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime','updatetime'];
|
||||
protected $update = ['updatetime'];
|
||||
|
||||
public function getNavigationList($where = null, $order = null, $field = null, $limit = null) {
|
||||
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['in', '0,1']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$data = $this->select();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getNavigationLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['in', '0,1']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
if (empty($value)) {
|
||||
return time();
|
||||
} else {
|
||||
return strtotime($value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
23
app/admin/model/Pinglun.php
Executable file
23
app/admin/model/Pinglun.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Pinglun extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['stat' => 0, 'ip'];
|
||||
|
||||
protected function setContentAttr($value) {
|
||||
return htmlspecialchars($value);
|
||||
}
|
||||
|
||||
protected function setIpAttr() {
|
||||
return Request::instance()->ip();
|
||||
}
|
||||
|
||||
}
|
||||
293
app/admin/model/Product.php
Executable file
293
app/admin/model/Product.php
Executable file
@@ -0,0 +1,293 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Product extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime', 'updatetime'];
|
||||
protected $update = ['updatetime'];
|
||||
|
||||
public function getCategoryProductList($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('product_category c', 'a.cid=c.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['eq', '0'], 'c.stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$data = $this->select();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getProductLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')
|
||||
// ->join('product_category c', 'a.cid=c.id', 'LEFT');
|
||||
->join('product_category c', 'a.cid=c.id AND c.stat=0', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
//$this->where('c.stat', ['eq', '0'], ['null', ''], 'or');
|
||||
if (is_array($where)) {
|
||||
// $where = array_merge(['a.stat' => ['eq', '0'], 'c.stat' => ['eq', '0']], $where);
|
||||
$where = array_merge(['a.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');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getRelatedProductList($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('p')->join('product_related pr', 'p.id=pr.related_product_id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['p.stat' => ['eq', '0'], 'pr.stat' => ['eq', '0'], 'pr.product_id' => '0'], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$data = $this->select();
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getAllCate($pid, &$cate_name='') {
|
||||
if ($pid) {
|
||||
$cate_info = model('product_category')->field('name, pid')->find($pid);
|
||||
if ($cate_name == '') {
|
||||
$cate_name = $cate_info['name'];
|
||||
} else {
|
||||
$cate_name = $cate_info['name'] . '->' . $cate_name;
|
||||
}
|
||||
self::getAllCate($cate_info['pid'], $cate_name);
|
||||
}
|
||||
return $cate_name;
|
||||
}
|
||||
|
||||
public function getExportSearchProductLists($where = null, $order = null, $limit = null, $count = false, $field = '*') {
|
||||
# 是否需要有关联产品
|
||||
$flag2 = 0;
|
||||
# 是否需要有相关驱动
|
||||
$flag3 = 0;
|
||||
# 是否需要有多颜色
|
||||
$flag4 = 0;
|
||||
# 是否需要有二级列表图
|
||||
$flag5 = 0;
|
||||
# 是否需要有链接
|
||||
$flag6 = 0;
|
||||
if (is_array($field)) {
|
||||
foreach ($field as $key => $value) {
|
||||
if ($value == 'a.is_comment') {
|
||||
unset($field[$key]);
|
||||
$flag1 = 1;
|
||||
continue;
|
||||
}
|
||||
if ($value == 'a.related_product') {
|
||||
unset($field[$key]);
|
||||
$flag2 = 1;
|
||||
continue;
|
||||
}
|
||||
if ($value == 'a.driver') {
|
||||
$flag3 = 1;
|
||||
unset($field[$key]);
|
||||
continue;
|
||||
}
|
||||
if ($value == 'a.multi_color') {
|
||||
$flag4 = 1;
|
||||
unset($field[$key]);
|
||||
continue;
|
||||
}
|
||||
if ($value == 'a.is_list2') {
|
||||
$flag5 = 1;
|
||||
unset($field[$key]);
|
||||
continue;
|
||||
}
|
||||
if ($value == 'a.url') {
|
||||
$flag6 = 1;
|
||||
unset($field[$key]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->alias('a')->join('product_category c', 'a.cid = c.id', 'LEFT');
|
||||
|
||||
// if ($flag === 0) {
|
||||
// // 如果不需要有评论的产品列表
|
||||
// $this->alias('a')
|
||||
// ->join('product_category c', 'a.cid = c.id', 'LEFT')
|
||||
// ->join('product_related r', 'a.id=r.related_product_id', 'LEFT')
|
||||
// ->join('product_dl d', 'a.id=d.product_id', 'LEFT');
|
||||
// } else {
|
||||
// // 需要有评论的产品列表
|
||||
// $this->alias('a')
|
||||
// ->join('product_category c', 'a.cid = c.id', 'LEFT')
|
||||
// ->join('product_related r', 'a.id=r.product_id', 'LEFT')
|
||||
// ->join('product_dl d', 'a.id=d.product_id', 'LEFT')
|
||||
// ->join('shopselle s', 'a.id=s.pid', 'RIGHT');
|
||||
// }
|
||||
|
||||
if (is_array($where)) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
//$object->fetchsql(true);
|
||||
if ($count) {
|
||||
$result = $this->count();
|
||||
return $result;
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
if (is_array($limit)) {
|
||||
//$limit = ['offset' => 1, 'length' => 1];
|
||||
$limit = array_values($limit);
|
||||
$this->limit($limit[0], $limit[1]);
|
||||
} else {
|
||||
$this->limit($limit);
|
||||
}
|
||||
}
|
||||
$result = $this->select();
|
||||
foreach ($result as $key => $value) {
|
||||
if($this->getAllCate($value['pid'])) {
|
||||
$result[$key]['categoryname'] = $this->getAllCate($value['pid']) . '->' . $value['categoryname'];
|
||||
}
|
||||
else{
|
||||
$result[$key]['categoryname'] = $value['categoryname'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($result as $key => $value) {
|
||||
if ($flag2 === 1) {
|
||||
// 有关联产品
|
||||
$related_product_list = model('product_related')->alias('a')->join('product b', 'a.related_product_id = b.id', 'LEFT')->where(['a.stat' => 0, 'b.stat' => 0, 'a.product_id' => $value['id']])->field('b.brand_id')->select();
|
||||
if (!empty($related_product_list)) {
|
||||
$related_product = '';
|
||||
foreach ($related_product_list as $k => $v) {
|
||||
$related_product .= $v['brand_id'] . ', ';
|
||||
}
|
||||
$result[$key]['related_product'] = rtrim($related_product, ', ');
|
||||
} else {
|
||||
$result[$key]['related_product'] = '';
|
||||
}
|
||||
|
||||
}
|
||||
if ($flag3 == 1) {
|
||||
// 有相关驱动
|
||||
$driver = model('product_dl')->where(['product_id' => $value['id'], 'stat' => 0])->limit(1)->select();
|
||||
if (!empty($driver)) {
|
||||
$result[$key]['driver'] = 1;
|
||||
} else {
|
||||
$result[$key]['driver'] = 0;
|
||||
}
|
||||
}
|
||||
if ($flag4 == 1) {
|
||||
// 有多颜色
|
||||
$count_product_two_img = model('product_two_img')->where(['product_id' => $value['id'], 'stat' => 0])->count();
|
||||
if ($count_product_two_img > 1) {
|
||||
$result[$key]['multi_color'] = 1;
|
||||
} else {
|
||||
$result[$key]['multi_color'] = 0;
|
||||
}
|
||||
}
|
||||
if ($flag5 == 1) {
|
||||
// 有二级列表图
|
||||
if ($count_product_two_img > 0) {
|
||||
$result[$key]['is_list2'] = 1;
|
||||
} else {
|
||||
$count_product_two_img = model('product_two_img')->where(['product_id' => $value['id'], 'stat' => 0])->count();
|
||||
if ($count_product_two_img > 0) {
|
||||
$result[$key]['is_list2'] = 1;
|
||||
} else {
|
||||
$result[$key]['is_list2'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($flag6 == 1) {
|
||||
// 有链接
|
||||
$result[$key]['url'] = $_SERVER['HTTP_HOST'] . '/product/detail/' . $value['id'] . '.html';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getRecycleLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')
|
||||
->join('product_category c', 'a.cid=c.id', 'LEFT')
|
||||
->join('user u', 'a.id=u.id', 'LEFT');
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
// 属性修改器 更新时间
|
||||
protected function setUpdatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
// 属性修改器 设置注册ip
|
||||
protected function setIpAttr() {
|
||||
return Request::instance()->ip();
|
||||
}
|
||||
|
||||
}
|
||||
20
app/admin/model/ProductBkImg.php
Executable file
20
app/admin/model/ProductBkImg.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: ORICO
|
||||
* Date: 2018-10-22
|
||||
* Time: 11:42
|
||||
*/
|
||||
|
||||
namespace app\admin\model;
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
|
||||
class ProductBkImg extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
|
||||
}
|
||||
247
app/admin/model/ProductCategory.php
Executable file
247
app/admin/model/ProductCategory.php
Executable file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class ProductCategory extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getCategoryLists($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) {
|
||||
$row['level'] = $level;
|
||||
$alldata[] = $row;
|
||||
$where['pid'] = $row['id'];
|
||||
//self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
!$row['haschild'] ? '' : self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
}
|
||||
}
|
||||
return $alldata;
|
||||
}
|
||||
|
||||
public function getCategoryList($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;
|
||||
}
|
||||
|
||||
public function getChildIDArray($id) {
|
||||
$list = $this->where(['pid' => $id, 'stat' => 0])->field(['id', 'haschild'])->select();
|
||||
$childIDArray = array((int) $id);
|
||||
if ($list) {
|
||||
foreach ($list as $val) {
|
||||
$childArray = $val['haschild'] ? self::getChildIDArray($val['id']) : array((int) $val['id']);
|
||||
$childIDArray = array_merge($childIDArray, $childArray);
|
||||
}
|
||||
}
|
||||
return $childIDArray;
|
||||
}
|
||||
|
||||
public function getTopParentID($id, $where = null) {
|
||||
$data = $this::get(function($query)use($id, $where) {
|
||||
$query->where(['id' => $id]);
|
||||
if ($where) {
|
||||
$query->where($where);
|
||||
}
|
||||
$query->field(['id', 'pid']);
|
||||
});
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
$topid = self::getTopParentID($data['pid'], $where);
|
||||
} else {
|
||||
$topid = $id;
|
||||
}
|
||||
return $topid;
|
||||
}
|
||||
|
||||
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
|
||||
if (!$id) {
|
||||
return array();
|
||||
}
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
$data = $this->field(['id', 'name', 'pid'])->get($id);
|
||||
$catarr[] = $data;
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
self::getBreadCrumb($data['pid'], $where, $catarr);
|
||||
} else {
|
||||
return array_reverse($catarr);
|
||||
}
|
||||
return $catarr;
|
||||
}
|
||||
|
||||
public function getCategoryOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
|
||||
$options = '';
|
||||
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 ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getCategoryOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
|
||||
$options = '';
|
||||
$disable = '';
|
||||
$separator = '';
|
||||
$selected = '';
|
||||
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) {
|
||||
if ($level) {
|
||||
$separator = str_repeat('    ', $level);
|
||||
} else {
|
||||
// $controller = Request::instance()->controller();
|
||||
// $disable = $controller == 'ProductCategory' ? '' : ' disabled="disabled"';
|
||||
}
|
||||
foreach ($list as $k => $row) {
|
||||
$selected = ($row['id'] == $id) ? ' selected="selected"' : '';
|
||||
$options.='<option value="' . $row['id'] . '"' . $disable . $selected . '>' . $separator . $row['name'] . '</option>' . "\n";
|
||||
$where['pid'] = $row['id'];
|
||||
//$options.=self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
$options.=!$row['haschild'] ? '' : self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getCategoryTree($where = null, $order = null, $field = null, $limit = 50, $level = 0) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
$result = array();
|
||||
if ($level > 5) {
|
||||
return $result;
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select(); // 获取
|
||||
if ($list) {
|
||||
foreach ($list as $row) {
|
||||
$row['level'] = $level;
|
||||
$where['pid'] = $row['id'];
|
||||
//$row['child'] = self::getCategoryTree($where, $order, $field, $limit, $level + 1);
|
||||
$row['child'] = !$row['haschild'] ? array() : self::getCategoryTree($where, $order, $field, $limit, $level + 1);
|
||||
$result[] = $row;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function deleteRow($id, $stat = -1) {
|
||||
//$result = $this::destroy($id);
|
||||
$data = ['id' => $id, 'pid' => 0, 'haschild' => 0, 'stat' => $stat,];
|
||||
$object = $this::update($data);
|
||||
return $object;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
12
app/admin/model/ProductDl.php
Executable file
12
app/admin/model/ProductDl.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class ProductDl extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
}
|
||||
12
app/admin/model/ProductImage.php
Executable file
12
app/admin/model/ProductImage.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class ProductImage extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
}
|
||||
12
app/admin/model/ProductRelated.php
Executable file
12
app/admin/model/ProductRelated.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class ProductRelated extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
}
|
||||
207
app/admin/model/ProductSeries.php
Normal file
207
app/admin/model/ProductSeries.php
Normal file
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class ProductSeries extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getSeriesLists($where = null, $order = null, $field = null, $limit = null, array &$alldata = array()) {
|
||||
|
||||
|
||||
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) {
|
||||
$row['level'] = $level;
|
||||
$alldata[] = $row;
|
||||
|
||||
}
|
||||
}
|
||||
return $alldata;
|
||||
}
|
||||
|
||||
public function getSeriesList($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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
|
||||
if (!$id) {
|
||||
return array();
|
||||
}
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
$data = $this->field(['id', 'name'])->get($id);
|
||||
$catarr[] = $data;
|
||||
|
||||
|
||||
return $catarr;
|
||||
}
|
||||
|
||||
public function getSeriesOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
|
||||
$options = '';
|
||||
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 ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getSeriesOptions($where = null, $order = null, $field = null, $limit = null, $id = 0) {
|
||||
$options = '';
|
||||
$disable = '';
|
||||
$separator = '';
|
||||
$selected = '';
|
||||
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) {
|
||||
if (is_array($id)) {
|
||||
$selected = in_array($row['id'], $id) ? ' selected="selected"' : '';
|
||||
} else {
|
||||
$selected = ($row['id'] == $id) ? ' selected="selected"' : '';
|
||||
}
|
||||
$options.='<option value="' . $row['id'] . '"' . $disable . $selected . '>' . $separator . $row['name'] . '</option>' . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getSeriesTree($where = null, $order = null, $field = null, $limit = 50) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
$result = array();
|
||||
if ($level > 5) {
|
||||
return $result;
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select(); // 获取
|
||||
if ($list) {
|
||||
foreach ($list as $row) {
|
||||
$result[] = $row;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function deleteRow($id, $stat = -1) {
|
||||
//$result = $this::destroy($id);
|
||||
$data = ['id' => $id, 'stat' => $stat,];
|
||||
$object = $this::update($data);
|
||||
return $object;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
12
app/admin/model/ProductSku.php
Executable file
12
app/admin/model/ProductSku.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class ProductSku extends Model {
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
}
|
||||
18
app/admin/model/ProductTwoImg.php
Executable file
18
app/admin/model/ProductTwoImg.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: ORICO
|
||||
* Date: 2018-10-22
|
||||
* Time: 10:37
|
||||
*/
|
||||
|
||||
namespace app\admin\model;
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class ProductTwoImg extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
}
|
||||
29
app/admin/model/Question.php
Executable file
29
app/admin/model/Question.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Question extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
// 属性修改器 创建时间
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
14
app/admin/model/QuestionCategory.php
Executable file
14
app/admin/model/QuestionCategory.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class QuestionCategory extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
|
||||
}
|
||||
12
app/admin/model/Report.php
Executable file
12
app/admin/model/Report.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Report extends Model {
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
}
|
||||
11
app/admin/model/Shopselle.php
Executable file
11
app/admin/model/Shopselle.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Shopselle extends Model {
|
||||
use \app\common\traits\AdminModel;
|
||||
}
|
||||
163
app/admin/model/Singlepage.php
Executable file
163
app/admin/model/Singlepage.php
Executable file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Singlepage extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
public function getSinglepageLists($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) {
|
||||
$row['level'] = $level;
|
||||
$alldata[] = $row;
|
||||
$where['pid'] = $row['id'];
|
||||
self::getSinglepageLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
}
|
||||
}
|
||||
return $alldata;
|
||||
}
|
||||
|
||||
public function getChildIDArray($id) {
|
||||
$list = $this->where(['pid' => $id])->field('id')->select();
|
||||
$childIDArray = array((int) $id);
|
||||
if ($list) {
|
||||
foreach ($list as $val) {
|
||||
$childArray = self::getChildIDArray($val['id']);
|
||||
$childIDArray = array_merge($childIDArray, $childArray);
|
||||
}
|
||||
}
|
||||
return $childIDArray;
|
||||
}
|
||||
|
||||
public function getTopParentID($id, $where = null) {
|
||||
$data = $this::get(function($query)use($id, $where) {
|
||||
$query->where(['id' => $id]);
|
||||
if ($where) {
|
||||
$query->where($where);
|
||||
}
|
||||
$query->field(['id', 'pid']);
|
||||
});
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
$topid = self::getTopParentID($data['pid'], $where);
|
||||
} else {
|
||||
$topid = $id;
|
||||
}
|
||||
return $topid;
|
||||
}
|
||||
|
||||
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
|
||||
if (!$id) {
|
||||
return array();
|
||||
}
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
$data = $this->field(['id', 'name', 'pid'])->get($id);
|
||||
$catarr[] = $data;
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
self::getBreadCrumb($data['pid'], $where, $catarr);
|
||||
} else {
|
||||
return array_reverse($catarr);
|
||||
}
|
||||
return $catarr;
|
||||
}
|
||||
|
||||
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = 20) {
|
||||
$options = '';
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
|
||||
$options = '';
|
||||
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) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
$where['pid'] = $row['id'];
|
||||
$options.=self::getOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
150
app/admin/model/Sysconfig.php
Executable file
150
app/admin/model/Sysconfig.php
Executable file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Sysconfig extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['stat' => 0,];
|
||||
|
||||
/**
|
||||
* 获取数据库中的配置列表
|
||||
* @return array 配置数组
|
||||
*/
|
||||
public function getGroupLists($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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库中的配置列表
|
||||
* @return array 配置数组
|
||||
*/
|
||||
public function getPageLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => 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');
|
||||
}
|
||||
$object = $this->paginate($limit);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库中的配置列表
|
||||
* @return array 配置数组
|
||||
*/
|
||||
public function configLists($where = null) {
|
||||
$this->where(['stat' => 0])->field('type,name,value,extra');
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
$this->order(['sort' => 'asc', 'id' => 'asc']);
|
||||
$data = $this->select();
|
||||
$config = [];
|
||||
if ($data && is_array($data)) {
|
||||
foreach ($data as $value) {
|
||||
$config[$value->data['name']] = self::parse($value->data['type'], $value->data['value'], $value->data['extra']);
|
||||
}
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据配置类型解析配置
|
||||
* @param integer $type 配置类型
|
||||
* @param string $value 配置值
|
||||
* @param string $extra 配置项
|
||||
*/
|
||||
private function parse($type, $value, $extra = '') {
|
||||
switch ($type) {
|
||||
// case 'number':
|
||||
// $value = intval($value);
|
||||
// break;
|
||||
case 'json':
|
||||
$value = json_decode($value, true);
|
||||
break;
|
||||
case 'array': //解析数组
|
||||
$array = preg_split('/[,;\r\n]+/', trim($value, ",;\r\n"));
|
||||
if (strpos($value, ':')) {
|
||||
$value = array();
|
||||
foreach ($array as $val) {
|
||||
list($k, $v) = explode(':', $val);
|
||||
$value[$k] = $v;
|
||||
}
|
||||
} else {
|
||||
$value = $array;
|
||||
}
|
||||
break;
|
||||
// case 'enum': //解析数组
|
||||
// $array = preg_split('/[,;\r\n]+/', trim($extra, ",;\r\n"));
|
||||
// if (strpos($value, ':')) {
|
||||
// $valarr = array();
|
||||
// foreach ($array as $val) {
|
||||
// list($k, $v) = explode(':', $val);
|
||||
// $valarr[$k] = $v;
|
||||
// }
|
||||
// } else {
|
||||
// $valarr = $array;
|
||||
// }
|
||||
// $value = isset($valarr[$value]) ? $valarr[$value] : $value;
|
||||
// break;
|
||||
case 'dump':
|
||||
dump($value);
|
||||
// die;
|
||||
break;
|
||||
default:
|
||||
//dump($value);
|
||||
// die;
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置标识转为小写
|
||||
* @param 类型 参数 参数说明
|
||||
*/
|
||||
protected function setNameAttr($value) {
|
||||
return strtolower($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置名称过滤
|
||||
* @param 类型 参数 参数说明
|
||||
*/
|
||||
protected function setTitleAttr($value) {
|
||||
return htmlspecialchars($value);
|
||||
}
|
||||
|
||||
}
|
||||
18
app/admin/model/Tbpl.php
Executable file
18
app/admin/model/Tbpl.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: ORICO
|
||||
* Date: 2019-01-07
|
||||
* Time: 10:10
|
||||
*/
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
class Tbpl extends Model
|
||||
{
|
||||
use \app\common\traits\AdminModel;
|
||||
}
|
||||
243
app/admin/model/User.php
Executable file
243
app/admin/model/User.php
Executable file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
use think\Session;
|
||||
|
||||
class User extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['stat' => 0, 'register_time', 'register_ip', 'last_update_time'];
|
||||
protected $update = ['last_update_time'];
|
||||
|
||||
public function getRoleUsers($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('u')->join('auth_role ar', 'u.role_id=ar.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge([], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
$this->group('u.id');
|
||||
//$this->having('max(ud.dept_id)');
|
||||
$object = $this->paginate($limit);
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getPageLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('u')->join('user_role ur', 'u.role_id=ur.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['u.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');
|
||||
}
|
||||
$object = $this->paginate($limit);
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
|
||||
$options = '';
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
//$options = '<option value="0">请选择...</option>' . "\n";
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['username'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['username'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function insertRow($data, $siteid = 32267) {
|
||||
$row = array(
|
||||
'username' => $data['username'],
|
||||
'email' => $data['email'],
|
||||
'role_id' => $data['role_id'],
|
||||
'stat' => $data['stat'],
|
||||
);
|
||||
if (isset($data['password'])) {
|
||||
//$salt = getstr_random();
|
||||
//$row['password'] = md5($data['password'] . $salt);
|
||||
$row['salt'] = $data['password'];
|
||||
$row['password'] = md5($data['password']);
|
||||
}
|
||||
if (isset($data['picture'])) {
|
||||
$row['picture'] = $data['picture'];
|
||||
}
|
||||
if (!isset($data['position'])) {
|
||||
$row['position'] = 'admin';
|
||||
}
|
||||
$row['siteid'] = $siteid;
|
||||
$object = $this::create($row);
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function updateRow($data = [], $where = [], $field = null) {
|
||||
if (isset($data['id'])) {
|
||||
$row['id'] = $data['id'];
|
||||
}
|
||||
if (isset($data['username'])) {
|
||||
$row['username'] = $data['username'];
|
||||
}
|
||||
if (isset($data['role_id'])) {
|
||||
$row['role_id'] = $data['role_id'];
|
||||
}
|
||||
if (isset($data['stat'])) {
|
||||
$row['stat'] = $data['stat'];
|
||||
}
|
||||
if (isset($data['position'])) {
|
||||
$row['position'] = $data['position'];
|
||||
}
|
||||
if (isset($data['email'])) {
|
||||
$row['email'] = $data['email'];
|
||||
}
|
||||
if (isset($data['picture'])) {
|
||||
$row['picture'] = $data['picture'];
|
||||
}
|
||||
$object = $this::update($row, $where, $field);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户密码
|
||||
*/
|
||||
public function updatePassword($data) {
|
||||
//$salt = getstr_random();
|
||||
$row = array(
|
||||
'id' => $data['id'],
|
||||
//'password' => md5($data['newpassword'] . $salt),
|
||||
'salt' => $data['newpassword'],
|
||||
'password' => md5($data['newpassword']),
|
||||
);
|
||||
$object = $this::update($row);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录认证
|
||||
* @param string $condition 验证条件如用户名邮箱手机号ID
|
||||
* @param string $password 用户密码
|
||||
* @param integer $type 用户名类型 (1-用户名,2-邮箱,3-手机,4-UID)
|
||||
* @return integer 登录成功-用户ID,登录失败-错误编号
|
||||
*/
|
||||
public function login($condition, $password, $type = 1) {
|
||||
$where = [];
|
||||
switch ($type) {
|
||||
case 1:$where['username'] = $condition;
|
||||
break;
|
||||
case 2:$where['email'] = $condition;
|
||||
break;
|
||||
case 3:$where['mobile'] = $condition;
|
||||
break;
|
||||
case 4:$where['id'] = $condition;
|
||||
break;
|
||||
default:
|
||||
action_log('登录失败', '提交参数错误 被序列化的信息:' . serialize(Request::instance()->request()), -1, Request::instance()->header());
|
||||
return ['status' => false, 'msg' => '参数错误', 'id' => 0]; //参数错误
|
||||
}
|
||||
/* 获取用户数据 */
|
||||
$row = $this->where($where)->find();
|
||||
if (empty($row) || (int) $row->stat < 0) {
|
||||
action_log('登录失败', '用户不存在或被禁用 被序列化的信息:' . serialize(Request::instance()->request()), -1, Request::instance()->header());
|
||||
return ['status' => false, 'msg' => '用户不存在或被禁用', 'id' => 0];
|
||||
}
|
||||
/* 验证用户密码 */
|
||||
if (md5($password) !== $row->password) {
|
||||
action_log('登录失败', '密码错误 被序列化的信息:' . serialize(Request::instance()->request()), -1, Request::instance()->header());
|
||||
return ['status' => false, 'msg' => '密码错误', 'id' => 0];
|
||||
}
|
||||
unset($row->password);
|
||||
unset($row->salt);
|
||||
/* 登录用户 */
|
||||
$this->autoLogin($row->toArray());
|
||||
return ['status' => true, 'msg' => '登录成功', 'id' => $row->id]; //登录成功,返回用户ID
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动登录用户
|
||||
* @param integer $row 用户信息数组
|
||||
*/
|
||||
private function autoLogin($row) {
|
||||
/* 更新登录信息 */
|
||||
$data = [
|
||||
'id' => $row['id'],
|
||||
'login' => \think\Db::raw('`login`+1'),
|
||||
'last_login_time' => Request::instance()->time(),
|
||||
'last_login_ip' => Request::instance()->ip()
|
||||
];
|
||||
$this::update($data);
|
||||
$fields = ['id', 'username', 'email', 'picture', 'last_login_time', 'role_id', 'stat', 'siteid'];
|
||||
foreach ($fields as $field) {
|
||||
$session_user[$field] = $row[$field];
|
||||
}
|
||||
/* 记录登录SESSION和COOKIES */
|
||||
Session::set('user_auth', $session_user);
|
||||
Session::set('user_auth_sign', data_auth_sign($session_user));
|
||||
$content = '用户' . $row['username'] . '(' . $row['id'] . ')上次登录时间:' . date('Y-m-d H:i:s', $row['last_login_time']) . ',上次登录IP:' . $row['last_login_ip'];
|
||||
action_log('登录成功', $content, $row['id'], Request::instance()->header());
|
||||
unset($row);
|
||||
//记录行为
|
||||
//$param = ['action' => 'user_login', 'model' => 'member', 'record_id' => $row['id']];
|
||||
//Hook::listen('user_behavior', $param);
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
Session::delete('user_auth', null);
|
||||
Session::delete('user_auth_sign', null);
|
||||
}
|
||||
|
||||
protected function setRegisterTimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setLastLoginTimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setLastUpdateTimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setRegisterIpAttr() {
|
||||
return Request::instance()->ip();
|
||||
}
|
||||
|
||||
}
|
||||
44
app/admin/model/UserRole.php
Executable file
44
app/admin/model/UserRole.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class UserRole extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = 0) {
|
||||
$options = '';
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
protected function setNameAttr($value) {
|
||||
return htmlspecialchars($value);
|
||||
}
|
||||
|
||||
}
|
||||
144
app/admin/model/Video.php
Executable file
144
app/admin/model/Video.php
Executable file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class Video extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime', 'updatetime'];
|
||||
protected $update = ['updatetime'];
|
||||
|
||||
public function getCategoryVideoList($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')->join('video_category c', 'a.cid=c.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['eq', '0'], 'c.stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$data = $this->select();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getCategoryVideoLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')
|
||||
->join('video_category c', 'a.cid=c.id', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['eq', '0'], 'c.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');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getExportSearchProductLists($where = null, $order = null, $limit = null, $count = false, $field = '*') {
|
||||
$this->alias('a')->join('video_category c', 'a.cid=c.id', 'LEFT');
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['a.stat' => ['eq', '0'], 'c.stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($count) {
|
||||
$result = $this->count();
|
||||
return $result;
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
if (is_array($limit)) {
|
||||
//$limit = ['offset' => 1, 'length' => 1];
|
||||
$limit = array_values($limit);
|
||||
$this->limit($limit[0], $limit[1]);
|
||||
} else {
|
||||
$this->limit($limit);
|
||||
}
|
||||
}
|
||||
$result = $this->select();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getRecycleLists($where = null, $order = null, $field = null, $limit = null) {
|
||||
$this->alias('a')
|
||||
->join('video_category c', 'a.cid=c.id', 'LEFT');
|
||||
//->join('user u', 'a.id=u.id', 'LEFT');
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if (empty($limit)) {
|
||||
$limit = Config::get('list_rows');
|
||||
}
|
||||
//$this->fetchsql(true);
|
||||
$object = $this->paginate($limit);
|
||||
// header("content-type:text/html;charset=utf8;");
|
||||
// print_r($object);
|
||||
// exit;
|
||||
return $object;
|
||||
}
|
||||
|
||||
// 属性修改器 创建时间
|
||||
protected function setCreatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
// 属性修改器 更新时间
|
||||
protected function setUpdatetimeAttr($value, $data) {
|
||||
return time();
|
||||
}
|
||||
|
||||
// 属性修改器 设置注册ip
|
||||
protected function setIpAttr() {
|
||||
return Request::instance()->ip();
|
||||
}
|
||||
|
||||
protected function setContentAttr($content, $data) {
|
||||
if (!empty($content)) {
|
||||
$config = \HTMLPurifier_Config::createDefault();
|
||||
$purifier = new \HTMLPurifier($config);
|
||||
$content = $purifier->purify($content);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
220
app/admin/model/VideoCategory.php
Executable file
220
app/admin/model/VideoCategory.php
Executable file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
class VideoCategory extends Model {
|
||||
|
||||
use \app\common\traits\AdminModel;
|
||||
|
||||
protected $insert = ['createtime'];
|
||||
|
||||
//protected $update = [];
|
||||
|
||||
|
||||
public function getCategoryLists($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) {
|
||||
$row['level'] = $level;
|
||||
$alldata[] = $row;
|
||||
$where['pid'] = $row['id'];
|
||||
//self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
!$row['haschild'] ? '' : self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
|
||||
}
|
||||
}
|
||||
return $alldata;
|
||||
}
|
||||
|
||||
public function getChildIDArray($id) {
|
||||
$list = $this->where(['pid' => $id, 'stat' => 0])->field(['id', 'haschild'])->select();
|
||||
$childIDArray = array((int) $id);
|
||||
if ($list) {
|
||||
foreach ($list as $val) {
|
||||
$childArray = $val['haschild'] ? self::getChildIDArray($val['id']) : array((int) $val['id']);
|
||||
$childIDArray = array_merge($childIDArray, $childArray);
|
||||
}
|
||||
}
|
||||
return $childIDArray;
|
||||
}
|
||||
|
||||
public function getTopParentID($id, $where = null) {
|
||||
$data = $this::get(function($query)use($id, $where) {
|
||||
$query->where(['id' => $id]);
|
||||
if ($where) {
|
||||
$query->where($where);
|
||||
}
|
||||
$query->field(['id', 'pid']);
|
||||
});
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
$topid = self::getTopParentID($data['pid'], $where);
|
||||
} else {
|
||||
$topid = $id;
|
||||
}
|
||||
return $topid;
|
||||
}
|
||||
|
||||
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
|
||||
if (!$id) {
|
||||
return array();
|
||||
}
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
$data = $this->field(['id', 'name', 'pid'])->get($id);
|
||||
$catarr[] = $data;
|
||||
if (isset($data['pid']) && $data['pid']) {
|
||||
self::getBreadCrumb($data['pid'], $where, $catarr);
|
||||
} else {
|
||||
return array_reverse($catarr);
|
||||
}
|
||||
return $catarr;
|
||||
}
|
||||
|
||||
public function getCategoryOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
|
||||
$options = '';
|
||||
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 ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select();
|
||||
if ($list) {
|
||||
foreach ($list as $k => $row) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getCategoryOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
|
||||
$options = '';
|
||||
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) {
|
||||
if ($row['id'] == $id) {
|
||||
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
} else {
|
||||
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('    ', $level) . '⌊' : '') . $row['name'] . '</option>' . "\n";
|
||||
}
|
||||
$where['pid'] = $row['id'];
|
||||
//$options.=self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
$options.=!$row['haschild'] ? '' : self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getCategoryTree($where = null, $order = null, $field = null, $limit = 50, $level = 0) {
|
||||
if (is_array($where)) {
|
||||
$where = array_merge(['stat' => ['eq', '0']], $where);
|
||||
}
|
||||
$result = array();
|
||||
if ($level > 5) {
|
||||
return $result;
|
||||
}
|
||||
if ($where) {
|
||||
$this->where($where);
|
||||
}
|
||||
if ($order) {
|
||||
$this->order($order);
|
||||
}
|
||||
if ($field) {
|
||||
$this->field($field);
|
||||
}
|
||||
if ($limit) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
$list = $this->select(); // 获取
|
||||
if ($list) {
|
||||
foreach ($list as $row) {
|
||||
$row['level'] = $level;
|
||||
$where['pid'] = $row['id'];
|
||||
//$row['child'] = self::getCategoryTree($where, $order, $field, $limit, $level + 1);
|
||||
$row['child'] = !$row['haschild'] ? array() : self::getCategoryTree($where, $order, $field, $limit, $level + 1);
|
||||
$result[] = $row;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function deleteRow($id, $stat = -1) {
|
||||
//$result = $this::destroy($id);
|
||||
$data = ['id' => $id, 'pid' => 0, 'haschild' => 0, 'stat' => $stat,];
|
||||
$object = $this::update($data);
|
||||
return $object;
|
||||
}
|
||||
|
||||
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