LogController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: leo
  5. * Date: 2018/2/24
  6. * Time: 下午12:48
  7. */
  8. namespace backendApi\modules\v1\controllers;
  9. use backendApi\modules\v1\models\exportForms\BonusExportForm;
  10. use backendApi\modules\v1\models\exportForms\LogExportForm;
  11. use backendApi\modules\v1\models\lists\log\AdminHandleList;
  12. use backendApi\modules\v1\models\lists\log\AdminLoginList;
  13. use backendApi\modules\v1\models\lists\bonus\FlowLxList;
  14. use backendApi\modules\v1\models\lists\log\SystemList;
  15. use backendApi\modules\v1\models\lists\log\UserHandleList;
  16. use backendApi\modules\v1\models\lists\log\UserLoginList;
  17. use backendApi\modules\v1\models\LogAdminHandle;
  18. use backendApi\modules\v1\models\LogAdminLogin;
  19. use backendApi\modules\v1\models\LogSystem;
  20. use backendApi\modules\v1\models\LogUserHandle;
  21. use backendApi\modules\v1\models\LogUserLogin;
  22. use common\helpers\Form;
  23. use common\helpers\MongodbSearchFilter;
  24. use common\models\User;
  25. use Yii;
  26. class LogController extends BaseController {
  27. public $modelClass = User::class;
  28. /**
  29. * 管理员操作日志
  30. * @return mixed
  31. * @throws \yii\base\Exception
  32. * @throws \yii\web\HttpException
  33. */
  34. public function actionAdminHandle() {
  35. $listObj = new AdminHandleList();
  36. $data = $listObj->getList();
  37. return static::notice($data);
  38. }
  39. /**
  40. * 会员操作日志
  41. * @return mixed
  42. * @throws \yii\base\Exception
  43. * @throws \yii\web\HttpException
  44. */
  45. public function actionUserHandle() {
  46. $listObj = new UserHandleList();
  47. $data = $listObj->getList();
  48. return static::notice($data);
  49. }
  50. /**
  51. * 管理员登录日志
  52. * @return mixed
  53. * @throws \yii\base\Exception
  54. * @throws \yii\web\HttpException
  55. */
  56. public function actionAdminLogin() {
  57. $listObj = new AdminLoginList();
  58. $data = $listObj->getList();
  59. return static::notice($data);
  60. }
  61. /**
  62. * 会员登录日志
  63. * @return mixed
  64. * @throws \yii\base\Exception
  65. * @throws \yii\web\HttpException
  66. */
  67. public function actionUserLogin() {
  68. $listObj = new UserLoginList();
  69. $data = $listObj->getList();
  70. return static::notice($data);
  71. }
  72. /**
  73. * 会员登录日志导出
  74. * @return mixed
  75. * @throws \yii\db\Exception
  76. * @throws \yii\web\HttpException
  77. */
  78. public function actionUserLoginExport() {
  79. $filter = MongodbSearchFilter::filterCondition([
  80. 'opt_type' => 'opt_type',
  81. 'user_name' => 'user_name',
  82. 'success_times' => 'success_times',
  83. 'fail_times' => 'fail_times',
  84. 'created_at' => 'created_at',
  85. 'period_num' => 'period_num',
  86. 'device' => 'device',
  87. 'user_agent' => 'user_agent',
  88. 'request_route' => 'user_agent',
  89. ]);
  90. $form = new LogExportForm();
  91. $result = $form->run($filter, 'Member_Login_Log'); // 会员登录日志
  92. if (!$result) {
  93. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  94. }
  95. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  96. }
  97. /**
  98. * 系统日志
  99. * @return mixed
  100. * @throws \yii\base\Exception
  101. * @throws \yii\web\HttpException
  102. */
  103. public function actionSystem() {
  104. $listObj = new SystemList();
  105. $data = $listObj->getList();
  106. return static::notice($data);
  107. }
  108. }