| | |
| | | import com.xcong.excoin.common.system.dto.RegisterDto; |
| | | import com.xcong.excoin.configurations.properties.ApplicationProperties; |
| | | import com.xcong.excoin.configurations.properties.SecurityProperties; |
| | | import com.xcong.excoin.modules.member.entity.MemberDeviceInfo; |
| | | import com.xcong.excoin.modules.member.service.MemberDeviceInfoService; |
| | | import com.xcong.excoin.modules.member.service.MemberService; |
| | | import com.xcong.excoin.utils.HttpUtils; |
| | | import com.xcong.excoin.utils.RedisUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @Resource |
| | | private RedisUtils redisUtils; |
| | | |
| | | @Resource |
| | | private MemberDeviceInfoService memberDeviceInfoService; |
| | | |
| | | @ApiOperation(value = "登陆接口", notes = "登陆接口") |
| | | @PostMapping("/login") |
| | | public Result login(@RequestBody @Validated LoginDto loginDto, HttpServletRequest request) { |
| | |
| | | authInfo.put("token", token); |
| | | authInfo.put("user", loginUserBean); |
| | | } |
| | | |
| | | MemberDeviceInfo deviceInfo = memberDeviceInfoService.getByMemberId(loginUserBean.getMemberEntity().getId()); |
| | | String ip = HttpUtils.getRealIp(request); |
| | | String userAgent = HttpUtils.getUserAgent(request); |
| | | if (deviceInfo == null) { |
| | | deviceInfo = new MemberDeviceInfo(); |
| | | deviceInfo.setIp(ip); |
| | | deviceInfo.setUserAgent(userAgent); |
| | | deviceInfo.setMemberId(loginUserBean.getMemberEntity().getId()); |
| | | memberDeviceInfoService.save(deviceInfo); |
| | | } else { |
| | | deviceInfo.setIp(ip); |
| | | deviceInfo.setUserAgent(userAgent); |
| | | memberDeviceInfoService.updateById(deviceInfo); |
| | | } |
| | | return Result.ok("success", authInfo); |
| | | } |
| | | |