<?php
namespace app\station\controller\v1;
;
use app\station\model\BusinessModel;
use think\Controller;
/**
 * 基站业务线API接口控制器
 * 负责业务线的增删改查
 * Class Business
 * @package app\station\controller
 */
class Business extends Controller
{

/**
 * 基站业务线数据列表
 */
    public function business_list()
    {
    	  $model=new BusinessModel;
    	  $data=$model->selectBusinessList();
          if($data['code']==200){
             if($data['data']){
               return jsonSucc('','suceeess',$data['data']);
             }else{
               return jsonSucc('70002','No Business Line Data Information');
             }
          }else{
               return jsonSucc('70001','Query error please try again');
          }
    	  
    }
/**
 * 添加基站业务线
 */
      public function business_add()
    {
    	$parem=$this->request->post();
    	if($parem){
    	 $model=new BusinessModel;
    	 $result=$model->insertBusiness($parem);
    	 if($result['code']==200){
           return jsonSucc('200','suceess');
    	 }else{
    	   return jsonSucc('70004','Add exceptions, try again');
    	 }
    	}else{
    		return jsonSucc('70003','Business line name cannot be empty');
    	}
    }
/**
 * 修改基站业务线
 */
     public function business_edit()
    {
    	 $parem=$this->request->post();
    	if($parem){
    	 $model=new BusinessModel;
    	 $result=$model->updBusiness($parem);
    	 if($result['code']==200){
           return jsonSucc('200','suceess');
    	 }else{
    	   return jsonSucc('70007','Edit exceptions, try again');
    	 }
    	}else{
    		return jsonSucc('70006','Error request parameters');
    	}
    }
/**
 * 获取修改基站业务线的数据
 */
    public function geteditbusiness()
    {
    	$parem=$this->request->post();
    	 $model=new BusinessModel;
    	 $result=$model->updselectBusiness($parem);
       if($result['code']==200){
            return jsonSucc('','suceess',$result);
       }else{
         return jsonSucc('70005','No relevant information was queried');
       }
    	 
    }
/**
 * 删除基站业务线的数据（软删除）
 */
     public function business_del()
    {
       $parem=$this->request->post();
    	 $model=new BusinessModel;
    	 $result=$model->delBusiness($parem);
          switch ($result['code']) {
          case '200':
          return jsonSucc('200','suceess');
          break;
          case '70008':
          return jsonSucc('70009','Delete exceptions');
          break;
          case '10001':
          return jsonSucc('70008','No relevant information was queried');
          break;
          default: 
          return jsonSucc('70000','error'); 
          break;
       }
     }
}