| | |
| | | package com.yuanchu.limslaboratory.clients; |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.shiro.utils.JwtUtils; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | |
| | | @Value("${login.secret}") |
| | | private String LoginSecret; |
| | | |
| | | // public Result<Map<String, Object>> LoginExamine(User user){ |
| | | // Map<String, Object> mapData = new HashMap<>(); |
| | | // mapData.put("LoginUserID", LoginUserID); |
| | |
| | | // Map data = (Map) result.getData(); |
| | | // String token = data.get("token").toString(); |
| | | // data.remove("token"); |
| | | // user.setMap(data); |
| | | //// user.setMap(data); |
| | | // //存入redis,二个小时后删除 |
| | | // RedisUtil.set(token, user, 2); |
| | | // // 将签发的 JWT token 返回给前端 |
| | |
| | | // } |
| | | // } |
| | | |
| | | public Result<Map<String, Object>> LoginExamine(){ |
| | | Map<String, Object> mapData = new HashMap<>(); |
| | | mapData.put("LoginUserID", LoginUserID); |
| | | mapData.put("LoginSecret", LoginSecret); |
| | | Result<?> code = userClient.BusynessUserLogin(mapData); |
| | | if (code.getCode() == 200){ |
| | | Result<?> result = userClient.BusynessUserLoginToken(code.getData().toString()); |
| | | if (result.getCode() == 200){ |
| | | Map data = (Map) result.getData(); |
| | | String token = data.get("token").toString(); |
| | | data.remove("token"); |
| | | // 将签发的 JWT token 返回给前端 |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("token", token); |
| | | return Result.success(map); |
| | | } else { |
| | | return Result.fail(result.getMessage()); |
| | | } |
| | | } else { |
| | | return Result.fail(code.getMessage()); |
| | | } |
| | | |
| | | public Result<Map<String, Object>> LoginExamine(User user){ |
| | | String token = JwtUtils.sign(user.getAccount()); |
| | | //存入redis,二个小时后删除 |
| | | RedisUtil.set(token, user, 2); |
| | | // 将签发的 JWT token 返回给前端 |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | String refresh = JwtUtils.sign(user.getAccount()); |
| | | map.put("token", token); |
| | | map.put("refresh", refresh); |
| | | RedisUtil.set(user.getAccount(), map, 120); |
| | | return Result.success(map); |
| | | } |
| | | } |