puhanshu
2022-01-08 262cdc113a44bbd51f98a56ce91966dc7b2ea938
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsInformationServiceImpl.java
@@ -2,11 +2,15 @@
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import javax.annotation.Resource;
import com.panzhihua.common.model.dtos.community.microCommercialStreet.McsInfoDTO;
import com.panzhihua.common.model.vos.community.microCommercialStreet.McsGameVO;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.service_community.util.NearbyUtil;
import com.spatial4j.core.shape.Rectangle;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@@ -206,4 +210,45 @@
        }
        return R.fail("发布失败,请重新尝试");
    }
    /**
     * h5分页查询戳戳资讯
     * @param pageMcsInformationDTO
     * @return
     */
    @Override
    public R pageH5McsInfo(PageMcsInformationDTO pageMcsInformationDTO) {
        Page page = new Page<>();
        page.setSize(pageMcsInformationDTO.getPageSize());
        page.setCurrent(pageMcsInformationDTO.getPageNum());
        String lat = pageMcsInformationDTO.getLat();
        String lon = pageMcsInformationDTO.getLon();
        Integer distance = pageMcsInformationDTO.getDistance();
        IPage<McsInformationVO> mcsInfos;
        if (isNotEmpty(lat) && isNotEmpty(lon) && nonNull(distance)) {
            Rectangle rectangle =new NearbyUtil().getRectangle(pageMcsInformationDTO.getDistance(),
                    Double.parseDouble(pageMcsInformationDTO.getLon()), Double.parseDouble(pageMcsInformationDTO.getLat()));
            mcsInfos = this.baseMapper.pageH5McsInfo(page, rectangle.getMinX(), rectangle.getMaxX(),
                    rectangle.getMinY(), rectangle.getMaxY(), pageMcsInformationDTO);
        } else {
            mcsInfos = this.baseMapper.pageH5McsInfo(page, null, null, null, null, pageMcsInformationDTO);
        }
        return R.ok(mcsInfos);
    }
    /**
     * 资讯详情
     * @param infoId
     * @return
     */
    @Override
    public R getMcsInfo(Long infoId) {
        McsInformation mcsInformation = this.baseMapper.selectById(infoId);
        if (isNull(mcsInformation)) {
            return R.fail("资源不存在");
        }
        McsInformationVO mcsInformationVO = new McsInformationVO();
        BeanUtils.copyProperties(mcsInformation, mcsInformationVO);
        return R.ok(mcsInformationVO);
    }
}