123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- namespace app\common\library;
- use think\Cache;
- use think\Validate;
- use think\Db;
- class Verify {
- public static function loginCheck($data){
- $rule = [
- 'userName' => 'require|length:4,25',
- 'pwd' => 'require|between:5,20',
- ];
- $msg = [
- 'name.require' => '用户名必须',
- 'name.length' => '用户名最多不能少于4个字符或者超过25个字符',
- 'pwd.require' => '密码不能为空',
- 'pwd.between' => '密码长度只能在1-120之间',
- ];
- $validate = new Validate($rule, $msg);
- $result = $validate->check($data);
- if(!$result){
- return json_encode(['status'=>'fail','code'=>'9999','msg'=>$validate->getError()]);
- }
- }
- public static function applicationCheck($data){
- $rule = [
- 'illness_desc' => 'max:2000',
- 'clin_symp' => 'max:2000',
- 'phys_sign' => 'max:2000',
- 'clin_diag' => 'max:2000',
- 'anamnesis' => 'max:2000',
- 'family_ill' => 'max:2000',
- 'marrital' => 'max:2000',
- 'remark' => 'max:3000',
- 'application_desc' => 'max:2000',
- ];
- $msg = [
- 'illness_desc.max' => '主诉最大字符长度不能超过2000',
- 'clin_symp.max' => '临床症状最大字符长度不能超过2000',
- 'phys_sign.max' => '体征最大字符长度不能超过2000',
- 'clin_diag.max' => '临床诊断最大字符长度不能超过2000',
- 'anamnesis.max' => '既往史最大字符长度不能超过2000',
- 'family_ill.max' => '家族史最大字符长度不能超过2000',
- 'marrital.max' => '婚姻史最大字符长度不能超过2000',
- 'remark.max' => '备注最大字符长度不能超过3000',
- 'application_desc.max' => '申请描述最大字符长度不能超过2000',
- ];
- $validate = new Validate($rule, $msg);
- $result = $validate->check($data);
- if(!$result){
- return json_encode(['status'=>'fail','code'=>'9999','msg'=>$validate->getError()]);
- }
- }
- public static function registerCheck($data)
- {
- $rule = [
- 'pnum' =>'require',
- 'name' => 'require|length:4,25',
- 'age' => 'require|between:1,120',
- 'sex' => 'require',
- 'birthday' => 'date',
- 'illness_desc' => 'max:2000',
- 'clin_symp' => 'max:2000',
- 'phys_sign' => 'max:2000',
- 'clin_diag' => 'max:2000',
- 'anamnesis' => 'max:2000',
- 'family_ill' => 'max:2000',
- 'marrital' => 'max:2000',
- 'remark' => 'max:3000',
- ];
- $msg = [
- 'pnum.require' => '姓名为必填项',
- 'name.require' => '姓名为必填项',
- 'name.length' => '用户名最多不能少于4个字符或者超过25个字符',
- 'age.require' => '年龄为必填项',
- 'age.between' => '年龄长度只能在1-120之间',
- 'sex.require' => '性别为必填项',
- 'illness_desc.max' => '主诉最大字符长度不能超过2000',
- 'clin_symp.max' => '临床症状最大字符长度不能超过2000',
- 'phys_sign.max' => '体征最大字符长度不能超过2000',
- 'clin_diag.max' => '临床诊断最大字符长度不能超过2000',
- 'anamnesis.max' => '既往史最大字符长度不能超过2000',
- 'family_ill.max' => '家族史最大字符长度不能超过2000',
- 'marrital.max' => '婚姻史最大字符长度不能超过2000',
- 'remark.max' => '备注最大字符长度不能超过3000',
- ];
- $validate = new Validate($rule, $msg);
- $result = $validate->check($data);
- if(!$result){
- return json_encode(['status'=>'fail','code'=>'9999','msg'=>$validate->getError()]);
- }
- }
- public function wreportCheck($data)
- {
- $rule = [
- 'impression' => 'max:2000',
- 'description' => 'max:2000',
- ];
- $msg = [
- 'impression.max' => '检查所见最大字符长度不能超过2000',
- 'description.max' => '检查印象最大字符长度不能超过2000',
- ];
- $validate = new Validate($rule, $msg);
- $result = $validate->check($data);
- if(!$result){
- return json_encode(['status'=>'fail','code'=>'9999','msg'=>$validate->getError()]);
- }
- }
- public static function check_role($sessionid,$num){
- $doctor = Cache::get($sessionid);
- $dclass = DB::table('doctor_class')->where('doctor_id',$doctor['id'])->field('doctor_class')->find();
- $doctor_class = explode(',',$dclass['doctor_class']);
- foreach ($doctor_class as $k=>$v) {
- if($v == $num){
- return 1;
- }
- }
- return 0;
- }
- }
|