package com.controller.report;

import com.config.BaseController;
import com.config.ControllerInterface;
import com.jfinal.aop.Clear;
import com.jfinal.plugin.activerecord.Page;
import com.service.report.CirculationStatisticsService;

/**
 * 图书流通统计
 */
@ControllerInterface(path="/circulationStatistics")
public class CirculationStatisticsController extends BaseController {
    CirculationStatisticsService service = CirculationStatisticsService.me;

    /**
     * 图书借阅排行
     */
    public void bookLendingRanking() {
        int orgid = this.getParaToInt("orgid");
        if(orgid == 0) {
            fail(1,"请求参数不完整!");
            return;
        }
        String kssj = this.getPara("kssj");
        String jssj = this.getPara("jssj");
        Integer topnum = this.getParaToInt("topnum");
        success(service.bookLendingRanking(this.getParaToInt("pageNumber",1),this.getParaToInt("pageSize",10),orgid,kssj,jssj,topnum));
    }

    /**
     * 图书分类借阅排行
     */
    public void bookTypeLendingRanking() {
        int orgid = this.getParaToInt("orgid");
        if(orgid == 0) {
            fail(1,"请求参数不完整!");
            return;
        }
        String kssj = this.getPara("kssj");
        String jssj = this.getPara("jssj");
        success(service.bookTypeLendingRanking(this.getParaToInt("pageNumber"),this.getParaToInt("pageSize",10),orgid,kssj,jssj));
    }

    /**
     * 读者借阅排行
     */
    public void readerLendingRanking() {
        int orgid = this.getParaToInt("orgid");
        if(orgid == 0) {
            fail(1,"请求参数不完整!");
            return;
        }
        String kssj = this.getPara("kssj");
        String jssj = this.getPara("jssj");
        Integer topnum = this.getParaToInt("topnum");
        Integer dept = this.getParaToInt("dept");
        Integer readerType = this.getParaToInt("readerType");
        success(service.readerLendingRanking(this.getParaToInt("pageNumber",1),this.getParaToInt("pageSize",10),orgid,kssj,jssj,topnum,dept,readerType));
    }
    /**
     * 部门借阅排行
     */
    public void deptLendingRanking() {
        int orgid = this.getParaToInt("orgid");
        if(orgid == 0) {
            fail(1,"请求参数不完整!");
            return;
        }
        String kssj = this.getPara("kssj");
        String jssj = this.getPara("jssj");
        success(service.deptLendingRanking(this.getParaToInt("pageNumber"),this.getParaToInt("pageSize",10),orgid,kssj,jssj));
    }
    /**
     * 部门人均借阅排行
     */
    public void deptPercapitaLendingRanking() {
        int orgid = this.getParaToInt("orgid");
        if(orgid == 0) {
            fail(1,"请求参数不完整!");
            return;
        }
        String kssj = this.getPara("kssj");
        String jssj = this.getPara("jssj");
        success(service.deptPercapitaLendingRanking(orgid,kssj,jssj));
    }
}
