提交 f7826a26 作者: 张小凤

user(add)

上级 9b63feb2
...@@ -18,6 +18,17 @@ ...@@ -18,6 +18,17 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.5</version>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId> <groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId> <artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version> <version>3.10.2</version>
...@@ -49,12 +60,6 @@ ...@@ -49,12 +60,6 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel-core</artifactId>
<version>3.1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
...@@ -103,10 +108,6 @@ ...@@ -103,10 +108,6 @@
<version>0.9.1</version> <version>0.9.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3.4</version> <version>3.4.3.4</version>
...@@ -117,12 +118,6 @@ ...@@ -117,12 +118,6 @@
<version>3.0.0</version> <version>3.0.0</version>
<!--<scope>compile</scope>--> <!--<scope>compile</scope>-->
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.32</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>spring-boot-starter-data-redis</artifactId>
...@@ -144,6 +139,14 @@ ...@@ -144,6 +139,14 @@
</excludes> </excludes>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
......
...@@ -2,7 +2,7 @@ package com.mmc.oms.common; ...@@ -2,7 +2,7 @@ package com.mmc.oms.common;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.mmc.oms.jwt.JwtConstant; import com.mmc.oms.jwt.JwtConstant;
import com.mmc.oms.jwt.JwtUtil;
import com.mmc.oms.model.dto.BaseAccountDTO; import com.mmc.oms.model.dto.BaseAccountDTO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
...@@ -55,33 +55,6 @@ public class AuthHandler { ...@@ -55,33 +55,6 @@ public class AuthHandler {
return account; return account;
} }
public String addLoginCache(Integer userId, Integer roleId, String tokenType, BaseAccountDTO loginInfo) {
Map<String, Object> map = new HashMap<String, Object>();
map.put(JwtConstant.USERIDKEY, userId);
map.put(JwtConstant.ROLEIDKEY, roleId);
map.put(JwtConstant.TOKEN_TYPE, tokenType);
String token = JwtUtil.createJwt(map);
// loginInfo.setTokenPort(tokenType);
// 缓存登录token-jwt
stringRedisTemplate.opsForValue().set(
RedisConstant.createLoginTokenKey(tokenType, roleId.toString(), userId.toString()), token,
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
// 平台PC管理端登录保存-单位的id及无限下级id集合
if (JwtConstant.SXTB_ACCOUNT_TOKEN.equals(tokenType)) {
/*if (loginInfo.getCompanyInfo() != null && !CollectionUtils.isEmpty(loginInfo.getCompanyInfo().getCompanys())) {
List<Integer> companys = loginInfo.getCompanyInfo().getCompanys();
this.refreshCompanys(companys, loginInfo.getCompanyInfo().getId());
// 置为null--省内存
loginInfo.getCompanyInfo().setCompanys(null);
}*/
}
// 缓存登录对象
stringRedisTemplate.opsForValue().set(token, JsonUtil.parseObjToJson(loginInfo), JwtConstant.EXPIRATION,
TimeUnit.MILLISECONDS);
return token;
}
/** /**
* 更新单位缓存 * 更新单位缓存
......
...@@ -24,8 +24,8 @@ public class RentalOrdersController extends BaseController{ ...@@ -24,8 +24,8 @@ public class RentalOrdersController extends BaseController{
@ApiOperation(value = "租赁-下单") @ApiOperation(value = "租赁-下单")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderInfoDTO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderInfoDTO.class)})
@PostMapping("feignAddLease") @PostMapping("feignAddLease")
public OrderInfoDTO feignAddLease(@RequestBody LeaseOrderVO param) { public OrderInfoDTO feignAddLease(HttpServletRequest request, @RequestBody LeaseOrderVO param) {
return rentalOrdersService.feignAddLease(param); return rentalOrdersService.feignAddLease(request,param);
} }
@ApiOperation(value = "订单-详情") @ApiOperation(value = "订单-详情")
......
package com.mmc.oms.jwt;
import com.mmc.oms.common.CodeUtil;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
import java.security.Key;
import java.util.Date;
import java.util.Map;
/**
* @Author small
* @Date 2023/5/24 16:01
* @Version 1.0
*/
public class JwtUtil {
/**
* 根据map中的信息生成token, tokenId为随机生成码,有效时间为24h
*
* @param claims 封装到token中的map
* @return
*/
public static String createJwt(Map<String, Object> claims) {
return createJwt(claims, JwtConstant.EXPIRATION);
}
public static String createJwt(Map<String, Object> claims, long expiration) {
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(JwtConstant.BASE64KEY);
Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
long nowMillis = System.currentTimeMillis();
long expMillis = nowMillis + expiration;
Date now = new Date(nowMillis);
Date exp = new Date(expMillis);
JwtBuilder builder = Jwts.builder().setClaims(claims).setId(CodeUtil.randomCode(6)).setIssuedAt(now)
.setSubject(JwtConstant.SUBJECT).setIssuer(JwtConstant.ISSUER).signWith(signatureAlgorithm, signingKey)
.setExpiration(exp);
return builder.compact();
}
/**
* 解析前端传来的token,解析成功则返回Claims,解析失败返回null;解析成功后可通过claims获取信息
*
* @param jwt
* @return
*/
public static Claims parseJwt(String jwt) {
Claims claims = Jwts.parser().setSigningKey(DatatypeConverter.parseBase64Binary(JwtConstant.BASE64KEY))
.parseClaimsJws(jwt).getBody();
return claims;
}
}
...@@ -8,6 +8,8 @@ import com.mmc.oms.model.qo.OrderInfoQO; ...@@ -8,6 +8,8 @@ import com.mmc.oms.model.qo.OrderInfoQO;
import com.mmc.oms.model.vo.LeaseOrderVO; import com.mmc.oms.model.vo.LeaseOrderVO;
import com.mmc.oms.model.vo.RentalOrderVO; import com.mmc.oms.model.vo.RentalOrderVO;
import javax.servlet.http.HttpServletRequest;
/** /**
* @Author small @Date 2023/5/26 10:52 @Version 1.0 * @Author small @Date 2023/5/26 10:52 @Version 1.0
*/ */
...@@ -16,7 +18,7 @@ public interface RentalOrdersService { ...@@ -16,7 +18,7 @@ public interface RentalOrdersService {
OrderInfoDTO getOrderDetail(String orderNo); OrderInfoDTO getOrderDetail(String orderNo);
OrderInfoDTO feignAddLease(LeaseOrderVO param); OrderInfoDTO feignAddLease(HttpServletRequest request, LeaseOrderVO param);
PageResult listPcOrderInfo(OrderInfoQO param, BaseAccountDTO cuser); PageResult listPcOrderInfo(OrderInfoQO param, BaseAccountDTO cuser);
......
...@@ -51,3 +51,4 @@ rabbitmq: ...@@ -51,3 +51,4 @@ rabbitmq:
workFlyerInfoKey: TEST_WORK_FLYER_INFO workFlyerInfoKey: TEST_WORK_FLYER_INFO
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论