Răsfoiți Sursa

新建项目,完成基础功能开发

戴中初 10 luni în urmă
comite
a7edd224f9
51 a modificat fișierele cu 1567 adăugiri și 0 ștergeri
  1. 33 0
      mcp/.gitignore
  2. 108 0
      mcp/pom.xml
  3. 15 0
      mcp/src/main/java/com/chuanxia/mcp/McpApplication.java
  4. 73 0
      mcp/src/main/java/com/chuanxia/mcp/aop/CheckTokenAspect.java
  5. 13 0
      mcp/src/main/java/com/chuanxia/mcp/aop/Login.java
  6. 16 0
      mcp/src/main/java/com/chuanxia/mcp/bean/dto/DomainBindDto.java
  7. 16 0
      mcp/src/main/java/com/chuanxia/mcp/bean/dto/DomainCityQueryDto.java
  8. 16 0
      mcp/src/main/java/com/chuanxia/mcp/bean/dto/DomainOperatorBindDto.java
  9. 17 0
      mcp/src/main/java/com/chuanxia/mcp/bean/dto/DomainQueryDto.java
  10. 9 0
      mcp/src/main/java/com/chuanxia/mcp/bean/dto/OperatorQueryDto.java
  11. 9 0
      mcp/src/main/java/com/chuanxia/mcp/bean/dto/PageQueryBaseDto.java
  12. 21 0
      mcp/src/main/java/com/chuanxia/mcp/bean/enums/DefaultDomainEnums.java
  13. 22 0
      mcp/src/main/java/com/chuanxia/mcp/bean/enums/ResultStatusEnum.java
  14. 23 0
      mcp/src/main/java/com/chuanxia/mcp/bean/model/CdnCity.java
  15. 51 0
      mcp/src/main/java/com/chuanxia/mcp/bean/model/CdnDomain.java
  16. 18 0
      mcp/src/main/java/com/chuanxia/mcp/bean/model/CdnDomainCity.java
  17. 27 0
      mcp/src/main/java/com/chuanxia/mcp/bean/model/CdnDomainOperator.java
  18. 26 0
      mcp/src/main/java/com/chuanxia/mcp/bean/model/CdnOperator.java
  19. 54 0
      mcp/src/main/java/com/chuanxia/mcp/bean/model/SystemUser.java
  20. 20 0
      mcp/src/main/java/com/chuanxia/mcp/bean/vo/CdnDomainCityVo.java
  21. 56 0
      mcp/src/main/java/com/chuanxia/mcp/bean/vo/Result.java
  22. 34 0
      mcp/src/main/java/com/chuanxia/mcp/config/SwaggerConfig.java
  23. 54 0
      mcp/src/main/java/com/chuanxia/mcp/controller/CdnDomainCityController.java
  24. 56 0
      mcp/src/main/java/com/chuanxia/mcp/controller/CdnDomainController.java
  25. 59 0
      mcp/src/main/java/com/chuanxia/mcp/controller/CdnOperatorController.java
  26. 40 0
      mcp/src/main/java/com/chuanxia/mcp/controller/UserController.java
  27. 30 0
      mcp/src/main/java/com/chuanxia/mcp/exception/GlobalExceptionHandler.java
  28. 26 0
      mcp/src/main/java/com/chuanxia/mcp/exception/ResultException.java
  29. 9 0
      mcp/src/main/java/com/chuanxia/mcp/mapper/CdnCityMapper.java
  30. 14 0
      mcp/src/main/java/com/chuanxia/mcp/mapper/CdnDomainCityMapper.java
  31. 9 0
      mcp/src/main/java/com/chuanxia/mcp/mapper/CdnDomainMapper.java
  32. 9 0
      mcp/src/main/java/com/chuanxia/mcp/mapper/CdnDomainOperatorMapper.java
  33. 9 0
      mcp/src/main/java/com/chuanxia/mcp/mapper/CdnOperatorMapper.java
  34. 9 0
      mcp/src/main/java/com/chuanxia/mcp/mapper/UserMapper.java
  35. 18 0
      mcp/src/main/java/com/chuanxia/mcp/service/CdnDoaminService.java
  36. 10 0
      mcp/src/main/java/com/chuanxia/mcp/service/CdnDomainCityService.java
  37. 7 0
      mcp/src/main/java/com/chuanxia/mcp/service/CdnDomainOperatorService.java
  38. 17 0
      mcp/src/main/java/com/chuanxia/mcp/service/CdnOperatorService.java
  39. 9 0
      mcp/src/main/java/com/chuanxia/mcp/service/CdnService.java
  40. 13 0
      mcp/src/main/java/com/chuanxia/mcp/service/UserService.java
  41. 122 0
      mcp/src/main/java/com/chuanxia/mcp/service/impl/CdnDoaminServiceImpl.java
  42. 30 0
      mcp/src/main/java/com/chuanxia/mcp/service/impl/CdnDomainCityServiceImpl.java
  43. 15 0
      mcp/src/main/java/com/chuanxia/mcp/service/impl/CdnDomainOperatorServiceImpl.java
  44. 87 0
      mcp/src/main/java/com/chuanxia/mcp/service/impl/CdnOperatorServiceImpl.java
  45. 32 0
      mcp/src/main/java/com/chuanxia/mcp/service/impl/CdnServiceImpl.java
  46. 100 0
      mcp/src/main/java/com/chuanxia/mcp/service/impl/UserServiceImpl.java
  47. 47 0
      mcp/src/main/java/com/chuanxia/mcp/util/Md5Util.java
  48. 17 0
      mcp/src/main/java/com/chuanxia/mcp/util/UidUtil.java
  49. 9 0
      mcp/src/main/resources/application-local.yml
  50. 7 0
      mcp/src/main/resources/application.yml
  51. 26 0
      mcp/src/main/resources/com/chuanxia/mcp/mapper/CdnDomainCityMapper.xml

+ 33 - 0
mcp/.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 108 - 0
mcp/pom.xml

@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.2.6.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.chuanxia</groupId>
+    <artifactId>mcp</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>mcp</name>
+    <description>mcp后台管理系统</description>
+    <properties>
+        <java.version>8</java.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <!--mvc-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <!--mysql-->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <!--log-->
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+        </dependency>
+        <!--fastjson-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>2.0.22</version>
+        </dependency>
+        <!-- hutool -->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.5.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+            <version>1.1.10</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+        </dependency>
+        <!--mybatis-plus-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.3.2</version>
+        </dependency>
+        <!--swagger2依赖-->
+        <dependency>
+            <groupId>com.spring4all</groupId>
+            <artifactId>swagger-spring-boot-starter</artifactId>
+            <version>1.9.1.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>swagger-bootstrap-ui</artifactId>
+            <version>1.7.8</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 15 - 0
mcp/src/main/java/com/chuanxia/mcp/McpApplication.java

@@ -0,0 +1,15 @@
+package com.chuanxia.mcp;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@MapperScan("com.chuanxia.mcp.mapper")
+public class McpApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(McpApplication.class, args);
+    }
+
+}

+ 73 - 0
mcp/src/main/java/com/chuanxia/mcp/aop/CheckTokenAspect.java

@@ -0,0 +1,73 @@
+package com.chuanxia.mcp.aop;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.chuanxia.mcp.bean.model.SystemUser;
+import com.chuanxia.mcp.exception.ResultException;
+import com.chuanxia.mcp.service.UserService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Method;
+import java.util.Date;
+
+/**
+ * @author Administrator
+ * @Aspect 声明是个切面的类(必要)
+ * @Component 将该类交给spring容器管理(必要)
+ * @Slf4j 日志输出
+ */
+@Aspect
+@Component
+@Slf4j
+@RequiredArgsConstructor
+public class CheckTokenAspect {
+
+    private final UserService userService;
+
+    /**
+     * @Pointct 表示该方法可用于 com.tdkj.DataApi.annotation.CheckToken 这个注解
+     * 还可以使用*号表示通配符
+     */
+    @Pointcut("@annotation(com.chuanxia.mcp.aop.Login)")
+    public void pointcut() {
+
+    }
+
+    @Around("pointcut()")
+    public Object checkTokenAroundAspect(ProceedingJoinPoint joinPoint) throws Throwable {
+        //获取请求头
+        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+        String token = request.getHeader("token");
+        if (StringUtils.isEmpty(token)) {
+            //返回的错误信息将会直接返回给用户。 可看本文最后一张图
+            throw new ResultException(600, "token不能为空");
+        }
+        LambdaQueryWrapper<SystemUser> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(SystemUser::getToken, token);
+        SystemUser one = userService.getOne(wrapper);
+        if (one == null) {
+            throw new ResultException(601, "token不存在");
+        }
+        Date tokenValidityTime = one.getTokenValidityTime();
+        if (System.currentTimeMillis() > tokenValidityTime.getTime()) {
+            throw new ResultException(602, "token已过期,需要重新登录");
+        }
+        // 打印出参 就只是输出
+        return joinPoint.proceed();
+    }
+
+}

+ 13 - 0
mcp/src/main/java/com/chuanxia/mcp/aop/Login.java

@@ -0,0 +1,13 @@
+package com.chuanxia.mcp.aop;
+
+import java.lang.annotation.*;
+
+/**
+ * @author Administrator
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Login {
+
+}

+ 16 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/dto/DomainBindDto.java

@@ -0,0 +1,16 @@
+package com.chuanxia.mcp.bean.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@ApiModel("域名绑定城市实体")
+@Data
+public class DomainBindDto {
+    @ApiModelProperty("域名id")
+    private Integer domainId;
+    @ApiModelProperty("城市id列表")
+    private List<Integer> cityIds;
+}

+ 16 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/dto/DomainCityQueryDto.java

@@ -0,0 +1,16 @@
+package com.chuanxia.mcp.bean.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel("分页查询区域域名绑定实体")
+public class DomainCityQueryDto extends PageQueryBaseDto {
+    @ApiModelProperty("城市名")
+    private String cname;
+    @ApiModelProperty("域名")
+    private String domain;
+}

+ 16 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/dto/DomainOperatorBindDto.java

@@ -0,0 +1,16 @@
+package com.chuanxia.mcp.bean.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@ApiModel("域名绑定运营商实体")
+@Data
+public class DomainOperatorBindDto {
+    @ApiModelProperty("域名id")
+    private Integer domainId;
+    @ApiModelProperty("运营商ids")
+    private List<Integer> operatorIds;
+}

+ 17 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/dto/DomainQueryDto.java

@@ -0,0 +1,17 @@
+package com.chuanxia.mcp.bean.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel("域名查询实体")
+public class DomainQueryDto extends PageQueryBaseDto {
+    @ApiModelProperty("域名(模糊查询)")
+    private String domain;
+    @ApiModelProperty("厂商(模糊查询)")
+    private String manufacturer;
+
+}

+ 9 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/dto/OperatorQueryDto.java

@@ -0,0 +1,9 @@
+package com.chuanxia.mcp.bean.dto;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class OperatorQueryDto extends PageQueryBaseDto {
+}

+ 9 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/dto/PageQueryBaseDto.java

@@ -0,0 +1,9 @@
+package com.chuanxia.mcp.bean.dto;
+
+import lombok.Data;
+
+@Data
+public class PageQueryBaseDto {
+    private Integer pageNum;
+    private Integer pageSize;
+}

+ 21 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/enums/DefaultDomainEnums.java

@@ -0,0 +1,21 @@
+package com.chuanxia.mcp.bean.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 自定义异常枚举类
+ *
+ * @author liyuntian
+ */
+@Getter
+@AllArgsConstructor
+public enum DefaultDomainEnums {
+    /**
+     * 业务异常枚举类
+     */
+    DEFAULTDOMAIN(1, "默认域名"),
+    NOT_DEFAULTDOMAIN(0, "非默认域名");
+    private Integer status;
+    private String message;
+}

+ 22 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/enums/ResultStatusEnum.java

@@ -0,0 +1,22 @@
+package com.chuanxia.mcp.bean.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 自定义异常枚举类
+ *
+ * @author liyuntian
+ */
+@Getter
+@AllArgsConstructor
+public enum ResultStatusEnum {
+    /**
+     * 业务异常枚举类
+     */
+    PASSWORD_ERROR(501, "密码错误"),
+    USERNAME_ERROR(503, "用户名不存在"),
+    USERNAME_ALREXISTS(502, "当前用户名已存在");
+    private Integer code;
+    private String message;
+}

+ 23 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/model/CdnCity.java

@@ -0,0 +1,23 @@
+package com.chuanxia.mcp.bean.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * @author Administrator
+ */
+@Data
+@TableName("cdn_city")
+public class CdnCity {
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+    @TableField("cname")
+    private String cname;
+    @TableField("parent_id")
+    private Integer parentId;
+    @TableField("ctype")
+    private Integer ctype;
+}

+ 51 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/model/CdnDomain.java

@@ -0,0 +1,51 @@
+package com.chuanxia.mcp.bean.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author liyuntian
+ */
+@Data
+@TableName("cdn_domain")
+@ApiModel("cdn域名")
+public class CdnDomain {
+    @ApiModelProperty("主键")
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+    @ApiModelProperty("域名")
+    @TableField("domain")
+    private String domain;
+    @ApiModelProperty("厂商")
+    @TableField("manufacturer")
+    private String manufacturer;
+    @ApiModelProperty("是否是默认域名")
+    @TableField("default_domain")
+    private Integer defaultDomain;
+    @ApiModelProperty("创建时间")
+    @TableField("create_time")
+    private Date createTime;
+    @ApiModelProperty("修改时间")
+    @TableField("update_time")
+    private Date updateTime;
+    @ApiModelProperty("创建人id")
+    @TableField("create_by")
+    private Integer createBy;
+    @TableField(exist = false)
+    @ApiModelProperty("创建人姓名")
+    private String createName;
+    @ApiModelProperty("修改人id")
+    @TableField("update_by")
+    private Integer updateBy;
+    @ApiModelProperty("修改人姓名")
+    @TableField(exist = false)
+    private String updateName;
+
+}

+ 18 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/model/CdnDomainCity.java

@@ -0,0 +1,18 @@
+package com.chuanxia.mcp.bean.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+@Data
+@TableName("cdn_domain_city")
+public class CdnDomainCity {
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+    @TableField("domain_id")
+    private Integer domainId;
+    @TableField("city_id")
+    private Integer cityId;
+}

+ 27 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/model/CdnDomainOperator.java

@@ -0,0 +1,27 @@
+package com.chuanxia.mcp.bean.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author Administrator
+ */
+@TableName("cdn_domain_operator")
+@Data
+public class CdnDomainOperator {
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+    @TableField("domain_id")
+    private Integer domainId;
+    @TableField("operator_id")
+    private Integer operatorId;
+    @TableField("create_by")
+    private Integer createBy;
+    @TableField("create_time")
+    private Date createTime;
+}

+ 26 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/model/CdnOperator.java

@@ -0,0 +1,26 @@
+package com.chuanxia.mcp.bean.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@TableName("cdn_operator")
+public class CdnOperator {
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+    @TableField("operator_name")
+    private String operatorName;
+    @TableField("create_by")
+    private Integer createBy;
+    @TableField("create_time")
+    private Date createTime;
+    @TableField("update_by")
+    private Integer updateBy;
+    @TableField("update_time")
+    private Date updateTime;
+}

+ 54 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/model/SystemUser.java

@@ -0,0 +1,54 @@
+package com.chuanxia.mcp.bean.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@ApiModel(value = "后台用户")
+@TableName("system_user")
+public class SystemUser implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "主键")
+    private Integer id;
+
+    /**
+     *
+     */
+    @ApiModelProperty(value = "用户名")
+    @TableField("username")
+    private String username;
+
+    /**
+     *
+     */
+    @ApiModelProperty(value = "密码")
+    @TableField("password")
+    private String password;
+
+    /**
+     *
+     */
+    @ApiModelProperty(value = "token")
+    @TableField("token")
+    private String token;
+
+    @ApiModelProperty(value = "token有效期")
+    @TableField("token_validity_time")
+    private Date tokenValidityTime;
+
+    @ApiModelProperty("真实姓名")
+    @TableField("real_name")
+    private String realName;
+
+
+}

+ 20 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/vo/CdnDomainCityVo.java

@@ -0,0 +1,20 @@
+package com.chuanxia.mcp.bean.vo;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@Api("区域列表视图")
+public class CdnDomainCityVo {
+    @ApiModelProperty("主键")
+    private Integer id;
+    @ApiModelProperty("城市id")
+    private Integer cityId;
+    @ApiModelProperty("城市名")
+    private String cityName;
+    @ApiModelProperty("域名id")
+    private Integer domainId;
+    @ApiModelProperty("域名")
+    private String domain;
+}

+ 56 - 0
mcp/src/main/java/com/chuanxia/mcp/bean/vo/Result.java

@@ -0,0 +1,56 @@
+package com.chuanxia.mcp.bean.vo;
+
+import lombok.Data;
+
+@Data
+public class Result<T> {
+    private Integer code;
+    private String msg;
+    private T data;
+ 
+
+    public String getMsg() {
+        return msg;
+    }
+ 
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+ 
+    public T getData() {
+        return data;
+    }
+ 
+    public void setData(T data) {
+        this.data = data;
+    }
+ 
+    public Result() {
+    }
+ 
+    public Result(T data) {
+        this.data = data;
+    }
+ 
+    public static Result success() {
+        Result result = new Result<>();
+        result.setCode(200);
+        result.setMsg("操作成功");
+        return result;
+    }
+ 
+    public static <T> Result<T> success(T data) {
+        Result<T> result = new Result<>(data);
+        result.setCode(200);
+        result.setMsg("操作成功");
+        return result;
+    }
+ 
+    public static Result error(Integer code, String msg) {
+        Result result = new Result();
+        result.setCode(code);
+        result.setMsg(msg);
+        return result;
+    }
+ 
+}

+ 34 - 0
mcp/src/main/java/com/chuanxia/mcp/config/SwaggerConfig.java

@@ -0,0 +1,34 @@
+package com.chuanxia.mcp.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.service.VendorExtension;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+
+@Configuration
+@EnableSwagger2 //开启seagger注解驱动
+public class SwaggerConfig {
+
+    @Bean
+    public Docket docket() {
+        return new Docket(DocumentationType.SWAGGER_2).groupName("mcp")
+                .apiInfo(getInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.chuanxia.mcp.controller"))
+                .build();
+    }
+
+    private ApiInfo getInfo() {
+        Contact contact = new Contact("李云天", "http://www.baidu.com", "2631125488@qq.com");
+        return new ApiInfo("mcp后台管理系统", "包含cdn,ua后台", "1.1.0", "http://www.jd.com",
+                contact, "川下科技", "http://www.aaa.com", new ArrayList<VendorExtension>());
+
+    }
+}

+ 54 - 0
mcp/src/main/java/com/chuanxia/mcp/controller/CdnDomainCityController.java

@@ -0,0 +1,54 @@
+package com.chuanxia.mcp.controller;
+
+import com.chuanxia.mcp.aop.Login;
+import com.chuanxia.mcp.bean.dto.DomainBindDto;
+import com.chuanxia.mcp.bean.dto.DomainCityQueryDto;
+import com.chuanxia.mcp.bean.vo.Result;
+import com.chuanxia.mcp.service.CdnDoaminService;
+import com.chuanxia.mcp.service.CdnService;
+import com.chuanxia.mcp.service.CdnDomainCityService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@Api("区域绑定")
+@RequestMapping("cdnDomainCity")
+@RequiredArgsConstructor
+public class CdnDomainCityController {
+    private final CdnService cdnService;
+    private final CdnDoaminService doaminService;
+    private final CdnDomainCityService domainCityService;
+
+    @GetMapping("cascade")
+    @ApiOperation("级联查询城市信息")
+    @Login
+    public Result cascade(@RequestParam(value = "parentId", required = false, defaultValue = "1") Integer parentId) {
+        return cdnService.cascade(parentId);
+    }
+
+    @PostMapping("listPage")
+    @ApiOperation("分页获取区域域名列表")
+    @Login
+    public Result listPage(@RequestBody DomainCityQueryDto queryDto) {
+        return domainCityService.listPage(queryDto);
+    }
+
+    @GetMapping("deleteById")
+    @ApiOperation("删除绑定")
+    @Login
+    public Result deleteById(@RequestParam("id") Integer id) {
+        domainCityService.removeById(id);
+        return Result.success();
+    }
+
+    @PostMapping("bindCdn")
+    @ApiOperation("域名绑定城市")
+    @Login
+    public Result bindCdn(@RequestBody DomainBindDto bindDto) {
+        return doaminService.bindCdn(bindDto);
+    }
+
+
+}

+ 56 - 0
mcp/src/main/java/com/chuanxia/mcp/controller/CdnDomainController.java

@@ -0,0 +1,56 @@
+package com.chuanxia.mcp.controller;
+
+/**
+ * @author liyuntian
+ */
+
+import com.chuanxia.mcp.aop.Login;
+import com.chuanxia.mcp.bean.dto.DomainQueryDto;
+import com.chuanxia.mcp.bean.model.CdnDomain;
+import com.chuanxia.mcp.bean.vo.Result;
+import com.chuanxia.mcp.service.CdnDoaminService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+
+/**
+ * @author liyuntian
+ */
+@RestController
+@Api("cdn域名管理")
+@RequestMapping("cdnDomain")
+@RequiredArgsConstructor
+public class CdnDomainController {
+    private final CdnDoaminService doaminService;
+
+    @PostMapping("listPage")
+    @ApiOperation("cdn域名列表(分页)")
+    @Login
+    public Result listPage(@RequestBody DomainQueryDto queryDto) {
+        return doaminService.listPage(queryDto);
+    }
+
+    @PostMapping("getList")
+    @ApiOperation("cdn域名列表(不分页,用于区域绑定)")
+    @Login
+    public Result getList() {
+        return Result.success(doaminService.list());
+    }
+
+    @PostMapping("saveDomain")
+    @ApiOperation("新增域名")
+    @Login
+    public Result saveDomain(@RequestBody CdnDomain domain) {
+        return doaminService.saveDomain(domain);
+    }
+
+    @PostMapping("updateDomain")
+    @ApiOperation("修改域名")
+    @Login
+    public Result updateDomain(@RequestBody CdnDomain domain) {
+        return doaminService.updateDomain(domain);
+    }
+
+}

+ 59 - 0
mcp/src/main/java/com/chuanxia/mcp/controller/CdnOperatorController.java

@@ -0,0 +1,59 @@
+package com.chuanxia.mcp.controller;
+
+import com.chuanxia.mcp.aop.Login;
+import com.chuanxia.mcp.bean.dto.DomainOperatorBindDto;
+import com.chuanxia.mcp.bean.dto.OperatorQueryDto;
+import com.chuanxia.mcp.bean.model.CdnOperator;
+import com.chuanxia.mcp.bean.vo.Result;
+import com.chuanxia.mcp.service.CdnOperatorService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author liyuntian
+ */
+@RestController
+@Api("cdn运营商管理")
+@RequestMapping("cdnOperator")
+@RequiredArgsConstructor
+public class CdnOperatorController {
+    private final CdnOperatorService operatorService;
+
+    @ApiOperation("新增运营商")
+    @Login
+    @PostMapping("saveOperator")
+    public Result saveOperator(@RequestBody CdnOperator operator) {
+        return operatorService.saveOperator(operator);
+    }
+
+    @ApiOperation("修改运营商")
+    @Login
+    @PostMapping("updateOperator")
+    public Result updateOperator(@RequestBody CdnOperator operator) {
+        return operatorService.updateOperator(operator);
+    }
+
+    @GetMapping("getList")
+    @ApiOperation("获取所有运营商列表(不分页)")
+    @Login
+    public Result getList() {
+        return Result.success(operatorService.list());
+    }
+
+    @PostMapping("bindCdn")
+    @ApiOperation("域名绑定运营商")
+    @Login
+    public Result bindCdn(@RequestBody DomainOperatorBindDto bindDto) {
+        return operatorService.bindCdn(bindDto);
+    }
+
+    @PostMapping("listPage")
+    @ApiOperation("运营商分页列表")
+    @Login
+    public Result listPage(@RequestBody OperatorQueryDto queryDto) {
+        return operatorService.listPage(queryDto);
+    }
+
+}

+ 40 - 0
mcp/src/main/java/com/chuanxia/mcp/controller/UserController.java

@@ -0,0 +1,40 @@
+package com.chuanxia.mcp.controller;
+
+import com.chuanxia.mcp.aop.Login;
+import com.chuanxia.mcp.bean.model.SystemUser;
+import com.chuanxia.mcp.bean.vo.Result;
+import com.chuanxia.mcp.service.UserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author liyuntian
+ */
+@RestController
+@Api("用户相关")
+@RequestMapping("user")
+@RequiredArgsConstructor
+public class UserController {
+    private final UserService userService;
+
+    @PostMapping("login")
+    @ApiOperation("登录")
+    public Result login(@RequestBody SystemUser user) {
+        return userService.login(user);
+    }
+
+    @PostMapping("register")
+    @ApiOperation("用户注册")
+    public Result register(@RequestBody SystemUser user) {
+        return userService.register(user);
+    }
+
+    @GetMapping("getUserDetail")
+    @ApiOperation("获取当前登录用户信息")
+    @Login
+    public Result getUserDetail() {
+        return Result.success(userService.getLoginUser());
+    }
+}

+ 30 - 0
mcp/src/main/java/com/chuanxia/mcp/exception/GlobalExceptionHandler.java

@@ -0,0 +1,30 @@
+package com.chuanxia.mcp.exception;
+
+import com.chuanxia.mcp.bean.vo.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * 全局异常处理
+ * @author liyuntian
+ */
+@ControllerAdvice
+@Slf4j
+public class GlobalExceptionHandler {
+    @ResponseBody
+    @ExceptionHandler(ResultException.class)
+    public Result handleCustomException(ResultException e) {
+        log.error("进入了业务异常全局异常捕获,异常原因:{}", e.getMessage());
+        return Result.error(e.getCode(), e.getMessage());
+    }
+
+    @ResponseBody
+    @ExceptionHandler(Exception.class)
+    public Result exceptionCatch(Exception e) {
+        log.error("系统发生异常,异常原因:{}", e.getMessage());
+        return Result.error(500, "系统发生异常,原因:"+e.getMessage());
+    }
+}
+

+ 26 - 0
mcp/src/main/java/com/chuanxia/mcp/exception/ResultException.java

@@ -0,0 +1,26 @@
+package com.chuanxia.mcp.exception;
+
+import com.chuanxia.mcp.bean.enums.ResultStatusEnum;
+import lombok.Data;
+
+/**
+ * 自定制异常类
+ *
+
+ */
+@Data
+public class ResultException extends RuntimeException {
+    private int code;
+    private String message;
+
+    public ResultException(int code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public ResultException(ResultStatusEnum resultStatusEnum) {
+        this.code = resultStatusEnum.getCode();
+        this.message = resultStatusEnum.getMessage();
+    }
+}
+

+ 9 - 0
mcp/src/main/java/com/chuanxia/mcp/mapper/CdnCityMapper.java

@@ -0,0 +1,9 @@
+package com.chuanxia.mcp.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chuanxia.mcp.bean.model.CdnCity;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface CdnCityMapper extends BaseMapper<CdnCity> {
+}

+ 14 - 0
mcp/src/main/java/com/chuanxia/mcp/mapper/CdnDomainCityMapper.java

@@ -0,0 +1,14 @@
+package com.chuanxia.mcp.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.chuanxia.mcp.bean.dto.DomainCityQueryDto;
+import com.chuanxia.mcp.bean.model.CdnDomainCity;
+import com.chuanxia.mcp.bean.vo.CdnDomainCityVo;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface CdnDomainCityMapper extends BaseMapper<CdnDomainCity> {
+    IPage<CdnDomainCityVo> listPage(IPage<CdnDomainCityVo> page, @Param("queryDto") DomainCityQueryDto queryDto);
+}

+ 9 - 0
mcp/src/main/java/com/chuanxia/mcp/mapper/CdnDomainMapper.java

@@ -0,0 +1,9 @@
+package com.chuanxia.mcp.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chuanxia.mcp.bean.model.CdnDomain;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface CdnDomainMapper extends BaseMapper<CdnDomain> {
+}

+ 9 - 0
mcp/src/main/java/com/chuanxia/mcp/mapper/CdnDomainOperatorMapper.java

@@ -0,0 +1,9 @@
+package com.chuanxia.mcp.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chuanxia.mcp.bean.model.CdnDomainOperator;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface CdnDomainOperatorMapper extends BaseMapper<CdnDomainOperator> {
+}

+ 9 - 0
mcp/src/main/java/com/chuanxia/mcp/mapper/CdnOperatorMapper.java

@@ -0,0 +1,9 @@
+package com.chuanxia.mcp.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chuanxia.mcp.bean.model.CdnOperator;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface CdnOperatorMapper extends BaseMapper<CdnOperator> {
+}

+ 9 - 0
mcp/src/main/java/com/chuanxia/mcp/mapper/UserMapper.java

@@ -0,0 +1,9 @@
+package com.chuanxia.mcp.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chuanxia.mcp.bean.model.SystemUser;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface UserMapper extends BaseMapper<SystemUser> {
+}

+ 18 - 0
mcp/src/main/java/com/chuanxia/mcp/service/CdnDoaminService.java

@@ -0,0 +1,18 @@
+package com.chuanxia.mcp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.chuanxia.mcp.bean.dto.DomainBindDto;
+import com.chuanxia.mcp.bean.dto.DomainQueryDto;
+import com.chuanxia.mcp.bean.model.CdnDomain;
+import com.chuanxia.mcp.bean.vo.Result;
+
+public interface CdnDoaminService extends IService<CdnDomain> {
+    Result listPage(DomainQueryDto queryDto);
+
+    Result saveDomain(CdnDomain domain);
+
+    Result bindCdn(DomainBindDto bindDto);
+
+    Result updateDomain(CdnDomain domain);
+
+}

+ 10 - 0
mcp/src/main/java/com/chuanxia/mcp/service/CdnDomainCityService.java

@@ -0,0 +1,10 @@
+package com.chuanxia.mcp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.chuanxia.mcp.bean.dto.DomainCityQueryDto;
+import com.chuanxia.mcp.bean.model.CdnDomainCity;
+import com.chuanxia.mcp.bean.vo.Result;
+
+public interface CdnDomainCityService extends IService<CdnDomainCity> {
+    Result listPage(DomainCityQueryDto queryDto);
+}

+ 7 - 0
mcp/src/main/java/com/chuanxia/mcp/service/CdnDomainOperatorService.java

@@ -0,0 +1,7 @@
+package com.chuanxia.mcp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.chuanxia.mcp.bean.model.CdnDomainOperator;
+
+public interface CdnDomainOperatorService extends IService<CdnDomainOperator> {
+}

+ 17 - 0
mcp/src/main/java/com/chuanxia/mcp/service/CdnOperatorService.java

@@ -0,0 +1,17 @@
+package com.chuanxia.mcp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.chuanxia.mcp.bean.dto.DomainOperatorBindDto;
+import com.chuanxia.mcp.bean.dto.OperatorQueryDto;
+import com.chuanxia.mcp.bean.model.CdnOperator;
+import com.chuanxia.mcp.bean.vo.Result;
+
+public interface CdnOperatorService extends IService<CdnOperator> {
+    Result saveOperator(CdnOperator operator);
+
+    Result updateOperator(CdnOperator operator);
+
+    Result bindCdn(DomainOperatorBindDto bindDto);
+
+    Result listPage(OperatorQueryDto queryDto);
+}

+ 9 - 0
mcp/src/main/java/com/chuanxia/mcp/service/CdnService.java

@@ -0,0 +1,9 @@
+package com.chuanxia.mcp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.chuanxia.mcp.bean.model.CdnCity;
+import com.chuanxia.mcp.bean.vo.Result;
+
+public interface CdnService extends IService<CdnCity> {
+    Result cascade(Integer parentId);
+}

+ 13 - 0
mcp/src/main/java/com/chuanxia/mcp/service/UserService.java

@@ -0,0 +1,13 @@
+package com.chuanxia.mcp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.chuanxia.mcp.bean.model.SystemUser;
+import com.chuanxia.mcp.bean.vo.Result;
+
+public interface UserService extends IService<SystemUser> {
+    Result login(SystemUser user);
+
+    Result register(SystemUser user);
+
+    SystemUser getLoginUser();
+}

+ 122 - 0
mcp/src/main/java/com/chuanxia/mcp/service/impl/CdnDoaminServiceImpl.java

@@ -0,0 +1,122 @@
+package com.chuanxia.mcp.service.impl;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chuanxia.mcp.bean.dto.DomainBindDto;
+import com.chuanxia.mcp.bean.dto.DomainQueryDto;
+import com.chuanxia.mcp.bean.enums.DefaultDomainEnums;
+import com.chuanxia.mcp.bean.model.CdnDomain;
+import com.chuanxia.mcp.bean.model.CdnDomainCity;
+import com.chuanxia.mcp.bean.model.SystemUser;
+import com.chuanxia.mcp.bean.vo.Result;
+import com.chuanxia.mcp.exception.ResultException;
+import com.chuanxia.mcp.mapper.CdnDomainMapper;
+import com.chuanxia.mcp.service.CdnDoaminService;
+import com.chuanxia.mcp.service.CdnDomainCityService;
+import com.chuanxia.mcp.service.UserService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Administrator
+ */
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class CdnDoaminServiceImpl extends ServiceImpl<CdnDomainMapper, CdnDomain> implements CdnDoaminService {
+    private final UserService userService;
+    private final CdnDomainMapper domainMapper;
+    private final CdnDomainCityService domainCityService;
+
+    @Override
+    public Result listPage(DomainQueryDto queryDto) {
+        IPage<CdnDomain> page = new Page<>(queryDto.getPageNum(), queryDto.getPageSize());
+        LambdaQueryWrapper<CdnDomain> query = Wrappers.lambdaQuery();
+        if (StringUtils.isNotBlank(queryDto.getDomain())) {
+            query.like(CdnDomain::getDomain, queryDto.getDomain());
+        }
+        if (StringUtils.isNotBlank(queryDto.getManufacturer())) {
+            query.like(CdnDomain::getManufacturer, queryDto.getManufacturer());
+        }
+        page = domainMapper.selectPage(page, query);
+        return Result.success(page);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result saveDomain(CdnDomain domain) {
+
+        SystemUser loginUser = userService.getLoginUser();
+        if (StringUtils.isBlank(domain.getDomain())) {
+            throw new ResultException(500, "域名不能为空");
+        }
+        if (StringUtils.isBlank(domain.getManufacturer())) {
+            throw new ResultException(500, "厂商不能为空");
+        }
+        Integer defaultDomain = domain.getDefaultDomain();
+        if (DefaultDomainEnums.DEFAULTDOMAIN.getStatus().equals(defaultDomain)) {
+            //判断是否已存在默认域名,存在则不允许添加了
+            LambdaQueryWrapper<CdnDomain> query = Wrappers.lambdaQuery();
+            query.eq(CdnDomain::getDefaultDomain, defaultDomain);
+            int count = this.count(query);
+            if (count >= 1) {
+                throw new ResultException(500, "已存在默认域名,不能再次添加默认域名");
+            }
+        }
+        domain.setCreateBy(loginUser.getId());
+        this.save(domain);
+        return Result.success();
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result bindCdn(DomainBindDto bindDto) {
+        Integer domainId = bindDto.getDomainId();
+        CdnDomain domain = this.getById(domainId);
+        if (domain == null) {
+            throw new ResultException(500, "当前域名id不存在");
+        }
+        if (CollectionUtil.isEmpty(bindDto.getCityIds())) {
+            throw new ResultException(500, "城市列表不能为空");
+        }
+        List<Integer> cityIds = bindDto.getCityIds();
+        List<CdnDomainCity> domainCityList = new ArrayList<>(cityIds.size());
+        for (Integer cityId : cityIds) {
+            CdnDomainCity domainCity = new CdnDomainCity();
+            domainCity.setCityId(cityId);
+            domainCity.setDomainId(domainId);
+            domainCityList.add(domainCity);
+        }
+        LambdaQueryWrapper<CdnDomainCity> del = Wrappers.lambdaQuery();
+        del.eq(CdnDomainCity::getDomainId, domainId);
+        domainCityService.remove(del);
+        domainCityService.saveBatch(domainCityList);
+        return Result.success();
+    }
+
+    @Override
+    public Result updateDomain(CdnDomain domain) {
+        Integer defaultDomain = domain.getDefaultDomain();
+        if (DefaultDomainEnums.DEFAULTDOMAIN.getStatus().equals(defaultDomain)) {
+            //判断是否已存在默认域名,存在则不允许添加了
+            LambdaQueryWrapper<CdnDomain> query = Wrappers.lambdaQuery();
+            query.eq(CdnDomain::getDefaultDomain, defaultDomain).ne(CdnDomain::getId, domain.getId());
+            int count = this.count(query);
+            if (count >= 1) {
+                throw new ResultException(500, "已存在默认域名,不能再次添加默认域名");
+            }
+        }
+        this.updateById(domain);
+        return Result.success();
+    }
+}

+ 30 - 0
mcp/src/main/java/com/chuanxia/mcp/service/impl/CdnDomainCityServiceImpl.java

@@ -0,0 +1,30 @@
+package com.chuanxia.mcp.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chuanxia.mcp.bean.dto.DomainCityQueryDto;
+import com.chuanxia.mcp.bean.model.CdnDomainCity;
+import com.chuanxia.mcp.bean.vo.CdnDomainCityVo;
+import com.chuanxia.mcp.bean.vo.Result;
+import com.chuanxia.mcp.mapper.CdnDomainCityMapper;
+import com.chuanxia.mcp.service.CdnDomainCityService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class CdnDomainCityServiceImpl extends ServiceImpl<CdnDomainCityMapper, CdnDomainCity> implements CdnDomainCityService {
+    private final CdnDomainCityMapper domainCityMapper;
+
+    @Override
+    public Result listPage(DomainCityQueryDto queryDto) {
+        IPage<CdnDomainCityVo> page = new Page<>(queryDto.getPageNum(), queryDto.getPageSize());
+        page = domainCityMapper.listPage(page, queryDto);
+        return Result.success(page);
+    }
+}
+
+

+ 15 - 0
mcp/src/main/java/com/chuanxia/mcp/service/impl/CdnDomainOperatorServiceImpl.java

@@ -0,0 +1,15 @@
+package com.chuanxia.mcp.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chuanxia.mcp.bean.model.CdnDomainOperator;
+import com.chuanxia.mcp.mapper.CdnDomainOperatorMapper;
+import com.chuanxia.mcp.service.CdnDomainOperatorService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class CdnDomainOperatorServiceImpl extends ServiceImpl<CdnDomainOperatorMapper, CdnDomainOperator> implements CdnDomainOperatorService {
+}

+ 87 - 0
mcp/src/main/java/com/chuanxia/mcp/service/impl/CdnOperatorServiceImpl.java

@@ -0,0 +1,87 @@
+package com.chuanxia.mcp.service.impl;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chuanxia.mcp.bean.dto.DomainBindDto;
+import com.chuanxia.mcp.bean.dto.DomainOperatorBindDto;
+import com.chuanxia.mcp.bean.dto.OperatorQueryDto;
+import com.chuanxia.mcp.bean.model.CdnDomain;
+import com.chuanxia.mcp.bean.model.CdnDomainOperator;
+import com.chuanxia.mcp.bean.model.CdnOperator;
+import com.chuanxia.mcp.bean.model.SystemUser;
+import com.chuanxia.mcp.bean.vo.Result;
+import com.chuanxia.mcp.exception.ResultException;
+import com.chuanxia.mcp.mapper.CdnDomainMapper;
+import com.chuanxia.mcp.mapper.CdnOperatorMapper;
+import com.chuanxia.mcp.service.CdnDomainOperatorService;
+import com.chuanxia.mcp.service.CdnOperatorService;
+import com.chuanxia.mcp.service.UserService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class CdnOperatorServiceImpl extends ServiceImpl<CdnOperatorMapper, CdnOperator> implements CdnOperatorService {
+    private final CdnOperatorMapper operatorMapper;
+    private final CdnDomainMapper domainMapper;
+    private final UserService userService;
+    private final CdnDomainOperatorService domainOperatorService;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result saveOperator(CdnOperator operator) {
+        SystemUser loginUser = userService.getLoginUser();
+        operator.setCreateBy(loginUser.getId());
+        operatorMapper.insert(operator);
+        return Result.success();
+    }
+
+    @Override
+    public Result updateOperator(CdnOperator operator) {
+        SystemUser loginUser = userService.getLoginUser();
+        operator.setUpdateBy(loginUser.getId());
+        operatorMapper.updateById(operator);
+        return Result.success();
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result bindCdn(DomainOperatorBindDto bindDto) {
+        Integer domainId = bindDto.getDomainId();
+        CdnDomain domain = domainMapper.selectById(domainId);
+        if (domain == null) {
+            throw new ResultException(500, "域名id不存在");
+        }
+        List<Integer> operatorIds = bindDto.getOperatorIds();
+        if (CollectionUtil.isEmpty(operatorIds)) {
+            throw new ResultException(500, "运营商id不能为空");
+        }
+        SystemUser loginUser = userService.getLoginUser();
+        List<CdnDomainOperator> arr = new ArrayList<>(operatorIds.size());
+        for (Integer operatorId : operatorIds) {
+            CdnDomainOperator domainOperator = new CdnDomainOperator();
+            domainOperator.setOperatorId(operatorId);
+            domainOperator.setDomainId(domainId);
+            domainOperator.setCreateBy(loginUser.getId());
+            arr.add(domainOperator);
+        }
+        LambdaQueryWrapper<CdnDomainOperator> del = Wrappers.lambdaQuery();
+        del.eq(CdnDomainOperator::getDomainId, domainId);
+        domainOperatorService.remove(del);
+        domainOperatorService.saveBatch(arr);
+        return Result.success();
+    }
+
+    @Override
+    public Result listPage(OperatorQueryDto queryDto) {
+        return null;
+    }
+}

+ 32 - 0
mcp/src/main/java/com/chuanxia/mcp/service/impl/CdnServiceImpl.java

@@ -0,0 +1,32 @@
+package com.chuanxia.mcp.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chuanxia.mcp.bean.model.CdnCity;
+import com.chuanxia.mcp.bean.vo.Result;
+import com.chuanxia.mcp.mapper.CdnCityMapper;
+import com.chuanxia.mcp.service.CdnService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author Administrator
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class CdnServiceImpl extends ServiceImpl<CdnCityMapper, CdnCity> implements CdnService {
+    private final CdnCityMapper cityMapper;
+
+    @Override
+    public Result cascade(Integer parentId) {
+        LambdaQueryWrapper<CdnCity> query = Wrappers.lambdaQuery();
+        query.eq(CdnCity::getParentId, parentId);
+        List<CdnCity> cdnCities = cityMapper.selectList(query);
+        return Result.success(cdnCities);
+    }
+}

+ 100 - 0
mcp/src/main/java/com/chuanxia/mcp/service/impl/UserServiceImpl.java

@@ -0,0 +1,100 @@
+package com.chuanxia.mcp.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chuanxia.mcp.bean.enums.ResultStatusEnum;
+import com.chuanxia.mcp.bean.model.SystemUser;
+import com.chuanxia.mcp.bean.vo.Result;
+import com.chuanxia.mcp.exception.ResultException;
+import com.chuanxia.mcp.mapper.UserMapper;
+import com.chuanxia.mcp.service.UserService;
+import com.chuanxia.mcp.util.Md5Util;
+import com.chuanxia.mcp.util.UidUtil;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @author Administrator
+ */
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class UserServiceImpl extends ServiceImpl<UserMapper, SystemUser> implements UserService {
+    private final UserMapper userMapper;
+    private final Md5Util md5Util;
+    private final UidUtil uidUtil;
+
+    @Override
+    public Result login(SystemUser user) {
+        LambdaQueryWrapper<SystemUser> query = Wrappers.lambdaQuery();
+        String md5 = md5Util.getMd5(user.getPassword());
+        query.eq(SystemUser::getUsername, user.getUsername());
+        SystemUser result = userMapper.selectOne(query);
+        if (result == null) {
+            throw new ResultException(ResultStatusEnum.USERNAME_ERROR);
+        }
+        query.eq(SystemUser::getPassword, md5);
+        result = userMapper.selectOne(query);
+        if (result == null) {
+            throw new ResultException(ResultStatusEnum.PASSWORD_ERROR);
+        }
+        String token = uidUtil.getUUID();
+        result.setToken(token);
+        Calendar instance = Calendar.getInstance();
+        instance.add(Calendar.DAY_OF_MONTH, 1);
+        Date tokenValidityTime = instance.getTime();
+        result.setTokenValidityTime(tokenValidityTime);
+        userMapper.updateById(result);
+        return Result.success(token);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result register(SystemUser user) {
+        LambdaQueryWrapper<SystemUser> query = Wrappers.lambdaQuery();
+        query.eq(SystemUser::getUsername, user.getUsername());
+        String password = user.getPassword();
+        if (StringUtils.isBlank(password)) {
+            throw new ResultException(500, "密码不能为空");
+        }
+        String realName = user.getRealName();
+        if (StringUtils.isBlank(realName)) {
+            throw new ResultException(500, "真实姓名不能为空");
+        }
+        if (userMapper.selectOne(query) != null) {
+            throw new ResultException(ResultStatusEnum.USERNAME_ALREXISTS);
+        }
+        String md5 = md5Util.getMd5(password);
+        user.setPassword(md5);
+        userMapper.insert(user);
+        return Result.success();
+    }
+
+    @Override
+    public SystemUser getLoginUser() {
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        if (attributes == null) {
+            throw new ResultException(500, "获取当前登录用户失败");
+        }
+        HttpServletRequest request = attributes.getRequest();
+        String token = request.getHeader("token");
+        LambdaQueryWrapper<SystemUser> query = Wrappers.lambdaQuery();
+        query.eq(SystemUser::getToken, token);
+        SystemUser systemUser = userMapper.selectOne(query);
+        if (systemUser == null) {
+            throw new ResultException(500, "获取当前用户信息为空");
+        }
+        return systemUser;
+    }
+}
+

+ 47 - 0
mcp/src/main/java/com/chuanxia/mcp/util/Md5Util.java

@@ -0,0 +1,47 @@
+package com.chuanxia.mcp.util;
+
+import java.security.MessageDigest;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author liyuntian
+ */
+@Slf4j
+@Component
+public class Md5Util {
+
+
+    /***
+     * MD5加码 生成32位md5码
+     */
+    public String getMd5(String inStr) {
+        MessageDigest md5 = null;
+        try {
+            md5 = MessageDigest.getInstance("MD5");
+        } catch (Exception e) {
+            log.info(e.toString());
+            e.printStackTrace();
+            return "";
+        }
+        char[] charArray = inStr.toCharArray();
+        byte[] byteArray = new byte[charArray.length];
+
+        for (int i = 0; i < charArray.length; i++) {
+            byteArray[i] = (byte) charArray[i];
+        }
+        byte[] md5Bytes = md5.digest(byteArray);
+        StringBuilder hexValue = new StringBuilder();
+        for (byte md5Byte : md5Bytes) {
+            int val = ((int) md5Byte) & 0xff;
+            if (val < 16) {
+                hexValue.append("0");
+            }
+            hexValue.append(Integer.toHexString(val));
+        }
+        return hexValue.toString();
+
+    }
+
+}

+ 17 - 0
mcp/src/main/java/com/chuanxia/mcp/util/UidUtil.java

@@ -0,0 +1,17 @@
+package com.chuanxia.mcp.util;
+
+import org.springframework.stereotype.Component;
+
+import java.util.UUID;
+/**
+ * @author Administrator
+ */
+@Component
+public class UidUtil {
+
+	public String getUUID(){
+		String id = UUID.randomUUID().toString();
+		return id.replaceAll("-", "");
+	}
+}
+

+ 9 - 0
mcp/src/main/resources/application-local.yml

@@ -0,0 +1,9 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://localhost:3306/mcp?serverTimezone=UTC&characterEncoding=utf8
+    username: root
+    password: root
+mybatis-plus:
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

+ 7 - 0
mcp/src/main/resources/application.yml

@@ -0,0 +1,7 @@
+spring:
+  profiles:
+    active: local
+server:
+  port: 8088
+  servlet:
+    context-path: /api

+ 26 - 0
mcp/src/main/resources/com/chuanxia/mcp/mapper/CdnDomainCityMapper.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC
+        "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.chuanxia.mcp.mapper.CdnDomainCityMapper">
+    <select id="listPage" resultType="com.chuanxia.mcp.bean.vo.CdnDomainCityVo">
+        SELECT
+        cdc.id,
+        cdc.`city_id` as cityId,
+        cdc.`domain_id` as domainId,
+        cd.`domain`,
+        cc.`cname` as cityName
+        FROM
+        `cdn_domain_city` cdc
+        LEFT JOIN `cdn_domain` cd
+        ON cdc.`domain_id` = cd.`id`
+        LEFT JOIN `cdn_city` cc
+        ON cdc.`city_id` = cc.`id`
+        <if test="queryDto.cname != null and queryDto.cname != ''">
+            and cc.cname = #{queryDto.cname}
+        </if>
+        <if test="queryDto.domain != null and queryDto.domain != ''">
+          and cd.domain = #{queryDto.domain}
+        </if>
+    </select>
+</mapper>