This commit is contained in:
hujiabin 2022-09-20 21:34:06 +08:00
parent a4c3cf9714
commit bfb9d35d6a
2 changed files with 34 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -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";
}
)
);
}
}