39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Controllers;
|
|
|
|
use Core\Model;
|
|
use \Core\View;
|
|
use App\Models;
|
|
|
|
class User extends \Core\Controller
|
|
{
|
|
function is_password($password) {
|
|
return preg_match("/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/", $password);
|
|
}
|
|
public function allAction(){
|
|
$user = new Models\User();
|
|
$all = $user->getAll();
|
|
$this->JsonResp(200,$all,"OK");
|
|
}
|
|
public function insertAction(){
|
|
$user = new Models\User();
|
|
date_default_timezone_set("Asia/Shanghai");
|
|
//var_dump($this->input);
|
|
|
|
$userdate = date("Y-m-d H:i:s",time());
|
|
$this->input->created_date = $userdate;
|
|
$this->input->update_date = $userdate;
|
|
if( strlen($this->input->user_pwd ) < 6){
|
|
$this->JsonResp(201,null,"password empty");
|
|
return;
|
|
}
|
|
if(!$this->is_password($this->input->user_pwd)){
|
|
$this->JsonResp(201,null,"password illegal");
|
|
return;
|
|
}
|
|
$all = $user->InsertObject($this->input);
|
|
$this->JsonResp(200,$all,"OK");
|
|
}
|
|
} |