package com.ssm.manage.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ssm.core.service.impl.BaseServiceImpl;
import com.ssm.manage.dao.SsmStoreRoomHandDao;
import com.ssm.manage.dao.SsmStoreRoomServiceDao;
import com.ssm.manage.entity.StoreRoom;
import com.ssm.manage.entity.StoreRoomHand;
import com.ssm.manage.query.StoreRoomHandRequest;
import com.ssm.manage.query.StoreRoomRequest;
import com.ssm.manage.service.SsmStoreRoomHandService;
import com.ssm.manage.service.SsmStoreRoomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
@Slf4j
public class SsmStoreRoomHandServiceImpl  extends BaseServiceImpl<StoreRoomHand> implements SsmStoreRoomHandService {


    @Autowired
    private SsmStoreRoomHandDao dao;

    @Override
    public SsmStoreRoomHandDao getDao() {
        return dao;
    }


    @Override
    public PageInfo<StoreRoomHand> selectPage(StoreRoomHandRequest storeRoomRequest){
        Example example = new Example(StoreRoom.class);
        Example.Criteria criteria = example.createCriteria();

        criteria.andEqualTo("roomId",storeRoomRequest.getRoomId());

        storeRoomRequest.setSort("row");
        PageHelper.startPage(storeRoomRequest.getPageNum(),storeRoomRequest.getPageSize(),storeRoomRequest.getOrderAndSort());
        List<StoreRoomHand> list = selectByExample(example);
        PageInfo<StoreRoomHand> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

}

