<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\controller\admin\operate;

use app\controller\Base;
use app\services\operate\ClientService;
use app\services\operate\ClientMenuService;
use app\services\operate\ClientConfigService;

class Client extends Base{

	/**
	 * @title 客户端列表
	 *
	 * @param ClientService $service
	 * @return void
	 */
	public function index(ClientService $service){
		$this->data['data'] = $service->getDataList($this->request);
		return $this->data;
	}

	/**
	 * @title 添加客户端
	 *
	 * @param ClientService $service
	 * @return void
	 */
	public function add(ClientService $service){
		try {
			$data = $service->create($this->request);
			$this->data['code'] = 1;
			$this->data['data'] = $data;
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return $this->data;
	}

	/**
	 * @title 编辑客户端
	 *
	 * @param ClientService $service
	 * @return void
	 */
	public function edit(ClientService $service){
		try {
			$data = $service->update($this->request);
			$this->data['code'] = 1;
			$this->data['data'] = $data;
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return $this->data;
	}

	/**
	 * @title 删除客户端
	 *
	 * @param ClientService $service
	 * @return void
	 */
	public function delete(ClientService $service){
		try {
			$data = $service->delete($this->request);
			$this->data['code'] = 1;
			$this->data['data'] = $data;
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return $this->data;
	}


	/**
	 * @title 客户端菜单列表
	 *
	 * @param ClientMenuService $service
	 * @return void
	 */
	public function menu(ClientMenuService $service){
		$this->data['data'] = $service->getDataList($this->request);
		return $this->data;
	}

	/**
	 * @title 添加客户端菜单
	 *
	 * @param ClientMenuService $service
	 * @return void
	 */
	public function addmenu(ClientMenuService $service){
		try {
			$data = $service->create($this->request);
			$this->data['code'] = 1;
			$this->data['data'] = $data;
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return $this->data;
	}

	/**
	 * @title 编辑客户端菜单
	 *
	 * @param ClientMenuService $service
	 * @return void
	 */
	public function editmenu(ClientMenuService $service){
		try {
			$data = $service->update($this->request);
			$this->data['code'] = 1;
			$this->data['data'] = $data;
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return $this->data;
	}

	/**
	 * @title 删除客户端菜单
	 *
	 * @param ClientMenuService $service
	 * @return void
	 */
	public function delmenu(ClientMenuService $service){
		try {
			$data = $service->delete($this->request);
			$this->data['code'] = 1;
			$this->data['data'] = $data;
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return $this->data;
	}

	/**
	 * @title 添加客户端配置
	 *
	 * @param ClientConfigService $service
	 * @return void
	 */
	public function addconfig(ClientConfigService $service){
		try {
			$data = $service->create($this->request);
			$this->data['code'] = 1;
			$this->data['data'] = $data;
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return $this->data;
	}

	/**
	 * @title 添加客户端配置
	 *
	 * @param ClientConfigService $service
	 * @return void
	 */
	public function editconfig(ClientConfigService $service){
		try {
			$data = $service->update($this->request);
			$this->data['code'] = 1;
			$this->data['data'] = $data;
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return $this->data;
	}

	/**
	 * @title 删除客户端配置
	 *
	 * @param ClientConfigService $service
	 * @return void
	 */
	public function delconfig(ClientConfigService $service){
		try {
			$data = $service->delete($this->request);
			$this->data['code'] = 1;
			$this->data['data'] = $data;
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return $this->data;
	}
}