12 changed files with 336 additions and 1 deletions
-
6build.gradle
-
50sql/demo.sql
-
50src/main/java/com/qyft/gd/common/config/MybatisPlusConfig.java
-
66src/main/java/com/qyft/gd/common/config/SwaggerConfig.java
-
30src/main/java/com/qyft/gd/controller/demo/DemoController.java
-
11src/main/java/com/qyft/gd/mapper/demo/PoiCollectInfoMapper.java
-
14src/main/java/com/qyft/gd/model/dto/demo/DemoUploadFileDto.java
-
44src/main/java/com/qyft/gd/model/entity/demo/DemoCollectInfo.java
-
10src/main/java/com/qyft/gd/service/demo/IDemoCollectInfoService.java
-
13src/main/java/com/qyft/gd/service/demo/impl/DemoCollectInfoServiceImpl.java
-
28src/main/resources/application.yml
-
15src/main/resources/mapper/demo/DemoCollectInfoMapper.xml
@ -0,0 +1,50 @@ |
|||||
|
-- 表名: collect_info |
||||
|
-- 描述: 收集信息 |
||||
|
|
||||
|
CREATE TABLE collect_info |
||||
|
( |
||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 自增主键 id |
||||
|
name TEXT, -- 生产线id |
||||
|
lon REAL, -- 经度 |
||||
|
lat REAL, -- 纬度 |
||||
|
create_time TEXT -- 创建时间,格式 'YYYY-MM-DD HH:MM:SS' |
||||
|
); |
||||
|
|
||||
|
-- 插入 30 条测试数据 |
||||
|
-- 数据规则说明: |
||||
|
-- 1. 生产线名称依次为 '生产线1' ~ '生产线30' |
||||
|
-- 2. 经度从 116.397128 起,每条记录递增 0.1 |
||||
|
-- 3. 纬度从 39.916527 起,每条记录递增 0.1 |
||||
|
-- 4. 创建时间从 '2023-01-01 08:00:00' 起,每条记录递增 5 分钟 |
||||
|
|
||||
|
INSERT INTO collect_info (name, lon, lat, create_time) |
||||
|
VALUES ('生产线1', 116.397128, 39.916527, '2023-01-01 08:00:00'), |
||||
|
('生产线2', 116.497128, 40.016527, '2023-01-01 08:05:00'), |
||||
|
('生产线3', 116.597128, 40.116527, '2023-01-01 08:10:00'), |
||||
|
('生产线4', 116.697128, 40.216527, '2023-01-01 08:15:00'), |
||||
|
('生产线5', 116.797128, 40.316527, '2023-01-01 08:20:00'), |
||||
|
('生产线6', 116.897128, 40.416527, '2023-01-01 08:25:00'), |
||||
|
('生产线7', 116.997128, 40.516527, '2023-01-01 08:30:00'), |
||||
|
('生产线8', 117.097128, 40.616527, '2023-01-01 08:35:00'), |
||||
|
('生产线9', 117.197128, 40.716527, '2023-01-01 08:40:00'), |
||||
|
('生产线10', 117.297128, 40.816527, '2023-01-01 08:45:00'), |
||||
|
('生产线11', 117.397128, 40.916527, '2023-01-01 08:50:00'), |
||||
|
('生产线12', 117.497128, 41.016527, '2023-01-01 08:55:00'), |
||||
|
('生产线13', 117.597128, 41.116527, '2023-01-01 09:00:00'), |
||||
|
('生产线14', 117.697128, 41.216527, '2023-01-01 09:05:00'), |
||||
|
('生产线15', 117.797128, 41.316527, '2023-01-01 09:10:00'), |
||||
|
('生产线16', 117.897128, 41.416527, '2023-01-01 09:15:00'), |
||||
|
('生产线17', 117.997128, 41.516527, '2023-01-01 09:20:00'), |
||||
|
('生产线18', 118.097128, 41.616527, '2023-01-01 09:25:00'), |
||||
|
('生产线19', 118.197128, 41.716527, '2023-01-01 09:30:00'), |
||||
|
('生产线20', 118.297128, 41.816527, '2023-01-01 09:35:00'), |
||||
|
('生产线21', 118.397128, 41.916527, '2023-01-01 09:40:00'), |
||||
|
('生产线22', 118.497128, 42.016527, '2023-01-01 09:45:00'), |
||||
|
('生产线23', 118.597128, 42.116527, '2023-01-01 09:50:00'), |
||||
|
('生产线24', 118.697128, 42.216527, '2023-01-01 09:55:00'), |
||||
|
('生产线25', 118.797128, 42.316527, '2023-01-01 10:00:00'), |
||||
|
('生产线26', 118.897128, 42.416527, '2023-01-01 10:05:00'), |
||||
|
('生产线27', 118.997128, 42.516527, '2023-01-01 10:10:00'), |
||||
|
('生产线28', 119.097128, 42.616527, '2023-01-01 10:15:00'), |
||||
|
('生产线29', 119.197128, 42.716527, '2023-01-01 10:20:00'), |
||||
|
('生产线30', 119.297128, 42.816527, '2023-01-01 10:25:00'); |
@ -0,0 +1,50 @@ |
|||||
|
package com.qyft.gd.common.config; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.DbType; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
@EnableTransactionManagement |
||||
|
@Configuration |
||||
|
public class MybatisPlusConfig { |
||||
|
|
||||
|
@Bean |
||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor() { |
||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
||||
|
// 乐观锁插件 |
||||
|
interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor()); |
||||
|
// 分页插件 |
||||
|
interceptor.addInnerInterceptor(paginationInnerInterceptor()); |
||||
|
// 阻断插件 |
||||
|
// interceptor.addInnerInterceptor(blockAttackInnerInterceptor()); |
||||
|
return interceptor; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 分页插件,自动识别数据库类型 |
||||
|
* https://baomidou.com/guide/interceptor-pagination.html |
||||
|
*/ |
||||
|
public PaginationInnerInterceptor paginationInnerInterceptor() { |
||||
|
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(); |
||||
|
// 设置数据库类型为mysql |
||||
|
paginationInnerInterceptor.setDbType(DbType.POSTGRE_SQL); |
||||
|
// 设置最大单页限制数量,默认 500 条,-1 不受限制 |
||||
|
paginationInnerInterceptor.setMaxLimit(-1L); |
||||
|
return paginationInnerInterceptor; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 乐观锁插件 |
||||
|
* https://baomidou.com/guide/interceptor-optimistic-locker.html |
||||
|
*/ |
||||
|
public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() { |
||||
|
return new OptimisticLockerInnerInterceptor(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,66 @@ |
|||||
|
/* |
||||
|
* Copyright (C) 2018 Zhejiang xiaominfo Technology CO.,LTD. |
||||
|
* All rights reserved. |
||||
|
* Official Web Site: http://www.xiaominfo.com. |
||||
|
* Developer Web Site: http://open.xiaominfo.com. |
||||
|
*/ |
||||
|
|
||||
|
package com.qyft.gd.common.config; |
||||
|
|
||||
|
import cn.hutool.core.util.RandomUtil; |
||||
|
import io.swagger.v3.oas.models.OpenAPI; |
||||
|
import io.swagger.v3.oas.models.info.Info; |
||||
|
import io.swagger.v3.oas.models.info.License; |
||||
|
import org.springdoc.core.customizers.GlobalOpenApiCustomizer; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/*** |
||||
|
* 创建Swagger配置 |
||||
|
* @since:knife4j-springdoc-openapi-demo 1.0 |
||||
|
* @author <a href="mailto:xiaoymin@foxmail.com">xiaoymin@foxmail.com</a> |
||||
|
* 2020/03/15 20:40 |
||||
|
*/ |
||||
|
@Configuration |
||||
|
public class SwaggerConfig { |
||||
|
/** |
||||
|
* 根据@Tag 上的排序,写入x-order |
||||
|
* |
||||
|
* @return the global open api customizer |
||||
|
*/ |
||||
|
@Bean |
||||
|
public GlobalOpenApiCustomizer orderGlobalOpenApiCustomizer() { |
||||
|
return openApi -> { |
||||
|
if (openApi.getTags()!=null){ |
||||
|
openApi.getTags().forEach(tag -> { |
||||
|
Map<String,Object> map=new HashMap<>(); |
||||
|
map.put("x-order", RandomUtil.randomInt(0,100)); |
||||
|
tag.setExtensions(map); |
||||
|
}); |
||||
|
} |
||||
|
if(openApi.getPaths()!=null){ |
||||
|
openApi.addExtension("x-test123","333"); |
||||
|
openApi.getPaths().addExtension("x-abb",RandomUtil.randomInt(1,100)); |
||||
|
} |
||||
|
|
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
@Bean |
||||
|
public OpenAPI customOpenAPI() { |
||||
|
return new OpenAPI() |
||||
|
.info(new Info() |
||||
|
.title("XXX用户系统API") |
||||
|
.version("1.0") |
||||
|
|
||||
|
.description( "Knife4j集成springdoc-openapi示例") |
||||
|
.termsOfService("http://doc.xiaominfo.com") |
||||
|
.license(new License().name("Apache 2.0") |
||||
|
.url("http://doc.xiaominfo.com"))); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
package com.qyft.gd.controller.demo; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.qyft.gd.model.entity.demo.DemoCollectInfo; |
||||
|
import com.qyft.gd.service.demo.IDemoCollectInfoService; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
@Slf4j |
||||
|
@Tag(name = "数据") |
||||
|
@RestController |
||||
|
@RequestMapping("/demo") |
||||
|
public class DemoController { |
||||
|
|
||||
|
@Autowired |
||||
|
IDemoCollectInfoService poiCollectInfoService; |
||||
|
|
||||
|
@Operation(summary = "分页列表") |
||||
|
@GetMapping(value = "/list") |
||||
|
public IPage<DemoCollectInfo> queryList() { |
||||
|
return poiCollectInfoService.page(new Page<DemoCollectInfo>(1, 10), null); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
package com.qyft.gd.mapper.demo; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qyft.gd.model.entity.demo.DemoCollectInfo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface PoiCollectInfoMapper extends BaseMapper<DemoCollectInfo> { |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package com.qyft.gd.model.dto.demo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
@Schema(name = "上传文件") |
||||
|
@Data |
||||
|
public class DemoUploadFileDto { |
||||
|
|
||||
|
@Schema(description = "文件名称") |
||||
|
private MultipartFile file; |
||||
|
|
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
package com.qyft.gd.model.entity.demo; |
||||
|
|
||||
|
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.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import lombok.experimental.Accessors; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
@Schema(description = "收集信息") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = false) |
||||
|
@Accessors(chain = true) |
||||
|
@TableName("collect_info") |
||||
|
public class DemoCollectInfo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
@Schema(description = "id", example = "1", requiredMode = Schema.RequiredMode.REQUIRED) |
||||
|
@TableId(value = "id", type = IdType.ASSIGN_ID) |
||||
|
private Long id; |
||||
|
|
||||
|
@Schema(description = "生产线id") |
||||
|
@TableField(value = "name") |
||||
|
private String name; |
||||
|
|
||||
|
@Schema(description = "经度") |
||||
|
@TableField(value = "lon") |
||||
|
private Double lon; |
||||
|
|
||||
|
@Schema(description = "纬度") |
||||
|
@TableField(value = "lat") |
||||
|
private Double lat; |
||||
|
|
||||
|
@Schema(description = "创建时间") |
||||
|
@TableField(value = "create_time") |
||||
|
private String createTime; |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
package com.qyft.gd.service.demo; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qyft.gd.model.entity.demo.DemoCollectInfo; |
||||
|
|
||||
|
|
||||
|
public interface IDemoCollectInfoService extends IService<DemoCollectInfo> { |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package com.qyft.gd.service.demo.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.qyft.gd.mapper.demo.PoiCollectInfoMapper; |
||||
|
import com.qyft.gd.model.entity.demo.DemoCollectInfo; |
||||
|
import com.qyft.gd.service.demo.IDemoCollectInfoService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
@Service |
||||
|
public class DemoCollectInfoServiceImpl extends ServiceImpl<PoiCollectInfoMapper, DemoCollectInfo> implements IDemoCollectInfoService { |
||||
|
|
||||
|
|
||||
|
} |
@ -1 +1,27 @@ |
|||||
spring.application.name=graphite_digestion_instrument |
|
||||
|
server: |
||||
|
servlet: |
||||
|
context-path: / |
||||
|
port: 8080 |
||||
|
|
||||
|
spring: |
||||
|
application: |
||||
|
name: graphite_digestion_instrument |
||||
|
datasource: |
||||
|
url: jdbc:sqlite:D:\\graphite_digestion.db |
||||
|
driver-class-name: org.sqlite.JDBC |
||||
|
# sql: |
||||
|
# init: |
||||
|
# mode: |
||||
|
|
||||
|
mybatis-plus: |
||||
|
configuration: |
||||
|
# 开启 SQL 日志输出(可选) |
||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
||||
|
# 如果需要加载 XML 文件(自定义 SQL),可配置 mapper-locations: |
||||
|
mapper-locations: classpath*:mapper/*.xml |
||||
|
|
||||
|
# 可选:开启 SQL 打印,调试时方便查看 |
||||
|
logging: |
||||
|
level: |
||||
|
root: INFO |
||||
|
org.mybatis: DEBUG |
@ -0,0 +1,15 @@ |
|||||
|
<?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.qyft.gd.mapper.demo.PoiCollectInfoMapper"> |
||||
|
|
||||
|
<!-- 通用查询映射结果 --> |
||||
|
<resultMap id="BaseResultMap" type="com.qyft.gd.model.entity.demo.DemoCollectInfo"> |
||||
|
<id column="id" property="id"/> |
||||
|
<result column="name" property="name"/> |
||||
|
<result column="lon" property="lon"/> |
||||
|
<result column="lat" property="lat"/> |
||||
|
<result column="create_time" property="createTime"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
|
||||
|
</mapper> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue