Browse Source

article

master
林一峰 6 years ago
parent
commit
38510c27e3
  1. 30
      app/Common/function.php
  2. 16
      app/Http/Controllers/Admin/ArticleController.php
  3. 123
      app/Http/Logic/ArctypeLogic.php
  4. 134
      app/Http/Logic/ArticleLogic.php
  5. 10
      app/Http/Logic/BaseLogic.php
  6. 123
      app/Http/Logic/FeedbackLogic.php
  7. 123
      app/Http/Logic/FriendlinkLogic.php
  8. 123
      app/Http/Logic/GoodsBrandLogic.php
  9. 127
      app/Http/Logic/GoodsLogic.php
  10. 123
      app/Http/Logic/GoodsTypeLogic.php
  11. 125
      app/Http/Logic/GuestbookLogic.php
  12. 125
      app/Http/Logic/PageLogic.php
  13. 123
      app/Http/Logic/PaymentLogic.php
  14. 123
      app/Http/Logic/RegionLogic.php
  15. 123
      app/Http/Logic/SlideLogic.php
  16. 107
      app/Http/Logic/SmsLogLogic.php
  17. 123
      app/Http/Logic/SysconfigLogic.php
  18. 107
      app/Http/Logic/TagindexLogic.php
  19. 107
      app/Http/Logic/TokenLogic.php
  20. 123
      app/Http/Logic/UserLogic.php
  21. 107
      app/Http/Logic/VerifyCodeLogic.php
  22. 176
      app/Http/Model/Article.php
  23. 26
      app/Http/Model/BaseModel.php
  24. 29
      app/Http/Requests/ArctypeRequest.php
  25. 42
      app/Http/Requests/ArticleRequest.php
  26. 20
      app/Http/Requests/FeedbackRequest.php
  27. 21
      app/Http/Requests/FriendlinkRequest.php
  28. 28
      app/Http/Requests/GoodsBrandRequest.php
  29. 31
      app/Http/Requests/GoodsTypeRequest.php
  30. 24
      app/Http/Requests/GuestbookRequest.php
  31. 26
      app/Http/Requests/PageRequest.php
  32. 22
      app/Http/Requests/PaymentRequest.php
  33. 22
      app/Http/Requests/RegionRequest.php
  34. 24
      app/Http/Requests/SlideRequest.php
  35. 21
      app/Http/Requests/SmsLogRequest.php
  36. 20
      app/Http/Requests/SysconfigRequest.php
  37. 19
      app/Http/Requests/TagindexRequest.php
  38. 20
      app/Http/Requests/TokenRequest.php
  39. 21
      app/Http/Requests/UserRequest.php
  40. 22
      app/Http/Requests/VerifyCodeRequest.php
  41. 2
      resources/views/admin/article/index.blade.php

30
app/Common/function.php

@ -1155,7 +1155,35 @@ function http_host($flag=true)
return $res;
}
/**
* 获取数据属性
* @param $dataModel 数据模型
* @param $data 数据
* @return array
*/
function getDataAttr($dataModel,$data = [])
{
if(empty($dataModel) || empty($data))
{
return false;
}
foreach($data as $k=>$v)
{
$_method_str=ucfirst(preg_replace_callback('/_([a-zA-Z])/', function ($match) {
return strtoupper($match[1]);
}, $k));
$_method = 'get' . $_method_str . 'Attr';
if(method_exists($dataModel, $_method))
{
$data[$k.'_text'] = $dataModel::$_method($data);
}
}
return $data;
}

16
app/Http/Controllers/Admin/ArticleController.php

@ -4,8 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Admin\CommonController;
use DB;
use Illuminate\Http\Request;
use App\Http\Requests\ArticleRequest;
use Validator;
use App\Http\Logic\ArticleLogic;
class ArticleController extends CommonController
{
@ -14,6 +13,11 @@ class ArticleController extends CommonController
parent::__construct();
}
public function getLogic()
{
return new ArticleLogic();
}
public function index()
{
$res = '';
@ -39,13 +43,7 @@ class ArticleController extends CommonController
}
};
$posts = parent::pageList('article', $where);
foreach($posts as $key=>$value)
{
$info = DB::table('arctype')->select('name')->where("id", $value->typeid)->first();
$posts[$key]->name = $info->name;
$posts[$key]->body = '';
}
$posts = $this->getLogic()->getPaginate($where);
$data['posts'] = $posts;

123
app/Http/Logic/ArctypeLogic.php

@ -0,0 +1,123 @@
<?php
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Arctype;
use App\Http\Requests\ArctypeRequest;
class ArctypeLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
}
public function getModel()
{
return new Arctype();
}
public function getValidate()
{
return Loader::validate('Arctype');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

134
app/Http/Logic/ArticleLogic.php

@ -0,0 +1,134 @@
<?php
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Article;
use App\Http\Requests\ArticleRequest;
use Validator;
class ArticleLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
}
public function getModel()
{
return new Article();
}
public function getValidate($data, $scene_name)
{
//数据验证
$validate = new ArticleRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = Article::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
$res['list'][$k]['typename'] = Article::getTypenameAttr(array('typeid'=>$v->typeid));
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = Article::getPaginate($where, $order, $field, $limit);
foreach($res as $k=>$v)
{
$res[$k]->typename = Article::getTypenameAttr(array('typeid'=>$v->typeid));
}
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = Article::getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = Article::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
$res['typename'] = Article::getTypenameAttr(array('typeid'=>$res->typeid));
Article::getDb()->increment('click', 1);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$validator = $this->getValidate($_REQUEST,'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Article::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = Article::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Article::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

10
app/Http/Logic/BaseLogic.php

@ -0,0 +1,10 @@
<?php
namespace App\Http\Logic;
class BaseLogic
{
public function __construct()
{
}
}

123
app/Http/Logic/FeedbackLogic.php

@ -0,0 +1,123 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Feedback;
class FeedbackLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Feedback();
}
public function getValidate()
{
return Loader::validate('Feedback');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

123
app/Http/Logic/FriendlinkLogic.php

@ -0,0 +1,123 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Friendlink;
class FriendlinkLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Friendlink();
}
public function getValidate()
{
return Loader::validate('Friendlink');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

123
app/Http/Logic/GoodsBrandLogic.php

@ -0,0 +1,123 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\GoodsBrand;
class GoodsBrandLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new GoodsBrand();
}
public function getValidate()
{
return Loader::validate('GoodsBrand');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

127
app/Http/Logic/GoodsLogic.php

@ -0,0 +1,127 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Goods;
class GoodsLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Goods();
}
public function getValidate()
{
return Loader::validate('Goods');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
$res['list'][$k]['typename'] = $this->getModel()->getTypenameAttr($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
$res['typename'] = $this->getModel()->getTypenameAttr($res);
$this->getModel()->getDb()->where($where)->setInc('click', 1);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

123
app/Http/Logic/GoodsTypeLogic.php

@ -0,0 +1,123 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\GoodsType;
class GoodsTypeLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new GoodsType();
}
public function getValidate()
{
return Loader::validate('GoodsType');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

125
app/Http/Logic/GuestbookLogic.php

@ -0,0 +1,125 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Guestbook;
class GuestbookLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Guestbook();
}
public function getValidate()
{
return Loader::validate('Guestbook');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
$this->getModel()->getDb()->where($where)->setInc('click', 1);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

125
app/Http/Logic/PageLogic.php

@ -0,0 +1,125 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Page;
class PageLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Page();
}
public function getValidate()
{
return Loader::validate('Page');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
$this->getModel()->getDb()->where($where)->setInc('click', 1);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

123
app/Http/Logic/PaymentLogic.php

@ -0,0 +1,123 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Payment;
class PaymentLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Payment();
}
public function getValidate()
{
return Loader::validate('Payment');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

123
app/Http/Logic/RegionLogic.php

@ -0,0 +1,123 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Region;
class RegionLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Region();
}
public function getValidate()
{
return Loader::validate('Region');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

123
app/Http/Logic/SlideLogic.php

@ -0,0 +1,123 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Slide;
class SlideLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Slide();
}
public function getValidate()
{
return Loader::validate('Slide');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

107
app/Http/Logic/SmsLogLogic.php

@ -0,0 +1,107 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\SmsLog;
class SmsLogLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new SmsLog();
}
public function getValidate()
{
return Loader::validate('SmsLog');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

123
app/Http/Logic/SysconfigLogic.php

@ -0,0 +1,123 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Sysconfig;
class SysconfigLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Sysconfig();
}
public function getValidate()
{
return Loader::validate('Sysconfig');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

107
app/Http/Logic/TagindexLogic.php

@ -0,0 +1,107 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Tagindex;
class TagindexLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Tagindex();
}
public function getValidate()
{
return Loader::validate('Tagindex');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

107
app/Http/Logic/TokenLogic.php

@ -0,0 +1,107 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Token;
class TokenLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new Token();
}
public function getValidate()
{
return Loader::validate('Token');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

123
app/Http/Logic/UserLogic.php

@ -0,0 +1,123 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\User;
class UserLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new User();
}
public function getValidate()
{
return Loader::validate('User');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

107
app/Http/Logic/VerifyCodeLogic.php

@ -0,0 +1,107 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\VerifyCode;
class VerifyCodeLogic extends BaseLogic
{
protected function initialize()
{
parent::initialize();
}
public function getModel()
{
return new VerifyCode();
}
public function getValidate()
{
return Loader::validate('VerifyCode');
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
}
}
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
return $res;
}
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
return $res;
}
//添加
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('add')->check($data);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改
public function edit($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除
public function del($where)
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$check = $this->getValidate()->scene('del')->check($where);
if($check === false){return ReturnData::create(ReturnData::PARAMS_ERROR,null,$this->getValidate()->getError());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 数据获取器
* @param array $data 要转化的数据
* @return array
*/
private function getDataView($data = array())
{
return getDataAttr($this->getModel(),$data);
}
}

176
app/Http/Model/Article.php

@ -1,5 +1,6 @@
<?php
namespace App\Http\Model;
use Illuminate\Support\Facades\DB;
class Article extends BaseModel
{
@ -38,6 +39,11 @@ class Article extends BaseModel
'id', 'typeid', 'tuijian', 'click', 'title', 'writer', 'source','litpic', 'pubdate', 'addtime', 'description', 'listorder'
);
public static function getDb()
{
return DB::table('article');
}
/**
* 获取关联到文章的分类
*/
@ -46,7 +52,37 @@ class Article extends BaseModel
return $this->belongsTo(Arctype::class, 'typeid', 'id');
}
public static function getList(array $param)
/**
* 列表
* @param array $where 查询条件
* @param string $order 排序
* @param string $field 字段
* @param int $offset 偏移量
* @param int $limit 取多少条
* @return array
*/
public static function getList($where = array(), $order = '', $field = '*', $offset = 0, $limit = 10)
{
$model = self::getDb();
if($where){$res = $res->where($where);}
$res['count'] = $model->count();
$res['list'] = array();
if($res['count'] > 0)
{
if($field){if(is_array($field)){$model = $model->select($field);}else{$model = $model->select(\DB::raw($field));}}
if($order){$model = $model->orderBy($order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
$res['list'] = $model->skip($offset)->take($limit)->get();
}
return $res;
}
/* public static function getList(array $param)
{
extract($param); //参数:group_id,limit,offset
@ -89,35 +125,107 @@ class Article extends BaseModel
}
return $res;
} */
/**
* 分页,用于前端html输出
* @param array $where 查询条件
* @param string $order 排序
* @param string $field 字段
* @param int $limit 每页几条
* @param int $page 当前第几页
* @return array
*/
public static function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = self::getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = $res->orderBy($order);}
if($limit){}else{$limit = 10;}
return $res->paginate($limit);
}
public static function getOne(array $param)
/**
* 查询全部
* @param array $where 查询条件
* @param string $order 排序
* @param string $field 字段
* @param int $limit 取多少条
* @return array
*/
public static function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
{
extract($param);
$res = self::getDb();
$where['id'] = $id;
if(isset($ischeck)){$where['ischeck'] = $ischeck;}
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = $res->orderBy($order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
$res = self::where($where)->first();
$res = $res->skip($offset)->take($limit)->get();
if($res){$res->type_name = Arctype::where('id', $res->typeid)->value('name');}
return $res;
}
/**
* 获取一条
* @param array $where 条件
* @param string $field 字段
* @return array
*/
public static function getOne($where, $field = '*')
{
$res = self::getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
$res = $res->find();
return $res;
}
public static function add(array $data)
/**
* 添加
* @param array $data 数据
* @return int
*/
public static function add(array $data,$type = 0)
{
if ($id = self::insertGetId($data))
if($type==0)
{
return $id;
// 新增单条数据并返回主键值
return self::insertGetId(parent::filterTableColumn($data,$this->table));
}
elseif($type==1)
{
/**
* 添加单条数据
* $data = ['foo' => 'bar', 'bar' => 'foo'];
* 添加多条数据
* $data = [
* ['foo' => 'bar', 'bar' => 'foo'],
* ['foo' => 'bar1', 'bar' => 'foo1'],
* ['foo' => 'bar2', 'bar' => 'foo2']
* ];
*/
return self::insert($data);
}
return false;
}
public static function modify($where, array $data)
/**
* 修改
* @param array $data 数据
* @param array $where 条件
* @return bool
*/
public static function edit($data, $where = array())
{
if (self::where($where)->update($data)!==false)
if (self::where($where)->update(parent::filterTableColumn($data,$this->table)) !== false)
{
return true;
}
@ -125,14 +233,42 @@ class Article extends BaseModel
return false;
}
//删除一条记录
public static function remove($id)
/* public static function modify($where, array $data)
{
if (!self::whereIn('id', explode(',', $id))->delete())
if (self::where($where)->update($data)!==false)
{
return false;
return true;
}
return true;
return false;
} */
//删除一条记录
/* public static function remove($id)
{
return self::whereIn('id', explode(',', $id))->delete();
} */
/**
* 删除
* @param array $where 条件
* @return bool
*/
public static function del($where)
{
return self::where($where)->delete();
}
//是否审核
public static function getIscheckAttr($data)
{
$arr = array(0 => '已审核', 1 => '未审核');
return $arr[$data['ischeck']];
}
//是否栏目名称
public static function getTypenameAttr($data)
{
return DB::table('arctype')->where(array('id'=>$data['typeid']))->value('name');
}
}
}

26
app/Http/Model/BaseModel.php

@ -1,8 +1,34 @@
<?php
namespace App\Http\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Schema;
class BaseModel extends Model
{
//获取某一表的所有字段
public static function getColumnListing($table)
{
return Schema::getColumnListing($table);
}
//过滤不是某一表的字段
public static function filterTableColumn($data, $table)
{
$table_column = Schema::getColumnListing($table);
if(!$table_column)
{
return $data;
}
foreach($data as $k=>$v)
{
if (!in_array($k,$table_column))
{
unset($data[$k]);
}
}
return $data;
}
}

29
app/Http/Requests/ArctypeRequest.php

@ -0,0 +1,29 @@
<?php
namespace app\common\validate;
use think\Validate;
class Arctype extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['reid', 'number','父级id必须是数字'],
['addtime', 'number','添加时间必须是数字'],
['typename', 'require|max:30','栏目名称必填|栏目名称不能超过30个字符'],
['seotitle', 'max:150','seo标题不能超过150个字符'],
['keywords', 'max:60','关键词不能超过60个字符'],
['description', 'max:250','描述不能超过250个字符'],
['listorder', 'number','排序必须是数字'],
['typedir', 'require|max:30','栏目别名必填|栏目别名不能超过30个字符'],
['templist', 'max:50','列表页模板不能超过50个字符'],
['temparticle', 'max:50','文章页模板不能超过50个字符'],
['litpic', 'max:100','封面或缩略图不能超过100个字符'],
['seokeyword', 'max:50','seokeyword不能超过50个字符'],
];
protected $scene = [
'add' => ['typename', 'typedir', 'reid', 'addtime', 'seotitle', 'keywords', 'description', 'listorder', 'templist', 'temparticle', 'litpic', 'seokeyword'],
'del' => ['id'],
];
}

42
app/Http/Requests/ArticleRequest.php

@ -8,27 +8,49 @@ class ArticleRequest extends Request
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'title' => 'required|max:150',
'typeid' => 'required|integer',
'click' => ['required','integer'],
'tuijian' => 'integer',
'click' => 'required|integer',
'title' => 'required|max:150',
'writer' => 'max:20',
'source' => 'max:30',
'litpic' => 'max:100',
'pubdate' => 'integer',
'add_time' => 'required|integer',
'keywords' => 'max:60',
'seotitle' => 'max:150',
'description' => 'max:250',
'ischeck' => 'between:[0,2]',
'user_id' => 'integer',
];
//总的自定义错误信息
protected $messages = [
'title.max' => '标题不能大于150个字',
'title.required' => '必须填写标题',
'typeid.required' => '类目ID必填',
'typeid.integer' => '栏目ID必须为数字',
'click.required' => '必须填写点击量',
'click.integer' => '点击必须为数字',
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'typeid.required' => '栏目ID必填',
'typeid.integer' => '栏目ID必须为数字',
'tuijian.integer' => '推荐等级必须是数字',
'click.integer' => '点击必须为数字',
'title.max' => '标题不能大于150个字',
'title.required' => '必须填写标题',
'writer.max' => '作者不能超过20个字符',
'source.max' => '来源不能超过30个字符',
'litpic.max' => '缩略图不能超过100个字符',
'pubdate.integer' => '更新时间格式不正确',
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间必须是数字',
'keywords.max' => '关键词不能超过60个字符',
'seotitle.max' => 'seo标题不能超过150个字符',
'description.max' => '描述不能超过250个字符',
'ischeck.between' => '审核状态:0审核,1未审核',
'user_id.integer' => '发布者ID必须是数字',
];
//场景验证规则
protected $scene = [
'add' => ['title','typeid','click'],
'edit' => ['title','typeid'],
'add' => ['typeid', 'title', 'tuijian', 'click', 'writer', 'source', 'litpic', 'pubdate', 'addtime', 'keywords', 'seotitle', 'description', 'ischeck', 'user_id'],
'edit' => ['typeid', 'title', 'tuijian', 'click', 'writer', 'source', 'litpic', 'pubdate', 'addtime', 'keywords', 'seotitle', 'description', 'ischeck', 'user_id'],
'del' => ['id'],
];

20
app/Http/Requests/FeedbackRequest.php

@ -0,0 +1,20 @@
<?php
namespace app\common\validate;
use think\Validate;
class Feedback extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['content', 'require','意见反馈内容必填'],
['title', 'max:150','标题必填|标题不能超过150个字符'],
['user_id', 'number', '用户ID必须是数字'],
];
protected $scene = [
'add' => ['content', 'title', 'user_id'],
'del' => ['id'],
];
}

21
app/Http/Requests/FriendlinkRequest.php

@ -0,0 +1,21 @@
<?php
namespace app\common\validate;
use think\Validate;
class Friendlink extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['webname', 'require|max:60','链接名称必填|链接名称不能超过60个字符'],
['url', 'max:100','跳转链接不能超过100个字符'],
['group_id', 'number', '分组ID必须是数字'],
['rank', 'number','排序必须是数字'],
];
protected $scene = [
'add' => ['webname', 'url', 'target', 'group_id', 'rank'],
'del' => ['id'],
];
}

28
app/Http/Requests/GoodsBrandRequest.php

@ -0,0 +1,28 @@
<?php
namespace app\common\validate;
use think\Validate;
class GoodsBrand extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['pid', 'number','父级ID必须是数字'],
['add_time', 'number','发布时间格式不正确'],
['title', 'require|max:150','标题必填|标题不能超过150个字符'],
['keywords', 'max:60','关键词不能超过60个字符'],
['seotitle', 'max:150','seo标题不能超过150个字符'],
['description', 'max:250','描述不能超过250个字符'],
['litpic', 'max:100','缩略图不能超过100个字符'],
['status', 'in:0,1','是否显示,0显示'],
['cover_img', 'max:100','封面不能超过100个字符'],
['click', 'number', '点击量必须是数字'],
['listorder', 'number|between:1,9999','排序必须是数字|排序只能1-9999'],
];
protected $scene = [
'add' => ['pid', 'add_time', 'title', 'keywords', 'seotitle', 'description', 'litpic', 'status', 'cover_img', 'click', 'listorder'],
'del' => ['id'],
];
}

31
app/Http/Requests/GoodsTypeRequest.php

@ -0,0 +1,31 @@
<?php
namespace app\common\validate;
use think\Validate;
class GoodsType extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['reid', 'number','父级id必须是数字'],
['addtime', 'number','添加时间必须是数字'],
['name', 'require|max:30','栏目名称必填|栏目名称不能超过30个字符'],
['seotitle', 'max:150','seo标题不能超过150个字符'],
['keywords', 'max:60','关键词不能超过60个字符'],
['description', 'max:250','描述不能超过250个字符'],
['typedir', 'require|max:30','栏目别名必填|栏目别名不能超过30个字符'],
['templist', 'max:50','列表页模板不能超过50个字符'],
['temparticle', 'max:50','文章页模板不能超过50个字符'],
['litpic', 'max:100','缩略图不能超过100个字符'],
['seokeyword', 'max:60','相关关键词不能超过60个字符'],
['status', 'in:0,1','状态 0不显示 1显示'],
['listorder', 'number|between:1,9999','排序必须是数字|排序只能1-9999'],
['cover_img', 'max:100','封面不能超过100个字符'],
];
protected $scene = [
'add' => ['reid', 'addtime', 'name', 'seotitle', 'keywords', 'description', 'typedir', 'templist', 'temparticle', 'litpic', 'seokeyword', 'status', 'listorder', 'cover_img'],
'del' => ['id'],
];
}

24
app/Http/Requests/GuestbookRequest.php

@ -0,0 +1,24 @@
<?php
namespace app\common\validate;
use think\Validate;
class Guestbook extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['title', 'require|max:150','标题必填|标题不能超过150个字符'],
['msg', 'require|max:250','内容必填|内容不能超过250个字符'],
['name', 'require|max:30','姓名必填|姓名不能超过30个字符'],
['phone', 'require|max:30','电话必填|电话不能超过30个字符'],
['email', 'require|max:60','邮箱必填|邮箱不能超过60个字符'],
['status', 'number', 'status必须是数字'],
['addtime', 'number','添加时间必须是数字'],
];
protected $scene = [
'add' => ['varname', 'info', 'value'],
'del' => ['id'],
];
}

26
app/Http/Requests/PageRequest.php

@ -0,0 +1,26 @@
<?php
namespace app\common\validate;
use think\Validate;
class Page extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['click', 'number', '点击量必须是数字'],
['title', 'require|max:150','标题必填|标题不能超过150个字符'],
['filename', 'max:60','别名不能超过60个字符'],
['template', 'max:30','模板名称不能超过30个字符'],
['litpic', 'max:100','缩略图不能超过100个字符'],
['pubdate', 'require|number', '更新时间必填|更新时间格式不正确'],
['keywords', 'max:60','关键词不能超过60个字符'],
['seotitle', 'max:150','seo标题不能超过150个字符'],
['description', 'max:250','描述不能超过60个字符'],
];
protected $scene = [
'add' => ['title', 'tuijian', 'click', 'filename', 'template', 'litpic', 'pubdate', 'keywords', 'seotitle', 'description'],
'del' => ['id'],
];
}

22
app/Http/Requests/PaymentRequest.php

@ -0,0 +1,22 @@
<?php
namespace app\common\validate;
use think\Validate;
class Payment extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['pay_code', 'require|max:20','支付方式的英文缩写必填|支付方式的英文缩写不能超过20个字符'],
['pay_name', 'require|max:100','支付方式名称必填|支付方式名称不能超过100个字符'],
['pay_fee', 'max:10','支付费用不能超过10个字符'],
['status', 'in:0,1', '是否可用;0否;1是'],
['listorder', 'number','排序必须是数字'],
];
protected $scene = [
'add' => ['pay_code', 'pay_name', 'pay_fee', 'status', 'listorder'],
'del' => ['id'],
];
}

22
app/Http/Requests/RegionRequest.php

@ -0,0 +1,22 @@
<?php
namespace app\common\validate;
use think\Validate;
class Region extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['parent_id', 'number','父级ID必须是数字'],
['name', 'require|max:64','名称必填|名称不能超过64个字符'],
['type', 'in:0,1,2,3','层级,0国家,1省,2市,3区'],
['sort_name', 'max:50','拼音或英文简写不能超过50个字符'],
['area_code', 'max:10', '电话区号不能超过10个字符'],
];
protected $scene = [
'add' => ['name', 'parent_id', 'type', 'sort_name', 'area_code'],
'del' => ['id'],
];
}

24
app/Http/Requests/SlideRequest.php

@ -0,0 +1,24 @@
<?php
namespace app\common\validate;
use think\Validate;
class Slide extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['title', 'require|max:150','标题必填|标题不能超过150个字符'],
['url', 'max:100','跳转链接不能超过100个字符'],
['target', 'number', '跳转方式必须是数字'],
['group_id', 'number', '分组ID必须是数字'],
['rank', 'number','排序必须是数字'],
['pic', 'max:100','图片地址不能超过100个字符'],
['is_show', 'in:0,1','是否显示,默认0显示'],
];
protected $scene = [
'add' => ['title', 'url', 'target', 'group_id', 'rank', 'pic', 'is_show'],
'del' => ['id'],
];
}

21
app/Http/Requests/SmsLogRequest.php

@ -0,0 +1,21 @@
<?php
namespace app\common\validate;
use think\Validate;
class SmsLog extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['mobile', 'require|max:20','手机号必填|手机号不能超过20个字符'],
['text', 'require|max:200','发送的内容必填|发送的内容不能超过200个字符'],
['status', 'in:1,2','状态:1成功,2失败'],
['result', 'max:500', '返回结果不能超过500个字符'],
];
protected $scene = [
'add' => ['mobile', 'text', 'status', 'result'],
'del' => ['id'],
];
}

20
app/Http/Requests/SysconfigRequest.php

@ -0,0 +1,20 @@
<?php
namespace app\common\validate;
use think\Validate;
class Sysconfig extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['varname', 'require|max:100','变量名必填|变量名不能超过100个字符'],
['info', 'require|max:100','变量值必填|变量值不能超过100个字符'],
['value', 'require', '变量说明必填'],
];
protected $scene = [
'add' => ['varname', 'info', 'value'],
'del' => ['id'],
];
}

19
app/Http/Requests/TagindexRequest.php

@ -0,0 +1,19 @@
<?php
namespace app\common\validate;
use think\Validate;
class Tagindex extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['tag', 'require|max:36','标签名称必填|标签名称不能超过10个字符'],
['filename', 'require|max:60','别名必填|别名不能超过60个字符'],
];
protected $scene = [
'add' => ['tag', 'filename'],
'del' => ['id'],
];
}

20
app/Http/Requests/TokenRequest.php

@ -0,0 +1,20 @@
<?php
namespace app\common\validate;
use think\Validate;
class Token extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['token', 'require|max:128','token必填|token不能超过128个字符'],
['type', 'in:0,1,2,3,4,5,6','token类型,0:app, 1:admin, 2:weixin, 3:wap, 4: pc'],
['uid', 'require|number','uid必填|uid必须是数字'],
];
protected $scene = [
'add' => ['token', 'type', 'uid'],
'del' => ['id'],
];
}

21
app/Http/Requests/UserRequest.php

@ -0,0 +1,21 @@
<?php
namespace app\common\validate;
use think\Validate;
class User extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['user_name', 'require|max:60','用户名必填|用户名不能超过60个字符'],
['sex', 'in:0,1,2','性别1男2女'],
['password', 'require|max:50','密码必填|密码不能超过50个字符'],
['status', 'in:1,2,3','用户状态 1正常状态 2 删除至回收站 3锁定'],
];
protected $scene = [
'add' => ['user_name', 'text', 'status', 'result'],
'del' => ['id'],
];
}

22
app/Http/Requests/VerifyCodeRequest.php

@ -0,0 +1,22 @@
<?php
namespace app\common\validate;
use think\Validate;
class VerifyCode extends Validate
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['code', 'require|max:10','验证码必填|验证码不能超过10个字符'],
['type', 'in:0,1,2,3,4,5,6,7,8,9','0通用,注册,1:手机绑定业务验证码,2:密码修改业务验证码'],
['mobile', 'require|max:20','手机号必填|手机号不能超过20个字符'],
['status', 'in:0,1','0:未使用 1:已使用'],
['result', 'max:500', '返回结果不能超过500个字符'],
];
protected $scene = [
'add' => ['mobile', 'text', 'status', 'result'],
'del' => ['id'],
];
}

2
resources/views/admin/article/index.blade.php

@ -22,7 +22,7 @@
<td><input name="arcID" type="checkbox" value="<?php echo $row->id; ?>" class="np"></td>
<td><a href="/fladmin/article/edit?id=<?php echo $row->id; ?>"><?php echo $row->title; ?></a> <?php if(!empty($row->litpic)){echo "<small style='color:red'>[图]</small>";}if($row->tuijian==1){echo "<small style='color:#22ac38'>[荐]</small>";} ?> </td>
<td><?php echo date('Y-m-d',$row->pubdate); ?></td>
<td><a href="/fladmin/article?id=<?php echo $row->typeid; ?>"><?php echo $row->name; ?></a></td><td><?php echo $row->click; ?></td><td><a target="_blank" href="<?php echo get_front_url(array("type"=>"content","catid"=>$row->typeid,"id"=>$row->id)); ?>">预览</a>&nbsp;<a href="/fladmin/article/edit?id=<?php echo $row->id; ?>">修改</a>&nbsp;<a onclick="delconfirm('/fladmin/article/del?id=<?php echo $row->id; ?>')" href="javascript:;">删除</a></td>
<td><a href="/fladmin/article?id=<?php echo $row->typeid; ?>"><?php echo $row->typename; ?></a></td><td><?php echo $row->click; ?></td><td><a target="_blank" href="<?php echo get_front_url(array("type"=>"content","catid"=>$row->typeid,"id"=>$row->id)); ?>">预览</a>&nbsp;<a href="/fladmin/article/edit?id=<?php echo $row->id; ?>">修改</a>&nbsp;<a onclick="delconfirm('/fladmin/article/del?id=<?php echo $row->id; ?>')" href="javascript:;">删除</a></td>
</tr>
<?php }} ?>
<tr>

Loading…
Cancel
Save