[更新]去除无效代码

This commit is contained in:
Anyon 2018-03-13 15:53:19 +08:00
parent 146ea1f2df
commit e1d07d4238
3 changed files with 0 additions and 304 deletions

View File

@ -145,43 +145,6 @@ class BasicAdmin extends Controller
return $result;
}
protected function _list_modal($dbQuery = null, $isPage = true, $isDisplay = true, $total = false, $result = [], $template = '')
{
$db = is_null($dbQuery) ? Db::name($this->table) : (is_string($dbQuery) ? Db::name($dbQuery) : $dbQuery);
// 列表排序默认处理
if ($this->request->isPost() && $this->request->post('action') === 'resort') {
$data = $this->request->post();
unset($data['action']);
foreach ($data as $key => $value) {
if (false === $db->where('id', intval(ltrim($key, '_')))->setField('sort', $value)) {
$this->error('列表排序失败, 请稍候再试');
}
}
$this->success('列表排序成功, 正在刷新列表', '');
}
// 列表数据查询与显示
if (null === $db->getOptions('order')) {
in_array('sort', $db->getTableFields($db->getTable())) && $db->order('sort asc');
}
if ($isPage) {
$rows = 10;
// 分页数据处理
$query = $this->request->get('', '', 'urlencode');
$page = $db->paginate($rows, $total, ['query' => $query]);
list($totalNum) = [$page->total()];
list($pattern, $replacement) = [['|href="(.*?)"|', '|pagination|'], ['href="javascript:;" onclick="pageto(this)"', 'pagination pull-right']];
$html = "<span class='pagination-trigger nowrap'>共 {$totalNum} 条记录," . "</select> 共 " . ceil($totalNum / $rows) . " 页。</span>";
list($result['total'], $result['list'], $result['page']) = [$totalNum, $page->all(), $html . preg_replace($pattern, $replacement, $page->render())];
} else {
$result['list'] = $db->select();
}
if ($isDisplay && (false !== $this->_callback('_data_filter', $result['list'], []))) {
!empty($this->title) && $this->assign('title', $this->title);
return $this->fetch($template, $result);
}
return $result;
}
/**
* 当前对象回调成员方法
* @param string $method

View File

@ -1,145 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace controller;
use service\ToolsService;
use think\Db;
use think\exception\HttpResponseException;
use think\Response;
/**
* App数据基础控制器
* Class BasicApp
* @package controller
*/
class BasicApp
{
/**
* 当前请求对象
* @var \think\Request
*/
protected $request;
/**
* App设备ID标识
* @var string
*/
protected $deviceid = '';
/**
* 微信unionid
* @var string
*/
protected $unionid = '';
/**
* App会员信息
* @var array
*/
protected $member = [];
/**
* 当前粉丝信息
* @var array
*/
protected $fans = [];
/**
* 构造方法
* BasicApp constructor.
*/
public function __construct()
{
ToolsService::corsOptionsHandler();
$this->request = app('request');
$this->unionid = $this->request->post('unionid', '');
$this->deviceid = $this->request->post('deviceid', '');
$this->_initialize();
}
/**
* App接口初始化
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
if (empty($this->deviceid) && empty($this->unionid)) {
$this->error("接口异常,缺少必要参数!");
}
return $this->checkLogin();
}
/**
* 检查用户登录
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function checkLogin()
{
$this->member = $this->initMember();
empty($this->member) && $this->error('还没有登录哦,请登录后再来访问!');
}
/**
* 初始化会员数据
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function initMember()
{
$where = "(deviceid='{$this->deviceid}' and deviceid<>'') or (unionid='{$this->unionid}' and unionid<>'')";
$this->member = Db::name('Member')->where(['status' => '1'])->where($where)->find();
if (!empty($this->member)) {
$where = ['level' => $this->member['level']];
$this->member['nickname'] = ToolsService::emojiDecode($this->member['nickname']);
$this->member['level_title'] = Db::name('MemberLevel')->where($where)->value('title', '');
// 计算会员的积分排行榜
$rateWhere = ['is_pass' => '1', 'total_integral' => ['>', $this->member['total_integral']]];
$rateCount = Db::name('Member')->where($rateWhere)->count();
$count = Db::name('Member')->where(['is_pass' => '1'])->count();
$this->member['integral_rate'] = number_format(floatval(100 - $rateCount * 100 / $count), 2);
}
return $this->member;
}
/**
* 返回成功的操作
* @param string $msg 消息内容
* @param array $data 返回数据
*/
protected function success($msg, $data = [])
{
$result = ['code' => 1, 'msg' => $msg, 'data' => $data];
throw new HttpResponseException(Response::create($result, 'json', 200, ToolsService::corsRequestHander()));
}
/**
* 返回失败的请求
* @param string $msg 消息内容
* @param array $data 返回数据
*/
protected function error($msg, $data = [])
{
$result = ['code' => 0, 'msg' => $msg, 'data' => $data];
throw new HttpResponseException(Response::create($result, 'json', 200, ToolsService::corsRequestHander()));
}
}

View File

@ -1,122 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | Think.Admin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/Think.Admin
// +----------------------------------------------------------------------
namespace controller;
use service\ToolsService;
use think\Db;
use think\exception\HttpResponseException;
use think\Request;
use think\Response;
/**
* PDA数据基础控制器
* Class BasicPda
* @package controller
*/
class BasicPda
{
/**
* 当前请求对象
* @var \think\Request
*/
protected $request;
/**
* PDA设备ID标识
* @var string
*/
protected $deviceid = '';
/**
* PDA用户信息
* @var array
*/
protected $user = [];
/**
* 检查登录
* @var bool
*/
protected $checkLogin = true;
/**
* 构造方法
* BasicPda constructor.
*/
public function __construct()
{
ToolsService::corsOptionsHandler();
$this->request = app('request');
$this->deviceid = $this->request->post('deviceid', '');
$this->_initialize();
}
/**
* PDA接口初始化
*/
public function _initialize()
{
empty($this->deviceid) && $this->error("接口异常,缺少必要参数!");
sysconf('depot_pda_secret_key') !== $this->request->post('appkey') && $this->error("PDA密钥有误");
$this->checkLogin && !$this->checkLogin() && $this->error('请登录后再操作!');
}
/**
* 检查用户登录
* @return bool
*/
protected function checkLogin()
{
return !!$this->initUser();
}
/**
* 初始化用户数据
* @return array|false|\PDOStatement|string|\think\Model
*/
protected function initUser()
{
$where = "deviceid='{$this->deviceid}' and deviceid<>''";
$this->user = Db::name('GoodsDepotKeeper')->where(['status' => '1', 'is_deleted' => 0])->where($where)->find();
if (!empty($this->user)) {
$this->user['depot'] = Db::name('GoodsDepot')->where(['id' => $this->user['depot_id']])->value('name');
}
return $this->user;
}
/**
* 返回成功的操作
* @param string $msg 消息内容
* @param array $data 返回数据
*/
protected function success($msg, $data = [])
{
$result = ['code' => 1, 'msg' => $msg, 'data' => $data];
throw new HttpResponseException(Response::create($result, 'json', 200, ToolsService::corsRequestHander()));
}
/**
* 返回失败的请求
* @param string $msg 消息内容
* @param array $data 返回数据
*/
protected function error($msg, $data = [])
{
$result = ['code' => 0, 'msg' => $msg, 'data' => $data];
throw new HttpResponseException(Response::create($result, 'json', 200, ToolsService::corsRequestHander()));
}
}