package com.boot.security.server.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.boot.security.server.dao.CopyrightDao;
import com.boot.security.server.model.BaseSettlement;
import com.boot.security.server.page.table.PageTableHandler;
import com.boot.security.server.service.CopyrightBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CopyrightBookServiceImpl implements CopyrightBookService {
    @Autowired
    CopyrightDao copyrightDao;
    @Override
    public String selectSettlement(Integer copyrightId,Integer page,Integer limit) {
        List<BaseSettlement> baseSettlements = copyrightDao.selectTableListMonth(copyrightId,page-1,limit);
        Integer count = copyrightDao.selectTableListMonthCount(copyrightId);
        return PageTableHandler.getJSONObject(baseSettlements,count);
    }

    @Override
    public String getAllCopyright() {
        List<BaseSettlement> baseSettlements = copyrightDao.selectCopyrightAll();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("data",baseSettlements);
        return jsonObject.toJSONString();
    }
}
