* code for bind dinguserid.

This commit is contained in:
wangyidong
2019-11-22 17:00:02 +08:00
parent 18a4c9220f
commit 303b48c1bb
3 changed files with 12 additions and 2 deletions
+1 -1
View File
@@ -3,6 +3,6 @@ CREATE TABLE `zt_dinguserid` (
`webhook` mediumint(8) unsigned NOT NULL,
`account` varchar(30) NOT NULL,
`userid` varchar(255) NOT NULL,
UNIQUE KEY `webhook_account_userid` (`webhook`,`account`,`userid`)
UNIQUE KEY `webhook_account` (`webhook`,`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `zt_translation`;
+8
View File
@@ -11,6 +11,14 @@
*/
class webhook extends control
{
/**
* Construct
*
* @param string $moduleName
* @param string $methodName
* @access public
* @return void
*/
public function __construct($moduleName = '', $methodName = '')
{
parent::__construct($moduleName, $methodName);
+3 -1
View File
@@ -221,6 +221,8 @@ class webhookModel extends model
public function bind($webhookID)
{
$data = fixer::input('post')->get();
$this->dao->delete()->from(TABLE_DINGUSERID)->where('account')->in(array_keys($data->userid))->exec();
foreach($data->userid as $account => $userid)
{
if(empty($userid)) continue;
@@ -229,7 +231,7 @@ class webhookModel extends model
$dingUser->webhook = $webhookID;
$dingUser->account = $account;
$dingUser->userid = $userid;
$this->dao->replace(TABLE_DINGUSERID)->data($dingUser)->exec();
$this->dao->insert(TABLE_DINGUSERID)->data($dingUser)->exec();
}
return !dao::isError();
}