jtoms 4 éve
szülő
commit
cf570532b3

+ 1 - 1
src/main/java/com/zhiqiyun/open/enmus/UserLoginLogState.java

@@ -10,7 +10,7 @@ public enum UserLoginLogState implements IEnum<Integer> {
      *
      */
     LOGIN_EXCEPTION(0, "登录异常"),
-    SUCCESS(1, "正常"),
+    SUCCESS(1, "成功"),
     CAPTCHA_ERROR(2, "验证码错误"),
     ACCOUNT_NOT_EXIST(3, "账号不存在"),
     PASSWORD_ERROR(4, "密码错误");

+ 8 - 17
src/main/java/com/zhiqiyun/open/mvc/manager/controller/UserInfoController.java

@@ -6,9 +6,9 @@ import com.zhiqiyun.open.enmus.PasswordType;
 import com.zhiqiyun.open.enmus.UserState;
 import com.zhiqiyun.open.models.*;
 import com.zhiqiyun.open.mvc.Result;
-import com.zhiqiyun.open.mvc.manager.params.QueryPageParams;
-import com.zhiqiyun.open.mvc.manager.params.QueryUserParam;
-import com.zhiqiyun.open.mvc.manager.params.SaveUserParam;
+import com.zhiqiyun.open.mvc.manager.params.*;
+import com.zhiqiyun.open.mybatis.paginator.domain.Order;
+import com.zhiqiyun.open.mybatis.paginator.domain.PageBounds;
 import com.zhiqiyun.open.mybatis.paginator.domain.PageResult;
 import com.zhiqiyun.open.service.OauthService;
 import com.zhiqiyun.open.service.UserBaseInfoService;
@@ -166,29 +166,20 @@ public class UserInfoController {
 
     @Permission(value = "oauth.user.find", tags = "查询用户操作日志")
     @PostMapping("/findOperateLogPage")
-    public Result findOperateLogPage(@RequestBody QueryPageParams params) {
-        PageResult<UserOperateLog> resultData = this.userBaseInfoService.findOperateLogPage(params.getPageBounds(), params.getQueryWrapper());
+    public Result findOperateLogPage(@RequestBody QueryOperateLogParams params) {
+        PageBounds bounds = params.getPageBounds();
+        bounds.addOrder(Order.create("request_time", Order.Direction.DESC));
+        PageResult<UserOperateLog> resultData = this.userBaseInfoService.findOperateLogPage(bounds, params.getQueryWrapper());
         return Result.instance(Result.Code.SUCCESS).setData(resultData);
     }
 
     @Permission(value = "oauth.user.find", tags = "查询用户登录日志")
     @PostMapping("/findLoginLogPage")
-    public Result findLoginLogPage(@RequestBody QueryPageParams params) {
+    public Result findLoginLogPage(@RequestBody QueryLoginLogParam params) {
         PageResult<UserLoginLog> resultData = this.userBaseInfoService.findLoginLogPage(params.getPageBounds(), params.getQueryWrapper());
         return Result.instance(Result.Code.SUCCESS).setData(resultData);
     }
 
-
-//	@Permission(value = "oauth.user.set.role", tags = "设置用户角色")
-//	@PostMapping("/saveRoles")
-//	public Result saveRoles(Long uid, @RequestBody Long[] roles) throws Exception {
-//		if (uid.equals(1000L)) {
-//			return Result.instance(Result.Code.MESSAGE_ERROR, "默认的用户不能修改角色");
-//		}
-//		this.userBaseInfoService.saveRoles(uid, roles);
-//		return Result.instance(Result.Code.MESSAGE_SUCCESS);
-//	}
-
     @Permission(tags = "搜索用户信息")
     @PostMapping(value = "/findSelectAccounts")
     public Result findSelectAccounts(String searchKey) {

+ 27 - 0
src/main/java/com/zhiqiyun/open/mvc/manager/params/QueryLoginLogParam.java

@@ -0,0 +1,27 @@
+package com.zhiqiyun.open.mvc.manager.params;
+
+import com.zhiqiyun.open.enmus.AccountType;
+import com.zhiqiyun.open.enmus.UserLoginLogState;
+import com.zhiqiyun.open.models.RangeDate;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class QueryLoginLogParam extends QueryPageParams {
+    private String loginAccount;
+    private AccountType accountType;
+    private String loginIp;
+    private String loginLocal;
+    private String fromSource;
+    private RangeDate loginTime;
+    private UserLoginLogState state;
+
+    public void setLoginTime(List<String> loginTime) {
+        this.loginTime = RangeDate.build(loginTime);
+    }
+
+}

+ 24 - 0
src/main/java/com/zhiqiyun/open/mvc/manager/params/QueryOperateLogParams.java

@@ -0,0 +1,24 @@
+package com.zhiqiyun.open.mvc.manager.params;
+
+import com.zhiqiyun.open.models.RangeDate;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class QueryOperateLogParams extends QueryPageParams {
+    private String nickName;
+    private String tags;
+    private String requestIp;
+    private String requestUrl;
+    private String requestParams;
+    private String requestData;
+    private RangeDate requestTime;
+
+    public void setRequestTime(List<String> requestTime) {
+        this.requestTime = RangeDate.build(requestTime);
+    }
+
+}

+ 44 - 7
src/main/resources/mybatis/mappers/UserBaseInfoMapper.xml

@@ -180,13 +180,31 @@
     </select>
     <select id="findLoginLogPage" resultMap="UserLoginLogResultMap">
         select
-        a.`id`, a.`login_account`, a.`account_type`, a.`login_ip`, a.`login_local`, a.`from_source`, a.`device_id`,
-        a.`login_time`, a.`state`
+        `id`, `login_account`, `account_type`, `login_ip`, `login_local`, `from_source`, `device_id`,
+        `login_time`, `state`
         from user_login_logs a
-        left join user_login_account b on a.`login_account`=b.`login_account`
         <where>
-            <if test="uid !=null">
-                b.`uid`=#{uid}
+            <if test="loginAccount !=null and loginAccount !=''">
+                AND `login_account` like CONCAT('%',#{loginAccount},'%')
+            </if>
+            <if test="accountType !=null">
+                AND `account_type`=#{accountType, typeHandler=com.zhiqiyun.open.mybatis.typeHandler.IEnumTypeHandler}
+            </if>
+            <if test="loginIp !=null and loginIp !=''">
+                AND `login_ip`=#{loginIp}
+            </if>
+            <if test="loginLocal !=null and loginLocal !=''">
+                AND `login_local` like CONCAT('%',#{loginLocal},'%')
+            </if>
+            <if test="fromSource !=null and fromSource !=''">
+                AND `from_source` like CONCAT('%',#{fromSource},'%')
+            </if>
+            <if test="loginTime !=null">
+                AND `login_time` between #{loginTime.statDate, jdbcType=TIMESTAMP} and
+                #{loginTime.endDate, jdbcType=TIMESTAMP}
+            </if>
+            <if test="state !=null">
+                AND `state` = #{state, typeHandler=com.zhiqiyun.open.mybatis.typeHandler.IEnumTypeHandler}
             </if>
         </where>
     </select>
@@ -198,8 +216,27 @@
         from user_operate_logs a
         left join user_base_info b on a.`uid`=b.`id`
         <where>
-            <if test="uid !=null">
-                b.`uid`=#{uid}
+            <if test="nickName !=null and nickName !=''">
+                AND b.`nick_name` like CONCAT("%",#{nickName},"%")
+            </if>
+            <if test="tags !=null and tags !=''">
+                AND a.`tags` like CONCAT("%",#{tags},"%")
+            </if>
+            <if test="requestIp !=null and requestIp !=''">
+                AND a.`request_ip` = #{requestIp}
+            </if>
+            <if test="requestUrl !=null and requestUrl !=''">
+                AND a.`request_url` like CONCAT("%",#{requestUrl},"%")
+            </if>
+            <if test="requestParams !=null and requestParams !=''">
+                AND a.`request_params` like CONCAT("%",#{requestParams},"%")
+            </if>
+            <if test="requestData !=null and requestData !=''">
+                AND a.`request_data` like CONCAT("%",#{requestData},"%")
+            </if>
+            <if test="requestTime !=null">
+                AND `request_time` between #{requestTime.statDate, jdbcType=TIMESTAMP} and
+                #{requestTime.endDate, jdbcType=TIMESTAMP}
             </if>
         </where>
     </select>