mirror of https://github.com/elunez/eladmin
# 修改匿名注解,支持注解组合
parent
66eeb7c76d
commit
acc1d253e4
|
@ -24,7 +24,7 @@ import java.lang.annotation.Target;
|
||||||
* @author jacky
|
* @author jacky
|
||||||
* 用于标记匿名访问方法
|
* 用于标记匿名访问方法
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.METHOD)
|
@Target({ElementType.METHOD,ElementType.ANNOTATION_TYPE})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface AnonymousAccess {
|
public @interface AnonymousAccess {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2016 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.zhengjie.annotation.rest;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import me.zhengjie.annotation.AnonymousAccess;
|
||||||
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation for mapping HTTP {@code DELETE} requests onto specific handler
|
||||||
|
* methods.
|
||||||
|
* 支持匿名访问 DeleteMapping
|
||||||
|
*
|
||||||
|
* @author liaojinlong
|
||||||
|
* @see AnonymousGetMapping
|
||||||
|
* @see AnonymousPostMapping
|
||||||
|
* @see AnonymousPutMapping
|
||||||
|
* @see AnonymousPatchMapping
|
||||||
|
* @see RequestMapping
|
||||||
|
*/
|
||||||
|
@AnonymousAccess
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@RequestMapping(method = RequestMethod.DELETE)
|
||||||
|
public @interface AnonymousDeleteMapping {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#name}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String name() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#value}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] value() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#path}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] path() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#params}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] params() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#headers}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] headers() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#consumes}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] consumes() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#produces}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] produces() default {};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2016 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.zhengjie.annotation.rest;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import me.zhengjie.annotation.AnonymousAccess;
|
||||||
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation for mapping HTTP {@code GET} requests onto specific handler
|
||||||
|
* methods.
|
||||||
|
* <p>
|
||||||
|
* 支持匿名访问 GetMapping
|
||||||
|
*
|
||||||
|
* @author liaojinlong
|
||||||
|
* @see RequestMapping
|
||||||
|
*/
|
||||||
|
@AnonymousAccess
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
|
public @interface AnonymousGetMapping {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#name}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String name() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#value}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] value() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#path}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] path() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#params}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] params() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#headers}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] headers() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#consumes}.
|
||||||
|
*
|
||||||
|
* @since 4.3.5
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] consumes() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#produces}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] produces() default {};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2016 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.zhengjie.annotation.rest;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import me.zhengjie.annotation.AnonymousAccess;
|
||||||
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation for mapping HTTP {@code PATCH} requests onto specific handler
|
||||||
|
* methods.
|
||||||
|
* * 支持匿名访问 PatchMapping
|
||||||
|
*
|
||||||
|
* @author liaojinlong
|
||||||
|
* @see AnonymousGetMapping
|
||||||
|
* @see AnonymousPostMapping
|
||||||
|
* @see AnonymousPutMapping
|
||||||
|
* @see AnonymousDeleteMapping
|
||||||
|
* @see RequestMapping
|
||||||
|
*/
|
||||||
|
@AnonymousAccess
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@RequestMapping(method = RequestMethod.PATCH)
|
||||||
|
public @interface AnonymousPatchMapping {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#name}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String name() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#value}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] value() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#path}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] path() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#params}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] params() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#headers}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] headers() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#consumes}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] consumes() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#produces}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] produces() default {};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2016 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.zhengjie.annotation.rest;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import me.zhengjie.annotation.AnonymousAccess;
|
||||||
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation for mapping HTTP {@code POST} requests onto specific handler
|
||||||
|
* methods.
|
||||||
|
* 支持匿名访问 PostMapping
|
||||||
|
*
|
||||||
|
* @author liaojinlong
|
||||||
|
* @see AnonymousGetMapping
|
||||||
|
* @see AnonymousPostMapping
|
||||||
|
* @see AnonymousPutMapping
|
||||||
|
* @see AnonymousDeleteMapping
|
||||||
|
* @see RequestMapping
|
||||||
|
*/
|
||||||
|
@AnonymousAccess
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@RequestMapping(method = RequestMethod.POST)
|
||||||
|
public @interface AnonymousPostMapping {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#name}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String name() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#value}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] value() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#path}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] path() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#params}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] params() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#headers}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] headers() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#consumes}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] consumes() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#produces}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] produces() default {};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2016 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.zhengjie.annotation.rest;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import me.zhengjie.annotation.AnonymousAccess;
|
||||||
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation for mapping HTTP {@code PUT} requests onto specific handler
|
||||||
|
* methods.
|
||||||
|
* * 支持匿名访问 PutMapping
|
||||||
|
*
|
||||||
|
* @author liaojinlong
|
||||||
|
* @see AnonymousGetMapping
|
||||||
|
* @see AnonymousPostMapping
|
||||||
|
* @see AnonymousPutMapping
|
||||||
|
* @see AnonymousDeleteMapping
|
||||||
|
* @see RequestMapping
|
||||||
|
*/
|
||||||
|
@AnonymousAccess
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@RequestMapping(method = RequestMethod.PUT)
|
||||||
|
public @interface AnonymousPutMapping {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#name}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String name() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#value}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] value() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#path}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] path() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#params}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] params() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#headers}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] headers() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#consumes}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] consumes() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link RequestMapping#produces}.
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
String[] produces() default {};
|
||||||
|
|
||||||
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
package me.zhengjie;
|
package me.zhengjie;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import me.zhengjie.annotation.AnonymousAccess;
|
import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
||||||
import me.zhengjie.utils.SpringContextHolder;
|
import me.zhengjie.utils.SpringContextHolder;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
@ -26,11 +26,11 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启审计功能 -> @EnableJpaAuditing
|
* 开启审计功能 -> @EnableJpaAuditing
|
||||||
|
*
|
||||||
* @author Zheng Jie
|
* @author Zheng Jie
|
||||||
* @date 2018/11/15 9:20:19
|
* @date 2018/11/15 9:20:19
|
||||||
*/
|
*/
|
||||||
|
@ -60,10 +60,10 @@ public class AppRun {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 访问首页提示
|
* 访问首页提示
|
||||||
|
*
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
@GetMapping("/")
|
@AnonymousGetMapping("/")
|
||||||
@AnonymousAccess
|
|
||||||
public String index() {
|
public String index() {
|
||||||
return "Backend service started successfully";
|
return "Backend service started successfully";
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,10 @@ import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import me.zhengjie.annotation.AnonymousAccess;
|
|
||||||
import me.zhengjie.annotation.Log;
|
import me.zhengjie.annotation.Log;
|
||||||
|
import me.zhengjie.annotation.rest.AnonymousDeleteMapping;
|
||||||
|
import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
||||||
|
import me.zhengjie.annotation.rest.AnonymousPostMapping;
|
||||||
import me.zhengjie.config.RsaProperties;
|
import me.zhengjie.config.RsaProperties;
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.security.config.SecurityProperties;
|
import me.zhengjie.modules.security.config.SecurityProperties;
|
||||||
|
@ -43,6 +45,7 @@ import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -72,8 +75,7 @@ public class AuthorizationController {
|
||||||
|
|
||||||
@Log("用户登录")
|
@Log("用户登录")
|
||||||
@ApiOperation("登录授权")
|
@ApiOperation("登录授权")
|
||||||
@AnonymousAccess
|
@AnonymousPostMapping(value = "/login")
|
||||||
@PostMapping(value = "/login")
|
|
||||||
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
|
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
|
||||||
// 密码解密
|
// 密码解密
|
||||||
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
|
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
|
||||||
|
@ -115,9 +117,8 @@ public class AuthorizationController {
|
||||||
return ResponseEntity.ok(SecurityUtils.getCurrentUser());
|
return ResponseEntity.ok(SecurityUtils.getCurrentUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
@AnonymousAccess
|
|
||||||
@ApiOperation("获取验证码")
|
@ApiOperation("获取验证码")
|
||||||
@GetMapping(value = "/code")
|
@AnonymousGetMapping(value = "/code")
|
||||||
public ResponseEntity<Object> getCode() {
|
public ResponseEntity<Object> getCode() {
|
||||||
// 算术类型 https://gitee.com/whvse/EasyCaptcha
|
// 算术类型 https://gitee.com/whvse/EasyCaptcha
|
||||||
ArithmeticCaptcha captcha = new ArithmeticCaptcha(111, 36);
|
ArithmeticCaptcha captcha = new ArithmeticCaptcha(111, 36);
|
||||||
|
@ -137,8 +138,7 @@ public class AuthorizationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("退出登录")
|
@ApiOperation("退出登录")
|
||||||
@AnonymousAccess
|
@AnonymousDeleteMapping(value = "/logout")
|
||||||
@DeleteMapping(value = "/logout")
|
|
||||||
public ResponseEntity<Object> logout(HttpServletRequest request) {
|
public ResponseEntity<Object> logout(HttpServletRequest request) {
|
||||||
onlineUserService.logout(tokenProvider.getToken(request));
|
onlineUserService.logout(tokenProvider.getToken(request));
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
|
|
@ -17,11 +17,11 @@ package me.zhengjie.modules.system.rest;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import me.zhengjie.annotation.AnonymousAccess;
|
|
||||||
import me.zhengjie.annotation.Limit;
|
import me.zhengjie.annotation.Limit;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,8 +38,7 @@ public class LimitController {
|
||||||
/**
|
/**
|
||||||
* 测试限流注解,下面配置说明该接口 60秒内最多只能访问 10次,保存到redis的键名为 limit_test,
|
* 测试限流注解,下面配置说明该接口 60秒内最多只能访问 10次,保存到redis的键名为 limit_test,
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@AnonymousGetMapping
|
||||||
@AnonymousAccess
|
|
||||||
@ApiOperation("测试")
|
@ApiOperation("测试")
|
||||||
@Limit(key = "test", period = 60, count = 10, name = "testLimit", prefix = "limit")
|
@Limit(key = "test", period = 60, count = 10, name = "testLimit", prefix = "limit")
|
||||||
public int test() {
|
public int test() {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import me.zhengjie.annotation.AnonymousAccess;
|
import me.zhengjie.annotation.AnonymousAccess;
|
||||||
import me.zhengjie.annotation.Log;
|
import me.zhengjie.annotation.Log;
|
||||||
|
import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
||||||
import me.zhengjie.domain.vo.TradeVo;
|
import me.zhengjie.domain.vo.TradeVo;
|
||||||
import me.zhengjie.domain.AlipayConfig;
|
import me.zhengjie.domain.AlipayConfig;
|
||||||
import me.zhengjie.utils.AliPayStatusEnum;
|
import me.zhengjie.utils.AliPayStatusEnum;
|
||||||
|
@ -31,6 +32,7 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -84,8 +86,7 @@ public class AliPayController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiIgnore
|
@ApiIgnore
|
||||||
@GetMapping("/return")
|
@AnonymousGetMapping("/return")
|
||||||
@AnonymousAccess
|
|
||||||
@ApiOperation("支付之后跳转的链接")
|
@ApiOperation("支付之后跳转的链接")
|
||||||
public ResponseEntity<String> returnPage(HttpServletRequest request, HttpServletResponse response) {
|
public ResponseEntity<String> returnPage(HttpServletRequest request, HttpServletResponse response) {
|
||||||
AlipayConfig alipay = alipayService.find();
|
AlipayConfig alipay = alipayService.find();
|
||||||
|
@ -109,7 +110,6 @@ public class AliPayController {
|
||||||
@ApiIgnore
|
@ApiIgnore
|
||||||
@RequestMapping("/notify")
|
@RequestMapping("/notify")
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
@SuppressWarnings("all")
|
|
||||||
@ApiOperation("支付异步通知(要公网访问),接收异步通知,检查通知内容app_id、out_trade_no、total_amount是否与请求中的一致,根据trade_status进行后续业务处理")
|
@ApiOperation("支付异步通知(要公网访问),接收异步通知,检查通知内容app_id、out_trade_no、total_amount是否与请求中的一致,根据trade_status进行后续业务处理")
|
||||||
public ResponseEntity<Object> notify(HttpServletRequest request) {
|
public ResponseEntity<Object> notify(HttpServletRequest request) {
|
||||||
AlipayConfig alipay = alipayService.find();
|
AlipayConfig alipay = alipayService.find();
|
||||||
|
|
Loading…
Reference in New Issue