41 changed files with 2800 additions and 41 deletions
-
30app/Common/function.php
-
16app/Http/Controllers/Admin/ArticleController.php
-
123app/Http/Logic/ArctypeLogic.php
-
134app/Http/Logic/ArticleLogic.php
-
10app/Http/Logic/BaseLogic.php
-
123app/Http/Logic/FeedbackLogic.php
-
123app/Http/Logic/FriendlinkLogic.php
-
123app/Http/Logic/GoodsBrandLogic.php
-
127app/Http/Logic/GoodsLogic.php
-
123app/Http/Logic/GoodsTypeLogic.php
-
125app/Http/Logic/GuestbookLogic.php
-
125app/Http/Logic/PageLogic.php
-
123app/Http/Logic/PaymentLogic.php
-
123app/Http/Logic/RegionLogic.php
-
123app/Http/Logic/SlideLogic.php
-
107app/Http/Logic/SmsLogLogic.php
-
123app/Http/Logic/SysconfigLogic.php
-
107app/Http/Logic/TagindexLogic.php
-
107app/Http/Logic/TokenLogic.php
-
123app/Http/Logic/UserLogic.php
-
107app/Http/Logic/VerifyCodeLogic.php
-
176app/Http/Model/Article.php
-
26app/Http/Model/BaseModel.php
-
29app/Http/Requests/ArctypeRequest.php
-
42app/Http/Requests/ArticleRequest.php
-
20app/Http/Requests/FeedbackRequest.php
-
21app/Http/Requests/FriendlinkRequest.php
-
28app/Http/Requests/GoodsBrandRequest.php
-
31app/Http/Requests/GoodsTypeRequest.php
-
24app/Http/Requests/GuestbookRequest.php
-
26app/Http/Requests/PageRequest.php
-
22app/Http/Requests/PaymentRequest.php
-
22app/Http/Requests/RegionRequest.php
-
24app/Http/Requests/SlideRequest.php
-
21app/Http/Requests/SmsLogRequest.php
-
20app/Http/Requests/SysconfigRequest.php
-
19app/Http/Requests/TagindexRequest.php
-
20app/Http/Requests/TokenRequest.php
-
21app/Http/Requests/UserRequest.php
-
22app/Http/Requests/VerifyCodeRequest.php
-
2resources/views/admin/article/index.blade.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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -0,0 +1,10 @@ |
|||
<?php |
|||
namespace App\Http\Logic; |
|||
|
|||
class BaseLogic |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
|
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
@ -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'], |
|||
]; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue