AbstractController.class.php
994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Created by PhpStorm.
*
* User: daijun
* Date: 2017-11-02
*/
namespace Api\Controller;
use \Common\Controller\Api\AbstractController as BaseAbstractController;
abstract class AbstractController extends BaseAbstractController
{
// 默认分页参数
const DEFAULT_LIMIT = 15;
/**
* 店号格式验证(K+6位数字)
*
* @param $dpSerialNums 店号
*
* @return string 返回店号,如果验证失败返回店号为空
*/
public function validate_dpSerialNums($dpSerialNums)
{
if (empty($dpSerialNums)) {
return $dpSerialNums;
}
// 店号中的字母转为大写
$dpSerialNums = rstrtoupper($dpSerialNums);
// 店号格式验证正则
$format_dpSerialNums = '/^K\d{6}$/';
// 店号格式不符合规范
if (!preg_match($format_dpSerialNums, $dpSerialNums)) {
$dpSerialNums = '';
}
return $dpSerialNums;
}
}