소스 검색

广告模块 增加广告接口

songfuqiang 1 년 전
부모
커밋
2dbecea011

+ 1 - 1
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/AdvertisementController.java

@@ -40,7 +40,7 @@ public class AdvertisementController {
      */
     @PostMapping("/add")
     public AppResultMap<String> add(@RequestBody AddAdvertisementParam param){
-        return new AppResultMap<>();
+        return new AppResultMap<>(CommonConstant.SUCCESS,CommonConstant.CODE_SUCCESS,advertisementService.add(param));
     }
 
 }

+ 7 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/service/AdvertisementService.java

@@ -1,5 +1,6 @@
 package cn.kdan.pdf.backend.core.service;
 
+import cn.kdan.pdf.backend.core.params.AddAdvertisementParam;
 import cn.kdan.pdf.backend.core.params.QueryAdvertisementParam;
 import cn.kdan.pdf.backend.core.pojo.app.AdvertisementVo;
 
@@ -18,4 +19,10 @@ public interface AdvertisementService {
      */
     List<AdvertisementVo> list(QueryAdvertisementParam param);
 
+    /**
+     * 增加广告/活动数据
+     * @param param 参数
+     * @return
+     */
+    String add(AddAdvertisementParam param);
 }

+ 13 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/AdvertisementServiceImpl.java

@@ -4,6 +4,7 @@ import cn.kdan.pdf.backend.core.enums.LanguageEnum;
 import cn.kdan.pdf.backend.core.mapper.AdvertisementsMapper;
 import cn.kdan.pdf.backend.core.model.Advertisements;
 import cn.kdan.pdf.backend.core.model.AdvertisementsExample;
+import cn.kdan.pdf.backend.core.params.AddAdvertisementParam;
 import cn.kdan.pdf.backend.core.params.QueryAdvertisementParam;
 import cn.kdan.pdf.backend.core.pojo.app.AdvertisementVo;
 import cn.kdan.pdf.backend.core.properties.OssProperties;
@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
+import utils.CommonUtils;
 
 import java.util.*;
 
@@ -102,4 +104,15 @@ public class AdvertisementServiceImpl implements AdvertisementService {
         advertisementsMapper.updateByPrimaryKey(adv);
     }
 
+    @Override
+    public String add(AddAdvertisementParam param) {
+        Advertisements adv = new Advertisements();
+        adv.setId(CommonUtils.generateId());
+        BeanUtils.copyProperties(param, adv);
+        Date now = new Date();
+        adv.setCreatedAt(now);
+        adv.setUpdatedAt(now);
+        advertisementsMapper.insert(adv);
+        return "增加广告成功";
+    }
 }