|
|
|
@@ -3,12 +3,14 @@ package com.iformall.controller; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.Result; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxCampaign; |
|
|
|
import com.iformall.domain.po.WxCouponChannel; |
|
|
|
import com.iformall.domain.vo.WxCouponChannelVo; |
|
|
|
import com.iformall.enums.EnumCampaignStatus; |
|
|
|
import com.iformall.enums.EnumCampaignType; |
|
|
|
import com.iformall.enums.EnumCouponChannelType; |
|
|
|
import com.iformall.service.WxCampaignService; |
|
|
|
import com.iformall.service.WxCouponChannelService; |
|
|
|
@@ -61,9 +63,26 @@ public class WxCampaignController extends BaseController { |
|
|
|
@PostMapping("add") |
|
|
|
public ResultData add(@RequestBody WxCampaign wxCampaign) { |
|
|
|
logger.debug("[" + getIpAddr() + "] WxCampaignController::add"); |
|
|
|
//Assert.notNull(wxCampaign.getName(), "角色名不能为空"); |
|
|
|
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); |
|
|
|
// int sortNum = wxCampaignService.getMaxSortNum(getTenantId()); |
|
|
|
if (StringUtils.isEmpty(wxCampaign.getCoverImg())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "封面图不能为空"); |
|
|
|
} |
|
|
|
if(wxCampaign.getType().equals(EnumCampaignType.STABLE.getCode())) { |
|
|
|
if (StringUtils.isEmpty(wxCampaign.getTitle())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "标题不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isEmpty(wxCampaign.getDetail())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "活动说明不能为空"); |
|
|
|
} |
|
|
|
}else if(wxCampaign.getType().equals(EnumCampaignType.FREE.getCode())) { |
|
|
|
if (StringUtils.isEmpty(wxCampaign.getHtml())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "图文不能为空"); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if (StringUtils.isEmpty(wxCampaign.getLink())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "图文不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) { |
|
|
|
String[] arys = wxCampaign.getCouponIds().split(","); |
|
|
|
wxCampaign.setCouponIds(JSON.toJSONString(arys)); |
|
|
|
@@ -72,7 +91,6 @@ public class WxCampaignController extends BaseController { |
|
|
|
} |
|
|
|
wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); |
|
|
|
wxCampaign.setTenantId(getTenantId()); |
|
|
|
// wxCampaign.setSortNum(sortNum+1); |
|
|
|
wxCampaignService.saveOrUpdate(wxCampaign); |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
@@ -81,6 +99,27 @@ public class WxCampaignController extends BaseController { |
|
|
|
@PostMapping("update") |
|
|
|
public ResultData update(@RequestBody WxCampaign wxCampaign) { |
|
|
|
logger.debug("[" + getIpAddr() + "] WxCampaignController::update"); |
|
|
|
|
|
|
|
if (StringUtils.isEmpty(wxCampaign.getCoverImg())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "封面图不能为空"); |
|
|
|
} |
|
|
|
if(wxCampaign.getType().equals(EnumCampaignType.STABLE.getCode())) { |
|
|
|
if (StringUtils.isEmpty(wxCampaign.getTitle())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "标题不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isEmpty(wxCampaign.getDetail())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "活动说明不能为空"); |
|
|
|
} |
|
|
|
}else if(wxCampaign.getType().equals(EnumCampaignType.FREE.getCode())) { |
|
|
|
if (StringUtils.isEmpty(wxCampaign.getHtml())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "图文不能为空"); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if (StringUtils.isEmpty(wxCampaign.getLink())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "图文不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) { |
|
|
|
String[] arys = wxCampaign.getCouponIds().split(","); |
|
|
|
wxCampaign.setCouponIds(JSON.toJSONString(arys)); |
|
|
|
|