简化
This commit is contained in:
@@ -14,6 +14,7 @@ import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.asm.AsmDepends;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.net.Request;
|
||||
@@ -1188,6 +1189,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
@AsmDepends
|
||||
@SuppressWarnings("unchecked")
|
||||
public int currentIntUserid() {
|
||||
if (currentUserid == CURRUSERID_NIL || currentUserid == null) {
|
||||
@@ -1207,6 +1209,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
@AsmDepends
|
||||
@SuppressWarnings("unchecked")
|
||||
public long currentLongUserid() {
|
||||
if (currentUserid == CURRUSERID_NIL || currentUserid == null) {
|
||||
@@ -1226,6 +1229,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@AsmDepends
|
||||
@SuppressWarnings("unchecked")
|
||||
public String currentStringUserid() {
|
||||
if (currentUserid == CURRUSERID_NIL || currentUserid == null) {
|
||||
@@ -1233,7 +1237,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
}
|
||||
return this.currentUserid.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前用户ID<br>
|
||||
*
|
||||
@@ -1244,6 +1248,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@AsmDepends
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Serializable> T currentUserid(Class<T> type) {
|
||||
if (currentUserid == CURRUSERID_NIL || currentUserid == null) {
|
||||
|
||||
@@ -2517,35 +2517,21 @@ public final class Rest {
|
||||
} else if (userid != null) { //HttpRequest.currentUserid
|
||||
mv.visitVarInsn(ALOAD, 1);
|
||||
if (ptype == int.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (ptype == long.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;");
|
||||
} else {
|
||||
mv.visitLdcInsn(Type.getType(Type.getDescriptor(ptype)));
|
||||
}
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, reqInternalName, "currentUserid", "(Ljava/lang/Class;)Ljava/io/Serializable;", false);
|
||||
if (ptype == int.class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Integer");
|
||||
mv.visitInsn(ICONST_0);
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false);
|
||||
mv.visitMethodInsn(INVOKESTATIC, restInternalName, "orElse", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", false);
|
||||
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Integer");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false);
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, reqInternalName, "currentIntUserid", "()I", false);
|
||||
mv.visitVarInsn(ISTORE, maxLocals);
|
||||
varInsns.add(new int[]{ILOAD, maxLocals});
|
||||
} else if (ptype == long.class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Long");
|
||||
mv.visitInsn(LCONST_0);
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false);
|
||||
mv.visitMethodInsn(INVOKESTATIC, restInternalName, "orElse", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", false);
|
||||
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Long");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Long", "longValue", "()J", false);
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, reqInternalName, "currentLongUserid", "()J", false);
|
||||
mv.visitVarInsn(LSTORE, maxLocals);
|
||||
varInsns.add(new int[]{LLOAD, maxLocals});
|
||||
maxLocals++;
|
||||
} else if (ptype == String.class) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, reqInternalName, "currentStringUserid", "()Ljava/lang/String;", false);
|
||||
mv.visitVarInsn(ASTORE, maxLocals);
|
||||
varInsns.add(new int[]{ALOAD, maxLocals});
|
||||
} else {
|
||||
mv.visitLdcInsn(Type.getType(Type.getDescriptor(ptype)));
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, reqInternalName, "currentUserid", "(Ljava/lang/Class;)Ljava/io/Serializable;", false);
|
||||
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(ptype));
|
||||
mv.visitVarInsn(ASTORE, maxLocals);
|
||||
varInsns.add(new int[]{ALOAD, maxLocals});
|
||||
|
||||
Reference in New Issue
Block a user