package com.fdkanfang.service.backend.impl;

import com.fdkanfang.common.model.PageDto;
import com.fdkanfang.dao.backend.HouseMapper;
import com.fdkanfang.dao.backend.IBaseMapper;
import com.fdkanfang.domain.backend.HouseEntity;
import com.fdkanfang.domain.response.HouseResponse;
import com.fdkanfang.service.BaseMapperServiceImpl;
import com.fdkanfang.service.backend.HouseService2;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * Created by owen on 2020/3/11 0011 16:16
 */
@Service
public class HouseServiceImpl2 extends BaseMapperServiceImpl<HouseEntity, Long> implements HouseService2 {

    @Autowired
    private HouseMapper entityMapper;

    @Override
    public IBaseMapper<HouseEntity, Long> getBaseMapper() {
        return this.entityMapper;
    }


    @Override
    public List<HouseResponse> findAllBySearchKey(PageDto param, Long userId, Long handlerId) {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        return entityMapper.findAllBySearchKey(param.getSearchKey(), userId, handlerId);
    }

    @Override
    public List<HouseResponse> findBySearchKeyForEditOrUploader(PageDto param, Long handlerId , Long uploadId) {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        return entityMapper.findBySearchKeyForEditOrUploader(param.getSearchKey(), handlerId ,uploadId);
    }

    @Override
    public Integer findByMaxNum() {
        return entityMapper.findByMaxNum();
    }

    @Override
    public List<HouseEntity> findByNum(String numbers) {
        return entityMapper.findByNum(numbers);
    }

    @Override
    public HouseEntity findBySceneCode(String sceneCode) {
        return entityMapper.findBySceneCode(sceneCode);
    }

    @Override
    public List<HouseResponse> findBySearchKey(PageDto param, Long userId, Long handlerId) {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        return entityMapper.findBySearchKey(param.getSearchKey(), userId, handlerId);
    }
}
