<?php
namespace app\station\controller\v1;
;
use app\station\model\StaffModel;
use think\Controller;
/**
 * 员工API接口控制器
 * 负责员工的增删改查
 * Class Staff
 * @package app\station\controller
 */
class Staff extends Controller
{

/**
 * 员工数据列表
 */
    public function staff_list()
    {
    	  $model=new StaffModel;
    	  $data=$model->selectStaffList();
          if($data['code']==200){
             if($data['data']){
               return jsonSucc('','suceeess',$data['data']);
             }else{
               return jsonSucc('20065','Staff line data does not exist');
             }
          }else{
               return jsonSucc('20063','Query error please try again');
          }
    	  
    }
/**
 * 添加员工
 */
      public function staff_add()
    {
    	$parem=$this->request->post();
    	if($parem){
    	 $model=new StaffModel;
    	 $result=$model->insertStaff($parem);
    	 if($result['code']==200){
           return jsonSucc('200','suceess');
    	 }else{
    	   return jsonSucc('200001','error');
    	 }
    	}else{
    		return jsonSucc('1000001','error');
    	}
    }
/**
 * 修改员工
 */
     public function staff_edit()
    {
    	 $parem=$this->request->post();
    	if($parem){
    	 $model=new StaffModel;
    	 $result=$model->updStaff($parem);
    	 if($result['code']==200){
           return jsonSucc('200','suceess');
    	 }else{
    	   return jsonSucc('200001','error');
    	 }
    	}else{
    		return jsonSucc('1000001','error');
    	}
    }
/**
 * 获取修改员工的数据
 */
    public function getOneStaff()
    {
    	$parem=$this->request->post();
    	 $model=new StaffModel;
    	 $result=$model->getOneStaff($parem);
       if($result['code']==10001){
          return jsonSucc('200001','暂无找到id');
        }else{
           return jsonSucc('','suceess',$result['data']);
        }
    }
/**
 * 删除员工的数据（软删除）
 */
     public function staff_del()
    { 
      $parem=$this->request->post();
    	if($parem){
    	 $model=new StaffModel;
    	 $result=$model->delStaff($parem);
    	 if($result['code']==200){
           return jsonSucc('200','suceess');
    	 }else{
    	   return jsonSucc('200001','error');
    	 }
    	}else{
    		return jsonSucc('1000001','error');
    	}
    }
}