package com.jfinal.club.my.doc;

import com.jfinal.aop.Inject;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.club.common.banner.BannersService;
import com.jfinal.club.common.model.Banners;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

/**
 * @ClassName UsersInfoIntreceptor
 * @Description TODO  用户基本信息
 * @Author caolong
 * @Date 2020/3/17 15:42
 */
public class TypeIntreceptor implements Interceptor {

    @Inject
    UsersDocService usersDocService;

    @Inject
    BannersService bannersService;


    /**
     * @return void
     * @Author Cc
     * @Description //TODO 查看所有分类
     * @Date 2020/3/24
     * @Param [inv]
     **/
    @Override
    public void intercept(Invocation inv) {

        List<Record> records = usersDocService.docTypeList();
        inv.getController().setAttr("doctypes", records);

        Page<Banners> bannersByType = bannersService.getBannersByType(1,0, 12);
        inv.getController().setAttr("banners", bannersByType.getList());
        inv.invoke();
    }
}
