| | |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { Button, message, Modal } from 'antd'; |
| | | import { Button, message, Modal, Tag } from 'antd'; |
| | | import { |
| | | FooterToolbar, |
| | | PageContainer, |
| | |
| | | import { repairBug } from '@/utils/common-util'; |
| | | |
| | | const TABLE_KEY = "pro-table-userLogin"; |
| | | |
| | | const typeMap = { |
| | | 0: { |
| | | color: '#87d068', |
| | | text: '登录成功', |
| | | }, |
| | | 1: { |
| | | color: '#f50', |
| | | text: '登录失败', |
| | | }, |
| | | 2: { |
| | | color: '', |
| | | text: '退出登录', |
| | | }, |
| | | 3: { |
| | | color: '#3b5999', |
| | | text: '续签token', |
| | | }, |
| | | }; |
| | | |
| | | const handleSave = async (val) => { |
| | | const hide = message.loading('正在添加'); |
| | |
| | | dataIndex: 'token', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | ellipsis: true, |
| | | width: 140, |
| | | copyable: true, |
| | | filterDropdown: (props) => <TextFilter |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='type' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '登录成功', value: 0 }, |
| | | { label: '登录失败', value: 1 }, |
| | | { label: '退出登录', value: 2 }, |
| | | { label: '续签token', value: 3 }, |
| | | ]} |
| | | />, |
| | | render: (_, record) => { |
| | | const type = typeMap[record.type] |
| | | return <Tag color={type.color}>{type.text}</Tag> |
| | | }, |
| | | }, |
| | | { |
| | | title: '添加时间', |
| | |
| | | title: '操作', |
| | | dataIndex: 'option', |
| | | width: 140, |
| | | hidden: true, |
| | | valueType: 'option', |
| | | render: (_, record) => [ |
| | | <Button |
| | | type="link" |
| | | key="edit" |
| | | hidden="true" |
| | | onClick={() => { |
| | | setModalVisible(true); |
| | | setCurrentRow(record); |
| | |
| | | <Button |
| | | type="link" |
| | | danger |
| | | hidden="true" |
| | | key="batchRemove" |
| | | onClick={async () => { |
| | | Modal.confirm({ |
| | |
| | | <Button |
| | | type="primary" |
| | | key="save" |
| | | hidden="true" |
| | | onClick={async () => { |
| | | setModalVisible(true) |
| | | }} |
| | |
| | | /> |
| | | </div> |
| | | |
| | | {selectedRows?.length > 0 && ( |
| | | {selectedRows?.length > 0 && false && ( |
| | | <FooterToolbar |
| | | extra={ |
| | | <div> |
| | |
| | | String token = JwtUtil.buildToken(jwtSubject, configProperties.getTokenExpireTime(), |
| | | configProperties.getTokenKey()); |
| | | response.addHeader(Constants.TOKEN_HEADER_NAME, token); |
| | | userLoginService.saveAsync(user.getId(), token, UserLogin.TYPE_REFRESH, null, request); |
| | | userLoginService.saveAsync(user.getId(), token, UserLogin.TYPE_REFRESH, user.getHostId(), null, request); |
| | | } |
| | | } |
| | | } catch (ExpiredJwtException e) { |
| | |
| | | } |
| | | String accessToken = JwtUtil.buildToken(new JwtSubject(username, user.getHostId()), |
| | | configProperties.getTokenExpireTime(), configProperties.getTokenKey()); |
| | | userLoginService.saveAsync(user.getId(), accessToken, UserLogin.TYPE_LOGIN, null, request); |
| | | userLoginService.saveAsync(user.getId(), accessToken, UserLogin.TYPE_LOGIN, hostId, null, request); |
| | | return R.ok("登录成功").add(new LoginResult(accessToken, user)); |
| | | } |
| | | |
| | |
| | | |
| | | public interface UserLoginService extends IService<UserLogin> { |
| | | |
| | | void saveAsync(Long userId, String token, Integer type, String memo, HttpServletRequest request); |
| | | void saveAsync(Long userId, String token, Integer type, Long hostId, String memo, HttpServletRequest request); |
| | | |
| | | } |
| | |
| | | |
| | | @Async |
| | | @Override |
| | | public void saveAsync(Long userId, String token, Integer type, String memo, HttpServletRequest request) { |
| | | public void saveAsync(Long userId, String token, Integer type, Long hostId, String memo, HttpServletRequest request) { |
| | | if (userId == null) { |
| | | return; |
| | | } |