广告命名规范与校验
This commit is contained in:
parent
cec8b55f51
commit
c71d11ca5c
|
@ -5,7 +5,7 @@ import lombok.Getter;
|
|||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AdBlong {
|
||||
public enum AdBelong {
|
||||
|
||||
ADMIN("0", "管理员广告"),
|
||||
STORE("1", "商户广告");
|
|
@ -1,8 +1,9 @@
|
|||
package com.ruoyi.bst.ad.service.impl;
|
||||
|
||||
import com.ruoyi.bst.ad.domain.Ad;
|
||||
import com.ruoyi.bst.ad.domain.enums.AdBlong;
|
||||
import com.ruoyi.bst.ad.domain.enums.AdBelong;
|
||||
import com.ruoyi.bst.ad.service.AdConverter;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
|
@ -12,13 +13,14 @@ public class AdConverterImpl implements AdConverter {
|
|||
|
||||
@Override
|
||||
public Ad toPoByCreate(Ad data) {
|
||||
if (data == null) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
Ad po = new Ad();
|
||||
po.setBelong(data.getBelong());
|
||||
// 基础信息
|
||||
if (po.getBelong().equals(AdBlong.STORE.getCode())) {
|
||||
if (po.getBelong().equals(AdBelong.STORE.getCode())) {
|
||||
ServiceUtil.assertion(data.getAreaId()==null,"商户运营区不可以为空");
|
||||
po.setAreaId(data.getAreaId());
|
||||
}else{
|
||||
po.setAreaId(null);
|
||||
|
@ -40,7 +42,7 @@ public class AdConverterImpl implements AdConverter {
|
|||
Ad po = new Ad();
|
||||
// 基础信息
|
||||
po.setBelong(data.getBelong());
|
||||
if (po.getBelong().equals(AdBlong.STORE.getCode())) {
|
||||
if (po.getBelong().equals(AdBelong.STORE.getCode())) {
|
||||
po.setAreaId(data.getAreaId());
|
||||
}else{
|
||||
po.setAreaId(null);
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
package com.ruoyi.bst.ad.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.ad.domain.AdVerifyDTO;
|
||||
import com.ruoyi.bst.ad.domain.enums.AdBlong;
|
||||
import com.ruoyi.bst.ad.domain.enums.AdBelong;
|
||||
import com.ruoyi.bst.ad.domain.enums.AdVerifyStatus;
|
||||
import com.ruoyi.bst.ad.service.AdConverter;
|
||||
import com.ruoyi.bst.area.domain.AreaVO;
|
||||
import com.ruoyi.bst.area.service.AreaService;
|
||||
import com.ruoyi.bst.order.service.OrderService;
|
||||
import com.ruoyi.common.core.domain.vo.UserVO;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
|
@ -75,10 +73,10 @@ public class AdServiceImpl implements AdService {
|
|||
public int insertAd(Ad ad) {
|
||||
// 默认设置为商户广告
|
||||
if (ad.getBelong() == null || ad.getBelong().equals("")) {
|
||||
ad.setBelong(AdBlong.STORE.getCode());
|
||||
ad.setBelong(AdBelong.STORE.getCode());
|
||||
}
|
||||
// 商户广告存在上限
|
||||
if (ad.getBelong().equals(AdBlong.STORE.getCode())) {
|
||||
if (ad.getBelong().equals(AdBelong.STORE.getCode())) {
|
||||
AreaVO area = areaService.selectAreaById(ad.getAreaId());
|
||||
ad.setStoreId(area.getUserId());
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.ruoyi.web.app;
|
|||
|
||||
import com.ruoyi.bst.ad.domain.AdQuery;
|
||||
import com.ruoyi.bst.ad.domain.AdVO;
|
||||
import com.ruoyi.bst.ad.domain.enums.AdBlong;
|
||||
import com.ruoyi.bst.ad.domain.enums.AdBelong;
|
||||
import com.ruoyi.bst.ad.domain.enums.AdVerifyStatus;
|
||||
import com.ruoyi.common.core.domain.vo.UserVO;
|
||||
import com.ruoyi.system.user.service.UserService;
|
||||
|
@ -43,7 +43,7 @@ public class AppAdController extends BaseController {
|
|||
UserVO user = userService.selectUserById(getUserId());
|
||||
if (user.getAreaId() != null) {
|
||||
query.setAreaId(user.getAreaId());
|
||||
query.setBelong(AdBlong.STORE.getCode());
|
||||
query.setBelong(AdBelong.STORE.getCode());
|
||||
List<AdVO> areaAdVOList = adService.selectAdList(query);
|
||||
if (areaAdVOList != null) {
|
||||
list.addAll(areaAdVOList);
|
||||
|
@ -52,7 +52,7 @@ public class AppAdController extends BaseController {
|
|||
|
||||
// 查询管理员发布的广告
|
||||
query.setAreaId(null);
|
||||
query.setBelong(AdBlong.ADMIN.getCode());
|
||||
query.setBelong(AdBelong.ADMIN.getCode());
|
||||
List<AdVO> adminAdVOList = adService.selectAdList(query);
|
||||
if (adminAdVOList != null) {
|
||||
list.addAll(adminAdVOList);
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.bst.ad.domain.enums.AdBelong;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -103,6 +104,7 @@ public class AdController extends BaseController
|
|||
ad.setAuditStatus("2");
|
||||
} else {
|
||||
ad.setAuditStatus("1");
|
||||
ad.setBelong(AdBelong.STORE.getCode());
|
||||
}
|
||||
ad = adConverter.toPoByCreate(ad);
|
||||
return toAjax(adService.insertAd(ad));
|
||||
|
|
Loading…
Reference in New Issue
Block a user