Эх сурвалжийг харах

1、加盟商系统增加广告位管理各项接口

marxjaw 5 сар өмнө
parent
commit
663cb8fcc4

+ 9 - 0
yt-advertise/advertise-feign/src/main/java/com/ytpm/feign/AdvertiseFeign.java

@@ -1,13 +1,18 @@
 package com.ytpm.feign;
 package com.ytpm.feign;
 
 
 import com.ytpm.advertise.param.AddAppParam;
 import com.ytpm.advertise.param.AddAppParam;
+import com.ytpm.advertise.param.AddPlacementParam;
 import com.ytpm.advertise.param.RelativeChannelParam;
 import com.ytpm.advertise.param.RelativeChannelParam;
 import com.ytpm.advertise.view.AddAppResponse;
 import com.ytpm.advertise.view.AddAppResponse;
+import com.ytpm.advertise.view.AddPlacementResponse;
 import com.ytpm.general.Result;
 import com.ytpm.general.Result;
+import com.ytpm.general.ResultTable;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
 
 
 @FeignClient(name = "advertise-service")
 @FeignClient(name = "advertise-service")
 public interface AdvertiseFeign {
 public interface AdvertiseFeign {
@@ -17,4 +22,8 @@ public interface AdvertiseFeign {
     Result<?> delApp(@Param("appId") String appId);
     Result<?> delApp(@Param("appId") String appId);
     @PostMapping("/advertise/relativePlatform")
     @PostMapping("/advertise/relativePlatform")
     Result<?> relativePlatform(@RequestBody RelativeChannelParam channelParam);
     Result<?> relativePlatform(@RequestBody RelativeChannelParam channelParam);
+    @PostMapping("/advertise/savePlacement")
+    ResultTable<AddPlacementResponse> savePlacement(@RequestBody AddPlacementParam param);
+    @GetMapping("/advertise/savePlacement")
+    Result<?> delPlacement(@RequestParam("placementId")String placementId);
 }
 }

+ 10 - 4
yt-advertise/advertise-service/src/main/java/com/ytpm/AdvertiseApplication.java

@@ -1,11 +1,17 @@
 package com.ytpm;
 package com.ytpm;
 
 
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.web.bind.annotation.RestController;
 
 
-/**
- * Hello world!
- *
- */
+@RestController
+@SpringBootApplication
+@EnableDiscoveryClient
+@MapperScan(basePackages = "com.ytpm.dao")
+@EnableFeignClients(basePackages = {"com.ytpm.feign"})
 public class AdvertiseApplication
 public class AdvertiseApplication
 {
 {
     public static void main( String[] args )
     public static void main( String[] args )

+ 23 - 0
yt-advertise/advertise-service/src/main/java/com/ytpm/controller/AdvertiseController.java

@@ -1,8 +1,11 @@
 package com.ytpm.controller;
 package com.ytpm.controller;
 
 
 import com.ytpm.advertise.param.AddAppParam;
 import com.ytpm.advertise.param.AddAppParam;
+import com.ytpm.advertise.param.AddPlacementParam;
+import com.ytpm.advertise.param.PlacementParam;
 import com.ytpm.advertise.param.RelativeChannelParam;
 import com.ytpm.advertise.param.RelativeChannelParam;
 import com.ytpm.advertise.view.AddAppResponse;
 import com.ytpm.advertise.view.AddAppResponse;
+import com.ytpm.advertise.view.AddPlacementResponse;
 import com.ytpm.advertise.view.AppV1View;
 import com.ytpm.advertise.view.AppV1View;
 import com.ytpm.agent.param.ChannelParam;
 import com.ytpm.agent.param.ChannelParam;
 import com.ytpm.general.Result;
 import com.ytpm.general.Result;
@@ -18,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
+import java.util.Collections;
+
 @Api("Taku广告聚合管理模块")
 @Api("Taku广告聚合管理模块")
 @RestController
 @RestController
 @RequestMapping("/advertise")
 @RequestMapping("/advertise")
@@ -61,4 +66,22 @@ public class AdvertiseController {
     public Result<AddAppResponse> delApp(@RequestParam("appId")String appId) {
     public Result<AddAppResponse> delApp(@RequestParam("appId")String appId) {
         return takuApiService.delApp(appId);
         return takuApiService.delApp(appId);
     }
     }
+
+    /**
+     * 保存广告位
+     */
+    @ApiOperation("保存广告位")
+    @PostMapping("/savePlacement")
+    public ResultTable<AddPlacementResponse> savePlacement(@RequestBody AddPlacementParam param) {
+        return takuApiService.addPlacements(param);
+    }
+
+    /**
+     * 删除广告位
+     */
+    @ApiOperation("删除广告位")
+    @GetMapping("/delPlacement")
+    public Result<?> delPlacement(@RequestParam("placementId")String placementId) {
+        return takuApiService.delPlacement(Collections.singletonList(placementId));
+    }
 }
 }

+ 54 - 0
yt-agent/agent-service/src/main/java/com/ytpm/controller/AgentPlacementController.java

@@ -0,0 +1,54 @@
+package com.ytpm.controller;
+
+import com.ytpm.agent.param.PlacementListParam;
+import com.ytpm.agent.param.PlacementParam;
+import com.ytpm.agent.view.AgentPlacementView;
+import com.ytpm.general.Result;
+import com.ytpm.general.ResultTable;
+import com.ytpm.service.PlacementService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@Api(tags = "应用内广告位管理")
+@RestController
+@RequestMapping("/placement")
+public class AgentPlacementController {
+
+    @Resource
+    private PlacementService placementService;
+
+    /**
+     * 查询广告位列表
+     */
+    @ApiOperation("广告位列表")
+    @PostMapping("/list")
+    public ResultTable<AgentPlacementView> placementList(@RequestBody PlacementListParam param){
+        return placementService.placementList(param);
+    }
+
+    /**
+     * 保存广告位
+     */
+    @ApiOperation("保存广告位")
+    @PostMapping("/save")
+    public Result<?> savePlacement(@RequestBody PlacementParam param){
+        return placementService.savePlacement(param);
+    }
+
+    /**
+     * 删除广告位
+     */
+    @ApiOperation("删除广告位")
+    @GetMapping("/del")
+    public Result<?> delPlacement(@RequestParam("placementId") String placementId){
+        return placementService.delPlacement(placementId);
+    }
+}

+ 32 - 0
yt-agent/agent-service/src/main/java/com/ytpm/dao/PlacementMapper.java

@@ -0,0 +1,32 @@
+package com.ytpm.dao;
+
+import com.ytpm.agent.model.YtAppPlacement;
+import com.ytpm.agent.param.PlacementListParam;
+import com.ytpm.agent.view.AgentPlacementView;
+import org.apache.ibatis.annotations.Param;
+import org.mapstruct.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface PlacementMapper {
+    /**
+     * 查询广告位列表
+     */
+    List<AgentPlacementView> selectList(PlacementListParam param);
+
+    /**
+     * 增加广告位
+     */
+    void addOne(YtAppPlacement placement);
+
+    /**
+     * 修改广告位
+     */
+    void updateOne(YtAppPlacement placement);
+
+    /**
+     * 删除广告位
+     */
+    void deleteOne(@Param("placementId") String placementId);
+}

+ 23 - 0
yt-agent/agent-service/src/main/java/com/ytpm/service/PlacementService.java

@@ -0,0 +1,23 @@
+package com.ytpm.service;
+
+import com.ytpm.agent.param.PlacementListParam;
+import com.ytpm.agent.param.PlacementParam;
+import com.ytpm.agent.view.AgentPlacementView;
+import com.ytpm.general.Result;
+import com.ytpm.general.ResultTable;
+
+public interface PlacementService {
+
+    /**
+     * 查询广告位列表
+     */
+    ResultTable<AgentPlacementView> placementList(PlacementListParam param);
+    /**
+     * 保存广告位
+     */
+    Result<?> savePlacement(PlacementParam param);
+    /**
+     * 删除广告位
+     */
+    Result<?> delPlacement(String placementId);
+}

+ 70 - 0
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/PlacementServiceImpl.java

@@ -0,0 +1,70 @@
+package com.ytpm.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.ytpm.advertise.param.AddPlacementParam;
+import com.ytpm.advertise.view.AddPlacementResponse;
+import com.ytpm.agent.model.YtAppPlacement;
+import com.ytpm.agent.param.PlacementListParam;
+import com.ytpm.agent.param.PlacementParam;
+import com.ytpm.agent.view.AgentPlacementView;
+import com.ytpm.dao.PlacementMapper;
+import com.ytpm.feign.AdvertiseFeign;
+import com.ytpm.general.RepMessage;
+import com.ytpm.general.Result;
+import com.ytpm.general.ResultTable;
+import com.ytpm.service.PlacementService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service
+public class PlacementServiceImpl implements PlacementService {
+
+    @Resource
+    private PlacementMapper placementMapper;
+    @Resource
+    private AdvertiseFeign advertiseFeign;
+
+    /**
+     * 查询广告位列表
+     */
+    @Override
+    public ResultTable<AgentPlacementView> placementList(PlacementListParam param) {
+        PageHelper.startPage(param.getPage(), param.getLimit());
+        return ResultTable.resultTableOk(new PageInfo<AgentPlacementView>(placementMapper.selectList(param)));
+    }
+
+    /**
+     * 保存广告位
+     * PS: 如需改变顺序请加上事务处理
+     */
+    @Override
+    public Result<?> savePlacement(PlacementParam param) {
+        AddPlacementParam placementParam = new AddPlacementParam(param);
+        ResultTable<AddPlacementResponse> resultTable = advertiseFeign.savePlacement(placementParam);
+        AddPlacementResponse response = resultTable.getData().get(0);
+        YtAppPlacement placement = new YtAppPlacement();
+        BeanUtil.copyProperties(param, placement);
+        if(StrUtil.isNotBlank(param.getPlacementId())){
+            placementMapper.updateOne(placement);
+        }else{
+            placement.setPlacementId(response.getPlacement_id());
+            placement.setPlacementName(response.getPlacement_name());
+            placementMapper.addOne(placement);
+        }
+        return Result.resultOk(RepMessage.SAVE_SUCCESS);
+    }
+
+    /**
+     * 删除广告位
+     */
+    @Override
+    public Result<?> delPlacement(String placementId) {
+        advertiseFeign.delPlacement(placementId);
+        placementMapper.deleteOne(placementId);
+        return Result.resultOk(RepMessage.DELETE_SUCCESS);
+    }
+}

+ 64 - 0
yt-agent/agent-service/src/main/resources/mapper/PlacementMapper.xml

@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ytpm.dao.PlacementMapper">
+    <insert id="addOne">
+        insert into yt_app_placement
+        (
+         placement_id,
+         placement_name,
+         app_id,
+         app_name,
+         network_app_id,
+         network_app_name,
+         status,
+         remark
+        )
+        values
+        (
+         #{placementId},
+         #{placementName},
+         #{appId},
+         #{appName},
+         #{networkAppId},
+         #{networkAppName},
+         #{status},
+         #{remark}
+        )
+    </insert>
+    <update id="updateOne">
+        update yt_app_placement
+        <set>
+            <if test="placementName != null">
+                placement_name = #{placementName},
+            </if>
+            <if test="appId != null">
+                app_id = #{appId},
+            </if>
+            <if test="appName != null">
+                app_name = #{appName},
+            </if>
+            <if test="networkAppId != null">
+                network_app_id = #{networkAppId},
+            </if>
+            <if test="networkAppName != null">
+                network_app_name = #{networkAppName},
+            </if>
+            <if test="status != null">
+                `status` = #{status},
+            </if>
+            <if test="remark != null">
+                remark = #{remark}
+            </if>
+        </set>
+        where placement_id = #{placementId}
+    </update>
+    <delete id="deleteOne">
+        delete from yt_app_placement where placement_id = #{placementId}
+    </delete>
+
+    <select id="selectList" resultType="com.ytpm.agent.view.AgentPlacementView">
+        select
+            placement_id, placement_name, app_id, app_name, network_app_id, network_app_name, status, remark
+        from yt_app_placement
+    </select>
+</mapper>

+ 13 - 0
yt-common/src/main/java/com/ytpm/advertise/param/AddPlacementParam.java

@@ -3,6 +3,8 @@ package com.ytpm.advertise.param;
 import lombok.Data;
 import lombok.Data;
 
 
 import javax.validation.constraints.Size;
 import javax.validation.constraints.Size;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.List;
 
 
 @Data
 @Data
@@ -14,4 +16,15 @@ public class AddPlacementParam {
     /** 创建或修改的广告位信息列表 */
     /** 创建或修改的广告位信息列表 */
     @Size(min = 1,max = 100)
     @Size(min = 1,max = 100)
     private List<PlacementParam> placements;
     private List<PlacementParam> placements;
+
+    public AddPlacementParam(com.ytpm.agent.param.PlacementParam param) {
+        this.app_id = param.getAppId();
+        PlacementParam placement = new PlacementParam();
+        placement.setPlacement_id(param.getPlacementId());
+        placement.setPlacement_name(param.getPlacementName());
+        placement.setAdformat(param.getAdFormat());
+        placement.setRemark(param.getRemark());
+        placement.setStatus(param.getStatus());
+        this.placements = Collections.singletonList(placement);
+    }
 }
 }

+ 23 - 0
yt-common/src/main/java/com/ytpm/agent/model/YtAppPlacement.java

@@ -0,0 +1,23 @@
+package com.ytpm.agent.model;
+
+import lombok.Data;
+
+@Data
+public class YtAppPlacement {
+    /** 广告位ID */
+    private String placementId;
+    /** 广告位名称 */
+    private String placementName;
+    /** 应用ID */
+    private String appId;
+    /** 应用名称 */
+    private String appName;
+    /** 渠道应用ID */
+    private String networkAppId;
+    /** 渠道应用名称 */
+    private String networkAppName;
+    /** 状态 */
+    private String status;
+    /** 备注 */
+    private String remark;
+}

+ 21 - 0
yt-common/src/main/java/com/ytpm/agent/param/PlacementListParam.java

@@ -0,0 +1,21 @@
+package com.ytpm.agent.param;
+
+import com.ytpm.general.PageMeta;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("广告位管理列表入参")
+public class PlacementListParam extends PageMeta {
+    @ApiModelProperty("所属应用ID")
+    private String appId;
+    @ApiModelProperty("广告平台应用ID")
+    private String networkAppId;
+}

+ 34 - 0
yt-common/src/main/java/com/ytpm/agent/param/PlacementParam.java

@@ -0,0 +1,34 @@
+package com.ytpm.agent.param;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("广告位入参")
+public class PlacementParam {
+    @ApiModelProperty("广告位ID")
+    private String placementId;
+    @ApiModelProperty("广告位名称")
+    private String placementName;
+    @ApiModelProperty("广告位样式")
+    private String adFormat;
+    @ApiModelProperty("备注")
+    private String remark;
+    @ApiModelProperty("广告位状态 1-锁定 2-待审核 3-正常")
+    private Integer status;
+    @ApiModelProperty("应用ID")
+    private String appId;
+    @ApiModelProperty("应用名称")
+    private String appName;
+    @ApiModelProperty("广告渠道应用ID")
+    private String networkAppId;
+    @ApiModelProperty("广告渠道应用名称")
+    private String networkAppName;
+    @ApiModelProperty("启用状态")
+    private Integer enabled;
+}

+ 39 - 0
yt-common/src/main/java/com/ytpm/agent/view/AgentPlacementView.java

@@ -0,0 +1,39 @@
+package com.ytpm.agent.view;
+
+import com.ytpm.general.PageMeta;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel("广告位视图")
+public class AgentPlacementView extends PageMeta {
+    @ApiModelProperty("平台应用ID")
+    private String appId;
+    @ApiModelProperty("应用名称")
+    private String appName;
+    @ApiModelProperty("广告平台应用ID")
+    private String networkAppId;
+    @ApiModelProperty("广告平台应用名称")
+    private String networkAppName;
+    @ApiModelProperty("应用类型")
+    private Integer appType;
+    @ApiModelProperty("广告位ID")
+    private String placementId;
+    @ApiModelProperty("广告位名称")
+    private String placementName;
+    @ApiModelProperty("广告样式")
+    private String adFormat;
+    @ApiModelProperty("备注")
+    private String remark;
+    @ApiModelProperty("广告位状态 1-锁定 2-待审核 3-正常")
+    private Integer status;
+    @ApiModelProperty("广告位开启、关闭状态")
+    private Integer enabled;
+}