package com.cool.bang.modules.business.service.impl;

import com.cool.bang.common.base.BaseServiceImpl;
import com.cool.bang.common.web.request.PageDomain;
import com.cool.bang.modules.business.mapper.JobCustomerMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cool.bang.modules.business.mapper.LpbHouseMapper;
import com.cool.bang.modules.business.domain.LpbHouse;
import com.cool.bang.modules.business.service.ILpbHouseService;

import java.util.List;
import java.util.Map;

/**
* 房屋信息
*
* @author Sy
* 2024-10-22 09:20
*/
@Service
public class LpbHouseServiceImpl extends BaseServiceImpl<LpbHouseMapper, LpbHouse> implements ILpbHouseService {
    @Autowired
    private JobCustomerMapper  jobCustomerMapper;

    @Override
    public List<LpbHouse> queryByUnit(Integer unitId) {
        return baseMapper.selectByUnit(unitId);
    }

    @Override
    public List<LpbHouse> queryByBuild(Integer buildingId) {
        return baseMapper.selectByBuild(buildingId);
    }


    @Override
    public PageInfo<LpbHouse> housePage(PageDomain page, LpbHouse param) {
        PageHelper.startPage(page.getPage(), page.getLimit());
        List<LpbHouse> list = baseMapper.selectByParam(param);
        for (LpbHouse res:list){
           int state = jobCustomerMapper.selectCountByOpenid(res.getId(),res.getOpenid());
           if (state > 0 ){
               res.setCollectType(1);
           }else{
               res.setCollectType(2);
           }
        }
        return new PageInfo<>(list);
    }

    @Override
    public boolean updateLike(Long id,Long communityId, Long houseId){
        return baseMapper.insertLike(id,communityId,houseId)>0;
    }



}
