package io.renren.service.impl;

import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import io.renren.common.constant.Constant;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.dao.ScopeCityDao;
import io.renren.dto.ScopeCityDTO;
import io.renren.entity.ScopeCityEntity;
import io.renren.service.ScopeCityService;

/**
 * 落地城市主表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2022-05-28
 */
@Service
public class ScopeCityServiceImpl extends CrudServiceImpl<ScopeCityDao, ScopeCityEntity, ScopeCityDTO> implements ScopeCityService {

    @Override
    public QueryWrapper<ScopeCityEntity> getWrapper(Map<String, Object> params){
    	Long pageId = (Long)params.get("pageId");
        String city = (String)params.get("city");

        QueryWrapper<ScopeCityEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("status", Constant.Status.ENABLE.getValue())
        		.eq(null != pageId, "page_id", pageId)
                .eq(StringUtils.isNotBlank(city), "city", city);

        return wrapper;
    }

}