Commit 22665e2b by weijiguang

下单时校验订单中sku数量

parent 86c0b006
......@@ -6,6 +6,7 @@ import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.page.TableDataInfo;
import com.soss.common.exception.ServiceException;
import com.soss.system.domain.SysBanner;
import com.soss.system.domain.po.BannerPo;
import com.soss.system.service.ISysBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -38,7 +39,7 @@ public class BannerController extends BaseController {
* @return
*/
@PostMapping("/create")
public AjaxResult create(@RequestBody SysBanner banner) {
public AjaxResult create(@RequestBody BannerPo banner) {
try {
return AjaxResult.success(bannerService.createBanner(banner));
} catch (ServiceException serviceException) {
......@@ -53,7 +54,7 @@ public class BannerController extends BaseController {
* @return
*/
@PostMapping("/update")
public AjaxResult update(@RequestBody SysBanner banner) {
public AjaxResult update(@RequestBody BannerPo banner) {
try {
return AjaxResult.success(bannerService.updateBanner(banner));
} catch (ServiceException serviceException) {
......
package com.soss.system.domain.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("轮播图请求类")
public class BannerPo {
/** 主键 */
private Long id;
/**
* 图片url
*/
private String image;
/**
* 页面url
*/
private String page;
/**
* 类型:1-小程序,2-KDS,3-点单屏
*/
private Integer type;
/**
* 目标:1-小程序首页,2-小程序我的
*/
private Integer target;
/**
* 排序
*/
private Integer sort;
@ApiModelProperty("可用省份列表,全国通用传 [0]")
private String[] province;
@ApiModelProperty("可用城市列表")
private String[] city;
@ApiModelProperty("可用区域列表")
private String[] area;
@ApiModelProperty("可用店铺ID列表")
private Long[] shopIds;
}
package com.soss.system.service;
import com.soss.system.domain.SysBanner;
import com.soss.system.domain.po.BannerPo;
import java.util.List;
......@@ -13,9 +14,9 @@ import java.util.List;
public interface ISysBannerService {
List<SysBanner> selectBanner(SysBanner banner);
Long createBanner(SysBanner banner);
Long createBanner(BannerPo banner);
Boolean updateBanner(SysBanner banner);
Boolean updateBanner(BannerPo banner);
Boolean updateState(Long bannerId, Integer state);
......
......@@ -4,6 +4,7 @@ import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils;
import com.soss.system.domain.Shop;
import com.soss.system.domain.SysBanner;
import com.soss.system.domain.po.BannerPo;
import com.soss.system.mapper.SysBannerMapper;
import com.soss.system.service.ISysBannerService;
import lombok.extern.slf4j.Slf4j;
......@@ -15,6 +16,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 轮播图Service业务层处理
......@@ -36,7 +38,8 @@ public class SysBannerServiceImpl implements ISysBannerService {
}
@Override
public Long createBanner(SysBanner banner) {
public Long createBanner(BannerPo bannerPo) {
SysBanner banner = copyBanner(bannerPo);
if (StringUtils.isEmpty(banner.getImage())) {
throw new ServiceException("图片地址不能为空");
}
......@@ -64,7 +67,8 @@ public class SysBannerServiceImpl implements ISysBannerService {
}
@Override
public Boolean updateBanner(SysBanner banner) {
public Boolean updateBanner(BannerPo bannerPo) {
SysBanner banner = copyBanner(bannerPo);
if (banner.getId() == null || banner.getId() <= 0) {
throw new ServiceException("id不能为空");
}
......@@ -93,6 +97,30 @@ public class SysBannerServiceImpl implements ISysBannerService {
return i > 0 ? true : false;
}
private SysBanner copyBanner(BannerPo bannerPo) {
SysBanner banner = new SysBanner();
banner.setId(bannerPo.getId());
banner.setImage(bannerPo.getImage());
banner.setPage(bannerPo.getPage());
banner.setType(bannerPo.getType());
banner.setTarget(bannerPo.getTarget());
banner.setSort(bannerPo.getSort());
if (bannerPo.getProvince() != null && bannerPo.getProvince().length > 0) {
banner.setProvince(Arrays.asList(bannerPo.getProvince()).stream().collect(Collectors.joining(",")));
}
if (bannerPo.getCity() != null && bannerPo.getCity().length > 0) {
banner.setCity(Arrays.asList(bannerPo.getCity()).stream().collect(Collectors.joining(",")));
}
if (bannerPo.getArea() != null && bannerPo.getArea().length > 0) {
banner.setArea(Arrays.asList(bannerPo.getArea()).stream().collect(Collectors.joining(",")));
}
if (bannerPo.getShopIds() != null && bannerPo.getShopIds().length > 0) {
banner.setShopIds(Arrays.asList(bannerPo.getShopIds()).stream().map(x -> String.valueOf(x)).collect(Collectors.joining(",")));
}
return banner;
}
@Override
public Boolean updateState(Long bannerId, Integer state) {
SysBanner banner = new SysBanner();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment