package com.xxl.job.admin.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.xxl.job.admin.service.HandlerNameService;
import com.yunzhupaas.util.context.SpringContext;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 *
 * @author 云筑产品开发平台组
 * @version V3.1.0
 * @copyright 深圳市乐程软件有限公司
 * @date 2024/3/16 8:49
 */
@Component
public class XxlJobListener implements ApplicationRunner {
    @Override
    public void run(ApplicationArguments args) throws Exception {
        HandlerNameService handlerNameService = SpringContext.getBean(HandlerNameService.class);
        handlerNameService.removeAll();
    }

    @Bean
    public MybatisPlusInterceptor pageHelper() {
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return mybatisPlusInterceptor;
    }
}

