<?php

namespace Admin\Controller;

use Think\Controller;

/**
 * 支付宝快捷认证控制器
 * @author 鹿文学
 */
class AlipayAuthController extends ThinkController {
    
    const model_name = 'AlipayAuth';

    /**
     * 支付宝快捷认证列表
     */
    public function lists(){
				
				if(is_numeric($_REQUEST['game_id']) && $_REQUEST['game_id']>0) {$extend['game_id']=$_REQUEST['game_id'];}
				
        
				$this->m_title = '支付宝快捷认证';
				$this->meta_title = '支付宝快捷认证';
				$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'AlipayAuth/lists','status'=>1])->find());
				
				$data = D(self::model_name)->lists($_GET['p'],$extend);
				
				$this->assign('list_data',$data['data']);
				$this->assign('_page',$data['page']);
				
				$this->display();
				
    }
		
		
		/**
     * 添加支付宝快捷认证
		 * @author 鹿文学
     */
		public function add() {
			if(IS_POST) {
				
				$alipayauth = D(self::model_name);
				
				if($alipayauth->update($_POST)) {
					$this->success('新增成功',U('lists'));
				} else {
					$this->error($alipayauth->getError());
				}
				
			} else {
				
				$this->meta_title = '新增支付宝快捷认证参数';
						
				$this->m_title = '支付宝快捷认证';
				$this->m_url = 'AlipayAuth/lists';
				$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'AlipayAuth/lists','status'=>1])->find());
				
				
				$this->display();
			}
		}
		
		/**
     * 编辑支付宝快捷认证
		 * @author 鹿文学
     */
		public function edit() {
			if(IS_POST) {
				
				$alipayauth = D(self::model_name);
				
				if($alipayauth->update($_POST)) {
					$this->success('编辑成功',U('lists'));
				} else {
					$this->error($alipayauth->getError());
				}
				
				
			} else {
				$map['id'] = $_REQUEST['id'];
				$data = D(self::model_name)->where($map)->find();
				$this->assign('data',$data);
				
				$this->meta_title = '编辑支付宝快捷认证参数';
						
				$this->m_title = '支付宝快捷认证';
				$this->m_url = 'AlipayAuth/lists';
				$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'AlipayAuth/lists','status'=>1])->find());
				
				
				$this->display();
			}
		}
		
		/**
     * 删除支付宝快捷认证
		 * @param array/integer  $ids  要删除的支付宝快捷认证编号
		 * @author 鹿文学
     */
		public function del($ids=null){
        $model = M('Model')->getByName(self::model_name); /*通过Model名称获取Model完整信息*/
        parent::del($model["id"],$ids);
    }
		
		/**
     * 开启关闭支付宝快捷认证
		 * @author 鹿文学
     */
		public function change_status() {
			
			parent::set_status(self::model_name);
			
		}

    

}