Compare commits
No commits in common. 'master' and 'origin' have entirely different histories.
18 changed files with 3 additions and 644 deletions
@ -1,75 +0,0 @@ |
||||
<?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>3.1.5</version> |
||||
<relativePath/> <!-- lookup parent from repository --> |
||||
</parent> |
||||
<groupId>com.cmcc</groupId> |
||||
<artifactId>PrivateLineManager</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<name>PrivateLineManager</name> |
||||
<description>PrivateLineManager</description> |
||||
<properties> |
||||
<java.version>17</java.version> |
||||
</properties> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.mysql</groupId> |
||||
<artifactId>mysql-connector-j</artifactId> |
||||
<scope>runtime</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-test</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
|
||||
<!-- jpa --> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-data-jpa</artifactId> |
||||
</dependency> |
||||
|
||||
|
||||
<dependency> |
||||
<groupId>org.modelmapper</groupId> |
||||
<artifactId>modelmapper</artifactId> |
||||
<version>3.0.0</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
<configuration> |
||||
<image> |
||||
<builder>paketobuildpacks/builder-jammy-base:latest</builder> |
||||
</image> |
||||
<excludes> |
||||
<exclude> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
</exclude> |
||||
</excludes> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
||||
@ -1,13 +0,0 @@ |
||||
package com.cmcc.privatelinemanager; |
||||
|
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
||||
@SpringBootApplication |
||||
public class PrivateLineManagerApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
SpringApplication.run(PrivateLineManagerApplication.class, args); |
||||
} |
||||
|
||||
} |
||||
@ -1,40 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.base; |
||||
|
||||
|
||||
import jakarta.persistence.Column; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* Created by Jm on 2023/11/20. |
||||
*/ |
||||
@Getter |
||||
@Setter |
||||
public class BaseVo implements Serializable { |
||||
|
||||
/** |
||||
* 专线名称 |
||||
*/ |
||||
@Column |
||||
private String name; |
||||
|
||||
/** |
||||
* 专线编号 |
||||
*/ |
||||
@Column |
||||
private String number; |
||||
|
||||
/** |
||||
* 专线类型 |
||||
*/ |
||||
@Column |
||||
private String type; |
||||
|
||||
/** |
||||
* 专线状态 |
||||
*/ |
||||
@Column |
||||
private String status; |
||||
} |
||||
@ -1,38 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.base; |
||||
|
||||
import jakarta.persistence.*; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.hibernate.annotations.GenericGenerator; |
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
||||
|
||||
@Getter |
||||
@Setter |
||||
@MappedSuperclass |
||||
@EntityListeners(AuditingEntityListener.class) |
||||
public class EntityBase { |
||||
|
||||
/** |
||||
* 主键 ID |
||||
*/ |
||||
|
||||
@Id |
||||
@GenericGenerator(name = "id") |
||||
@GeneratedValue(generator = "id") |
||||
@Column(length = 36) |
||||
private int id; |
||||
|
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
@Column(name = "create_time",columnDefinition = "date") |
||||
private Long createTime; |
||||
/** |
||||
* 更新时间 |
||||
*/ |
||||
@Column(name = "update_time",columnDefinition = "date") |
||||
private Long updateTime; |
||||
|
||||
|
||||
} |
||||
@ -1,34 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.base; |
||||
|
||||
import jakarta.persistence.Column; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
@Getter |
||||
@Setter |
||||
public class PrivateLineInfoBase extends EntityBase { |
||||
|
||||
/** |
||||
* 专线名称 |
||||
*/ |
||||
@Column |
||||
private String name; |
||||
|
||||
/** |
||||
* 专线编号 |
||||
*/ |
||||
@Column |
||||
private String number; |
||||
|
||||
/** |
||||
* 专线类型 |
||||
*/ |
||||
@Column |
||||
private String type; |
||||
|
||||
/** |
||||
* 专线状态 |
||||
*/ |
||||
@Column |
||||
private String status; |
||||
} |
||||
@ -1,35 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.controller; |
||||
|
||||
import com.cmcc.privatelinemanager.service.LineMangerService; |
||||
import com.cmcc.privatelinemanager.tools.response.Response; |
||||
import com.cmcc.privatelinemanager.vo.ProductInfoBaseVo; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 中国移动专线管家入口 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/privateLine") |
||||
public class CmccPrivateLineManger { |
||||
|
||||
|
||||
@Autowired |
||||
private LineMangerService lineMangerService; |
||||
|
||||
|
||||
// 查询相关接口————————————————————————————————————————
|
||||
|
||||
/** |
||||
* 查询全部产品 |
||||
* @return 返回全部产品基础信息 |
||||
*/ |
||||
@RequestMapping("/getAllProduct") |
||||
public Response<List<ProductInfoBaseVo>> getAllProduct(){ |
||||
List<ProductInfoBaseVo> productInfoBaseVos = lineMangerService.getAllProduct(); |
||||
return Response.success(productInfoBaseVos); |
||||
} |
||||
} |
||||
@ -1,11 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.dao; |
||||
|
||||
import com.cmcc.privatelinemanager.controller.CmccPrivateLineManger; |
||||
import org.hibernate.sql.ast.tree.expression.JdbcParameter; |
||||
import org.springframework.data.jpa.repository.JpaRepository; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
@Repository |
||||
public interface CmccPrivateLineMangerRepository extends JpaRepository<CmccPrivateLineManger, Integer> { |
||||
|
||||
} |
||||
@ -1,42 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.entity; |
||||
|
||||
import com.cmcc.privatelinemanager.base.PrivateLineInfoBase; |
||||
import jakarta.persistence.Column; |
||||
import jakarta.persistence.Entity; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
|
||||
/** |
||||
* 专线信息 |
||||
*/ |
||||
@Getter |
||||
@Setter |
||||
@Entity(name = "private_line_info") |
||||
public class PrivateLineInfo extends PrivateLineInfoBase { |
||||
|
||||
/** |
||||
* 产品描述 |
||||
*/ |
||||
@Column |
||||
private String description; |
||||
|
||||
|
||||
/** |
||||
* 产品描述视频id |
||||
*/ |
||||
@Column |
||||
private String descriptionVideoId; |
||||
|
||||
/** |
||||
* 产品优势id |
||||
*/ |
||||
@Column |
||||
private String advantageId; |
||||
|
||||
/** |
||||
* 适用场景 |
||||
*/ |
||||
@Column |
||||
private String scene; |
||||
} |
||||
@ -1,31 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.entity; |
||||
|
||||
|
||||
import com.cmcc.privatelinemanager.base.EntityBase; |
||||
import jakarta.persistence.Entity; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* 产品优势表 |
||||
*/ |
||||
@Getter |
||||
@Setter |
||||
@Entity(name = "product_advantage") |
||||
public class ProductAdvantage extends EntityBase { |
||||
/** |
||||
* 产品id |
||||
*/ |
||||
private String productId; |
||||
|
||||
/** |
||||
* 产品优势 |
||||
*/ |
||||
|
||||
private String advantage; |
||||
|
||||
/** |
||||
* 产品优势描述 |
||||
*/ |
||||
private String advantageDesc; |
||||
} |
||||
@ -1,9 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.service; |
||||
|
||||
import com.cmcc.privatelinemanager.vo.ProductInfoBaseVo; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface LineMangerService { |
||||
List<ProductInfoBaseVo> getAllProduct(); |
||||
} |
||||
@ -1,33 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.service.impl; |
||||
|
||||
import com.cmcc.privatelinemanager.controller.CmccPrivateLineManger; |
||||
import com.cmcc.privatelinemanager.dao.CmccPrivateLineMangerRepository; |
||||
import com.cmcc.privatelinemanager.service.LineMangerService; |
||||
import com.cmcc.privatelinemanager.vo.ProductInfoBaseVo; |
||||
import org.modelmapper.ModelMapper; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@Service |
||||
public class LineMangerServiceImpl implements LineMangerService { |
||||
|
||||
@Autowired |
||||
CmccPrivateLineMangerRepository cmccPrivateLineMangerRepository; |
||||
|
||||
@Override |
||||
public List<ProductInfoBaseVo> getAllProduct() { |
||||
ModelMapper modelMapper = new ModelMapper(); |
||||
|
||||
List<CmccPrivateLineManger> cmccPrivateLineMangers = cmccPrivateLineMangerRepository.findAll(); |
||||
|
||||
List<ProductInfoBaseVo> productInfoBaseVos; |
||||
productInfoBaseVos = cmccPrivateLineMangers.stream() |
||||
.map(cmccPrivateLineManger -> modelMapper.map(cmccPrivateLineManger, ProductInfoBaseVo.class)) |
||||
.toList(); |
||||
|
||||
return productInfoBaseVos; |
||||
} |
||||
} |
||||
@ -1,47 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.tools.exception; |
||||
|
||||
|
||||
|
||||
import com.cmcc.privatelinemanager.tools.response.ResponseCode; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* 功能:自定义系统异常 |
||||
* |
||||
* @author jm |
||||
* Created by jm on 2022-12-16 13:22. |
||||
*/ |
||||
@Getter |
||||
@Setter |
||||
public class ServiceException extends RuntimeException { |
||||
|
||||
private int code; |
||||
|
||||
/** |
||||
* 异常时传递参数 |
||||
*/ |
||||
private Object content; |
||||
|
||||
public ServiceException(int code, String message) { |
||||
super(message); |
||||
this.code = code; |
||||
} |
||||
|
||||
public ServiceException(ResponseCode responseCode) { |
||||
super(responseCode.getMessage()); |
||||
this.code = responseCode.getCode(); |
||||
} |
||||
|
||||
public ServiceException(ResponseCode responseCode, String message) { |
||||
super(message); |
||||
this.code = responseCode.getCode(); |
||||
} |
||||
|
||||
public ServiceException(ResponseCode responseCode, String message, Object obj) { |
||||
super(message); |
||||
this.code = responseCode.getCode(); |
||||
this.content=obj; |
||||
} |
||||
|
||||
} |
||||
@ -1,156 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.tools.response; |
||||
|
||||
public class Response<T> { |
||||
|
||||
|
||||
private int code; |
||||
private T data; |
||||
private String message; |
||||
|
||||
public Response(int code, T data, String message) { |
||||
this.code = code; |
||||
this.data = data; |
||||
this.message = message; |
||||
} |
||||
|
||||
public Response(int code, String message) { |
||||
this.code = code; |
||||
this.message = message; |
||||
} |
||||
|
||||
public Response(ResponseCode code, T data, String message) { |
||||
this.code = code.getCode(); |
||||
this.data = data; |
||||
this.message = message; |
||||
} |
||||
|
||||
public Response(ResponseCode code, String message) { |
||||
this.code = code.getCode(); |
||||
this.message = message; |
||||
} |
||||
|
||||
/** |
||||
* 默认成功响应 |
||||
* |
||||
* @return |
||||
*/ |
||||
public static Response success() { |
||||
Response response = new Response(ResponseCode.SUCCESS, ResponseCode.SUCCESS.getMessage()); |
||||
return response; |
||||
} |
||||
|
||||
/** |
||||
* 成功响应,携带响应数据 |
||||
* |
||||
* @param data |
||||
* @param <T> |
||||
* @return |
||||
*/ |
||||
public static <T> Response<T> success(T data) { |
||||
return new Response(ResponseCode.SUCCESS, data, ResponseCode.SUCCESS.getMessage()); |
||||
} |
||||
|
||||
/** |
||||
* 失败响应,指定错误码 |
||||
* |
||||
* @param responseCode |
||||
* @return |
||||
*/ |
||||
public static Response fail(int responseCode) { |
||||
return new Response(responseCode, null); |
||||
} |
||||
|
||||
/** |
||||
* 失败响应,指定错误码 |
||||
* |
||||
* @param responseCode |
||||
* @return |
||||
*/ |
||||
public static Response fail(ResponseCode responseCode) { |
||||
return new Response(responseCode, responseCode.getMessage()); |
||||
} |
||||
|
||||
/** |
||||
* 失败响应,指定错误码,指定错误信息提示 |
||||
* |
||||
* @param responseCode |
||||
* @param message |
||||
* @return |
||||
*/ |
||||
public static Response fail(int responseCode, String message) { |
||||
return new Response(responseCode, message); |
||||
} |
||||
|
||||
/** |
||||
* 失败响应,指定错误码,指定错误信息提示 |
||||
* |
||||
* @param responseCode |
||||
* @param message |
||||
* @return |
||||
*/ |
||||
public static Response fail(ResponseCode responseCode, String message) { |
||||
return new Response(responseCode, message); |
||||
} |
||||
|
||||
/** |
||||
* 失败响应,指定错误码,指定错误信息提示,并携带错误数据 |
||||
* |
||||
* @param responseCode |
||||
* @param message |
||||
* @param data |
||||
* @param <T> |
||||
* @return |
||||
*/ |
||||
public static <T> Response<T> fail(int responseCode, String message, T data) { |
||||
return new Response(responseCode, data, message); |
||||
} |
||||
|
||||
/** |
||||
* 失败响应,指定错误码,指定错误信息提示,并携带错误数据 |
||||
* |
||||
* @param responseCode |
||||
* @param message |
||||
* @param data |
||||
* @param <T> |
||||
* @return |
||||
*/ |
||||
public static <T> Response<T> fail(ResponseCode responseCode, String message, T data) { |
||||
return new Response(responseCode, data, message); |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public Response<T> setCode(int code) { |
||||
this.code = code; |
||||
return this; |
||||
} |
||||
|
||||
public T getData() { |
||||
return data; |
||||
} |
||||
|
||||
public Response<T> setData(T data) { |
||||
this.data = data; |
||||
return this; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
|
||||
public Response<T> setMessage(String message) { |
||||
this.message = message; |
||||
return this; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "Response{" + |
||||
"code=" + code + |
||||
", data=" + data + |
||||
", message='" + message + '\'' + |
||||
'}'; |
||||
} |
||||
} |
||||
@ -1,27 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.tools.response; |
||||
|
||||
|
||||
import lombok.Getter; |
||||
|
||||
@Getter |
||||
public enum ResponseCode { |
||||
|
||||
SUCCESS(200, "SUCCESS"), |
||||
ERROR(500, "ERROR"); |
||||
|
||||
private final int code; |
||||
private final String message; |
||||
|
||||
ResponseCode(int code, String message) { |
||||
this.code = code; |
||||
this.message = message; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
} |
||||
@ -1,14 +0,0 @@ |
||||
package com.cmcc.privatelinemanager.vo; |
||||
|
||||
|
||||
import com.cmcc.privatelinemanager.base.BaseVo; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
@Getter |
||||
@Setter |
||||
public class ProductInfoBaseVo extends BaseVo { |
||||
|
||||
private String productName; |
||||
|
||||
} |
||||
@ -1,26 +0,0 @@ |
||||
spring: |
||||
profiles: |
||||
active: dev |
||||
application: |
||||
name: cmcc-PrivateLineManager |
||||
datasource: |
||||
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
url: jdbc:mysql://localhost:3306/CMCC_PrivateLineManager?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8 |
||||
username: root |
||||
password: abc123 |
||||
hikari: |
||||
connection-timeout: 2000 |
||||
minimum-idle: 5 |
||||
maximum-pool-size: 20 |
||||
idle-timeout: 200000 |
||||
auto-commit: true |
||||
max-lifetime: 1800000 |
||||
connection-test-query: select 1 |
||||
jpa: |
||||
database: mysql |
||||
show-sql: false |
||||
generate-ddl: true |
||||
server: |
||||
port: 8080 |
||||
servlet: |
||||
context-path: /apis/cmcc-PrivateLineManager |
||||
@ -1,13 +0,0 @@ |
||||
package com.cmcc.privatelinemanager; |
||||
|
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
||||
@SpringBootTest |
||||
class PrivateLineManagerApplicationTests { |
||||
|
||||
@Test |
||||
void contextLoads() { |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue