123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/11
- * Time: 下午3:08
- */
- namespace backend\server;
- use yii\base\Component;
- use common\models\ListClassnev;
- use common\models\ListHouse;
- use Yii;
- use yii\db\Exception;
- class Listclassnevserver extends Component
- {
- /*
- * lyy 获取类目信息(公共)
- * */
- public function getClassNevData($input)
- {
- if (!isset($input['type']) || empty($input['type'])) {
- return false;
- }
- $model = new ListClassnev();
- $model->type = $input['type'];
- $dataInfo = $model->getList($input);
- return $dataInfo;
- }
- /*
- * 获取栏目列表
- * */
- public function getClassNevList($type,$select)
- {
- if (empty($type)) {
- return false;
- }
- return ListClassnev::find()->where(['type'=>$type,'state'=>1])->select($select)->asArray()->all();
- }
- /*
- * 获取一条数据
- * */
- public function getFindOne($id)
- {
- return ListClassnev::findOne($id);
- }
- /*
- * lyy 添加今日头条类目
- * */
- public function addDayToutiao($input)
- {
- $model = new ListClassnev();
- $model->load($input, '');
- if ($model->validate() && $model->save(false)) {
- return true;
- }
- return false;
- }
- /*
- * lyy 编辑
- * */
- public function editDayToutiao($input)
- {
- if (!empty($input['id']) && is_numeric($input['id'])) {
- $model = ListClassnev::findOne($input['id']);
- $model->day_title = $input['day_title'];
- $model->day_email = $input['day_email'];
- if ($model->save()) return true;
- }
- return false;
- }
- /*
- * lyy 今日头条栏目设置
- * */
- public function setDayToutiao($input)
- {
- if (!isset($input['code']) || empty($input['code']) || empty($input['id'])) {
- return false;
- }
- $model = ListClassnev::findOne($input['id']);
- switch ($input['code']) {
- case 'del':
- if ($model->delete()) return true;
- break;
- case 'sort':
- $model->sort = $input['val'];
- if ($model->update()) return true;
- break;
- case 'state':
- $model->state = $input['val'];
- if ($model->update()) return true;
- break;
- }
- return false;
- }
-
- /**************************************关联信息操作ListHouse***********************************************/
- /**
- * 自定义类目关联数据获取
- * */
- public function getTypeListData($input)
- {
- if (!isset($input['type_id']) || empty($input['type_id'])) {
- return ['msg' => '参数错误', 'count' => 0, 'data' => 0];
- }
- $model = new ListHouse();
- $data = $model->GetCharachterForm($input);
- return ['msg' => $data['msg'], 'count' => $data['count'], 'data' => $data['data']];
- }
- /**
- *自定义类目关联数据添加
- *
- */
- public function addListData($input)
- {
- if (!isset($input['type_id']) || empty($input['type_id'])) {
- return false;
- }
- //获取品质新房
- $model = new ListHouse();
- if (ListHouse::find()->where(['list_id'=>$input['type_id'],'hid'=>$input['hid']])->exists()){
- return '楼盘已存在';
- }
- $model->list_id = $input['type_id'];
- $model->hid = $input['hid'];
- if($model->insert()){
- return true;
- }
- return '添加失败';
- }
- /**
- *自定义类目关联数据编辑
- *
- */
- public function editListData($input)
- {
- if (!isset($input['id']) || empty($input['id'])) {
- return false;
- }
- //获取品质新房
- $model = ListHouse::findOne($input['id']);
- $model->hid = $input['hid'];
- return $model->update(false);
- }
- /**
- *自定义类目关联数据设置
- * */
- public function setListData($input)
- {
- if (!isset($input['id']) || empty($input['id'])) {
- return false;
- }
- $model = ListHouse::findOne($input['id']);
- switch ($input['code']) {
- case 'state':
- $model->state = $input['val'];
- return $model->update(false);
- break;
- case 'sort':
- $model->sort = $input['val'];
- return $model->update(false);
- break;
- case 'del':
- return $model->delete();
- break;
- }
- }
- /**
- * 获取自定义类目关联楼盘的一条数据
- * */
- public function GetListHouseOne($id)
- {
- $model = new ListHouse();
- return $model->getFindOne($id);
- }
- }
|