1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/11
- * Time: 下午3:08
- */
- namespace backend\server;
- use yii\base\Component;
- use common\models\Sensitivewords;
- use common\models\Syncwordrecord;
- use Yii;
- use yii\db\Exception;
- class SyncWord extends Component
- {
- public function LiveOpe($input)
- {
- $content = $input['content'];
- $info = $input['info'];
- $operator = $input['operator'];
- $model = new Sensitivewords();
- $wordinfo = $model->getList();
- $Transaction = Yii::$app->db->beginTransaction();
- if (!empty($wordinfo)) {
- $query = Sensitivewords::findOne($wordinfo['id']);
- $query->content = $content;
- $query->info = $info;
- $query->update_at = time();
- $s = $query->save();
- if ($s != true) return '目标站敏感四更新失败';
- $cordInfo = new Syncwordrecord();
- $cordInfo->mode = 'edit';
- $cordInfo->operator = $operator;
- $cordInfo->oos_content = $content;
- $cordInfo->oos_info = $info;
- $cordInfo->this_content = $wordinfo['content'];
- $cordInfo->this_info = $wordinfo['info'];
- $cordInfo->create_at = time();
- $cordInfo->update_at = time();
- $s = $cordInfo->save();
- if ($s != true) {
- $Transaction->rollBack();
- return '目标站更新纪录失败';
- }
- $Transaction->commit();
- } else {
- $query = $model;
- $query->content = $content;
- $query->info = $info;
- $query->create_at = time();
- $s = $query->save();
- if ($s != true) return '目标站敏感四添加失败';
- $cordInfo = new Syncwordrecord();
- $cordInfo->mode = 'add';
- $cordInfo->operator = $operator;
- $cordInfo->oos_content = $content;
- $cordInfo->oos_info = $info;
- $cordInfo->create_at = time();
- $cordInfo->update_at = time();
- $s = $cordInfo->save();
- if ($s != true) {
- $Transaction->rollBack();
- return '目标站添加纪录失败';
- }
- $Transaction->commit();
- }
- return true;
- }
- }
|