admin
2024-10-30 010ef2a907e66efd4702443c06cdd18f8a7ffa5b
IP归属地查询接口集成
21个文件已修改
14个文件已添加
2124 ■■■■■ 已修改文件
pom.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/admin/api/AdAreaConfigAdminController.java 169 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/ConfigParser.java 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/UserParser.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/dao/ad/AdAreaConfigDao.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/domain/ad/AdAreaConfig.java 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/domain/ad/ThirdAdType.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/dto/ad/AdAreaConfigDto.java 117 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/ad/AdAreaConfigServiceImpl.java 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/inter/ad/AdAreaConfigService.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/IPUtil.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/Utils.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/ad/AdAreaUtil.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/factory/ad/AdAreaConfigFactory.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/RabbitDelayConsumeFailConsumer.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/RabbitDelayConsumer.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/SolrNewListener.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/UpdateIntenetSearchListener.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/UpdateResourceVideoListener.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoResourceDeleteListener.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoSyncDataV2Listener.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoUpdateExtrainfoListener.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoUpdateFuntv2Listener.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoUpdateIqiyi2Listener.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoUpdatePPTVListener.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/vo/ad/AdConfigTypeVO.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/vo/ad/AdPositionVO.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/domain/ad/AdAreaConfig.hbm.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/hibernate.cfg.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/admin/new/ad-area-config.html 224 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/admin/new/add-ad-area-config.html 348 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/admin/new/js/navsetting.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/admin/new/update-ad-area-config.html 380 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/ad/AdTest.java 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -978,6 +978,13 @@
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.28</version>
            <scope>provided</scope>
        </dependency>
src/main/java/com/yeshi/buwan/controller/admin/api/AdAreaConfigAdminController.java
New file
@@ -0,0 +1,169 @@
package com.yeshi.buwan.controller.admin.api;
import com.google.gson.*;
import com.yeshi.buwan.domain.ad.AdAreaConfig;
import com.yeshi.buwan.domain.ad.ThirdAdType;
import com.yeshi.buwan.domain.system.DetailSystem;
import com.yeshi.buwan.dto.ad.AdAreaConfigDto;
import com.yeshi.buwan.job.AdJob;
import com.yeshi.buwan.service.imp.SystemService;
import com.yeshi.buwan.service.inter.ad.AdAreaConfigService;
import com.yeshi.buwan.util.JsonUtil;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.TimeUtil;
import com.yeshi.buwan.util.factory.ad.AdAreaConfigFactory;
import com.yeshi.buwan.vo.ad.AdConfigTypeVO;
import com.yeshi.buwan.vo.ad.AdPositionVO;
import com.yeshi.buwan.web.tag.PageEntity;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource;
import java.io.PrintWriter;
import java.lang.reflect.Type;
import java.util.*;
@Controller
@RequestMapping("admin/new/api/adAreaConfig")
public class AdAreaConfigAdminController {
    @Resource
    private AdAreaConfigService adAreaConfigService;
    @Resource
    private SystemService systemService;
    private final Gson gson = new GsonBuilder()
            .registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
                @Override
                public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
                    return src == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(src.getTime(), "yyyy.MM.dd HH:mm:ss"));
                }
            }).registerTypeAdapter(ThirdAdType.class, new JsonSerializer<ThirdAdType>() {
                @Override
                public JsonElement serialize(ThirdAdType src, Type typeOfSrc, JsonSerializationContext context) {
                    return src == null ? new JsonPrimitive("") : new JsonPrimitive(src.name());
                }
            }).registerTypeAdapter(AdConfigTypeVO.class, new JsonSerializer<AdConfigTypeVO>() {
                @Override
                public JsonElement serialize(AdConfigTypeVO src, Type typeOfSrc, JsonSerializationContext context) {
                    if (src == null) {
                        return null;
                    } else {
                        return new JsonPrimitive(new Gson().toJson(AdPositionVO.builder().name(src.getName()).value(src.name()).build()));
                    }
                }
            })
            .create();
    @RequestMapping("list")
    public void list(Long detailSystem, int page, PrintWriter out) {
        if (detailSystem != null && detailSystem == 0L) {
            detailSystem = null;
        }
        List<AdAreaConfig> list = adAreaConfigService.list(detailSystem, page, 20);
        Set<Long> detailSystemIds = new HashSet<>();
        for (AdAreaConfig ad : list) {
            detailSystemIds.add(ad.getDetailSystemId());
        }
        Map<Long, DetailSystem> detailSystemMap = new HashMap<>();
        for (Long sid : detailSystemIds) {
            DetailSystem ds = systemService.getDetailSystemById(sid + "");
            DetailSystem fds = new DetailSystem();
            fds.setId(ds.getId());
            fds.setAppName(ds.getAppName());
            detailSystemMap.put(sid, fds);
        }
        List<AdAreaConfigDto> flist = new ArrayList<>();
        for (AdAreaConfig ad : list) {
            AdAreaConfigDto dto = AdAreaConfigFactory.createDTO(ad);
            dto.setDetailSystem(detailSystemMap.get(ad.getDetailSystemId()));
            flist.add(dto);
        }
        long count = adAreaConfigService.count(detailSystem);
        JSONObject root = new JSONObject();
        root.put("code", 0);
        root.put("pageEntity", new PageEntity(page, 20, (int) count));
        root.put("data", gson.toJson(flist));
        out.print(root.toString());
    }
    @RequestMapping("get")
    public void get(Long id, PrintWriter out) {
        AdAreaConfig detail = adAreaConfigService.get(id);
        DetailSystem ds = systemService.getDetailSystemById(detail.getDetailSystemId() + "");
        DetailSystem fds = new DetailSystem();
        fds.setId(ds.getId());
        fds.setAppName(ds.getAppName());
        AdAreaConfigDto dto = AdAreaConfigFactory.createDTO(detail);
        dto.setDetailSystem(fds);
        out.print(JsonUtil.loadTrueAdmin(gson.toJson(dto)));
    }
    @RequestMapping(value = "add", method = RequestMethod.POST)
    public void add(AdAreaConfig config, PrintWriter out) {
        if (config.getDetailSystemId() == null) {
            out.print(JsonUtil.loadFalseAdmin("系统编号未上传"));
            return;
        }
        if (StringUtil.isNullOrEmpty(config.getStartTime()) || StringUtil.isNullOrEmpty(config.getEndTime())) {
            out.print(JsonUtil.loadFalseAdmin("请上传生效时间"));
            return;
        }
        if (StringUtil.isNullOrEmpty(config.getChannel())) {
            out.print(JsonUtil.loadFalseAdmin("渠道不能为空"));
            return;
        }
        adAreaConfigService.addConfig(config);
        out.print(JsonUtil.loadTrueAdmin(""));
    }
    @RequestMapping(value = "update", method = RequestMethod.POST)
    public void update(AdAreaConfig config, PrintWriter out) {
        if (config.getId() == null) {
            out.print(JsonUtil.loadFalseAdmin("请上传id"));
            return;
        }
        adAreaConfigService.updateConfig(config);
        out.print(JsonUtil.loadTrueAdmin(""));
    }
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    public void delete(Long id, PrintWriter out) {
        if (id == null) {
            out.print(JsonUtil.loadFalseAdmin("请上传id"));
            return;
        }
        adAreaConfigService.delete(id);
        out.print(JsonUtil.loadTrueAdmin(""));
    }
    /***
     * @author hxh
     * @description 请获取广告位列表
     * @date 14:10 2024/10/28
     * @param: out
     * @return void
     **/
    @RequestMapping(value = "getPositionList", method = RequestMethod.POST)
    public void getPositionList(PrintWriter out) {
        JSONArray array = new JSONArray();
        for (AdConfigTypeVO vo : AdConfigTypeVO.values()) {
            array.add(AdPositionVO.builder().name( vo.getName()).value( vo.name()).build());
        }
        out.print(JsonUtil.loadTrueAdmin(array));
    }
}
src/main/java/com/yeshi/buwan/controller/parser/ConfigParser.java
@@ -3,14 +3,14 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;
import com.google.gson.reflect.TypeToken;
import com.yeshi.buwan.domain.ad.AdAreaConfig;
import com.yeshi.buwan.domain.ad.ThirdAdType;
import com.yeshi.buwan.domain.recommend.FloatAD;
import com.yeshi.buwan.domain.system.DetailSystem;
import com.yeshi.buwan.dto.config.ADShieldIPConfig;
import com.yeshi.buwan.dto.log.BaseLog;
import com.yeshi.buwan.log.LogHelper;
import com.yeshi.buwan.service.imp.DetailSystemConfigService;
import com.yeshi.buwan.service.imp.SystemService;
import com.yeshi.buwan.service.inter.ad.AdAreaConfigService;
import com.yeshi.buwan.service.inter.ad.FloatADService;
import com.yeshi.buwan.service.inter.system.SystemConfigService;
import com.yeshi.buwan.service.inter.user.UserDPContentWatchStatisticService;
@@ -19,11 +19,11 @@
import com.yeshi.buwan.util.IPUtil;
import com.yeshi.buwan.util.JsonUtil;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.ad.AdAreaUtil;
import com.yeshi.buwan.util.log.LoggerUtil;
import com.yeshi.buwan.util.log.UserActiveLogFactory;
import com.yeshi.buwan.vo.AcceptData;
import com.yeshi.buwan.vo.ad.AdConfigTypeVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,9 +32,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.PrintWriter;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -44,6 +42,9 @@
    Logger logger = LoggerFactory.getLogger(ConfigParser.class);
    Logger debugLogger = LoggerFactory.getLogger("debug");
    @Resource
    private DetailSystemConfigService configService;
    @Resource
@@ -63,6 +64,9 @@
    @Resource
    private APPManager appManager;
    @Resource
    private AdAreaConfigService adAreaConfigService;
    public ADConfig getAdShowType(String key, String channel, int version, Map<String, String> map) {
@@ -113,45 +117,41 @@
    // 获取广告配置信息
    private void loadAdConfig(AcceptData acceptData, Map<String, String> map, String ip, boolean isDPUser,JSONObject data) {
        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        Map<String, Boolean> shieldMap = new HashMap<>();
        // 获取区域屏蔽信息
        String shieldInfo = map.get("ad_shield_province_rules");
        if (!StringUtil.isNullOrEmpty(shieldInfo)) {
            JSONObject json = JSONObject.fromObject(shieldInfo);
            //获取渠道需要屏蔽的城市
            JSONObject shieldProvinceRules = json.optJSONObject(acceptData.getChannel().toLowerCase());
            if (shieldProvinceRules != null) {
        List<AdAreaConfig> areaConfigList = null;
        try {
            areaConfigList = adAreaConfigService.listCache(acceptData.getChannel(), Long.parseLong(acceptData.getDetailSystem().getId()));
        } catch (Exception e) {
        }
                IPUtil.IPInfo ipInfo = null;
        if (areaConfigList != null && areaConfigList.size() > 0) {
                try {
                    ipInfo = ipManager.getIPInfo(ip);
                if (ipInfo != null) {
                    debugLogger.info("IP归属地:IP-{},版本-{}, 渠道-{},省-{}, 市-{}", ip, acceptData.getVersion(), acceptData.getChannel(), ipInfo.getProvince(), ipInfo.getCity());
                }
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.error("IP地址位置信息获取失败:" + ip);
                }
                if (ipInfo != null) {
                    //获取是否需要屏蔽开屏
                    for (AdConfigTypeVO adType : AdConfigTypeVO.values()) {
                        JSONArray splashProvinces = shieldProvinceRules.optJSONArray(adType.getSettingKey());
                        if (splashProvinces != null) {
                            for (int i = 0; i < splashProvinces.size(); i++) {
                                String p = splashProvinces.optString(i);
                                if (p.equalsIgnoreCase(ipInfo.getProvince())) {
                                    shieldMap.put(adType.getSettingKey(), true);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        JSONObject adNew = new JSONObject();
        JSONObject ad = new JSONObject();
        for (AdConfigTypeVO adType: AdConfigTypeVO.values()){
            ADConfig    adConfig = getAdShowType(adType.getDbKey(), acceptData.getChannel(), acceptData.getVersion(), map);
            if (shieldMap.get(adType.getSettingKey())!=null&&shieldMap.get(adType.getSettingKey())) {
                //屏蔽广告
            // 判断广告是否根据地域屏蔽
            if (ipInfo != null) {
                ThirdAdType thirdAdType = AdAreaUtil.getAdType(ipInfo.getProvince(), ipInfo.getCity(), adType, areaConfigList);
                if (thirdAdType != null) {
                    if (thirdAdType == ThirdAdType.none) {
                        // 不展示广告
                adConfig = null;
                    } else if (adConfig != null) {
                        // 指定广告类型
                        adConfig.setType(thirdAdType.name());
                    }
                }
            }
            ad.put(adType.getVoKey(), adConfig == null ? "" : adConfig.getType());
            adNew.put(adType.getVoKey(), gson.toJson(adConfig));
src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
@@ -731,9 +731,9 @@
                    getVideoDetailForInternetSearch(acceptData, videoId, request, out);
                    //VIVO 渠道每日广告最多展示一次
                    if ("vivo".equalsIgnoreCase(acceptData.getChannel())) {
                        deviceAdStrategyService.setFSAShowTomorrow(acceptData.getUtdId(), acceptData.getDetailSystem().getId());
                    }
//                    if ("vivo".equalsIgnoreCase(acceptData.getChannel())) {
//                        deviceAdStrategyService.setFSAShowTomorrow(acceptData.getUtdId(), acceptData.getDetailSystem().getId());
//                    }
                    return;
                }
            }
@@ -928,9 +928,9 @@
            out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), deviceAdStrategyService.getVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel(), loginUid, videoId, from), attention, sessionId)), array.toString(),
                    obj.toString()));
            //VIVO 渠道每日广告最多展示一次
            if ("vivo".equalsIgnoreCase(acceptData.getChannel())) {
                deviceAdStrategyService.setFSAShowTomorrow(acceptData.getUtdId(), acceptData.getDetailSystem().getId());
            }
//            if ("vivo".equalsIgnoreCase(acceptData.getChannel())) {
//                deviceAdStrategyService.setFSAShowTomorrow(acceptData.getUtdId(), acceptData.getDetailSystem().getId());
//            }
        } else {
            out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(),
                    obj.toString()));
src/main/java/com/yeshi/buwan/controller/parser/UserParser.java
@@ -1160,7 +1160,7 @@
        }
        int port = request.getRemotePort();
        String ip = getIp(request);
        String ip = IPUtil.getRemotIP(request);
        if (StringUtil.isNullOrEmpty(nickName))
            nickName = "无名氏";
@@ -1615,47 +1615,12 @@
    }
    public void getIPInfo(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        String ip = request.getHeader("x-forwarded-for");
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("X-Real-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
        }
        String ip = IPUtil.getRemotIP(request);
        try {
            out.print(ip + "-----" + new Gson().toJson(IPUtil.getLocalIPInfo(request.getRemoteAddr())));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static String getIp(HttpServletRequest request) {
        String ip = request.getHeader("x-forwarded-for");
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("HTTP_CLIENT_IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("HTTP_X_FORWARDED_FOR");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
        }
        return ip;
    }
}
src/main/java/com/yeshi/buwan/dao/ad/AdAreaConfigDao.java
New file
@@ -0,0 +1,15 @@
package com.yeshi.buwan.dao.ad;
import com.yeshi.buwan.dao.base.BaseDao;
import com.yeshi.buwan.domain.ad.AdAreaConfig;
import org.springframework.stereotype.Repository;
/**
 * @author hxh
 * @title: AdAreaConfigDao
 * @description:
 * @date 2024/10/24 11:10
 */
@Repository
public class AdAreaConfigDao extends BaseDao<AdAreaConfig> {
}
src/main/java/com/yeshi/buwan/domain/ad/AdAreaConfig.java
New file
@@ -0,0 +1,118 @@
package com.yeshi.buwan.domain.ad;
import java.util.Date;
/**
 * @author hxh
 * @title: AdAreaConfig
 * @description: 广告地域配置
 * @date 2024/10/24 10:47
 */
public class AdAreaConfig {
    private Long id;
    private Long detailSystemId;
    private String channel;
    private ThirdAdType adType;
    private String provinces;
    private String positions;
    private String citys;
    private String startTime;
    private String endTime;
    private Date createTime;
    private Date updateTime;
    public AdAreaConfig() {
    }
    public AdAreaConfig(Long id) {
        this.id = id;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getDetailSystemId() {
        return detailSystemId;
    }
    public void setDetailSystemId(Long detailSystemId) {
        this.detailSystemId = detailSystemId;
    }
    public String getChannel() {
        return channel;
    }
    public void setChannel(String channel) {
        this.channel = channel;
    }
    public ThirdAdType getAdType() {
        return adType;
    }
    public void setAdType(ThirdAdType adType) {
        this.adType = adType;
    }
    public String getProvinces() {
        return provinces;
    }
    public void setProvinces(String provinces) {
        this.provinces = provinces;
    }
    public String getCitys() {
        return citys;
    }
    public void setCitys(String citys) {
        this.citys = citys;
    }
    public String getStartTime() {
        return startTime;
    }
    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }
    public String getEndTime() {
        return endTime;
    }
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getPositions() {
        return positions;
    }
    public void setPositions(String positions) {
        this.positions = positions;
    }
}
src/main/java/com/yeshi/buwan/domain/ad/ThirdAdType.java
New file
@@ -0,0 +1,11 @@
package com.yeshi.buwan.domain.ad;
/**
 * @author hxh
 * @title: ThirdAdType
 * @description: 三方广告类型
 * @date 2024/10/24 10:50
 */
public enum ThirdAdType {
    none,csj,gdt, hw, vivo, unknown;
}
src/main/java/com/yeshi/buwan/dto/ad/AdAreaConfigDto.java
New file
@@ -0,0 +1,117 @@
package com.yeshi.buwan.dto.ad;
import com.yeshi.buwan.domain.ad.ThirdAdType;
import com.yeshi.buwan.domain.system.DetailSystem;
import com.yeshi.buwan.vo.ad.AdConfigTypeVO;
import java.util.Date;
import java.util.List;
/**
 * @author hxh
 * @title: AdAreaConfigDto
 * @description: TODO
 * @date 2024/10/24 11:18
 */
public class AdAreaConfigDto {
    private Long id;
    private DetailSystem detailSystem;
    private String channel;
    private ThirdAdType adType;
    private List<String> provinces;
    private List<String> citys;
    private List<AdConfigTypeVO> positions;
    private String startTime;
    private String endTime;
    private Date createTime;
    private Date updateTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public DetailSystem getDetailSystem() {
        return detailSystem;
    }
    public void setDetailSystem(DetailSystem detailSystem) {
        this.detailSystem = detailSystem;
    }
    public String getChannel() {
        return channel;
    }
    public void setChannel(String channel) {
        this.channel = channel;
    }
    public ThirdAdType getAdType() {
        return adType;
    }
    public void setAdType(ThirdAdType adType) {
        this.adType = adType;
    }
    public List<String> getProvinces() {
        return provinces;
    }
    public void setProvinces(List<String> provinces) {
        this.provinces = provinces;
    }
    public List<String> getCitys() {
        return citys;
    }
    public void setCitys(List<String> citys) {
        this.citys = citys;
    }
    public List<AdConfigTypeVO> getPositions() {
        return positions;
    }
    public void setPositions(List<AdConfigTypeVO> positions) {
        this.positions = positions;
    }
    public String getStartTime() {
        return startTime;
    }
    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }
    public String getEndTime() {
        return endTime;
    }
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
src/main/java/com/yeshi/buwan/service/imp/ad/AdAreaConfigServiceImpl.java
New file
@@ -0,0 +1,139 @@
package com.yeshi.buwan.service.imp.ad;
import com.yeshi.buwan.dao.ad.AdAreaConfigDao;
import com.yeshi.buwan.domain.ad.AdAreaConfig;
import com.yeshi.buwan.service.inter.ad.AdAreaConfigService;
import com.yeshi.buwan.util.StringUtil;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * @author hxh
 * @title: AdAreaConfigServiceImpl
 * @description: TODO
 * @date 2024/10/24 13:10
 */
@Service
public class AdAreaConfigServiceImpl implements AdAreaConfigService {
    @Resource
    private AdAreaConfigDao adAreaConfigDao;
    @Override
    public void addConfig(AdAreaConfig config) {
        if (config.getCreateTime() == null) {
            config.setCreateTime(new Date());
        }
        adAreaConfigDao.save(config);
    }
    @Override
    public void updateConfig(AdAreaConfig config) {
        if (config.getId() == null) {
            return;
        }
        List<Serializable> params = new ArrayList<>();
        List<String> wheres = new ArrayList<>();
        if (config.getUpdateTime() == null) {
            config.setUpdateTime(new Date());
        }
        if (config.getDetailSystemId() != null) {
            wheres.add("c.detailSystemId=?");
            params.add(config.getDetailSystemId());
        }
        if (config.getChannel() != null) {
            wheres.add("c.channel=?");
            params.add(config.getChannel());
        }
        if (config.getAdType() != null) {
            wheres.add("c.adType=?");
            params.add(config.getAdType());
        }
        if (config.getProvinces() != null) {
            wheres.add("c.provinces=?");
            params.add(config.getProvinces());
        }
        if (config.getPositions() != null) {
            wheres.add("c.positions=?");
            params.add(config.getPositions());
        }
        if (config.getCitys() != null) {
            wheres.add("c.citys=?");
            params.add(config.getCitys());
        }
        if (config.getStartTime() != null) {
            wheres.add("c.startTime=?");
            params.add(config.getStartTime());
        }
        if (config.getEndTime() != null) {
            wheres.add("c.endTime=?");
            params.add(config.getEndTime());
        }
        if (config.getCreateTime() != null) {
            wheres.add("c.createTime=?");
            params.add(config.getCreateTime());
        }
        if (config.getUpdateTime() != null) {
            wheres.add("c.updateTime=?");
            params.add(config.getUpdateTime());
        }
        params.add(config.getId());
        Serializable[] ps = new Serializable[params.size()];
        params.toArray(ps);
        adAreaConfigDao.update("update AdAreaConfig c set " + StringUtil.join(wheres, ",")+" where c.id =?", ps);
    }
    @Override
    public List<AdAreaConfig> list(String channel, Long detailSystemId) {
        return adAreaConfigDao.list("from AdAreaConfig g where g.channel=? and g.detailSystemId=?", new Serializable[]{channel, detailSystemId});
    }
    @Cacheable(value = "configCache", key = "'adAreaConfig-listCache'+'-'+#channel+'-'+#detailSystemId")
    @Override
    public List<AdAreaConfig> listCache(String channel, Long detailSystemId) {
        return list(channel, detailSystemId);
    }
    @Override
    public List<AdAreaConfig> list(Long detailSystemId, int page, int pageSize) {
        if (detailSystemId != null) {
            return adAreaConfigDao.list("from AdAreaConfig g where g.detailSystemId=?", (page - 1) * pageSize, pageSize, new Serializable[]{detailSystemId});
        } else {
            return adAreaConfigDao.list("from AdAreaConfig g", (page - 1) * pageSize, pageSize, new  Serializable[]{});
        }
    }
    @Override
    public long count(Long detailSystemId) {
        if (detailSystemId != null) {
            return adAreaConfigDao.getCount("from AdAreaConfig g where g.detailSystemId=?", new Serializable[]{detailSystemId});
        } else {
            return adAreaConfigDao.getCount("from AdAreaConfig g", new Serializable[]{});
        }
    }
    @Override
    public void delete(Long id) {
        adAreaConfigDao.delete(new AdAreaConfig(id));
    }
    @Override
    public AdAreaConfig get(Long id) {
        return adAreaConfigDao.find(AdAreaConfig.class, id);
    }
}
src/main/java/com/yeshi/buwan/service/inter/ad/AdAreaConfigService.java
New file
@@ -0,0 +1,57 @@
package com.yeshi.buwan.service.inter.ad;
import com.yeshi.buwan.domain.ad.AdAreaConfig;
import org.springframework.cache.annotation.Cacheable;
import java.util.List;
/**
 * @author hxh
 * @title: AdAreaConfigService
 * @description: 广告区域配置
 * @date 2024/10/24 11:12
 */
public interface AdAreaConfigService {
    /**
     * @author hxh
     * @description 添加配置
     * @date 13:15 2024/10/24
     * @param: config
     * @return void
     **/
    public void addConfig(AdAreaConfig config);
    /**
     * @author hxh
     * @description 更新配置
     * @date 13:15 2024/10/24
     * @param: config
     * @return void
     **/
    public void updateConfig(AdAreaConfig config);
    /**
     * @author hxh
     * @description 根据渠道与系统ID查询
     * @date 13:15 2024/10/24
     * @param: channel
     * @param: detailSystemId
     * @return java.util.List<com.yeshi.buwan.domain.ad.AdAreaConfig>
     **/
    public List<AdAreaConfig> list(String channel,Long detailSystemId);
    public List<AdAreaConfig> listCache(String channel,Long detailSystemId);
    public List<AdAreaConfig> list(Long detailSystemId, int page, int pageSize);
    public long count(Long detailSystemId);
    public void delete(Long id);
    public AdAreaConfig get(Long id);
}
src/main/java/com/yeshi/buwan/util/IPUtil.java
@@ -7,6 +7,7 @@
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
import org.lionsoul.ip2region.xdb.Searcher;
import org.yeshi.utils.HttpUtil;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedInputStream;
@@ -16,6 +17,9 @@
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public class IPUtil {
    private static Searcher searcher;
@@ -114,10 +118,25 @@
    }
    public static IPInfo getLocalIPInfo(String ip) throws Exception {
        String info = searcher.search(ip);
        String[] infos = info.split("\\|");
        IPInfo ipInfo = new IPInfo(infos[0], infos[2], infos[3]);
        String appcode = "46789780da4f4d92885c3d39b97e3ba9";
        // 通过阿里云的接口获取IP信息
        String url = "https://zjip.market.alicloudapi.com/lifeservice/QueryIpAddr/query?ip=" + URLEncoder.encode(ip, "UTF-8");
        // 网络请求
        HttpClient client = new HttpClient();
        client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);
        GetMethod method = new GetMethod(url);
        method.setRequestHeader("Authorization",  "APPCODE " + appcode);
        client.executeMethod(method);
        String result = method.getResponseBodyAsString();
        System.out.println(result);
        JSONObject data = JSONObject.fromObject(result);
        if (data.optInt("error_code") == 0) {
            data = data.optJSONObject("result");
            IPInfo ipInfo = new IPInfo(data.optString("country"), data.optString("province"), data.optString("city"));
        return ipInfo;
        } else {
            throw new Exception(data.optString("reason"));
        }
    }
    public static class IPInfo {
src/main/java/com/yeshi/buwan/util/Utils.java
@@ -320,27 +320,6 @@
    public final static int TYPE_DANGER = 3;
    public static String getIP(HttpServletRequest request) {
        String ip = request.getHeader("x-forwarded-for");
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("X-Real-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
        }
        return ip;
    }
    public static String getCoverImage(VideoInfo info) {
        if (!StringUtil.isNullOrEmpty(info.getLatestHpicture()))
            return info.getLatestHpicture();
src/main/java/com/yeshi/buwan/util/ad/AdAreaUtil.java
New file
@@ -0,0 +1,55 @@
package com.yeshi.buwan.util.ad;
import com.yeshi.buwan.domain.ad.AdAreaConfig;
import com.yeshi.buwan.domain.ad.ThirdAdType;
import com.yeshi.buwan.dto.ad.AdAreaConfigDto;
import com.yeshi.buwan.util.TimeUtil;
import com.yeshi.buwan.util.factory.ad.AdAreaConfigFactory;
import com.yeshi.buwan.vo.ad.AdConfigTypeVO;
import java.util.List;
/**
 * @author hxh
 * @title: AdAreaUtil
 * @description: 地域广告帮助类
 * @date 2024/10/24 14:22
 */
public class AdAreaUtil {
    /**
     * @return com.yeshi.buwan.domain.ad.ThirdAdType : 返回null表示采用原有的广告渠道
     * @author hxh
     * @description 获取广告显示类型
     * @date 14:27 2024/10/24
     * @param: province
     * @param: city
     * @param: position
     * @param: adConfigList
     **/
    public static ThirdAdType getAdType(String province, String city, AdConfigTypeVO position, List<AdAreaConfig> adConfigList) {
        if (adConfigList == null || adConfigList.size() == 0) {
            return null;
        }
        int nowTime = Integer.parseInt(TimeUtil.getGernalTime(System.currentTimeMillis(),"HHmmss"));
        for(AdAreaConfig config:adConfigList){
            if(Integer.parseInt(config.getStartTime().replace(":","")) > nowTime|| Integer.parseInt(config.getEndTime().replace(":","")) < nowTime){
                continue;
            }
            AdAreaConfigDto dto = AdAreaConfigFactory.createDTO(config);
            if(!dto.getPositions().contains(position)){
                continue;
            }
            // 城市匹配
            if(dto.getProvinces()!=null&&dto.getProvinces().contains(province)){
                return dto.getAdType();
            }
            if(dto.getCitys()!=null&&dto.getCitys().contains(city)){
                return dto.getAdType();
            }
        }
        return null;
    }
}
src/main/java/com/yeshi/buwan/util/factory/ad/AdAreaConfigFactory.java
New file
@@ -0,0 +1,77 @@
package com.yeshi.buwan.util.factory.ad;
import com.yeshi.buwan.domain.ad.AdAreaConfig;
import com.yeshi.buwan.domain.system.DetailSystem;
import com.yeshi.buwan.dto.ad.AdAreaConfigDto;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.vo.ad.AdConfigTypeVO;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
 * @author hxh
 * @title: AdAreaConfigFactory
 * @description: 广告区域配置工厂
 * @date 2024/10/24 11:25
 */
public class AdAreaConfigFactory {
    public static AdAreaConfigDto createDTO(AdAreaConfig bean) {
        AdAreaConfigDto dto = new AdAreaConfigDto();
        dto.setId(bean.getId());
        dto.setDetailSystem(new DetailSystem(bean.getDetailSystemId() + ""));
        dto.setChannel(bean.getChannel());
        dto.setAdType(bean.getAdType());
        if (!StringUtil.isNullOrEmpty(bean.getProvinces())) {
            dto.setProvinces(Arrays.asList(bean.getProvinces().split(",")));
        }
        if (!StringUtil.isNullOrEmpty(bean.getCitys())) {
            dto.setCitys(Arrays.asList(bean.getCitys().split(",")));
        }
        if (!StringUtil.isNullOrEmpty(bean.getPositions())) {
            List<AdConfigTypeVO> positionList = new ArrayList<>();
            String[] ps = bean.getPositions().split(",");
            for (String p : ps) {
                positionList.add(AdConfigTypeVO.valueOf(p));
            }
            dto.setPositions(positionList);
        }
        dto.setStartTime(bean.getStartTime());
        dto.setEndTime(bean.getEndTime());
        dto.setCreateTime(bean.getCreateTime());
        dto.setUpdateTime(bean.getUpdateTime());
        return dto;
    }
    public static AdAreaConfig createBean(AdAreaConfigDto dto) {
        AdAreaConfig bean = new AdAreaConfig();
        bean.setId(dto.getId());
        if (dto.getDetailSystem() != null) {
            bean.setDetailSystemId(Long.parseLong(dto.getDetailSystem().getId()));
        }
        bean.setChannel(dto.getChannel());
        bean.setAdType(dto.getAdType());
        if (dto.getProvinces() != null) {
            bean.setProvinces(StringUtil.join(dto.getProvinces(), ","));
        }
        if (dto.getCitys() != null) {
            bean.setCitys(StringUtil.join(dto.getCitys(), ","));
        }
        if (dto.getPositions() != null) {
            List<String> positionList = new ArrayList<>();
            for (AdConfigTypeVO p : dto.getPositions()) {
                positionList.add(p.name());
            }
            bean.setPositions(StringUtil.join(positionList, ","));
        }
        bean.setStartTime(dto.getStartTime());
        bean.setEndTime(dto.getEndTime());
        bean.setCreateTime(dto.getCreateTime());
        bean.setUpdateTime(dto.getUpdateTime());
        return bean;
    }
}
src/main/java/com/yeshi/buwan/util/mq/rabbit/RabbitDelayConsumeFailConsumer.java
@@ -7,6 +7,7 @@
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@@ -20,12 +21,12 @@
 * @description: 消费重试队列处理
 * @date 2024/10/12 11:21
 */
public class RabbitDelayConsumeFailConsumer {
public class RabbitDelayConsumeFailConsumer implements ChannelAwareMessageListener {
    private Logger logger = LoggerFactory.getLogger("infoLog");
    @Resource
    private RabbitTemplate rabbitTemplate;
//    @RabbitListener(queues = RabbitmqSenderUtil.CONSUME_FAIL_QUEUE_NAME, ackMode = "MANUAL")
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
        logger.info("RabbitDelayConsumeFailConsumer-{}", msg);
src/main/java/com/yeshi/buwan/util/mq/rabbit/RabbitDelayConsumer.java
@@ -7,6 +7,7 @@
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;
import org.yeshi.utils.StringUtil;
@@ -19,8 +20,7 @@
 * @description: 延时队列消费处理
 * @date 2024/10/12 11:21
 */
//@Component
public class RabbitDelayConsumer  {
public class RabbitDelayConsumer implements ChannelAwareMessageListener {
   private Logger logger = LoggerFactory.getLogger("infoLog");
@@ -28,7 +28,7 @@
    private RabbitTemplate rabbitTemplate;
//    @RabbitListener(queues = RabbitmqSenderUtil.DELAY_QUEUE_NAME, ackMode = "MANUAL")
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        String msg =  new String( message.getBody(), StandardCharsets.UTF_8);
        logger.info("RabbitDelayConsumer-{}",msg);
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/SolrNewListener.java
@@ -12,6 +12,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;
import org.yeshi.utils.StringUtil;
@@ -26,8 +27,7 @@
 * @description:
 * @date 2024/9/26 13:47
 */
@Component
public class SolrNewListener {
public class SolrNewListener  implements ChannelAwareMessageListener {
    private final static Logger logger = LoggerFactory.getLogger(SolrNewListener.class);
@@ -43,7 +43,7 @@
    @Resource
    private SolrAlbumVideoDataManager solrDataManager;
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> {
            String result = new String(message.getBody(), StandardCharsets.UTF_8);
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/UpdateIntenetSearchListener.java
@@ -11,7 +11,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.yeshi.utils.StringUtil;
import javax.annotation.Resource;
@@ -23,8 +23,7 @@
 * @description:
 * @date 2024/9/26 13:47
 */
@Component
public class UpdateIntenetSearchListener {
public class UpdateIntenetSearchListener   implements ChannelAwareMessageListener {
    private final static Logger logger = LoggerFactory.getLogger(UpdateIntenetSearchListener.class);
    @Resource
@@ -35,7 +34,7 @@
    @Resource
    private SolrInternetSearchVideoDataManager solrInternetSearchVideoDataManager;
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> {
            String result = new String(message.getBody(), StandardCharsets.UTF_8);
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/UpdateResourceVideoListener.java
@@ -15,6 +15,7 @@
import net.sf.json.JSONObject;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;
import org.yeshi.utils.StringUtil;
@@ -27,8 +28,7 @@
 * @description:
 * @date 2024/9/26 13:47
 */
@Component
public class UpdateResourceVideoListener {
public class UpdateResourceVideoListener   implements ChannelAwareMessageListener {
    @Resource
    private RabbitTemplate rabbitTemplate;
@@ -46,7 +46,7 @@
    @Resource
    private IqiyiUtil2 iqiyiUtil2;
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> {
            String result = new String(message.getBody(), StandardCharsets.UTF_8);
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoResourceDeleteListener.java
@@ -10,6 +10,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;
import org.yeshi.utils.StringUtil;
@@ -23,8 +24,7 @@
 * @description:
 * @date 2024/9/26 13:47
 */
@Component
public class VideoResourceDeleteListener {
public class VideoResourceDeleteListener   implements ChannelAwareMessageListener {
    private final static Logger logger = LoggerFactory.getLogger(VideoResourceDeleteListener.class);
    @Resource
@@ -39,6 +39,7 @@
    @Resource
    private RabbitmqManager rabbitmqManager;
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> {
            String result = new String(message.getBody(), StandardCharsets.UTF_8);
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoSyncDataV2Listener.java
@@ -5,6 +5,7 @@
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;
import org.yeshi.utils.StringUtil;
@@ -17,12 +18,12 @@
 * @description:
 * @date 2024/9/26 13:47
 */
@Component
public class VideoSyncDataV2Listener {
public class VideoSyncDataV2Listener   implements ChannelAwareMessageListener {
    @Resource
    private RabbitTemplate rabbitTemplate;
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> {
            String result = new String(message.getBody(), StandardCharsets.UTF_8);
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoUpdateExtrainfoListener.java
@@ -10,6 +10,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;
import org.yeshi.utils.StringUtil;
@@ -22,8 +23,7 @@
 * @description:
 * @date 2024/9/26 13:47
 */
@Component
public class VideoUpdateExtrainfoListener {
public class VideoUpdateExtrainfoListener   implements ChannelAwareMessageListener {
    private final static Logger logger = LoggerFactory.getLogger(VideoUpdateExtrainfoListener.class);
    @Resource
@@ -35,6 +35,7 @@
    @Resource
    private RabbitmqManager rabbitmqManager;
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> {
            String result = new String(message.getBody(), StandardCharsets.UTF_8);
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoUpdateFuntv2Listener.java
@@ -8,6 +8,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;
import org.yeshi.utils.StringUtil;
@@ -20,8 +21,7 @@
 * @description:
 * @date 2024/9/26 13:47
 */
@Component
public class VideoUpdateFuntv2Listener {
public class VideoUpdateFuntv2Listener   implements ChannelAwareMessageListener {
    private final static Logger logger = LoggerFactory.getLogger(VideoUpdateFuntv2Listener.class);
    @Resource
@@ -30,6 +30,7 @@
    @Resource
    private FunTV2Service funTV2Service;
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> {
            String result = new String(message.getBody(), StandardCharsets.UTF_8);
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoUpdateIqiyi2Listener.java
@@ -9,7 +9,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
@@ -20,8 +20,7 @@
 * @description:
 * @date 2024/9/26 13:47
 */
@Component
public class VideoUpdateIqiyi2Listener {
public class VideoUpdateIqiyi2Listener   implements ChannelAwareMessageListener {
    private final static Logger logger = LoggerFactory.getLogger(VideoUpdateIqiyi2Listener.class);
@@ -31,6 +30,7 @@
    @Resource
    private Iqiyi2Service iqiyi2Service;
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> {
            String result = new String(message.getBody(), StandardCharsets.UTF_8);
src/main/java/com/yeshi/buwan/util/mq/rabbit/consumer/VideoUpdatePPTVListener.java
@@ -11,7 +11,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
@@ -22,8 +22,7 @@
 * @description:
 * @date 2024/9/26 13:47
 */
@Component
public class VideoUpdatePPTVListener {
public class VideoUpdatePPTVListener   implements ChannelAwareMessageListener {
    private final static Logger logger = LoggerFactory.getLogger(VideoUpdatePPTVListener.class);
    @Resource
@@ -31,7 +30,7 @@
    @Resource
    private PPTVService pptvService;
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> {
            String result = new String(message.getBody(), StandardCharsets.UTF_8);
src/main/java/com/yeshi/buwan/vo/ad/AdConfigTypeVO.java
@@ -7,26 +7,28 @@
 * @date 2023/4/12 13:28
 */
public enum AdConfigTypeVO {
    splash("ad_splash_config","splash","splash"),
    playVideoPre("ad_play_video_pre","videoPlayPre","play_video_pre"),
    exitApp("ad_exit_app","exitApp","exit_app"),
    videoDetailFullVideo("ad_video_detail_full_video","videoDetailFullVideo","video_detail_full_video"),
    videoSearch("ad_video_search","videoSearch","video_search"),
    pptvNoAdReward("pptv_no_ad_reward","pptvNoAdReward","pptv_no_ad_reward"),
    splashHotStart("ad_splash_hot_start","splashHotStart","splash_hot_start"),
    homeInterstitial("home_ad_interstitial","homeInterstitial","home_interstitial"),
    exitFullVideo("ad_exit_app_fullvideo","exitAppFullvideo","exit_app_fullvideo"),
    other("ad_other","other","other");
    splash("ad_splash_config","splash","splash", "开屏"),
    playVideoPre("ad_play_video_pre","videoPlayPre","play_video_pre","视频播放贴片"),
    exitApp("ad_exit_app","exitApp","exit_app","退出应用"),
    videoDetailFullVideo("ad_video_detail_full_video","videoDetailFullVideo","video_detail_full_video", "视频播放弹出"),
    videoSearch("ad_video_search","videoSearch","video_search", "视频搜索"),
    pptvNoAdReward("pptv_no_ad_reward","pptvNoAdReward","pptv_no_ad_reward", "PPTV去广告激励"),
    splashHotStart("ad_splash_hot_start","splashHotStart","splash_hot_start","热启动开屏"),
    homeInterstitial("home_ad_interstitial","homeInterstitial","home_interstitial","首页插屏"),
    exitFullVideo("ad_exit_app_fullvideo","exitAppFullvideo","exit_app_fullvideo","退出应用全屏"),
    other("ad_other","other","other","其他位置");
    private String dbKey;
    private String voKey;
    //配置文件里面的键
    private String settingKey;
    private String name;
    private AdConfigTypeVO(String dbKey, String voKey,String settingKey) {
    private AdConfigTypeVO(String dbKey, String voKey,String settingKey,String name) {
        this.dbKey = dbKey;
        this.voKey = voKey;
        this.settingKey = settingKey;
        this.name = name;
    }
    public String getDbKey(){
@@ -41,4 +43,7 @@
        return settingKey;
    }
    public String getName() {
        return name;
    }
}
src/main/java/com/yeshi/buwan/vo/ad/AdPositionVO.java
New file
@@ -0,0 +1,22 @@
package com.yeshi.buwan.vo.ad;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Tolerate;
/**
 * @author hxh
 * @title: AdPositionVO
 * @description: TODO
 * @date 2024/10/28 15:07
 */
@Data
@Builder
public class AdPositionVO {
    @Tolerate
    public AdPositionVO(){
    }
    private String value;
    private String name;
}
src/main/resources/domain/ad/AdAreaConfig.hbm.xml
New file
@@ -0,0 +1,27 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
          "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
          "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.yeshi.buwan.domain.ad">
    <class name="AdAreaConfig" table="wk_ad_area_config">
        <id name="id" column="id">
            <generator class="native"></generator>
        </id>
        <property name="detailSystemId" type="long" column="`detail_system_id`"></property>
        <property name="channel" column="`channel`" type="string"></property>
        <property name="adType" column="ad_type">
            <type name="org.hibernate.type.EnumType">
                <param name="enumClass">com.yeshi.buwan.domain.ad.ThirdAdType</param>
                <!--12表示varchar -->
                <param name="type">12</param>
            </type>
        </property>
        <property name="provinces" column="provinces" type="string"></property>
        <property name="positions" column="positions" type="string"></property>
        <property name="citys" column="citys" type="string"></property>
        <property name="startTime" column="start_time" type="string"></property>
        <property name="endTime" column="end_time" type="string"></property>
        <property name="createTime" column="create_time" type="timestamp"></property>
        <property name="updateTime" column="update_time" type="timestamp"></property>
    </class>
</hibernate-mapping>
src/main/resources/hibernate.cfg.xml
@@ -72,6 +72,7 @@
        <mapping resource="domain/Comment2.hbm.xml"/>
        <mapping resource="domain/YSDQVideoUrl.hbm.xml"/>
        <mapping resource="domain/ad/YouDaoStatistics.hbm.xml"/>
        <mapping resource="domain/ad/AdAreaConfig.hbm.xml"/>
        <mapping resource="domain/BiliBiliUrlId.hbm.xml"/>
        <mapping resource="domain/YouKuVideoUrl.hbm.xml"/>
        <mapping resource="domain/AdRecommendRight.hbm.xml"/>
src/main/webapp/admin/new/ad-area-config.html
New file
@@ -0,0 +1,224 @@
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="referrer" content="never">
    <title>设置-广告地域设置</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/maincontent.css" rel="stylesheet">
    <style type="text/css">
        .appname .checkbox input {
            margin-left: 0 !important;
        }
        .appname label input {
            margin-right: 50px;
        }
        .appname label span {
            margin-left: 20px;
        }
    </style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
</nav>
<div id="mainbody">
    <div id="sidebar">
        <dl>
        </dl>
    </div>
    <div id="neirong">
        <div class="erjidh">
            <table class="table">
                <tbody>
                <tr>
                    <td class="xiala">
                        <select name="select" class="form-control select-detailsystem">
                        </select>
                    </td>
                    <td>
                        <form class="form-inline" role="form">
                            <div class="form-group" role="search">
                                <input type="text" class="form-control searchText" style="width:200px;"
                                       placeholder="搜索">
                            </div>
                            <button type="button" class="btn btn-default search" @click="requestConfigs(1)">搜索</button>
                        </form>
                    </td>
                    <td>
                        <div class="tianjia">
                            <a href="add-ad-area-config.html" class="btn btn-primary" role="button">添加内容&nbsp;+</a>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="zhuti">
            <div class="zhutisousuo">
                <table class="table">
                    <thead>
                    <tr>
                        <th width="30px">选择</th>
                        <th width="30px">编号</th>
                        <th width="100px">APP名称</th>
                        <th width="40px">渠道</th>
                        <th width="30px">广告类型</th>
                        <th width="150px">广告位置</th>
                        <th width="100px">省份</th>
                        <th width="100px">城市</th>
                        <th width="40px">生效开始时间</th>
                        <th width="40px">生效结束时间</th>
                        <th width="40px">创建时间</th>
                        <th width="40px">更新时间</th>
                        <th width="40px">删除</th>
                        <th width="40px">编辑</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr v-for="item in datas">
                        <td>
                            <label>
                                <input type="checkbox" value="" :key="item.id">
                            </label>
                        </td>
                        <td>
                           {{item.id}}
                        </td>
                        <td>
                            <div>{{item.detailSystem.appName}}</div>
                        </td>
                        <td>
                            <div>{{item.channel}}</div>
                        </td>
                        <td>
                            <div>{{item.adType}}</div>
                        </td>
                        <td>
                            <div><span v-for="(citem, cindex) in item.positions">{{citem.name}}<span v-if="cindex < item.positions.length-1">、</span></span></div>
                        </td>
                        <td>
                            <div><span v-for="(citem, cindex) in item.provinces">{{citem}}<span v-if="cindex < item.provinces.length-1">、</span></span></div>
                        </td>
                        <td>
                            <div><span v-for="(citem, cindex) in item.citys">{{citem}}<span v-if="cindex < item.citys.length-1">、</span></span></div>
                        </td>
                        <td>
                            <div>{{item.startTime}}</div>
                        </td>
                        <td>
                            <div>{{item.endTime}}</div>
                        </td>
                        <td>
                            <div>{{item.createTime}}</div>
                        </td>
                        <td>
                            <div>{{item.updateTime}}</div>
                        </td>
                        <td>
                            <a class="anniu shanchu"><img src="image/dustbin.png" @click = "deleteConfig(item.id)"></a></td>
                        <td>
                            <a class="anniu bianji"><img src="image/bianji.png" @click="updateConfig(item.id)"/></a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="liebiao">
                <div class="bottom">
                    <div class="page">
                        <ul class="pagination">
                            <li class="disabled pre">
                                <a href="#">&laquo;</a>
                            </li>
                            <li>
                                <a href="#" class="next">&raquo;</a>
                            </li>
                        </ul>
                        <div class="form-group">
                            <div class="tzan">
                                <button type="button" class="btn btn-primary">跳转</button>
                            </div>
                            <div class="tz">
                                <input class="form-control" type="text" placeholder="页数">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src="js/jquery.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <script src="js/nav.js"></script>
        <script src="js/common.js"></script>
        <script src="js/page.js"></script>
        <script src="layer/layer.js"></script>
        <script src="js/vue.min.js"></script>
</body>
<script>
    $(function () {
        var app = new Vue({
            el: "#mainbody",
            data: {
                datas: []
            },
            methods: {
                requestConfigs: function (page) {
                    var sys = $(".xiala .select-detailsystem > option:checked").val();
                    if (sys == undefined) {
                        sys = 0;
                    }
                    $.post("api/adAreaConfig/list", {"page": page, "detailSystem": sys}, function (data) {
                        if (data.code == 0) {
                            app.datas = data.data;
                            fillPage(data.pageEntity, function (pageIndex) {
                                app.requestConfigs(pageIndex);
                            });
                        } else {
                            alert("加载失败");
                        }
                    }, 'json')
                },
                requestPositionList: function () {
                    $.post("api/adAreaConfig/getPositionList", {}, function (data) {
                        if (data.code == 0) {
                        } else {
                        }
                    }, 'json')
                },
                deleteConfig: function (id) {
                    $.post("api/adAreaConfig/delete", {id:id}, function (data) {
                        if (data.code == 0) {
                            layer.msg("删除成功");
                            app.requestConfigs(1);
                        } else {
                            layer.msg(data.msg);
                        }
                    }, 'json')
                },
                updateConfig:function(id){
                    window.location.href = "update-ad-area-config.html?id="+id;
                }
            }
        });
        app.requestConfigs(1);
    });
</script>
</html>
src/main/webapp/admin/new/add-ad-area-config.html
New file
@@ -0,0 +1,348 @@
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="referrer" content="never">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>广告地域设置-添加</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/maincontent.css" rel="stylesheet">
    <link href="css/tablestyle.css" rel="stylesheet">
    <style>
        .form-group {
            margin-bottom: 30px;
        }
        .checkbox input[type=checkbox] {
            top: 6px;
        }
        #container-video {
            display: block;
        }
        #container-web {
            display: none;
        }
        #container-special {
            display: none;
        }
        #dialog-chooselink {
            padding: 20px;
        }
        #dialog-chooselink select {
            width: 100px;
        }
        #dialog-chooselink label {
            display: inline;
        }
        #dialog-chooselink input[type=text] {
            display: inline;
            width: 500px;
        }
        #dialog-chooselink ul {
            display: block;
            list-style: none;
        }
        #dialog-chooselink ul li {
            display: inline;
            list-style: none;
            width: 33%;
            float: left;
        }
        #dialog-chooselink input[type=radio] {
            width: 20px;
            height: 20px;
        }
        #dialog-chooselink .search-result {
            height: 630px;
            overflow-y: scroll;
        }
    </style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
</nav>
<div id="mainbody">
    <div id="sidebar">
        <dl>
        </dl>
    </div>
    <div id="neirong">
        <div class="erjidh">
            <ol class="breadcrumb">
                <li>
                    <a href="tuijian-banner.html">广告地域设置</a>
                </li>
                <li class="active">添加设置</li>
            </ol>
        </div>
        <form class="form-horizontal">
            <div class="form-group">
                <label class="changdu1 control-label">渠道</label>
                <div class="col-sm-1">
                    <select class="form-control" id="channel">
                        <option value="qq">应用宝</option>
                        <option value="huawei">华为</option>
                        <option value="vivo">VIVO</option>
                        <option value="oppo">OPPO</option>
                        <option value="xiaomi">小米</option>
                        <option value="baidu">百度</option>
                        <option value="honor">荣耀</option>
                        <option value="meizu">魅族</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">广告类型</label>
                <div class="col-sm-2">
                    <select class="form-control" id="adType">
                        <option value="csj">穿山甲广告</option>
                        <option value="gdt">广点通/优量汇广告</option>
                        <option value="vivo">VIVO广告</option>
                        <option value="hw">华为广告</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">广告位置</label>
                <div class="col-sm-3 position">
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">省份</label>
                <div class="col-sm-3">
                    <textarea class="form-control" rows="4" id="provinces" placeholder="采用逗号分隔"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">城市</label>
                <div class="col-sm-3">
                    <textarea class="form-control" rows="4" id="citys"  placeholder="采用逗号分隔"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">开始生效时间</label>
                <div class="col-sm-1">
                    <input type="text" class="form-control" id="startTime">
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">结束生效时间</label>
                <div class="col-sm-1">
                    <input type="text" class="form-control" id="endTime">
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">媒体</label>
                <div class="col-sm-2 detailsystem">
                </div>
            </div>
            <div class="button0">
                <div class="button">
                    <button type="button" class="btn btn-primary save">保存</button>
                </div>
                <div class="button">
                    <input type="reset" class="btn btn-default" value="重置"/>
                </div>
            </div>
        </form>
    </div>
    <div id="dialog-chooselink" style="display: none;">
        <div class="row" style="height: 690px;">
            <div class="col-lg-3 col-md-3" style="display: inline;">
                <select class="form-control">
                    <option value="1">视频</option>
                    <option value="2">网页</option>
                    <option value="3">合集</option>
                </select>
            </div>
            <div class="col-lg-9 col-md-9" style="display: inline;">
                <!--视频选择 -->
                <div id="container-video">
                    <div class="search">
                        <input type="text" class="form-control" placeholder="请输入关键字"
                               style="width: 200px;display: inline;"/>
                        <button class="btn btn-info">搜索</button>
                    </div>
                    <!-- 搜索结果展示区域-->
                    <div class="search-result">
                        <table class="table">
                            <thead>
                            <th>编号</th>
                            <th>名称</th>
                            <th>封面</th>
                            <th>是否显示</th>
                            <th>选择</th>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
                <!--网页填写 -->
                <div id="container-web">
                    <label>网页链接:</label>
                    <input type="text" class="form-control"/>
                </div>
                <!--合集选择 -->
                <div id="container-special">
                    <label>合集列表</label>
                    <ul>
                        <li>
                            <div class="checkbox"><label><input type="checkbox" value="46">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;布丸影视大全Web1</label>
                            </div>
                        </li>
                        <li>
                            <div class="checkbox"><label><input type="checkbox" value="46">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;布丸影视大全Web2</label>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div style="float: right;">
            <button class="btn btn-info sure">确定</button>
            <button class="btn btn-default cancel">取消</button>
        </div>
    </div>
</div>
<script src="//cdn.bootcss.com/jquery/1.10.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/nav.js"></script>
<script src="js/common.js"></script>
<script src="layer/layer.js"></script>
<script src="js/vue.min.js"></script>
<script>
    var index;
    $(function () {
        $.post('api/adAreaConfig/getPositionList', {}, function (data) {
            if (data.code == 0) {
                var datas = data.data;
                var dsStr = "";
                datas.forEach(function (ds) {
                    dsStr += "<div class='checkbox '><label>";
                    dsStr += "<input type='checkbox' value=" + ds.value + ">";
                    dsStr += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + ds.name;
                    dsStr += "</label></div>";
                });
                $(".position").eq(0).html(dsStr);
            }
        }, "json");
        $.post('/BuWan/admin/new/api/common/detailsystemlist', function (data) {
            if (data.code == 0) {
                var dsStr = "<select id='detailsystem' class='form-control'>";
                data.data.forEach(function (ds) {
                    dsStr += "<option type='checkbox' value=" + ds.id + ">";
                    dsStr += ds.name;
                    dsStr += "</option>";
                });
                dsStr += "</select>"
                $(".detailsystem").html(dsStr);
            }
        }, 'json');
        $(".save").click(function () {
            var params = {};
            params.channel = $("#channel").val();
            params.adType = $("#adType").val();
            params.detailSystemId = $("#detailsystem").val();
            params.provinces = $("#provinces").val();
            params.citys = $("#citys").val();
            params.startTime = $("#startTime").val();
            params.endTime = $("#endTime").val();
            var $positions = $(".position input[type=checkbox]");
            var dess = "";
            for (var i = 0; i < $positions.length; i++) {
                if ($positions.eq(i).is(":checked")) {
                    dess += $positions.eq(i).val() + ",";
                }
            }
            if (dess.length > 0)
                dess = dess.substr(0, dess.length - 1);
            params.positions = dess;
            console.log("获取到的数据:", params);
            // 判断数据格式是否正确
            if(params.positions.length<1){
                layer.msg("请选择广告位置");
                return;
            }
            const timePattern =  /^(?:[01]?\d|2[0-3]):[0-5]\d:[0-5]\d$/;
            if(!timePattern.test(params.startTime)||!timePattern.test(params.endTime)){
                layer.msg("时间格式不正确");
                return;
            }
            var index = layer.load(0, {
                'shade': false
            });
            $.post('/BuWan/admin/new/api/adAreaConfig/add', params, function (data) {
                layer.close(index);
                if(data.code ==0){
                    layer.msg("添加成功");
                }else {
                    layer.msg(data.msg);
                }
                doResponse(data, function () {
                });
            }, 'json');
        });
    });
</script>
</body>
</html>
src/main/webapp/admin/new/js/navsetting.xml
@@ -191,6 +191,11 @@
            <url></url>
        </secondNav>
        <secondNav url="ad-area-config.html" name="广告地域设置">
            <!-- 网页链接 -->
            <url></url>
        </secondNav>
        <secondNav url="cache-update.html" name="清除缓存">
            <!-- 网页链接 -->
src/main/webapp/admin/new/update-ad-area-config.html
New file
@@ -0,0 +1,380 @@
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="referrer" content="never">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>广告地域设置-添加</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/maincontent.css" rel="stylesheet">
    <link href="css/tablestyle.css" rel="stylesheet">
    <style>
        .form-group {
            margin-bottom: 30px;
        }
        .checkbox input[type=checkbox] {
            top: 6px;
        }
        #container-video {
            display: block;
        }
        #container-web {
            display: none;
        }
        #container-special {
            display: none;
        }
        #dialog-chooselink {
            padding: 20px;
        }
        #dialog-chooselink select {
            width: 100px;
        }
        #dialog-chooselink label {
            display: inline;
        }
        #dialog-chooselink input[type=text] {
            display: inline;
            width: 500px;
        }
        #dialog-chooselink ul {
            display: block;
            list-style: none;
        }
        #dialog-chooselink ul li {
            display: inline;
            list-style: none;
            width: 33%;
            float: left;
        }
        #dialog-chooselink input[type=radio] {
            width: 20px;
            height: 20px;
        }
        #dialog-chooselink .search-result {
            height: 630px;
            overflow-y: scroll;
        }
    </style>
    <script src="js/http.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
</nav>
<div id="mainbody">
    <div id="sidebar">
        <dl>
        </dl>
    </div>
    <div id="neirong">
        <div class="erjidh">
            <ol class="breadcrumb">
                <li>
                    <a href="tuijian-banner.html">广告地域设置</a>
                </li>
                <li class="active">添加设置</li>
            </ol>
        </div>
        <form class="form-horizontal">
            <div class="form-group">
                <label class="changdu1 control-label">渠道</label>
                <div class="col-sm-1">
                    <select class="form-control" id="channel">
                        <option value="qq">应用宝</option>
                        <option value="huawei">华为</option>
                        <option value="vivo">VIVO</option>
                        <option value="oppo">OPPO</option>
                        <option value="xiaomi">小米</option>
                        <option value="baidu">百度</option>
                        <option value="honor">荣耀</option>
                        <option value="meizu">魅族</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">广告类型</label>
                <div class="col-sm-2">
                    <select class="form-control" id="adType">
                        <option value="csj">穿山甲广告</option>
                        <option value="gdt">广点通/优量汇广告</option>
                        <option value="vivo">VIVO广告</option>
                        <option value="hw">华为广告</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">广告位置</label>
                <div class="col-sm-3 position">
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">省份</label>
                <div class="col-sm-3">
                    <textarea class="form-control" rows="4" id="provinces" placeholder="采用逗号分隔"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">城市</label>
                <div class="col-sm-3">
                    <textarea class="form-control" rows="4" id="citys"  placeholder="采用逗号分隔"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">开始生效时间</label>
                <div class="col-sm-1">
                    <input type="text" class="form-control" id="startTime">
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">结束生效时间</label>
                <div class="col-sm-1">
                    <input type="text" class="form-control" id="endTime">
                </div>
            </div>
            <div class="form-group">
                <label class="changdu1 control-label">媒体</label>
                <div class="col-sm-2 detailsystem">
                </div>
            </div>
            <div class="button0">
                <div class="button">
                    <button type="button" class="btn btn-primary save">保存</button>
                </div>
                <div class="button">
                    <input type="reset" class="btn btn-default" value="重置"/>
                </div>
            </div>
        </form>
    </div>
    <div id="dialog-chooselink" style="display: none;">
        <div class="row" style="height: 690px;">
            <div class="col-lg-3 col-md-3" style="display: inline;">
                <select class="form-control">
                    <option value="1">视频</option>
                    <option value="2">网页</option>
                    <option value="3">合集</option>
                </select>
            </div>
            <div class="col-lg-9 col-md-9" style="display: inline;">
                <!--视频选择 -->
                <div id="container-video">
                    <div class="search">
                        <input type="text" class="form-control" placeholder="请输入关键字"
                               style="width: 200px;display: inline;"/>
                        <button class="btn btn-info">搜索</button>
                    </div>
                    <!-- 搜索结果展示区域-->
                    <div class="search-result">
                        <table class="table">
                            <thead>
                            <th>编号</th>
                            <th>名称</th>
                            <th>封面</th>
                            <th>是否显示</th>
                            <th>选择</th>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
                <!--网页填写 -->
                <div id="container-web">
                    <label>网页链接:</label>
                    <input type="text" class="form-control"/>
                </div>
                <!--合集选择 -->
                <div id="container-special">
                    <label>合集列表</label>
                    <ul>
                        <li>
                            <div class="checkbox"><label><input type="checkbox" value="46">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;布丸影视大全Web1</label>
                            </div>
                        </li>
                        <li>
                            <div class="checkbox"><label><input type="checkbox" value="46">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;布丸影视大全Web2</label>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div style="float: right;">
            <button class="btn btn-info sure">确定</button>
            <button class="btn btn-default cancel">取消</button>
        </div>
    </div>
</div>
<script src="//cdn.bootcss.com/jquery/1.10.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/nav.js"></script>
<script src="js/common.js"></script>
<script src="layer/layer.js"></script>
<script src="js/vue.min.js"></script>
<script>
    var index;
    $(function () {
        const id = ysdqapp.getQueryParam("id");
        $.post('/BuWan/admin/new/api/common/detailsystemlist', function (data) {
            if (data.code == 0) {
                var dsStr = "<select id='detailsystem' class='form-control'>";
                data.data.forEach(function (ds) {
                    dsStr += "<option type='checkbox' value=" + ds.id + ">";
                    dsStr += ds.name;
                    dsStr += "</option>";
                });
                dsStr += "</select>"
                $(".detailsystem").html(dsStr);
                $.post('api/adAreaConfig/getPositionList', {}, function (data) {
                    if (data.code == 0) {
                        var datas = data.data;
                        var dsStr = "";
                        datas.forEach(function (ds) {
                            dsStr += "<div class='checkbox '><label>";
                            dsStr += "<input type='checkbox' value=" + ds.value + ">";
                            dsStr += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + ds.name;
                            dsStr += "</label></div>";
                        });
                        $(".position").eq(0).html(dsStr);
                        $.post('api/adAreaConfig/get', {id:id}, function (data) {
                            if (data.code == 0) {
                                var data = data.data;
                                $("#channel").val(data.channel);
                                $("#adType").val(data.adType);
                                var positions = $(".position").eq(0).find("input[type=checkbox]");
                                console.log($(positions[0]));
                                for(var i=0;i<positions.length;i++){
                                    for(var n=0;n<data.positions.length;n++){
                                        if(data.positions[n].value ==   $(positions[i]).attr("value")){
                                            $(positions[i]).attr('checked', 'checked');
                                            break;
                                        }
                                    }
                                }
                                $("#provinces").val(data.provinces);
                                $("#citys").val(data.citys);
                                $("#startTime").val(data.startTime);
                                $("#endTime").val(data.endTime);
                                $("#detailsystem").val(data.detailSystem.id);
                            }
                        }, "json");
                    }
                }, "json");
            }
        }, 'json');
        $(".save").click(function () {
            var params = {};
            params.id = id;
            params.channel = $("#channel").val();
            params.adType = $("#adType").val();
            params.detailSystemId = $("#detailsystem").val();
            params.provinces = $("#provinces").val();
            params.citys = $("#citys").val();
            params.startTime = $("#startTime").val();
            params.endTime = $("#endTime").val();
            var $positions = $(".position input[type=checkbox]");
            var dess = "";
            for (var i = 0; i < $positions.length; i++) {
                if ($positions.eq(i).is(":checked")) {
                    dess += $positions.eq(i).val() + ",";
                }
            }
            if (dess.length > 0)
                dess = dess.substr(0, dess.length - 1);
            params.positions = dess;
            console.log("获取到的数据:", params);
            // 判断数据格式是否正确
            if(params.positions.length<1){
                layer.msg("请选择广告位置");
                return;
            }
            const timePattern =  /^(?:[01]?\d|2[0-3]):[0-5]\d:[0-5]\d$/;
            if(!timePattern.test(params.startTime)||!timePattern.test(params.endTime)){
                layer.msg("时间格式不正确");
                return;
            }
            var index = layer.load(0, {
                'shade': false
            });
            $.post('/BuWan/admin/new/api/adAreaConfig/update', params, function (data) {
                layer.close(index);
                if(data.code ==0){
                    layer.msg("更新成功");
                }else {
                    layer.msg(data.msg);
                }
                doResponse(data, function () {
                });
            }, 'json');
        });
    });
</script>
</body>
</html>
src/test/java/com/hxh/spring/test/ad/AdTest.java
@@ -1,11 +1,21 @@
package com.hxh.spring.test.ad;
import com.google.gson.*;
import com.yeshi.buwan.dao.jump.JumpDetailDao;
import com.yeshi.buwan.dao.recommend.FloatADDao;
import com.yeshi.buwan.domain.ad.AdAreaConfig;
import com.yeshi.buwan.domain.ad.ThirdAdType;
import com.yeshi.buwan.domain.jump.JumpDetail;
import com.yeshi.buwan.domain.jump.JumpTypeEnum;
import com.yeshi.buwan.domain.recommend.FloatAD;
import com.yeshi.buwan.domain.system.DetailSystem;
import com.yeshi.buwan.dto.ad.AdAreaConfigDto;
import com.yeshi.buwan.service.imp.SystemService;
import com.yeshi.buwan.service.inter.ad.AdAreaConfigService;
import com.yeshi.buwan.util.ad.AdAreaUtil;
import com.yeshi.buwan.util.factory.ad.AdAreaConfigFactory;
import com.yeshi.buwan.vo.ad.AdConfigTypeVO;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -16,7 +26,8 @@
import org.yeshi.utils.TimeUtil;
import javax.annotation.Resource;
import java.util.Date;
import java.lang.reflect.Type;
import java.util.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring.xml"})
@@ -28,6 +39,9 @@
    @Resource
    private FloatADDao floatADDao;
    @Resource
    private AdAreaConfigService adAreaConfigService;
    @Test
    public void addJumpDetail() {
@@ -66,4 +80,91 @@
    public void getFloatAd() {
        floatADDao.list(true, new Date(), 1, 1);
    }
    @Test
    public void addAdAreaConfig() {
        AdAreaConfigDto config = new AdAreaConfigDto();
        config.setChannel("vivo");
        config.setDetailSystem(new DetailSystem(44L+""));
        config.setAdType(ThirdAdType.vivo);
        config.setProvinces(Arrays.asList(new String[]{"广东", "浙江"}));
        config.setPositions(Arrays.asList(new AdConfigTypeVO[]{AdConfigTypeVO.homeInterstitial, AdConfigTypeVO.videoDetailFullVideo}));
        config.setStartTime("00:00:00");
        config.setEndTime("23:59:59");
        adAreaConfigService.addConfig(AdAreaConfigFactory.createBean(config));
    }
    @Test
    public void updateAdAreaConfig() {
        AdAreaConfigDto config = new AdAreaConfigDto();
        config.setStartTime("00:00:01");
        config.setEndTime("23:59:59");
        AdAreaConfig bean = AdAreaConfigFactory.createBean(config);
        bean.setId(2L);
        adAreaConfigService.updateConfig(bean);
    }
    @Test
    public void listAdAreaConfig() {
        List<AdAreaConfig> mList = adAreaConfigService.listCache("huawei", 44L);
        ThirdAdType adType = AdAreaUtil.getAdType("重庆", "深圳", AdConfigTypeVO.homeInterstitial, mList);
        System.out.println(mList);
        for (AdAreaConfig bean : mList) {
            AdAreaConfigDto dto = AdAreaConfigFactory.createDTO(bean);
            System.out.println(dto);
        }
    }
    private final Gson gson = new GsonBuilder()
            .registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
                @Override
                public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
                    return src == null ? new JsonPrimitive("") : new JsonPrimitive(com.yeshi.buwan.util.TimeUtil.getGernalTime(src.getTime(), "yyyy.MM.dd HH:mm:ss"));
                }
            }).registerTypeAdapter(ThirdAdType.class, new JsonSerializer<ThirdAdType>() {
                @Override
                public JsonElement serialize(ThirdAdType src, Type typeOfSrc, JsonSerializationContext context) {
                    return src == null ? new JsonPrimitive("") : new JsonPrimitive(src.name());
                }
            }).registerTypeAdapter(AdConfigTypeVO.class, new JsonSerializer<AdConfigTypeVO>() {
                @Override
                public JsonElement serialize(AdConfigTypeVO src, Type typeOfSrc, JsonSerializationContext context) {
                    return src == null ? new JsonPrimitive("") : new JsonPrimitive(src.getName());
                }
            })
            .create();
    @Resource
    private SystemService systemService;
    @Test
    public void testList(){
        List<AdAreaConfig> list = adAreaConfigService.list(null, 1, 20);
        Set<Long> detailSystemIds = new HashSet<>();
        for (AdAreaConfig ad : list) {
            detailSystemIds.add(ad.getDetailSystemId());
        }
        Map<Long, DetailSystem> detailSystemMap = new HashMap<>();
        for (Long sid : detailSystemIds) {
            detailSystemMap.put(sid, systemService.getDetailSystemById(sid + ""));
        }
        List<AdAreaConfigDto> flist = new ArrayList<>();
        for (AdAreaConfig ad : list) {
            AdAreaConfigDto dto = AdAreaConfigFactory.createDTO(ad);
//            dto.setDetailSystem(detailSystemMap.get(ad.getDetailSystemId()));
            flist.add(dto);
        }
        System.out.println( gson.toJson(flist));
    }
}