package com.cyksj.config;

import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
import cn.dev33.satoken.interceptor.SaRouteInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/*
 *项目名: yicang-admin
 *文件名: SaTokenConfigure
 *创建者: JavaZou
 *创建时间:2022/12/19 10:01
 */
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
	// 注册拦截器
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new SaRouteInterceptor())
				.addPathPatterns(List.of("/manage/**", "/manager/**", "/sys/update", "/sys/delete/**"))
				.excludePathPatterns(List.of("/manage/admin/login",
						"/manage/admin/get/loginInfo",
						"/manage/corp/**",
						"/manage/coupon/corp/send",
						"/manage/coupon",
						"/manage/register/wx/refund/notify",
						"/manage/register/unLimit",
						"/manage/gzh/msg/notify",
						"/manage/admin/send/template",
						"/manage/order/put/status/*",
						"/manage/user/get/loginInfo",
						"/manage/user/login",
						"/manage/admin/send/template",
						"/manage/admin/callback",
						"/manage/coupon/get/classification",
						"/manage/account/get/latest/orders",
						"/manage/account/get/expired/accounts",
						"/manage/account/put/account",
						"/manage/coupon/get/classificationList",
						"/manage/coupon/get/couponList",
						"manage/order/wx/refund/notify",
						"/manage/goods/whole/sale/deposit/refund/notify",
						"/manage/admin/get/yh/user/token"));
		//注解权限校验
		registry.addInterceptor(new SaAnnotationInterceptor()).addPathPatterns("/**");
	}
}

