Browse Source

增加服务器配置管理

chenlei1231 3 months ago
parent
commit
508c657044
13 changed files with 522 additions and 6 deletions
  1. 3 0
      jeecg-boot-base-core/src/main/java/org/jeecg/common/util/filter/SsrfFileTypeFilter.java
  2. 6 0
      jeecg-module-system/jeecg-system-biz/pom.xml
  3. 127 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/service/DomainService.java
  4. 6 5
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/impl/AdwebEnquiryServiceImpl.java
  5. 1 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/product/service/impl/AdwebProductServiceImpl.java
  6. 162 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/controller/AdwebServerController.java
  7. 102 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/entity/AdwebServer.java
  8. 14 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/mapper/AdwebServerMapper.java
  9. 5 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/mapper/xml/AdwebServerMapper.xml
  10. 14 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/service/IAdwebServerService.java
  11. 18 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/service/impl/AdwebServerServiceImpl.java
  12. 50 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/controller/WPSiteController.java
  13. 14 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/SiteManageService.java

+ 3 - 0
jeecg-boot-base-core/src/main/java/org/jeecg/common/util/filter/SsrfFileTypeFilter.java

@@ -69,6 +69,9 @@ public class SsrfFileTypeFilter {
         FILE_TYPE_WHITE_LIST.add("apk");
         FILE_TYPE_WHITE_LIST.add("wgt");
 
+        // 秘钥文件后缀
+        FILE_TYPE_WHITE_LIST.add("pem");
+        FILE_TYPE_WHITE_LIST.add("cer");
         //设置禁止文件的头部标记
         FILE_TYPE_MAP.put("3c25402070616765206c", "jsp");
         FILE_TYPE_MAP.put("3c3f7068700a0a2f2a2a0a202a205048", "php");

+ 6 - 0
jeecg-module-system/jeecg-system-biz/pom.xml

@@ -113,6 +113,12 @@
             <artifactId>ganymed-ssh2</artifactId>
             <version>262</version>
         </dependency>
+
+        <dependency>
+            <groupId>dnsjava</groupId>
+            <artifactId>dnsjava</artifactId>
+            <version>3.5.2</version>
+        </dependency>
     </dependencies>
 
 </project>

+ 127 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/service/DomainService.java

@@ -0,0 +1,127 @@
+package org.jeecg.modules.adweb.common.service;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.xbill.DNS.CNAMERecord;
+import org.xbill.DNS.Lookup;
+import org.xbill.DNS.Record;
+import org.xbill.DNS.Type;
+
+import java.net.InetAddress;
+import java.util.List;
+
+
+/**
+ * @Author: 汤星鹏
+ * @Description: 物料收集数据service
+ * @Date: 2020/4/2 9:13
+ */
+@Service
+@Slf4j
+public class DomainService {
+
+    /**
+     * 核实域名是否指向规定cname
+     *
+     * @param cname  网站cname
+     * @param domain 站点域名
+     * @return
+     * @author Cyan -- 2019/12/6 11:47
+     * @Update chenpeiqing -- 2025/1/3 17:53
+     */
+    public Boolean checkDomainIsCname(String cname, String domain) {
+        boolean flag = false;
+        try {
+            Record[] records = null;
+            Lookup lookup = new Lookup(domain, Type.CNAME);
+            lookup.run();
+            //连通并获取结果集
+            if (lookup.getResult() == Lookup.SUCCESSFUL) {
+                records = lookup.getAnswers();
+            } else {
+                //未查到结果
+                log.info("未查询到结果!");
+                return false;
+            }
+            for (Record record : records) {
+                CNAMERecord mx = (CNAMERecord) record;
+                log.info("域名:{}  ", mx.getName());
+                log.info("CNAME: {} ", mx.getTarget().toString());
+                int code = mx.getTarget().toString().indexOf(cname);
+                if (-1 != code) {
+                    flag = true;
+                }
+            }
+        } catch (Exception e) {
+            log.error("核实域名是否指向规定cname: {}", e.getMessage());
+            flag = false;
+        }
+        return flag;
+    }
+
+    /**
+     * 核实域名是否指向规定cname
+     *
+     * @param ip     网站ip
+     * @param domain 站点域名
+     * @return true:域名指向了ip   false:域名没有指向ip
+     * @author Cyan -- 2019/12/6 11:47
+     */
+    public Boolean checkDomainIsIp(String domain, String ip) {
+        Boolean flag = false;
+        try {
+            InetAddress[] addresses = InetAddress.getAllByName(domain);
+            for (int i = 0; i < addresses.length; i++) {
+                String hostAddress = addresses[i].getHostAddress();
+                int code = hostAddress.indexOf(ip);
+                if (-1 != code) {
+                    flag = true;
+                    break;
+                }
+            }
+        } catch (Exception e) {
+            log.error("核实域名是否指向规定cname: {}", e.getMessage());
+            flag = false;
+        }
+        return flag;
+    }
+
+    /**
+     * 核实域名是否指向规定cname或ip
+     *
+     * @param cname  网站cname
+     * @param domain 站点域名
+     * @param ip
+     * @return
+     * @author Cyan -- 2019/12/6 11:47
+     */
+    public Boolean checkDomainIsCnameOrIp(String cname, String domain, String ip) {
+        Boolean flag = false;
+        boolean toCname = checkDomainIsCname(cname, domain);
+        boolean toIP = checkDomainIsIp(domain, ip);
+        //cname或ip  二者有其一指向正确
+        if (toCname || toIP) {
+            flag = true;
+        }
+        return flag;
+    }
+
+    /**
+     * 检验域名以什么开头
+     *
+     * @param domain   域名
+     * @param headStrs 头字符串集合
+     * @return true:是以存在集合中的元素开头   false:不是以存在集合中的元素开头
+     * @author Cyan -- 2019/12/12 9:36
+     */
+    public Boolean checkDomainBegin(String domain, List<String> headStrs) {
+        Boolean flag = false;
+        for (String headStr : headStrs) {
+            if (domain.startsWith(headStr)) {
+                flag = true;
+                break;
+            }
+        }
+        return flag;
+    }
+}

+ 6 - 5
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/impl/AdwebEnquiryServiceImpl.java

@@ -19,9 +19,9 @@ import org.jeecg.common.constant.WebsocketConst;
 import org.jeecg.common.system.vo.DictModel;
 import org.jeecg.common.system.vo.DictPropertyModel;
 import org.jeecg.common.util.FastJsonUtil;
-import org.jeecg.modules.adweb.common.jedis.ObjectUtil;
 import org.jeecg.modules.adweb.common.constant.NumConstant;
 import org.jeecg.modules.adweb.common.dto.CountryAreaApiDto;
+import org.jeecg.modules.adweb.common.jedis.ObjectUtil;
 import org.jeecg.modules.adweb.common.service.FeishuService;
 import org.jeecg.modules.adweb.common.service.WebSocketService;
 import org.jeecg.modules.adweb.common.util.*;
@@ -195,6 +195,9 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
     @Value("${judge_waste_enquiry.ip.notBlackListDate}")
     private Integer ipNotBlackListDate;
 
+    private static final int USER_EFFECTIVE_ACTIVE = 1;
+    private static final int USER_EFFECTIVE_WAIT_ACTIVE = 2;
+
     @PostConstruct
     public void startEnquiryRedisListener() {
         enquiryRedisService.init();
@@ -308,15 +311,13 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
             log.error("站点为:{},  recordId为:{} 保存询盘到数据库失败,原因是:{}", adwebSite.getName(), enquiryDto.getRecordId(), e.getMessage());
         }
 
-        // 给该站点所属的用户发送消息 // TODO 更改为站内信 和 websocket 通知
+
+        // 站内websocket通知
         AdwebSite targetSite = adwebSiteService.getSiteByCode(target.getSiteCode());
         SysUser sysUser = sysUserService.getUserByName("admin");
         String[] userIds = {targetSite.getUid(), sysUser.getId()};
-
-        // TODO 之后仅对有效询盘进行发送消息通知
         webSocketService.sendMessage(userIds, "询盘通知", "您已经收到询盘,请尽快处理", WebsocketConst.CMD_ENQUIRY);
 
-
         // 发送询盘邮件
         sendValidateEmail(target, adwebSite, principalEmailMap);
     }

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/product/service/impl/AdwebProductServiceImpl.java

@@ -143,7 +143,7 @@ public class AdwebProductServiceImpl extends ServiceImpl<AdwebProductMapper, Adw
                 HttpResponse response = HttpRequest
                         .post(SOHOEB2B_PUSH_PRODUCT_API)
                         .header("Content-Type", "application/json")
-                        .header("Authorization", "f354b8a705c862abeae1f4f96dc55999fb9b3579")
+                        .header("tokenAuth", "f354b8a705c862abeae1f4f96dc55999fb9b3579")
                         .body(params.toString())
                         .execute(true);
 

+ 162 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/controller/AdwebServerController.java

@@ -0,0 +1,162 @@
+package org.jeecg.modules.adweb.server.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.adweb.server.entity.AdwebServer;
+import org.jeecg.modules.adweb.server.service.IAdwebServerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.util.Arrays;
+
+/**
+ * @Description: wp站点服务器配置信息
+ * @Author: jeecg-boot
+ * @Date: 2025-01-02
+ * @Version: V1.0
+ */
+@Tag(name = "wp站点服务器配置信息")
+@RestController
+@RequestMapping("/adweb/adwebServer")
+@Slf4j
+public class AdwebServerController extends JeecgController<AdwebServer, IAdwebServerService> {
+    @Autowired
+    private IAdwebServerService adwebServerService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param adwebServer
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    //@AutoLog(value = "wp站点服务器配置信息-分页列表查询")
+    @Operation(summary = "wp站点服务器配置信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<AdwebServer>> queryPageList(AdwebServer adwebServer,
+                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                    HttpServletRequest req) {
+        QueryWrapper<AdwebServer> queryWrapper = QueryGenerator.initQueryWrapper(adwebServer, req.getParameterMap());
+        Page<AdwebServer> page = new Page<AdwebServer>(pageNo, pageSize);
+        IPage<AdwebServer> pageList = adwebServerService.page(page, queryWrapper);
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 添加
+     *
+     * @param adwebServer
+     * @return
+     */
+    @AutoLog(value = "wp站点服务器配置信息-添加")
+    @Operation(summary = "wp站点服务器配置信息-添加")
+    @PreAuthorize("@jps.requiresPermissions('adweb:adweb_server:add')")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody AdwebServer adwebServer) {
+        adwebServerService.save(adwebServer);
+        return Result.OK("添加成功!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param adwebServer
+     * @return
+     */
+    @AutoLog(value = "wp站点服务器配置信息-编辑")
+    @Operation(summary = "wp站点服务器配置信息-编辑")
+    @PreAuthorize("@jps.requiresPermissions('adweb:adweb_server:edit')")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> edit(@RequestBody AdwebServer adwebServer) {
+        adwebServerService.updateById(adwebServer);
+        return Result.OK("编辑成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "wp站点服务器配置信息-通过id删除")
+    @Operation(summary = "wp站点服务器配置信息-通过id删除")
+    @PreAuthorize("@jps.requiresPermissions('adweb:adweb_server:delete')")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        adwebServerService.removeById(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "wp站点服务器配置信息-批量删除")
+    @Operation(summary = "wp站点服务器配置信息-批量删除")
+    @PreAuthorize("@jps.requiresPermissions('adweb:adweb_server:deleteBatch')")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.adwebServerService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("批量删除成功!");
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    //@AutoLog(value = "wp站点服务器配置信息-通过id查询")
+    @Operation(summary = "wp站点服务器配置信息-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<AdwebServer> queryById(@RequestParam(name = "id", required = true) String id) {
+        AdwebServer adwebServer = adwebServerService.getById(id);
+        if (adwebServer == null) {
+            return Result.error("未找到对应数据");
+        }
+        return Result.OK(adwebServer);
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param adwebServer
+     */
+    @PreAuthorize("@jps.requiresPermissions('adweb:adweb_server:exportXls')")
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, AdwebServer adwebServer) {
+        return super.exportXls(request, adwebServer, AdwebServer.class, "wp站点服务器配置信息");
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @PreAuthorize("@jps.requiresPermissions('adweb:adweb_server:importExcel')")
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, AdwebServer.class);
+    }
+
+}

+ 102 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/entity/AdwebServer.java

@@ -0,0 +1,102 @@
+package org.jeecg.modules.adweb.server.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+
+/**
+ * @Description: wp站点服务器配置信息
+ * @Author: jeecg-boot
+ * @Date: 2025-01-02
+ * @Version: V1.0
+ */
+@Data
+@TableName("adweb_server")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description = "wp站点服务器配置信息")
+public class AdwebServer implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(type = IdType.ASSIGN_ID)
+    @Schema(description = "主键")
+    private java.lang.String id;
+    /**
+     * 创建人
+     */
+    @Schema(description = "创建人")
+    private java.lang.String createBy;
+    /**
+     * 创建日期
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Schema(description = "创建日期")
+    private java.util.Date createTime;
+    /**
+     * 更新人
+     */
+    @Schema(description = "更新人")
+    private java.lang.String updateBy;
+    /**
+     * 更新日期
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Schema(description = "更新日期")
+    private java.util.Date updateTime;
+    /**
+     * 服务器IP
+     */
+    @Excel(name = "服务器IP", width = 15)
+    @Schema(description = "服务器IP")
+    private java.lang.String serverIp;
+    /**
+     * 服务器端口
+     */
+    @Excel(name = "服务器端口", width = 15)
+    @Schema(description = "服务器端口")
+    private java.lang.String serverPort;
+    /**
+     * 用户名
+     */
+    @Excel(name = "用户名", width = 15)
+    @Schema(description = "用户名")
+    private java.lang.String userName;
+    /**
+     * 密码
+     */
+    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
+    @Excel(name = "密码", width = 15)
+    @Schema(description = "密码")
+    private java.lang.String serverPassword;
+    /**
+     * 秘钥
+     */
+    @Excel(name = "秘钥", width = 15)
+    @Schema(description = "秘钥")
+    private java.lang.String serverPem;
+    /**
+     * 服务器名称
+     */
+    @Excel(name = "服务器名称", width = 15)
+    @Schema(description = "服务器名称")
+    private java.lang.String serverName;
+
+    @Excel(name = "CNAME记录", width = 15)
+    @Schema(description = "CNAME记录")
+    private java.lang.String cname;
+}

+ 14 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/mapper/AdwebServerMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.adweb.server.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.adweb.server.entity.AdwebServer;
+
+/**
+ * @Description: wp站点服务器配置信息
+ * @Author: jeecg-boot
+ * @Date: 2025-01-02
+ * @Version: V1.0
+ */
+public interface AdwebServerMapper extends BaseMapper<AdwebServer> {
+
+}

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/mapper/xml/AdwebServerMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.adweb.server.mapper.AdwebServerMapper">
+
+</mapper>

+ 14 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/service/IAdwebServerService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.adweb.server.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.adweb.server.entity.AdwebServer;
+
+/**
+ * @Description: wp站点服务器配置信息
+ * @Author: jeecg-boot
+ * @Date: 2025-01-02
+ * @Version: V1.0
+ */
+public interface IAdwebServerService extends IService<AdwebServer> {
+
+}

+ 18 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/server/service/impl/AdwebServerServiceImpl.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.adweb.server.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.adweb.server.entity.AdwebServer;
+import org.jeecg.modules.adweb.server.mapper.AdwebServerMapper;
+import org.jeecg.modules.adweb.server.service.IAdwebServerService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Description: wp站点服务器配置信息
+ * @Author: jeecg-boot
+ * @Date: 2025-01-02
+ * @Version: V1.0
+ */
+@Service
+public class AdwebServerServiceImpl extends ServiceImpl<AdwebServerMapper, AdwebServer> implements IAdwebServerService {
+
+}

+ 50 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/controller/WPSiteController.java

@@ -9,11 +9,19 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.config.security.utils.SecureUtil;
+import org.jeecg.modules.adweb.common.service.DomainService;
 import org.jeecg.modules.adweb.common.util.AdwebRedisUtil;
+import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.service.SelfWebSiteService;
+import org.jeecg.modules.adweb.site.service.SiteManageService;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @autor jerry
  * @date: 2022/1/11 20:45
@@ -29,6 +37,12 @@ public class WPSiteController {
     @Resource
     private AdwebRedisUtil adwebRedisUtil;
 
+    @Resource
+    private SiteManageService siteManageService;
+
+    @Resource
+    private DomainService domainService;
+
     /**
      * 创建站点
      *
@@ -118,4 +132,40 @@ public class WPSiteController {
         return Result.OK(result);
     }
 
+    @RequestMapping(value = "/check/domain", method = RequestMethod.POST)
+    @ResponseBody
+    public Result<?> checkDomain(HttpServletRequest request, String cname, String ip, String domain) {
+
+        log.info("====== checkDomain cname:{},ip:{},domain:{} ======", cname, ip, domain);
+        if (cname.equalsIgnoreCase(domain) || ip.equalsIgnoreCase(domain)) {
+
+            return new Result<>(100, "请勿提交我们的CNAME或IP");
+        }
+
+        //提交的域名已发布或被他人使用
+        List<AdwebSite> siteList = siteManageService.checkSiteDomainIsExists(domain);
+        log.info("siteList:{}", siteList);
+        if (!siteList.isEmpty()) {
+            return new Result<>(102, "您填写的域名已发布或被他人使用,请勿重复提交!");
+        }
+        //检验域名是否以http开头
+        List<String> headStrs = new ArrayList<>();
+        headStrs.add("http://");
+        headStrs.add("https://");
+        boolean isHttp = domainService.checkDomainBegin(domain, headStrs);
+        //isHttp == true 是以http或https开头 直接返回
+        if (isHttp) {
+            return new Result<>(101, "域名请勿以http://或https://开头");
+        }
+        //检验域名是否指向cname或ip
+        boolean isToCnameOrIp = domainService.checkDomainIsCnameOrIp(cname, domain, ip);
+        if (isToCnameOrIp) {
+            //满足不以http等开头 并且域名指向cname或ip中的一个
+            return Result.ok();
+        } else {
+            //未指向cname或ip任意一个
+            return new Result<>(103, "请确认您的域名已指向CNAME或IP");
+        }
+    }
+
 }

+ 14 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/SiteManageService.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.adweb.site.service;
 
 import cn.hutool.core.util.RandomUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -202,4 +203,17 @@ public class SiteManageService {
 //        return commonMapper.getReachStandardDayNum(historyId, commonMapper.getKeywordStandard(siteCode), specifyKeywordNum, longTailKeywordNum);
         return 0;
     }
+
+    /**
+     * 检测网站域名是否存在
+     *
+     * @param domain
+     * @return
+     */
+    public List<AdwebSite> checkSiteDomainIsExists(String domain) {
+        QueryWrapper<AdwebSite> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("domain", domain);
+        queryWrapper.ne("status", 0);
+        return adwebSiteMapper.selectList(queryWrapper);
+    }
 }