Browse Source

Merge branch 'pre-production'

master
pref_mail@163.com 5 months ago
parent
commit
90540baca8
  1. 16
      blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java
  2. 77
      blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/LoginLog.java
  3. 11
      blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java
  4. 5
      blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClientFallback.java
  5. 14
      blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java
  6. 29
      blade-service/blade-system/src/main/java/org/springblade/system/mapper/LoginLogMapper.java
  7. 7
      blade-service/blade-system/src/main/java/org/springblade/system/mapper/LoginLogMapper.xml
  8. 39
      blade-service/blade-system/src/main/java/org/springblade/system/service/ILoginLogService.java
  9. 36
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/LoginLogServiceImpl.java

16
blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java

@ -30,6 +30,7 @@ import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springblade.system.cache.ParamCache;
import org.springblade.system.entity.LoginLog;
import org.springblade.system.entity.Tenant;
import org.springblade.system.entity.User;
import org.springblade.system.entity.UserInfo;
@ -44,6 +45,7 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
@ -179,7 +181,19 @@ public class BladeUserDetailsServiceImpl implements UserDetailsService {
user.getTenantId(), StringPool.EMPTY, user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(userInfo.getRoles()), Func.toStr(user.getAvatar(), TokenUtil.DEFAULT_AVATAR),
username, AuthConstant.ENCRYPT + user.getPassword(), userInfo.getDetail(), true, true, true, true,
AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles())));
try {
sysClient.log(LoginLog.builder()
.userId(user.getId().toString())
.userAccount(username)
.userName(user.getName())
.loginWay(userType)
.loginTime(LocalDateTime.now())
.loginStatus(1)
.tenantId(tenantId)
.build());
}catch (Exception e){
log.error("登录日志保存失败 {}", e.getMessage());
}
return bladeUserDetails;
} else {
throw new UsernameNotFoundException(result.getMsg());

77
blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/LoginLog.java

@ -0,0 +1,77 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.system.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.java.Log;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 登录日志
*
* @author zqb
*/
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
@TableName("blade_login_log")
@ApiModel(value = "LoginLog对象", description = "登录日志")
public class LoginLog implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 用户ID
*/
private String userId;
/**
* 用户账号
*/
private String userAccount;
/**
* 用户名称
*/
private String userName;
/** 登录时间 */
private LocalDateTime loginTime;
/** IP地址 */
private String ipAddress;
/** 设备信息 */
private String deviceInfo;
/** 登录状态 */
private Integer loginStatus;
/** 登录途径 */
private String loginWay;
/** 系统版本号 */
private String systemVersion;
/** 租户id */
private String tenantId;
}

11
blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java

@ -22,6 +22,8 @@ import org.springblade.system.entity.*;
import org.springblade.system.vo.RegionAllVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@ -65,6 +67,7 @@ public interface ISysClient {
String PARAM_VALUE = API_PREFIX + "/param-value";
String REGION = API_PREFIX + "/region";
String REGIONS = API_PREFIX + "/regions";
String LOG = API_PREFIX + "/log";
/**
* 获取菜单
@ -307,4 +310,12 @@ public interface ISysClient {
@GetMapping(REGIONS)
R<List<RegionAllVO>> getRegionALL();
/**
* 保存登录日志
*
* @return
*/
@PostMapping(LOG)
void log(@RequestBody LoginLog loginLog);
}

5
blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClientFallback.java

@ -18,6 +18,7 @@ package org.springblade.system.feign;
import org.springblade.core.tool.api.R;
import org.springblade.system.entity.Dept;
import org.springblade.system.entity.LoginLog;
import org.springblade.system.entity.Menu;
import org.springblade.system.entity.Param;
import org.springblade.system.entity.Post;
@ -174,5 +175,9 @@ public class ISysClientFallback implements ISysClient {
return R.fail("获取数据失败");
}
@Override
public void log(LoginLog loginLog) {
}
}

14
blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java

@ -21,6 +21,7 @@ import lombok.AllArgsConstructor;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.system.entity.Dept;
import org.springblade.system.entity.LoginLog;
import org.springblade.system.entity.Menu;
import org.springblade.system.entity.Param;
import org.springblade.system.entity.Post;
@ -29,6 +30,7 @@ import org.springblade.system.entity.Role;
import org.springblade.system.entity.Tenant;
import org.springblade.system.entity.TenantPackage;
import org.springblade.system.service.IDeptService;
import org.springblade.system.service.ILoginLogService;
import org.springblade.system.service.IMenuService;
import org.springblade.system.service.IParamService;
import org.springblade.system.service.IPostService;
@ -69,6 +71,7 @@ public class SysClient implements ISysClient {
private final IParamService paramService;
private final IRegionService regionService;
private final ILoginLogService loginLogService;
@Override
@GetMapping(MENU)
@ -185,15 +188,15 @@ public class SysClient implements ISysClient {
@Override
public R<Tenant> getTenantByName(String tenantName) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("tenant_name",tenantName);
queryWrapper.eq("is_deleted",0);
queryWrapper.eq("tenant_name", tenantName);
queryWrapper.eq("is_deleted", 0);
return R.data(tenantService.getOne(queryWrapper));
}
@Override
public R<List<Tenant>> getTenantList() {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_deleted",0);
queryWrapper.eq("is_deleted", 0);
return R.data(tenantService.list(queryWrapper));
}
@ -227,4 +230,9 @@ public class SysClient implements ISysClient {
return R.data(regionService.lazyListAll());
}
@Override
public void log(LoginLog loginLog) {
loginLogService.save(loginLog);
}
}

29
blade-service/blade-system/src/main/java/org/springblade/system/mapper/LoginLogMapper.java

@ -0,0 +1,29 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.system.entity.LoginLog;
/**
* 登录日志 Mapper 接口
*
* @author Chill
*/
public interface LoginLogMapper extends BaseMapper<LoginLog> {
}

7
blade-service/blade-system/src/main/java/org/springblade/system/mapper/LoginLogMapper.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.system.mapper.LoginLogMapper">
</mapper>

39
blade-service/blade-system/src/main/java/org/springblade/system/service/ILoginLogService.java

@ -0,0 +1,39 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.system.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.system.entity.LoginLog;
import org.springblade.system.entity.Region;
import org.springblade.system.excel.RegionExcel;
import org.springblade.system.vo.RegionAllVO;
import org.springblade.system.vo.RegionVO;
import java.util.List;
import java.util.Map;
/**
* 登录日志 服务类
*
* @author zqb
*/
public interface ILoginLogService extends IService<LoginLog> {
}

36
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/LoginLogServiceImpl.java

@ -0,0 +1,36 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springblade.system.entity.LoginLog;
import org.springblade.system.mapper.LoginLogMapper;
import org.springblade.system.service.ILoginLogService;
import org.springframework.stereotype.Service;
/**
* 登录日志 服务实现类
*
* @author zqb
*/
@Slf4j
@Service
public class LoginLogServiceImpl extends ServiceImpl<LoginLogMapper, LoginLog> implements ILoginLogService {
}
Loading…
Cancel
Save