|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- /**
- * 数据库表类 log_user_operation
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 倪宗锋
- * PhpStorm LoginController.php
- * Create By 2017/10/18 11:14 $
- */
-
- namespace common\models;
-
- use yii\db\ActiveRecord;
-
- /**
- * 数据库表类 log_user_operation.
- * @property integer $id
- * @property string $title
- * @property string $memo
- * @property integer $uid
- * @property integer $user_type
- * @property string $user_name
- * @property integer $resources_id
- * @property integer $resources_type
- * @property string $resources_name
- * @property string $phpsessid
- * @property string $user_agent
- * @property string $create_time
- */
- class LogUserOperation extends ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'log_user_operation';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['title', 'memo', 'user_name'], 'required'],
- [['memo'], 'string'],
- [['uid', 'user_type', 'resources_id', 'resources_type'], 'integer'],
- [['create_time'], 'safe'],
- [['title'], 'string', 'max' => 120],
- [['user_name', 'resources_name', 'phpsessid', 'user_agent', 'last_login'], 'string', 'max' => 255],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'title' => 'Title',
- 'memo' => 'Memo',
- 'uid' => 'Uid',
- 'user_type' => 'User Type',
- 'user_name' => 'User Name',
- 'resources_id' => 'Resources ID',
- 'resources_type' => 'Resources Type',
- 'resources_name' => 'Resources Name',
- 'phpsessid' => 'Phpsessid',
- 'user_agent' => 'User Agent',
- 'create_time' => 'Crate Time',
- 'last_login' => 'last_login'
- ];
- }
-
- /**
- * Des:添加新记录
- * Name: addNew
- * @param $title string 标题
- * @param $memo string 内容
- * @param $user_info array 用户信息
- * @param $sourceInfo array 资源信息
- * @return bool
- * @author 倪宗锋
- */
- public function addNew($title, $memo, $user_info, $sourceInfo)
- {
- $data = [
- 'id' => 'ID',
- 'title' => $title,
- 'memo' => $memo,
- 'uid' => $user_info['uid'],
- 'user_type' => $user_info['user_type'],
- 'user_name' => $user_info['user_name'],
- 'last_login' => $user_info['last_login'],
- 'resources_id' => $sourceInfo['resources_id'],
- 'resources_type' => $sourceInfo['resources_type'],
- 'resources_name' => $sourceInfo['resources_name'],
- 'phpsessid' => session_id(),
- 'user_agent' => empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'],
- ];
- $this->setAttributes($data);
- $insertFlag = $this->insert();
- $msg = $this->getErrors();
- return $insertFlag;
- }
- }
|