Authored by kun

add new files

package com.yoho.ufo.controller.brand;
import com.yoho.ufo.service.IBrandSeriesService;
import com.yohobuy.ufo.model.common.ApiResponse;
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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @author kun.wang
* @date 2018/9/11
*/
@RestController
@RequestMapping(value = "/brandSeries")
public class BrandSeriesController {
private static final Logger LOGGER = LoggerFactory.getLogger(BrandSeriesController.class);
@Resource
private IBrandSeriesService brandSeriesService;
@RequestMapping(value = "/saveOrUpdateBrandSeries", method = RequestMethod.POST)
public ApiResponse<Object> saveOrUpdateBrandSeries(BrandSeriesRequestBo brandSeriesRequestBo) {
LOGGER.info("saveOrUpdateBrandSeries param = {}", brandSeriesRequestBo);
brandSeriesService.saveOrUpdateBrandSeries(brandSeriesRequestBo);
return new ApiResponse<>();
}
@RequestMapping(value = "/getBrandSeriesById", method = RequestMethod.POST)
public ApiResponse<BrandSeriesResponseBo> getBrandSeriesById(Integer id) {
LOGGER.info("getBrandSeriesById param = {}", id);
return new ApiResponse<>(brandSeriesService.getBrandSeriesById(id));
}
@RequestMapping(value = "/getBrandSeriesPageList", method = RequestMethod.POST)
public ApiResponse<PageResponseBO<BrandSeriesResponseBo>> getBrandSeriesPageList(BrandSeriesRequestBo brandSeriesRequestBo) {
LOGGER.info("getBrandSeriesPageList param = {}", brandSeriesRequestBo);
return new ApiResponse<>(brandSeriesService.getBrandSeriesPageList(brandSeriesRequestBo));
}
@RequestMapping(value = "/updateBrandSeriesStatus", method = RequestMethod.POST)
public ApiResponse<Object> updateBrandSeriesStatus(BrandSeriesRequestBo brandSeriesRequestBo) {
LOGGER.info("updateBrandSeriesStatus param = {}", brandSeriesRequestBo);
brandSeriesService.updateBrandSeriesStatus(brandSeriesRequestBo);
return new ApiResponse<>();
}
}
... ...
package com.yoho.ufo.service;
import com.yohobuy.ufo.model.common.PageResponseBO;
import com.yohobuy.ufo.model.request.brand.BrandSeriesRequestBo;
import com.yohobuy.ufo.model.request.brand.BrandSeriesResponseBo;
/**
* @author kun.wang
* @date 2018/9/11
*/
public interface IBrandSeriesService {
/**
* 保存或更新一条品牌系列记录
* @param brandSeriesRequestBo
* @return
*/
int saveOrUpdateBrandSeries(BrandSeriesRequestBo brandSeriesRequestBo);
/**
* 获取品牌系列分页列表
* @param brandSeriesRequestBo
* @return
*/
PageResponseBO<BrandSeriesResponseBo> getBrandSeriesPageList(BrandSeriesRequestBo brandSeriesRequestBo);
/**
* 根据主键获取一条品牌系列记录
* @param id
* @return
*/
BrandSeriesResponseBo getBrandSeriesById(Integer id);
/**
* 更新品牌系列状态
* @param brandSeriesRequestBo
* @return
*/
int updateBrandSeriesStatus(BrandSeriesRequestBo brandSeriesRequestBo);
}
... ...
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);
}
}
... ...
... ... @@ -35,10 +35,11 @@ public class BrandServiceImpl implements IBrandService {
LOGGER.info("insertOrUpdateBrand param = {}", brandRequestBo);
Brand brand = OrikaUtils.map(brandRequestBo, Brand.class);
brand.setEditTime(DateUtil.currentTimeSeconds());
// 默认开启状态
brand.setStatus(1);
brand.setEditPid(0);
// TODO
brand.setEditPid(10086);
if (brand.getId() == null || brand.getId() == 0) {
// 默认开启状态
brand.setStatus(1);
// 新增一条品牌记录
brand.setCreateTime(DateUtil.currentTimeSeconds());
return brandMapper.insertBrand(brand);
... ... @@ -84,6 +85,7 @@ public class BrandServiceImpl implements IBrandService {
LOGGER.info("updateBrandStatus param = {}", requestBo);
Brand brand = OrikaUtils.map(requestBo, Brand.class);
brand.setEditTime(DateUtil.currentTimeSeconds());
// TODO
brand.setEditPid(1111111);
return brandMapper.updateBrandStatus(brand);
}
... ...