1
This commit is contained in:
parent
a4c3cf9714
commit
bfb9d35d6a
@ -534,4 +534,23 @@ class UserController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
public function like(){
|
||||
$account_id = getReqVal('target_id', '');
|
||||
if (! $account_id){
|
||||
$this->_rspErr(1, 'target_id param error');
|
||||
return;
|
||||
}
|
||||
if ($account_id == $this->_getAccountId()){
|
||||
$this->_rspErr(1, 'target_id param error');
|
||||
return;
|
||||
}
|
||||
$userDb = User::find($account_id);
|
||||
if (!$userDb){
|
||||
$this->_rspErr(1, 'target_id param error');
|
||||
return;
|
||||
}
|
||||
User::updateLikeCount($account_id);
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -143,4 +143,19 @@ class User extends BaseModel {
|
||||
);
|
||||
}
|
||||
|
||||
public static function updateLikeCount($targetId){
|
||||
SqlHelper::update
|
||||
(myself()->_getSelfMysql(),
|
||||
't_user',
|
||||
array(
|
||||
'account_id' => $targetId,
|
||||
),
|
||||
array(
|
||||
'like_count' => function(){
|
||||
return "like_count + 1";
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user