|
|
package com.yoho.ufo.service.impl;
|
|
|
|
|
|
import com.yoho.core.common.utils.DateUtil;
|
|
|
import com.yoho.ufo.dal.UfoBrandSeriesMapper;
|
|
|
import com.yoho.ufo.model.brand.BrandSeries;
|
|
|
import com.yoho.ufo.service.IBrandSeriesService;
|
|
|
import com.yoho.ufo.util.OrikaUtils;
|
|
|
import com.yohobuy.ufo.model.common.PageModel;
|
|
|
import com.yohobuy.ufo.model.common.PageResponseBO;
|
|
|
import com.yohobuy.ufo.model.request.brand.BrandSeriesRequestBo;
|
|
|
import com.yohobuy.ufo.model.request.brand.BrandSeriesResponseBo;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author kun.wang
|
|
|
* @date 2018/9/11
|
|
|
*/
|
|
|
@Service
|
|
|
public class BrandSeriesServiceImpl implements IBrandSeriesService {
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(BrandSeriesServiceImpl.class);
|
|
|
|
|
|
@Resource
|
|
|
private UfoBrandSeriesMapper ufoBrandSeriesMapper;
|
|
|
|
|
|
@Override
|
|
|
public int saveOrUpdateBrandSeries(BrandSeriesRequestBo brandSeriesRequestBo) {
|
|
|
LOGGER.info("insertOrUpdateBrandSeries param = {}", brandSeriesRequestBo);
|
|
|
BrandSeries brandSeries = OrikaUtils.map(brandSeriesRequestBo, BrandSeries.class);
|
|
|
if (brandSeries.getId() == null || brandSeries.getId() == 0) {
|
|
|
// 默认开启状态
|
|
|
brandSeries.setStatus(1);
|
|
|
// 新增一条品牌记录
|
|
|
brandSeries.setCreateTime(DateUtil.currentTimeSeconds());
|
|
|
brandSeries.setUpdateTime(DateUtil.currentTimeSeconds());
|
|
|
return ufoBrandSeriesMapper.insertBrandSeries(brandSeries);
|
|
|
} else {
|
|
|
brandSeries.setUpdateTime(DateUtil.currentTimeSeconds());
|
|
|
// 更新一条品牌记录
|
|
|
return ufoBrandSeriesMapper.updateBrandSeries(brandSeries);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageResponseBO<BrandSeriesResponseBo> getBrandSeriesPageList(BrandSeriesRequestBo brandSeriesRequestBo) {
|
|
|
LOGGER.info("getBrandSeriesPageList param = {}", brandSeriesRequestBo);
|
|
|
BrandSeries brandSeries = OrikaUtils.map(brandSeriesRequestBo, BrandSeries.class);
|
|
|
PageModel pageModel = brandSeriesRequestBo.toPageModel();
|
|
|
int count = ufoBrandSeriesMapper.selectBrandSeriesCount(brandSeries);
|
|
|
if (count == 0) {
|
|
|
LOGGER.warn("getBrandSeriesPageList count is 0, param = {}", brandSeriesRequestBo);
|
|
|
return new PageResponseBO<>();
|
|
|
}
|
|
|
List<BrandSeries> brandSeriesList = ufoBrandSeriesMapper.getBrandSeriesPageList(brandSeries, pageModel);
|
|
|
List<BrandSeriesResponseBo> brandSeriesResponseBos = brandSeriesList.stream().map(brandSeries1 -> {
|
|
|
BrandSeriesResponseBo brandSeriesResponseBo = OrikaUtils.map(brandSeries1, BrandSeriesResponseBo.class);
|
|
|
brandSeriesResponseBo.setCreateTime(DateUtil.getDateStrBySecond(brandSeries1.getCreateTime(), DateUtil.DATE_TIME_FORMAT));
|
|
|
return brandSeriesResponseBo;
|
|
|
}).collect(Collectors.toList());
|
|
|
return new PageResponseBO<>(count, brandSeriesResponseBos, pageModel.getCurrentPage(), pageModel.getPageSize());
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public BrandSeriesResponseBo getBrandSeriesById(Integer id) {
|
|
|
LOGGER.info("getBrandSeriesById id = {}", id);
|
|
|
BrandSeries brandSeries = ufoBrandSeriesMapper.selectOneById(id);
|
|
|
return OrikaUtils.map(brandSeries, BrandSeriesResponseBo.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int updateBrandSeriesStatus(BrandSeriesRequestBo brandSeriesRequestBo) {
|
|
|
LOGGER.info("updateBrandStatus param = {}", brandSeriesRequestBo);
|
|
|
BrandSeries brandSeries = OrikaUtils.map(brandSeriesRequestBo, BrandSeries.class);
|
|
|
brandSeries.setUpdateTime(DateUtil.currentTimeSeconds());
|
|
|
return ufoBrandSeriesMapper.updateBrandSeriesStatus(brandSeries);
|
|
|
}
|
|
|
} |
...
|
...
|
|