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

/**
 * 部门数据列表
 */
    public function department_list()
    {
    	  $model=new DepartmentModel;
    	  $data=$model->selectDepartmentList();
          if($data['code']==200){
             if($data['data']){
               return jsonSucc('','suceeess',$data['data']);
             }else{
               return jsonSucc('20065','Department line data does not exist');
             }
          }else{
               return jsonSucc('20063','Query error please try again');
          }
    	  
    }
/**
 * 添加部门
 */
      public function department_add()
    {
    	$parem=$this->request->post();
    	if($parem){
    	 $model=new DepartmentModel;
    	 $result=$model->insertDepartment($parem);
    	 if($result['code']==200){
           return jsonSucc('200','suceess');
    	 }else{
    	   return jsonSucc('200001','error');
    	 }
    	}else{
    		return jsonSucc('1000001','error');
    	}
    }
/**
 * 修改部门
 */
     public function department_edit()
    {
    	 $parem=$this->request->post();
    	if($parem){
    	 $model=new DepartmentModel;
    	 $result=$model->updDepartment($parem);
    	 if($result['code']==200){
           return jsonSucc('200','suceess');
    	 }else{
    	   return jsonSucc('200001','error');
    	 }
    	}else{
    		return jsonSucc('1000001','error');
    	}
    }
/**
 * 获取修改部门的数据
 */
    public function geteditDepartment()
    {
    	$parem=$this->request->post();
    	 $model=new DepartmentModel;
    	 $result=$model->getOneDepartment($parem);
       if($result['code']==10001){
          return jsonSucc('200001','暂无找到id');
        }else{
           return jsonSucc('','suceess',$result['data']);
        }
    	 
    }
/**
 * 删除部门的数据（软删除）
 */
     public function department_del()
    { 
      $parem=$this->request->post();
    	if($parem){
    	 $model=new DepartmentModel;
    	 $result=$model->delDepartment($parem);
    	 if($result['code']==200){
           return jsonSucc('200','suceess');
    	 }else{
    	   return jsonSucc('200001','error');
    	 }
    	}else{
    		return jsonSucc('1000001','error');
    	}
    }
}