Browse Source

新增员工查询接口

huangsanjia 1 year ago
parent
commit
faeef28fc7
1 changed files with 22 additions and 0 deletions
  1. 22 0
      application/api/controller/ReportingWork.php

+ 22 - 0
application/api/controller/ReportingWork.php

@@ -179,6 +179,28 @@ class ReportingWork extends Api
         }
         $this->success('请求成功',rtrim($data));
     }
+    /**
+     * 根据员工编号获取姓名-优化
+     * @ApiMethod GET
+     * @params string code
+     */
+    public function getStaffNameTwo(){
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['code']) || empty($params['code'])) {
+            $this->error('参数错误');
+        }
+        $data = \db('人事_基本资料')->where('员工编号',$params['code'])->field('员工姓名')->select();
+        if (empty($data)){
+            $data = \db('人事_基本资料')->where('pycode',$params['code'])->field('rtrim(员工姓名) as 员工姓名')->select();
+        }
+        $num = count($data);
+        $res['total'] = $num;
+        $res['data'] = $data;
+        $this->success('请求成功',$res);
+    }
     /**
      * 提交巡查记录
      * @ApiMethod POST