Kaynağa Gözat

用户操作日志添加分条件查询

liusw 8 yıl önce
ebeveyn
işleme
da45b8f995

+ 9 - 5
src/main/java/com/uas/platform/b2c/common/account/controller/UsageLogController.java

@@ -1,17 +1,19 @@
 package com.uas.platform.b2c.common.account.controller;
 
 import com.uas.platform.b2c.common.account.model.UsageLog;
-import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.account.service.UsageLogService;
-import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
+import com.wordnik.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Sort;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
 
 
 /**
@@ -33,8 +35,11 @@ public class UsageLogController {
 	 * @return
 	 */
 	@RequestMapping(method = RequestMethod.GET)
-	public Page<UsageLog> getAllByPage(PageParams params) {
+	public Page<UsageLog> getAllByPage(PageParams params,@ApiParam(required = true, value = "用户名") String userName) {
 		PageInfo info = new PageInfo(params);
+		if (userName!=null && !userName.equals("")) {
+			info.filter("user.userName", userName);
+		}
 		if(info.getSort() == null)
 			info.sorting("time", Sort.Direction.DESC);
 		return usageLogService.findAllByPageInfo(info);
@@ -52,5 +57,4 @@ public class UsageLogController {
 			info.sorting("time", Sort.Direction.DESC);
 		return usageLogService.findAllByPageInfo(info);
 	}
-
 }

+ 44 - 0
src/main/webapp/resources/js/admin/controllers/LogUsageCtrl.js

@@ -0,0 +1,44 @@
+define(['app/app'], function (app) {
+  'use strict';
+  app.register.controller('LogUsageCtrl', ['$scope', 'ngTableParams', 'logUsage', 'toaster', 'BaseService','$modal', function ($scope, ngTableParams, logUsage, toaster, BaseService,$modal) {
+    //table设置
+    $scope.logUsageTableParams = new ngTableParams({
+      page : 1,
+      count : 20
+    }, {
+      total : 0,
+      getData : function ($defer, params) {
+        $scope.paginationParams = params;
+        const param = BaseService.parseParams(params.url());
+        //param.status = $scope.status;
+        if($scope.search !=null){
+          if($scope.search == 1){
+            param.userUu = $scope.searchContent;
+          }
+          if($scope.search == 2){
+            param.userName = $scope.searchContent;
+          }
+        }
+        logUsage.getAllByPage(param, function (data) {
+          params.total(data.totalElements);
+          $defer.resolve(data.content);
+        }, function (response) {
+          toaster.pop('error', '获取用户操作日志失败');
+        });
+      }
+    });
+
+    //搜索
+    $scope.onSearch = function(){
+      if(!$scope.search){
+        toaster.pop('error', '请选择搜索条件');
+        return;
+      }
+      if($scope.searchContent==null){
+        toaster.pop('error', '请输入搜索内容');
+        return;
+      }
+      $scope.logUsageTableParams.reload();
+    }
+  }]);
+});