Browse Source

logic

master
林一峰 7 years ago
parent
commit
bb49cad88b
  1. 32
      app/Http/Logic/ArctypeLogic.php
  2. 4
      app/Http/Logic/ArticleLogic.php
  3. 44
      app/Http/Logic/FeedbackLogic.php
  4. 44
      app/Http/Logic/FriendlinkLogic.php
  5. 44
      app/Http/Logic/GoodsBrandLogic.php
  6. 54
      app/Http/Logic/GoodsLogic.php
  7. 44
      app/Http/Logic/GoodsTypeLogic.php
  8. 46
      app/Http/Logic/GuestbookLogic.php
  9. 46
      app/Http/Logic/PageLogic.php
  10. 58
      app/Http/Logic/PaymentLogic.php
  11. 58
      app/Http/Logic/RegionLogic.php
  12. 44
      app/Http/Logic/SlideLogic.php
  13. 58
      app/Http/Logic/SmsLogLogic.php
  14. 44
      app/Http/Logic/SysconfigLogic.php
  15. 58
      app/Http/Logic/TagindexLogic.php
  16. 58
      app/Http/Logic/TokenLogic.php
  17. 44
      app/Http/Logic/UserLogic.php
  18. 58
      app/Http/Logic/VerifyCodeLogic.php
  19. 154
      app/Http/Model/Arctype.php
  20. 10
      app/Http/Model/Article.php
  21. 6
      app/Http/Model/Goods.php
  22. 2
      app/Http/Requests/ArctypeRequest.php
  23. 30
      lqycms.sql

32
app/Http/Logic/ArctypeLogic.php

@ -3,6 +3,7 @@ namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Arctype;
use App\Http\Requests\ArctypeRequest;
use Validator;
class ArctypeLogic extends BaseLogic
{
@ -16,15 +17,17 @@ class ArctypeLogic extends BaseLogic
return new Arctype();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Arctype');
//数据验证
$validate = new ArctypeRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Arctype::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,7 @@ class ArctypeLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = Arctype::getPaginate($where, $order, $field, $limit);
return $res;
}
@ -48,7 +51,7 @@ class ArctypeLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = Arctype::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -64,7 +67,7 @@ class ArctypeLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = Arctype::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -77,10 +80,10 @@ class ArctypeLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Arctype::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -91,7 +94,10 @@ class ArctypeLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Arctype::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -102,10 +108,10 @@ class ArctypeLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Arctype::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

4
app/Http/Logic/ArticleLogic.php

@ -88,7 +88,7 @@ class ArticleLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$validator = $this->getValidate($_REQUEST, 'add');
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Article::add($data,$type);
@ -102,7 +102,7 @@ class ArticleLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$validator = $this->getValidate($_REQUEST, 'edit');
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Article::edit($data,$where);

44
app/Http/Logic/FeedbackLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Feedback;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Feedback;
use App\Http\Requests\FeedbackRequest;
use Validator;
class FeedbackLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class FeedbackLogic extends BaseLogic
return new Feedback();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Feedback');
//数据验证
$validate = new FeedbackRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Feedback::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,7 @@ class FeedbackLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = Feedback::getPaginate($where, $order, $field, $limit);
return $res;
}
@ -48,7 +51,7 @@ class FeedbackLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = Feedback::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -64,7 +67,7 @@ class FeedbackLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = Feedback::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -77,10 +80,10 @@ class FeedbackLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Feedback::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -91,7 +94,10 @@ class FeedbackLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Feedback::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -102,10 +108,10 @@ class FeedbackLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Feedback::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

44
app/Http/Logic/FriendlinkLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Friendlink;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Friendlink;
use App\Http\Requests\FriendlinkRequest;
use Validator;
class FriendlinkLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class FriendlinkLogic extends BaseLogic
return new Friendlink();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Friendlink');
//数据验证
$validate = new FriendlinkRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Friendlink::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,7 @@ class FriendlinkLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = Friendlink::getPaginate($where, $order, $field, $limit);
return $res;
}
@ -48,7 +51,7 @@ class FriendlinkLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = Friendlink::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -64,7 +67,7 @@ class FriendlinkLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = Friendlink::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -77,10 +80,10 @@ class FriendlinkLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Friendlink::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -91,7 +94,10 @@ class FriendlinkLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Friendlink::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -102,10 +108,10 @@ class FriendlinkLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Friendlink::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

44
app/Http/Logic/GoodsBrandLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\GoodsBrand;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\GoodsBrand;
use App\Http\Requests\GoodsBrandRequest;
use Validator;
class GoodsBrandLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class GoodsBrandLogic extends BaseLogic
return new GoodsBrand();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('GoodsBrand');
//数据验证
$validate = new GoodsBrandRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = GoodsBrand::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,7 @@ class GoodsBrandLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = GoodsBrand::getPaginate($where, $order, $field, $limit);
return $res;
}
@ -48,7 +51,7 @@ class GoodsBrandLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = GoodsBrand::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -64,7 +67,7 @@ class GoodsBrandLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = GoodsBrand::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -77,10 +80,10 @@ class GoodsBrandLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = GoodsBrand::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -91,7 +94,10 @@ class GoodsBrandLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = GoodsBrand::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -102,10 +108,10 @@ class GoodsBrandLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = GoodsBrand::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

54
app/Http/Logic/GoodsLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Goods;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Goods;
use App\Http\Requests\GoodsRequest;
use Validator;
class GoodsLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,22 +17,24 @@ class GoodsLogic extends BaseLogic
return new Goods();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Goods');
//数据验证
$validate = new GoodsRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Goods::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);
$res['list'][$k]->typename = Goods::getTypenameAttr(array('typeid' => $v->typeid));
}
}
@ -41,7 +44,11 @@ class GoodsLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = Goods::getPaginate($where, $order, $field, $limit);
foreach($res as $k=>$v)
{
$res[$k]->typename = Goods::getTypenameAttr(array('typeid'=>$v->typeid));
}
return $res;
}
@ -49,7 +56,7 @@ class GoodsLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = Goods::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -65,13 +72,13 @@ class GoodsLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = Goods::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
$res['typename'] = $this->getModel()->getTypenameAttr($res);
$res->typename = Goods::getTypenameAttr(array('typeid'=>$res->typeid));
$this->getModel()->getDb()->where($where)->setInc('click', 1);
Goods::getDb()->where($where)->increment('click', 1);
return $res;
}
@ -81,10 +88,10 @@ class GoodsLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Goods::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -95,7 +102,10 @@ class GoodsLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Goods::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -106,10 +116,10 @@ class GoodsLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Goods::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

44
app/Http/Logic/GoodsTypeLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\GoodsType;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\GoodsType;
use App\Http\Requests\GoodsTypeRequest;
use Validator;
class GoodsTypeLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class GoodsTypeLogic extends BaseLogic
return new GoodsType();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('GoodsType');
//数据验证
$validate = new GoodsTypeRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = GoodsType::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,7 @@ class GoodsTypeLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = GoodsType::getPaginate($where, $order, $field, $limit);
return $res;
}
@ -48,7 +51,7 @@ class GoodsTypeLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = GoodsType::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -64,7 +67,7 @@ class GoodsTypeLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = GoodsType::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -77,10 +80,10 @@ class GoodsTypeLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = GoodsType::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -91,7 +94,10 @@ class GoodsTypeLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = GoodsType::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -102,10 +108,10 @@ class GoodsTypeLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = GoodsType::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

46
app/Http/Logic/GuestbookLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Guestbook;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Guestbook;
use App\Http\Requests\GuestbookRequest;
use Validator;
class GuestbookLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class GuestbookLogic extends BaseLogic
return new Guestbook();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Guestbook');
//数据验证
$validate = new GuestbookRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Guestbook::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,7 @@ class GuestbookLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = Guestbook::getPaginate($where, $order, $field, $limit);
return $res;
}
@ -48,7 +51,7 @@ class GuestbookLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = Guestbook::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -64,13 +67,11 @@ class GuestbookLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = Guestbook::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
$this->getModel()->getDb()->where($where)->setInc('click', 1);
return $res;
}
@ -79,10 +80,10 @@ class GuestbookLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Guestbook::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -93,7 +94,10 @@ class GuestbookLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Guestbook::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -104,10 +108,10 @@ class GuestbookLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Guestbook::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

46
app/Http/Logic/PageLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Page;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Page;
use App\Http\Requests\PageRequest;
use Validator;
class PageLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class PageLogic extends BaseLogic
return new Page();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Page');
//数据验证
$validate = new PageRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Page::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,7 @@ class PageLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = Page::getPaginate($where, $order, $field, $limit);
return $res;
}
@ -48,7 +51,7 @@ class PageLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = Page::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -64,13 +67,11 @@ class PageLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = Page::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
$this->getModel()->getDb()->where($where)->setInc('click', 1);
return $res;
}
@ -79,10 +80,10 @@ class PageLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Page::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -93,7 +94,10 @@ class PageLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Page::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -104,10 +108,10 @@ class PageLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Page::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

58
app/Http/Logic/PaymentLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Payment;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Payment;
use App\Http\Requests\PaymentRequest;
use Validator;
class PaymentLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class PaymentLogic extends BaseLogic
return new Payment();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Payment');
//数据验证
$validate = new PaymentRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Payment::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -37,10 +40,18 @@ class PaymentLogic extends BaseLogic
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = Payment::getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = Payment::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -53,18 +64,10 @@ class PaymentLogic extends BaseLogic
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);
$res = Payment::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -77,10 +80,10 @@ class PaymentLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Payment::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -91,7 +94,10 @@ class PaymentLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Payment::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -102,10 +108,10 @@ class PaymentLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Payment::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

58
app/Http/Logic/RegionLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Region;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Region;
use App\Http\Requests\RegionRequest;
use Validator;
class RegionLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class RegionLogic extends BaseLogic
return new Region();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Region');
//数据验证
$validate = new RegionRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Region::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -37,10 +40,18 @@ class RegionLogic extends BaseLogic
return $res;
}
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = Region::getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = Region::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -53,18 +64,10 @@ class RegionLogic extends BaseLogic
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);
$res = Region::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -77,10 +80,10 @@ class RegionLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Region::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -91,7 +94,10 @@ class RegionLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Region::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -102,10 +108,10 @@ class RegionLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Region::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

44
app/Http/Logic/SlideLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Slide;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Slide;
use App\Http\Requests\SlideRequest;
use Validator;
class SlideLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class SlideLogic extends BaseLogic
return new Slide();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Slide');
//数据验证
$validate = new SlideRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Slide::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,7 @@ class SlideLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = Slide::getPaginate($where, $order, $field, $limit);
return $res;
}
@ -48,7 +51,7 @@ class SlideLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = Slide::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -64,7 +67,7 @@ class SlideLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = Slide::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -77,10 +80,10 @@ class SlideLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Slide::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -91,7 +94,10 @@ class SlideLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Slide::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -102,10 +108,10 @@ class SlideLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Slide::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

58
app/Http/Logic/SmsLogLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\SmsLog;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\SmsLog;
use App\Http\Requests\SmsLogRequest;
use Validator;
class SmsLogLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class SmsLogLogic extends BaseLogic
return new SmsLog();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('SmsLog');
//数据验证
$validate = new SmsLogRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = SmsLog::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,23 @@ class SmsLogLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = SmsLog::getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = SmsLog::getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
@ -48,7 +67,7 @@ class SmsLogLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = SmsLog::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -61,10 +80,10 @@ class SmsLogLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = SmsLog::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -75,7 +94,10 @@ class SmsLogLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = SmsLog::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -86,10 +108,10 @@ class SmsLogLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = SmsLog::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

44
app/Http/Logic/SysconfigLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Sysconfig;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Sysconfig;
use App\Http\Requests\SysconfigRequest;
use Validator;
class SysconfigLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class SysconfigLogic extends BaseLogic
return new Sysconfig();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Sysconfig');
//数据验证
$validate = new SysconfigRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Sysconfig::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,7 @@ class SysconfigLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = Sysconfig::getPaginate($where, $order, $field, $limit);
return $res;
}
@ -48,7 +51,7 @@ class SysconfigLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = Sysconfig::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -64,7 +67,7 @@ class SysconfigLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = Sysconfig::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -77,10 +80,10 @@ class SysconfigLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Sysconfig::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -91,7 +94,10 @@ class SysconfigLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Sysconfig::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -102,10 +108,10 @@ class SysconfigLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Sysconfig::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

58
app/Http/Logic/TagindexLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Tagindex;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Tagindex;
use App\Http\Requests\TagindexRequest;
use Validator;
class TagindexLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class TagindexLogic extends BaseLogic
return new Tagindex();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Tagindex');
//数据验证
$validate = new TagindexRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Tagindex::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,23 @@ class TagindexLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = Tagindex::getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = Tagindex::getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
@ -48,7 +67,7 @@ class TagindexLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = Tagindex::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -61,10 +80,10 @@ class TagindexLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Tagindex::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -75,7 +94,10 @@ class TagindexLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Tagindex::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -86,10 +108,10 @@ class TagindexLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Tagindex::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

58
app/Http/Logic/TokenLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\Token;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Token;
use App\Http\Requests\TokenRequest;
use Validator;
class TokenLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class TokenLogic extends BaseLogic
return new Token();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('Token');
//数据验证
$validate = new TokenRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = Token::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,23 @@ class TokenLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = Token::getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = Token::getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
@ -48,7 +67,7 @@ class TokenLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = Token::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -61,10 +80,10 @@ class TokenLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = Token::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -75,7 +94,10 @@ class TokenLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = Token::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -86,10 +108,10 @@ class TokenLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = Token::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

44
app/Http/Logic/UserLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\User;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\User;
use App\Http\Requests\UserRequest;
use Validator;
class UserLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class UserLogic extends BaseLogic
return new User();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('User');
//数据验证
$validate = new UserRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = User::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,7 @@ class UserLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = User::getPaginate($where, $order, $field, $limit);
return $res;
}
@ -48,7 +51,7 @@ class UserLogic extends BaseLogic
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
$res = User::getAll($where, $order, $field, $limit);
/* if($res)
{
@ -64,7 +67,7 @@ class UserLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = User::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -77,10 +80,10 @@ class UserLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = User::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -91,7 +94,10 @@ class UserLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = User::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -102,10 +108,10 @@ class UserLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = User::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

58
app/Http/Logic/VerifyCodeLogic.php

@ -1,14 +1,15 @@
<?php
namespace app\common\logic;
use think\Loader;
use app\common\lib\ReturnData;
use app\common\model\VerifyCode;
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\VerifyCode;
use App\Http\Requests\VerifyCodeRequest;
use Validator;
class VerifyCodeLogic extends BaseLogic
{
protected function initialize()
public function __construct()
{
parent::initialize();
parent::__construct();
}
public function getModel()
@ -16,15 +17,17 @@ class VerifyCodeLogic extends BaseLogic
return new VerifyCode();
}
public function getValidate()
public function getValidate($data, $scene_name)
{
return Loader::validate('VerifyCode');
//数据验证
$validate = new VerifyCodeRequest();
return Validator::make($data, $validate->getSceneRules($scene_name), $validate->getSceneRulesMessages());
}
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$res = VerifyCode::getList($where, $order, $field, $offset, $limit);
if($res['list'])
{
@ -40,7 +43,23 @@ class VerifyCodeLogic extends BaseLogic
//分页html
public function getPaginate($where = array(), $order = '', $field = '*', $limit = '')
{
$res = $this->getModel()->getPaginate($where, $order, $field, $limit);
$res = VerifyCode::getPaginate($where, $order, $field, $limit);
return $res;
}
//全部列表
public function getAll($where = array(), $order = '', $field = '*', $limit = '')
{
$res = VerifyCode::getAll($where, $order, $field, $limit);
/* if($res)
{
foreach($res as $k=>$v)
{
$res[$k] = $this->getDataView($v);
}
} */
return $res;
}
@ -48,7 +67,7 @@ class VerifyCodeLogic extends BaseLogic
//详情
public function getOne($where = array(), $field = '*')
{
$res = $this->getModel()->getOne($where, $field);
$res = VerifyCode::getOne($where, $field);
if(!$res){return false;}
$res = $this->getDataView($res);
@ -61,10 +80,10 @@ class VerifyCodeLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
$res = VerifyCode::add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -75,7 +94,10 @@ class VerifyCodeLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$res = $this->getModel()->edit($data,$where);
$validator = $this->getValidate($data, 'edit');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = VerifyCode::edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -86,10 +108,10 @@ class VerifyCodeLogic extends BaseLogic
{
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());}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
$res = VerifyCode::del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

154
app/Http/Model/Arctype.php

@ -13,6 +13,7 @@ class Arctype extends Model
* @var string
*/
protected $table = 'arctype';
const TABLE_NAME = 'article';
/**
* 表明模型是否应该被打上时间戳
@ -37,6 +38,11 @@ class Arctype extends Model
'id', 'pid', 'addtime', 'name', 'seotitle', 'keywords', 'description','typedir', 'templist', 'temparticle', 'litpic', 'listorder', 'is_show'
);
public static function getDb()
{
return DB::table(self::TABLE_NAME);
}
/**
* 获取分类对应的文章
*/
@ -45,7 +51,7 @@ class Arctype extends Model
return $this->hasMany(Article::class, 'typeid', 'id');
}
public static function getList(array $param)
/* public static function getList(array $param)
{
extract($param); //参数:group_id,limit,offset
@ -88,32 +94,138 @@ class Arctype extends Model
return false;
}
return $res;
} */
/**
* 列表
* @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){$model = $model->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 = parent::getOrderByData($model, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
$res['list'] = $model->skip($offset)->take($limit)->get();
}
return $res;
}
public static function getOne(array $param)
/**
* 分页,用于前端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 = '')
{
extract($param);
$res = self::getDb();
$where['id'] = $id;
if(isset($is_show)){$where['is_show'] = $is_show;}
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 = parent::getOrderByData($res, $order);}
if($limit){}else{$limit = 10;}
return self::where($where)->first();
return $res->paginate($limit);
}
public static function add(array $data)
/**
* 查询全部
* @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)
{
if ($id = self::insertGetId($data))
$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 = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
$res = $res->skip($offset)->take($limit)->get();
return $res;
}
/**
* 获取一条
* @param array $where 条件
* @param string $field 字段
* @return array
*/
public static function getOne($where, $field = '*')
{
return $id;
$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->first();
return $res;
}
return false;
/**
* 添加
* @param array $data 数据
* @return int
*/
public static function add(array $data,$type = 0)
{
if($type==0)
{
// 新增单条数据并返回主键值
return self::insertGetId(parent::filterTableColumn($data,'arctype'));
}
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);
}
}
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,'arctype')) !== false)
{
return true;
}
@ -121,14 +233,20 @@ class Arctype extends Model
return false;
}
//删除一条记录
public static function remove($id)
{
if (!self::whereIn('id', explode(',', $id))->delete())
/**
* 删除
* @param array $where 条件
* @return bool
*/
public static function del($where)
{
return false;
return self::where($where)->delete();
}
return true;
//是否显示,默认0显示
public static function getIsShowAttr($data)
{
$arr = array(0 => '显示', 1 => '隐藏');
return $arr[$data->is_show];
}
}

10
app/Http/Model/Article.php

@ -12,7 +12,7 @@ class Article extends BaseModel
* @var string
*/
protected $table = 'article';
const TABLE_NAME = 'article';
/**
* 表明模型是否应该被打上时间戳
* 默认情况下,Eloquent 期望 created_at 和updated_at 已经存在于数据表中,如果你不想要这些 Laravel 自动管理的数据列,在模型类中设置 $timestamps 属性为 false
@ -41,7 +41,7 @@ class Article extends BaseModel
public static function getDb()
{
return DB::table('article');
return DB::table(self::TABLE_NAME);
}
/**
@ -199,7 +199,7 @@ class Article extends BaseModel
if($type==0)
{
// 新增单条数据并返回主键值
return self::insertGetId(parent::filterTableColumn($data,'article'));
return self::insertGetId(parent::filterTableColumn($data,self::TABLE_NAME));
}
elseif($type==1)
{
@ -225,7 +225,7 @@ class Article extends BaseModel
*/
public static function edit($data, $where = array())
{
if (self::where($where)->update(parent::filterTableColumn($data,'article')) !== false)
if (self::where($where)->update(parent::filterTableColumn($data,self::TABLE_NAME)) !== false)
{
return true;
}
@ -266,7 +266,7 @@ class Article extends BaseModel
return $arr[$data->ischeck];
}
//是否栏目名称
//获取栏目名称
public static function getTypenameAttr($data)
{
return DB::table('arctype')->where(array('id'=>$data['typeid']))->value('name');

6
app/Http/Model/Goods.php

@ -309,4 +309,10 @@ class Goods extends BaseModel
DB::table('goods')->where(array('id'=>$goods_id))->decrement('goods_number', $goods_number);
}
}
//获取栏目名称
public static function getTypenameAttr($data)
{
return DB::table('goods_type')->where(array('id'=>$data['typeid']))->value('name');
}
}

2
app/Http/Requests/ArctypeRequest.php

@ -43,7 +43,7 @@ class ArctypeRequest extends BaseRequest
//场景验证规则
protected $scene = [
'add' => ['typename', 'typedir', 'pid', 'addtime', 'seotitle', 'keywords', 'description', 'listorder', 'templist', 'temparticle', 'litpic', 'seokeyword'],
'add' => ['name', 'typedir', 'pid', 'addtime', 'seotitle', 'keywords', 'description', 'listorder', 'templist', 'temparticle', 'litpic', 'seokeyword'],
'del' => ['id'],
];

30
lqycms.sql

@ -78,13 +78,15 @@ insert into `ecs_topic`(`topic_id`,`title`,`intro`,`start_time`,`end_time`,`dat
DROP TABLE IF EXISTS `fl_access`;
CREATE TABLE `fl_access` (
`role_id` mediumint(7) unsigned NOT NULL DEFAULT '0',
`menu_id` mediumint(7) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
`role_id` int(11) unsigned NOT NULL DEFAULT '0',
`menu_id` int(11) unsigned NOT NULL DEFAULT '0',
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=182 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
/*Data for the table `fl_access` */
insert into `fl_access`(`role_id`,`menu_id`) values (3,1),(3,11),(3,12),(3,13),(3,14),(3,15),(3,16),(3,17),(3,18),(3,19),(3,20),(3,21),(3,22),(3,23),(3,24),(3,25),(3,32),(3,33),(3,34),(3,35),(3,36),(3,37),(3,6),(3,78),(3,83),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13),(1,14),(1,15),(1,16),(1,17),(1,18),(1,19),(1,20),(1,21),(1,22),(1,23),(1,24),(1,25),(1,26),(1,27),(1,28),(1,29),(1,30),(1,31),(1,32),(1,33),(1,34),(1,35),(1,36),(1,37),(1,38),(1,39),(1,40),(1,41),(1,42),(1,43),(1,44),(1,45),(1,46),(1,47),(1,48),(1,49),(1,50),(1,51),(1,52),(1,53),(1,54),(1,55),(1,56),(1,57),(1,58),(1,59),(1,60),(1,61),(1,62),(1,63),(1,64),(1,65),(1,66),(1,67),(1,68),(1,69),(1,70),(1,71),(1,72),(1,73),(1,74),(1,75),(1,76),(1,77),(1,78),(1,79),(1,80),(1,81),(1,82),(1,83),(1,84),(1,85),(1,86),(1,87),(1,88),(1,89),(1,90),(1,91),(1,92),(1,93),(1,94),(1,95),(1,96),(1,97),(1,98),(1,99),(1,100),(1,101),(1,102),(1,103),(1,104),(1,105),(1,106),(1,107),(1,108),(1,109),(1,110),(1,111),(1,112),(1,113),(1,114),(1,115),(1,116),(1,117),(2,2),(2,38),(2,39),(2,40),(2,41),(2,42),(2,50),(2,43),(2,44),(2,45),(2,46),(2,47),(2,48),(2,49),(2,51),(2,107),(2,108),(2,109),(2,110),(2,111),(2,112),(2,5),(2,7),(2,8),(2,9),(2,10),(2,104),(1,118),(1,119),(1,120),(1,121),(1,122),(1,123),(1,124),(1,125),(1,126),(1,127),(1,128),(1,129);
insert into `fl_access`(`role_id`,`menu_id`,`id`) values (3,1,1),(3,11,2),(3,12,3),(3,13,4),(3,14,5),(3,15,6),(3,16,7),(3,17,8),(3,18,9),(3,19,10),(3,20,11),(3,21,12),(3,22,13),(3,23,14),(3,24,15),(3,25,16),(3,32,17),(3,33,18),(3,34,19),(3,35,20),(3,36,21),(3,37,22),(3,6,23),(3,78,24),(3,83,25),(1,1,26),(1,2,27),(1,3,28),(1,4,29),(1,5,30),(1,6,31),(1,7,32),(1,8,33),(1,9,34),(1,10,35),(1,11,36),(1,12,37),(1,13,38),(1,14,39),(1,15,40),(1,16,41),(1,17,42),(1,18,43),(1,19,44),(1,20,45),(1,21,46),(1,22,47),(1,23,48),(1,24,49),(1,25,50),(1,26,51),(1,27,52),(1,28,53),(1,29,54),(1,30,55),(1,31,56),(1,32,57),(1,33,58),(1,34,59),(1,35,60),(1,36,61),(1,37,62),(1,38,63),(1,39,64),(1,40,65),(1,41,66),(1,42,67),(1,43,68),(1,44,69),(1,45,70),(1,46,71),(1,47,72),(1,48,73),(1,49,74),(1,50,75),(1,51,76),(1,52,77),(1,53,78),(1,54,79),(1,55,80),(1,56,81),(1,57,82),(1,58,83),(1,59,84),(1,60,85),(1,61,86),(1,62,87),(1,63,88),(1,64,89),(1,65,90),(1,66,91),(1,67,92),(1,68,93),(1,69,94),(1,70,95),(1,71,96),(1,72,97),(1,73,98),(1,74,99),(1,75,100),(1,76,101),(1,77,102),(1,78,103),(1,79,104),(1,80,105),(1,81,106),(1,82,107),(1,83,108),(1,84,109),(1,85,110),(1,86,111),(1,87,112),(1,88,113),(1,89,114),(1,90,115),(1,91,116),(1,92,117),(1,93,118),(1,94,119),(1,95,120),(1,96,121),(1,97,122),(1,98,123),(1,99,124),(1,100,125),(1,101,126),(1,102,127),(1,103,128),(1,104,129),(1,105,130),(1,106,131),(1,107,132),(1,108,133),(1,109,134),(1,110,135),(1,111,136),(1,112,137),(1,113,138),(1,114,139),(1,115,140),(1,116,141),(1,117,142),(2,2,143),(2,38,144),(2,39,145),(2,40,146),(2,41,147),(2,42,148),(2,50,149),(2,43,150),(2,44,151),(2,45,152),(2,46,153),(2,47,154),(2,48,155),(2,49,156),(2,51,157),(2,107,158),(2,108,159),(2,109,160),(2,110,161),(2,111,162),(2,112,163),(2,5,164),(2,7,165),(2,8,166),(2,9,167),(2,10,168),(2,104,169),(1,118,170),(1,119,171),(1,120,172),(1,121,173),(1,122,174),(1,123,175),(1,124,176),(1,125,177),(1,126,178),(1,127,179),(1,128,180),(1,129,181);
/*Table structure for table `fl_admin` */
@ -96,7 +98,7 @@ CREATE TABLE `fl_admin` (
`email` varchar(30) NOT NULL DEFAULT '' COMMENT '邮箱',
`logintime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '登录时间',
`pwd` char(32) NOT NULL DEFAULT '' COMMENT 'admin',
`role_id` smallint(4) unsigned NOT NULL DEFAULT '0' COMMENT '角色id',
`role_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '角色id',
`status` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '用户状态 0:正常; 1:禁用 ;2:未验证',
`mobile` varchar(20) NOT NULL DEFAULT '' COMMENT '手机号',
`avatar` varchar(150) NOT NULL DEFAULT '' COMMENT '头像',
@ -113,7 +115,7 @@ insert into `fl_admin`(`id`,`username`,`email`,`logintime`,`pwd`,`role_id`,`sta
DROP TABLE IF EXISTS `fl_admin_role`;
CREATE TABLE `fl_admin_role` (
`id` smallint(4) unsigned NOT NULL AUTO_INCREMENT,
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL DEFAULT '' COMMENT '角色名',
`des` varchar(150) NOT NULL DEFAULT '' COMMENT '描述',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '状态,0启用,1禁用',
@ -396,7 +398,7 @@ CREATE TABLE `fl_goods` (
/*Data for the table `fl_goods` */
insert into `fl_goods`(`id`,`typeid`,`tuijian`,`click`,`title`,`body`,`sn`,`price`,`litpic`,`pubdate`,`add_time`,`keywords`,`seotitle`,`description`,`status`,`shipping_fee`,`market_price`,`goods_number`,`user_id`,`sale`,`cost_price`,`goods_weight`,`point`,`comments`,`promote_start_date`,`promote_price`,`promote_end_date`,`goods_img`,`warn_number`,`spec`,`listorder`,`brand_id`) values (1,2,1,5677,'示例产品一','<p>是的发生</p>','sn123456','45000.00','/uploads/2018/04/1.jpg',1512273964,1496577749,'示例,产品,一','','是的发生',0,'0.00','50000.00',99,1,123,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706041951031181.jpg',0,'',50,0),(2,1,1,37,'示例产品二','说的是','sn987','1.00','/uploads/2018/04/2.jpg',1496578330,1496578313,'产品,示例,二','','',0,'3.00','2.00',106,1,67,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706042011354141.jpg',0,'',50,0),(3,1,0,38,'示例产品三','是的发生','sn232143','5.10','/uploads/2018/04/3.jpg',1496578380,1496578380,'示例,产品,三','','',0,'3.00','4.00',103,1,99,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706042012428057.jpg',0,'',50,1),(4,1,0,115,'示例产品四','<p>电热熔</p>','sn9809702','5.00','/uploads/2018/04/4.jpg',1519736409,1496578429,'示例,产品,四','','电热熔',0,'3.00','6.00',91,1,345,'0.00','0.00',0,0,1518435963,'2.00',1519905139,'/uploads/2017/06/201706042013331349.jpg',0,'',50,0),(5,1,0,10,'示例产品五','就回家好看','kjkhk3','989.00','/uploads/2018/04/5.jpg',1522849406,1522849066,'示例,产品,五','','',0,'898.00','98.00',8989,1,1234,'0.00','0.00',0,0,1523281235,'909.00',1524750039,'',1,'',50,0);
insert into `fl_goods`(`id`,`typeid`,`tuijian`,`click`,`title`,`body`,`sn`,`price`,`litpic`,`pubdate`,`add_time`,`keywords`,`seotitle`,`description`,`status`,`shipping_fee`,`market_price`,`goods_number`,`user_id`,`sale`,`cost_price`,`goods_weight`,`point`,`comments`,`promote_start_date`,`promote_price`,`promote_end_date`,`goods_img`,`warn_number`,`spec`,`listorder`,`brand_id`) values (1,2,1,5699,'示例产品一','<p>是的发生</p>','sn123456','45000.00','/uploads/2018/04/1.jpg',1512273964,1496577749,'示例,产品,一','','是的发生',0,'0.00','50000.00',99,1,123,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706041951031181.jpg',0,'',50,0),(2,1,1,38,'示例产品二','说的是','sn987','1.00','/uploads/2018/04/2.jpg',1496578330,1496578313,'产品,示例,二','','',0,'3.00','2.00',106,1,67,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706042011354141.jpg',0,'',50,0),(3,1,0,39,'示例产品三','是的发生','sn232143','5.10','/uploads/2018/04/3.jpg',1496578380,1496578380,'示例,产品,三','','',0,'3.00','4.00',103,1,99,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706042012428057.jpg',0,'',50,1),(4,1,0,115,'示例产品四','<p>电热熔</p>','sn9809702','5.00','/uploads/2018/04/4.jpg',1519736409,1496578429,'示例,产品,四','','电热熔',0,'3.00','6.00',91,1,345,'0.00','0.00',0,0,1518435963,'2.00',1519905139,'/uploads/2017/06/201706042013331349.jpg',0,'',50,0),(5,1,0,12,'示例产品五','就回家好看','kjkhk3','989.00','/uploads/2018/04/5.jpg',1522849406,1522849066,'示例,产品,五','','',0,'898.00','98.00',8989,1,1234,'0.00','0.00',0,0,1523281235,'909.00',1524750039,'',1,'',50,0);
/*Table structure for table `fl_goods_brand` */
@ -551,8 +553,8 @@ insert into `fl_kuaidi`(`id`,`name`,`code`,`money`,`country`,`des`,`tel`,`websi
DROP TABLE IF EXISTS `fl_menu`;
CREATE TABLE `fl_menu` (
`id` int(6) unsigned NOT NULL AUTO_INCREMENT,
`pid` int(6) unsigned NOT NULL DEFAULT '0' COMMENT '父级id',
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`pid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '父级id',
`action` varchar(50) NOT NULL DEFAULT '' COMMENT '操作名称',
`data` varchar(50) NOT NULL DEFAULT '' COMMENT '额外参数',
`type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '菜单类型 1:权限认证+菜单;0:只作为菜单',
@ -799,6 +801,8 @@ CREATE TABLE `fl_session` (
`session_id` varchar(250) NOT NULL COMMENT 'session_id',
`session_expire` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '过期时间',
`session_data` blob NOT NULL COMMENT 'session数据',
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY `session_id` (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -917,12 +921,14 @@ DROP TABLE IF EXISTS `fl_taglist`;
CREATE TABLE `fl_taglist` (
`tid` int(11) unsigned NOT NULL COMMENT '标签id',
`aid` int(11) unsigned NOT NULL COMMENT '文章id',
PRIMARY KEY (`tid`,`aid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='tag标签-文章关系表';
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_tid_aid` (`tid`,`aid`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='tag标签-文章关系表';
/*Data for the table `fl_taglist` */
insert into `fl_taglist`(`tid`,`aid`) values (1,2),(1,5),(1,13),(2,10),(2,12);
insert into `fl_taglist`(`tid`,`aid`,`id`) values (1,2,1),(1,5,2),(1,13,3),(2,10,4),(2,12,5);
/*Table structure for table `fl_token` */

Loading…
Cancel
Save