Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

114 řádky
3.4 KiB

  1. <?php
  2. /**
  3. * 数据库表类 log_user_operation
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 倪宗锋
  12. * PhpStorm LoginController.php
  13. * Create By 2017/10/18 11:14 $
  14. */
  15. namespace common\models;
  16. use yii\db\ActiveRecord;
  17. /**
  18. * 数据库表类 log_user_operation.
  19. * @property integer $id
  20. * @property string $title
  21. * @property string $memo
  22. * @property integer $uid
  23. * @property integer $user_type
  24. * @property string $user_name
  25. * @property integer $resources_id
  26. * @property integer $resources_type
  27. * @property string $resources_name
  28. * @property string $phpsessid
  29. * @property string $user_agent
  30. * @property string $create_time
  31. */
  32. class LogUserOperation extends ActiveRecord
  33. {
  34. /**
  35. * @inheritdoc
  36. */
  37. public static function tableName()
  38. {
  39. return 'log_user_operation';
  40. }
  41. /**
  42. * @inheritdoc
  43. */
  44. public function rules()
  45. {
  46. return [
  47. [['title', 'memo', 'user_name'], 'required'],
  48. [['memo'], 'string'],
  49. [['uid', 'user_type', 'resources_id', 'resources_type'], 'integer'],
  50. [['create_time'], 'safe'],
  51. [['title'], 'string', 'max' => 120],
  52. [['user_name', 'resources_name', 'phpsessid', 'user_agent', 'last_login'], 'string', 'max' => 255],
  53. ];
  54. }
  55. /**
  56. * @inheritdoc
  57. */
  58. public function attributeLabels()
  59. {
  60. return [
  61. 'id' => 'ID',
  62. 'title' => 'Title',
  63. 'memo' => 'Memo',
  64. 'uid' => 'Uid',
  65. 'user_type' => 'User Type',
  66. 'user_name' => 'User Name',
  67. 'resources_id' => 'Resources ID',
  68. 'resources_type' => 'Resources Type',
  69. 'resources_name' => 'Resources Name',
  70. 'phpsessid' => 'Phpsessid',
  71. 'user_agent' => 'User Agent',
  72. 'create_time' => 'Crate Time',
  73. 'last_login' => 'last_login'
  74. ];
  75. }
  76. /**
  77. * Des:添加新记录
  78. * Name: addNew
  79. * @param $title string 标题
  80. * @param $memo string 内容
  81. * @param $user_info array 用户信息
  82. * @param $sourceInfo array 资源信息
  83. * @return bool
  84. * @author 倪宗锋
  85. */
  86. public function addNew($title, $memo, $user_info, $sourceInfo)
  87. {
  88. $data = [
  89. 'id' => 'ID',
  90. 'title' => $title,
  91. 'memo' => $memo,
  92. 'uid' => $user_info['uid'],
  93. 'user_type' => $user_info['user_type'],
  94. 'user_name' => $user_info['user_name'],
  95. 'last_login' => $user_info['last_login'],
  96. 'resources_id' => $sourceInfo['resources_id'],
  97. 'resources_type' => $sourceInfo['resources_type'],
  98. 'resources_name' => $sourceInfo['resources_name'],
  99. 'phpsessid' => session_id(),
  100. 'user_agent' => empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'],
  101. ];
  102. $this->setAttributes($data);
  103. $insertFlag = $this->insert();
  104. $msg = $this->getErrors();
  105. return $insertFlag;
  106. }
  107. }