init project

master
qyx-git 4 years ago
commit 0c494944a4

33
.gitignore vendored

@ -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/

@ -0,0 +1,7 @@
# 项目框架
数据层 - JPA
容器 - SpringBoot
表现层 - SpringMVC
# 项目代码
AB单处理逻辑代码

@ -0,0 +1,3 @@
USE ;
DROP TABLE IF EXISTS ``;

@ -0,0 +1,63 @@
<?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.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.yuyou.openapi</groupId>
<artifactId>openapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>openapi</name>
<description>Open API Center for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-data-jpa</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</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>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,13 @@
package com.yuyou.openapi.openapi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class OpenapiApplication {
public static void main(String[] args) {
SpringApplication.run(OpenapiApplication.class, args);
}
}

@ -0,0 +1,51 @@
package com.yuyou.openapi.openapi.api;
import com.yuyou.openapi.openapi.common.CommonResponse;
import com.yuyou.openapi.openapi.model.dto.ABMessageDTO;
import com.yuyou.openapi.openapi.model.vo.ABClientInterMessageVO;
import com.yuyou.openapi.openapi.service.ABClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: DBABClient
* Author: x
* Date: 2020/8/4 5:26 PM
* Description: AB
* History:
* <author> <time> <version> <desc>
* x 2020/8/4 v1.0
*/
@RestController
@Slf4j
public class ABClient {
@Autowired
private ABClientService abClientService;
/**
*
*
* @return
*/
@PostMapping("/api/req/taginfo")
@ResponseBody
public CommonResponse getDBTagInfo(@RequestBody ABClientInterMessageVO vo) {
// 记录日志
log.info("====== [ one request comming,request content is {} ] ======", vo.toString());
// 转换实体类映射
ABMessageDTO dto = new ABMessageDTO();
BeanUtils.copyProperties(vo, dto);
// 调用业务处理接口
abClientService.recordAndSendABClientMsg(dto);
// 返回校验成功的结果
return CommonResponse.createBySuccess();
}
}

@ -0,0 +1,92 @@
package com.yuyou.openapi.openapi.common;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.io.Serializable;
//属性为 空("" 或者为 NULL 都不序列化则返回的json是没有这个字段的。这样对移动端会更省流量
@JsonSerialize
@Getter // 设置get方法
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@NoArgsConstructor
public class CommonResponse<T> implements Serializable {
// 成功还是失败的状态标识 0,成功 1,失败
private int status;
// 返回信息
private String msg;
// 返回的结果数据
private T data;
/*
*/
private CommonResponse(int status) {
this.status = status;
}
private CommonResponse(int status, T data) { // ps: 当调用T为String类型时候,会默认调用下面的ServerResponse(int status, String msg)类型的构造器
this.status = status;
this.data = data;
}
private CommonResponse(int status, String msg, T data) {
this.status = status;
this.msg = msg;
this.data = data;
}
private CommonResponse(int status, String msg) {
this.status = status;
this.msg = msg;
}
/*
,,
*/
//返回成功码和默认的成功信息
public static <T> CommonResponse<T> createBySuccess() {
return new CommonResponse<T>(ResponseCode.SUCCESS.getCode(),ResponseCode.SUCCESS.getDesc());
}
//返回成功码和成功信息
public static <T> CommonResponse<T> createBySuccessMessage(String msg) {
return new CommonResponse<T>(ResponseCode.SUCCESS.getCode(), msg);
}
//返回成功码和数据
public static <T> CommonResponse<T> createBySuccess(T data) {
return new CommonResponse<T>(ResponseCode.SUCCESS.getCode(), data);
}
//返回成功码和成功信息和数据
public static <T> CommonResponse<T> createBySuccess(String msg, T data) {
return new CommonResponse<T>(ResponseCode.SUCCESS.getCode(), msg, data);
}
/*
,,
*/
//返回错误码和错误描述
public static <T> CommonResponse<T> createByError(){
return new CommonResponse<T>(ResponseCode.ERROR.getCode(),ResponseCode.ERROR.getDesc());
}
//返回错误码和错误信息(传入)
public static <T> CommonResponse<T> createByErrorMessage(String errorMessage){
return new CommonResponse<T>(ResponseCode.ERROR.getCode(),errorMessage);
}
//返回错误码(传入)和错误信息(传入)
public static <T> CommonResponse<T> createByErrorCodeMessage(int errorCode,String errorMessage){
return new CommonResponse<T>(errorCode,errorMessage);
}
}

@ -0,0 +1,36 @@
package com.yuyou.openapi.openapi.common;
/**
* FileName: ResponseCode
* Author: x
* Date: 2019/12/11 20:30
* Description: Response ->
* History:
* <author> <time> <version> <desc>
* x 2019/12/11 v 1.0
*/
public enum ResponseCode {
SUCCESS(0,"SUCCESS"),
ERROR(1,"ERROR"),
// 请求参数校验
ILLEGAL_ARGUMENT(2,"请求参数格式错误"),
EMPTY_ARGUMENT(1,"请求参数为空");
private final int code;
private final String desc;
ResponseCode(int code, String desc){
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
}

@ -0,0 +1,18 @@
package com.yuyou.openapi.openapi.model.dto;
import lombok.Data;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: ABMessageDTO
* Author: x
* Date: 2020/8/5 2:12 PM
* Description: AB
* History:
* <author> <time> <version> <desc>
* x 2020/8/5 v1.0
*/
@Data
public class ABMessageDTO {
}

@ -0,0 +1,33 @@
package com.yuyou.openapi.openapi.model.vo;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: ABClientBaseVO
* Author: x
* Date: 2020/8/4 7:02 PM
* Description:
* History:
* <author> <time> <version> <desc>
* x 2020/8/4 v1.0
*/
public class ABClientBaseVO {
/* *//**
*
*//*
private Tag tag;
*//**
* Tag
*//*
private Datas data;
abstract class Tag{
}
abstract class Datas{
}*/
}

@ -0,0 +1,43 @@
package com.yuyou.openapi.openapi.model.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: ABClientInterMessageVO
* Author: x
* Date: 2020/8/5 2:00 PM
* Description: AB
* History:
* <author> <time> <version> <desc>
* x 2020/8/5 v1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ABClientInterMessageVO implements Serializable {
/**
* poneNum Base64
*/
private String mobile;
/**
* Base64
*/
private String actName;
/**
*
*/
private Long startTime;
/**
* 1:A,2:B....
*/
private Integer clientType;
}

@ -0,0 +1,79 @@
package com.yuyou.openapi.openapi.model.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: ABClientMessageVO
* Author: x
* Date: 2020/8/4 6:59 PM
* Description: ABClient
* History:
* <author> <time> <version> <desc>
* x 2020/8/4 v1.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class ABClientZMMessageVO extends ABClientBaseVO implements Serializable {
/**
*
*/
private Tag tag;
/**
* Tag
*/
private Datas data;
class Tag{
/**
* -key
*/
private String tag_key_name;
/**
* -key
*/
private String tag_key_mobile;
/**
* -key
*/
private String tag_key_grade;
/**
* -key
*/
private String tag_key_course;
}
class Datas{
/**
*
*/
private String name;
/**
*
*/
private String mobile;
/**
*
*/
private String grade;
/**
*
*/
private String course;
}
}

@ -0,0 +1,22 @@
package com.yuyou.openapi.openapi.service;
import com.yuyou.openapi.openapi.model.dto.ABMessageDTO;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: ABClientService
* Author: x
* Date: 2020/8/4 7:20 PM
* Description: ABClient
* History:
* <author> <time> <version> <desc>
* x 2020/8/4 v1.0
*/
public interface ABClientService {
/**
* ,
*/
void recordAndSendABClientMsg(ABMessageDTO dto);
}

@ -0,0 +1,24 @@
package com.yuyou.openapi.openapi.service.impl;
import com.yuyou.openapi.openapi.model.dto.ABMessageDTO;
import com.yuyou.openapi.openapi.service.ABClientService;
import org.springframework.stereotype.Service;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: ABClientServiceImpl
* Author: x
* Date: 2020/8/4 7:20 PM
* Description: TODO
* History:
* <author> <time> <version> <desc>
* x 2020/8/4 v1.0
*/
@Service
public class ABClientServiceImpl implements ABClientService {
@Override
public void recordAndSendABClientMsg(ABMessageDTO dto) {
}
}

@ -0,0 +1,10 @@
server:
port: 8090
spring:
# 序列化忽略null的k-v配置
jackson:
default-property-inclusion: non_null

@ -0,0 +1,13 @@
package com.yuyou.openapi.openapi;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class OpenapiApplicationTests {
@Test
void contextLoads() {
}
}
Loading…
Cancel
Save