Van333
2022-09-02 2234cee8e872fd7633b95eef5b0c760cbbb8eabf
src/main/java/api/service/SinglelampDataServer.java
@@ -3,6 +3,7 @@
import api.bean.ReqParams;
import api.bean.SinglelampDataEntity;
import api.dao.SinglelampDataDao;
import cn.hutool.core.collection.ListUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
@@ -33,15 +34,35 @@
        List<SinglelampDataEntity> list = null;
        Integer count = null;
        if(roleId.longValue() == 1 ){
            PageHelper.startPage(reqParams.getPage(),reqParams.getLimit());
            list = singlelampDao.selectAll();
        }else if (roleId.longValue() == 2 || roleId.longValue() == 3){
           PageHelper.startPage(reqParams.getPage(),reqParams.getLimit());
            list = singlelampDao.selectByCompany(reqParams.getPage(),reqParams.getLimit(),userId);
            count = singlelampDao.countByCompany(userId);
            list = singlelampDao.selectByCompany(1, count, userId);
        }
        PageInfo<SinglelampDataEntity> page = new PageInfo<>(list);
        Integer listLimit = reqParams.getLimit();
        Integer listPage = reqParams.getPage();
        if ((listLimit > listPage * listLimit)
            || listLimit < listPage){
            listLimit = count;
        }
        List<SinglelampDataEntity> pageList =
                ListUtil.sortByProperty(list,"streetlightId");
        List<SinglelampDataEntity> finalList =
                ListUtil.page(listPage-1, listLimit, pageList);
        PageInfo<SinglelampDataEntity> page = new PageInfo<>(finalList);
        page.setStartRow(list.size());
        page.setEndRow(count);
        return page;
    }