接口添加评论上传

deploy
DESKTOP-4RNDQIC\29019 2020-04-13 12:48:18 +08:00
parent 78cf379dd1
commit 57857b23b5
5 changed files with 15 additions and 38 deletions

View File

@ -12,22 +12,12 @@ use App\Config;
class DocComment extends Controller
{
public function insertAction(){
$user = new Models\User();
$comment = new Models\DocComment();
date_default_timezone_set("Asia/Shanghai");
//var_dump($this->input);
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");
$comment->InsertObject($this->input);
//$this->JsonResp(200,$all,"OK");
}
}

View File

@ -8,5 +8,9 @@ use PDO;
class DocComment extends Model
{
public $tableName = 'doc_comment';
function InsertObject($obj)
{
return parent::InsertObject($obj); // TODO: Change the autogenerated stub
}
}

View File

@ -23,27 +23,10 @@ class User extends \Core\Model
$stmt = $db->query('SELECT * FROM users');
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
public function Insert($user){
public function Insert($comment){
$db = static::getDB();
$stmt = $db->query(`insert into users('user_name','user_pwd','create_date','update_date','display_name'
,'email_address','tel','avatar') values (` + $user["user_name"] + `,` +
$user["user_pwd"] + `,` +
$user["create_date"] + `,` +
$user["update_date"] + `,` +
$user["display_name"] + `,` +
$user["email_address"] + `,` +
$user["tel"] + `,` +
$user["avatar"] + `,` +
+ `)` + `ON DUPLICATE KEY UPDATE users.user_name = ` + $user["user_pwd"] + `,` +
`users.user_pwd = ` +$user["user_pwd"] + `,` +
`users.create_date = ` +$user["create_date"] + `,` +
`users.update_date = ` +$user["update_date"] + `,` +
`users.display_name = ` +$user["display_name"] + `,` +
`users.email_address = ` +$user["email_address"] + `,` +
`users.tel = ` +$user["tel"] + `,` +
`users.avatar = ` +$user["avatar"] + `,`
$stmt = $db->query(`insert into doc_comment('doc_id','child_id','content','time'') values (` + $comment["doc_id"] + `,` + $comment["child_id"] + `,` + $comment["content"] + `,` + $comment["time"] + `;`
);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
}

View File

@ -248,7 +248,6 @@ ul li a{
updateMenu();
firstinit = true;
}else{
console.log("first init pass");
}
console.log($("#doc_type_{{type}}").innerText);
$("#doc_type_{{type}}").addClass("active");

View File

@ -95,9 +95,10 @@ abstract class Model
$query = $query.$val;
$stmt = $db->query($query);
$res = $stmt->fectchAll();
var_dump($stmt);
print_r($stmt->errorInfo());
//$res = $stmt->fetch();
//$result = $stmt->fetchAll();
return $res;
//return $res;
}
}