SystemList.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\log;
  3. use common\helpers\MongodbSearchFilter;
  4. use common\libs\dataList\DataListInterface;
  5. use common\libs\dataList\column\DateTime;
  6. use common\models\LogSystem;
  7. class SystemList extends \common\libs\dataList\DataList implements DataListInterface
  8. {
  9. /**
  10. * 列表名称
  11. * @return string
  12. */
  13. public function getListName(){
  14. return '系统日志';
  15. }
  16. /**
  17. * 列表筛选到的数据
  18. * @throws \yii\base\Exception
  19. */
  20. public function dataHandle()
  21. {
  22. $filter = MongodbSearchFilter::filterCondition([
  23. 'opt_type' => 'opt_type',
  24. 'opt_target_name' => 'opt_target_name',
  25. 'opt_obj_name' => 'opt_obj_name',
  26. 'opt_user' => 'opt_user',
  27. 'created_at' => 'created_at',
  28. 'period_num' => 'period_num',
  29. 'ip' => 'ip',
  30. 'device' => 'device',
  31. 'user_agent' => 'user_agent',
  32. 'request_route' => 'request_route',
  33. ]);
  34. $this->listData = LogSystem::lists($filter['condition'], []);
  35. }
  36. /**
  37. * 要展示和导出的所有字段
  38. * @return array
  39. */
  40. public function getColumn(){
  41. if(!$this->columns){
  42. $this->columns = [
  43. 'opt_type' => [
  44. 'header' => \Yii::t('ctx', 'operatingType'),
  45. 'headerOther' => [
  46. 'width' => '120',
  47. ],
  48. 'value' => function($row) {
  49. return (isset($row['opt_type']) && $row['opt_type'] == 'call' )? \Yii::t('ctx', 'call') : \Yii::t('ctx', 'beCcalled');
  50. },
  51. 'valueOther' => function($row) {
  52. return [
  53. 'tag'=>['type'=>(isset($row['opt_type']) && $row['opt_type'] == 'call' )? 'success' : 'danger', 'size' => 'small']
  54. ];
  55. },
  56. ],
  57. 'opt_target_name' => [
  58. 'header' => \Yii::t('ctx', 'operatingObject'),
  59. 'headerOther' => [
  60. 'width' => '120',
  61. ],
  62. ],
  63. 'opt_obj_name' => [
  64. 'header' => \Yii::t('ctx', 'objectNumber'),
  65. 'headerOther' => [
  66. 'width' => '110',
  67. ],
  68. ],
  69. 'request_content' => [
  70. 'header' => \Yii::t('ctx', 'requestContent'),
  71. 'headerOther' => [
  72. 'show-overflow-tooltip'=>true,
  73. 'min-width'=>'250',
  74. ],
  75. ],
  76. 'response_content' => [
  77. 'header' => \Yii::t('ctx', 'requestContent'),
  78. 'headerOther' => [
  79. 'show-overflow-tooltip'=>true,
  80. 'min-width'=>'250',
  81. ],
  82. ],
  83. 'opt_user' => [
  84. 'header' => \Yii::t('ctx', 'operator'),
  85. 'headerOther' => [
  86. 'width' => '130',
  87. ],
  88. ],
  89. 'created_at' => [
  90. 'header' => \Yii::t('ctx', 'operatingTime'),
  91. 'value' => function($row) {
  92. return (new DateTime([
  93. 'value' => $row['created_at'],
  94. ]))->result();
  95. },
  96. 'headerOther' => ['width' => '180'],
  97. ],
  98. 'period_num' => \Yii::t('ctx', 'numberOfPhases'),
  99. 'ip' => [
  100. 'header' => \Yii::t('ctx', 'IPAddress'),
  101. 'headerOther' => [
  102. 'width' => '150',
  103. ],
  104. ],
  105. 'device' => [
  106. 'header' => \Yii::t('ctx', 'IPAddress'),
  107. 'headerOther' => [
  108. 'width' => '150',
  109. ],
  110. ],
  111. 'user_agent' => [
  112. 'header' => \Yii::t('ctx', 'operatingSystem'),
  113. 'headerOther' => [
  114. 'width' => '350',
  115. ],
  116. ],
  117. 'request_route' => [
  118. 'header' => \Yii::t('ctx', 'requestPath'),
  119. 'headerOther' => [
  120. 'width' => '250',
  121. ],
  122. ],
  123. ];
  124. }
  125. return $this->columns;
  126. }
  127. /**
  128. * 前台用于筛选的类型集合
  129. * @return mixed
  130. */
  131. public function getFilterTypes()
  132. {
  133. if(!$this->filterTypes){
  134. $this->filterTypes = [
  135. 'opt_type' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'operatingType'), 'other'=> 'select', 'selectData'=> [['id'=> 'call', 'name'=> \Yii::t('ctx', 'call')], ['id'=> 'called', 'name'=> \Yii::t('ctx', 'beCcalled')]]],
  136. 'opt_target_name' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'operatingObject')],
  137. 'opt_obj_name' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'objectNumber')],
  138. 'opt_user' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'operator')],
  139. 'created_at' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'operatingTime'), 'other'=> 'date'],
  140. 'period_num' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'numberOfPhases')],
  141. 'ip' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'IPAddress')],
  142. 'device' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'client')],
  143. 'user_agent' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'operatingSystem')],
  144. 'request_route' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'requestPath')],
  145. ];
  146. }
  147. return $this->filterTypes;
  148. }
  149. }