Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
blg
Commits
d79c5b8f
Commit
d79c5b8f
authored
Apr 14, 2026
by
wujipeng
Browse files
设备资产
parent
8175bc40
Changes
12
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
d79c5b8f
...
...
@@ -42,6 +42,16 @@
<artifactId>
hutool-all
</artifactId>
<version>
5.8.38
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
2.9.2
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
2.9.2
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/org/example/blg/config/SwaggerConfig.java
0 → 100644
View file @
d79c5b8f
package
org.example.blg.config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.service.Contact
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
@Configuration
// 标明是配置类
@EnableSwagger2
//开启swagger功能
public
class
SwaggerConfig
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
// DocumentationType.SWAGGER_2 固定的,代表swagger2
//.groupName("分布式任务系统") // 如果配置多个文档的时候,那么需要配置groupName来分组标识
.
apiInfo
(
apiInfo
())
// 用于生成API信息
.
select
()
// select()函数返回一个ApiSelectorBuilder实例,用来控制接口被swagger做成文档
// 扫描指定包下的接口,最为常用
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"org.example.blg.controller"
))
//.withClassAnnotation(RestController.class) // 扫描带有指定注解的类下所有接口
//.withMethodAnnotation(PostMapping.class) // 扫描带有指定注解的方法接口
//.apis(RequestHandlerSelectors.any()) // 扫描所有
// 选择所有的API,如果你想只为部分API生成文档,可以配置这里
.
paths
(
PathSelectors
.
any
()
//.any() // 满足条件的路径,该断言总为true
//.none() // 不满足条件的路径,该断言总为false(可用于生成环境屏蔽 swagger)
//.ant("/user/**") // 满足字符串表达式路径
//.regex("") // 符合正则的路径
)
.
build
();
}
/**
* 用于定义API主界面的信息,比如可以声明所有的API的总标题、描述、版本
* @return
*/
private
ApiInfo
apiInfo
()
{
Contact
contact
=
new
Contact
(
"我是作者姓名"
,
// 作者姓名
"https://blog.csdn.net/"
,
// 作者网址
"123456789@163.com"
);
// 作者邮箱
return
new
ApiInfoBuilder
()
.
title
(
"XX项目API"
)
// 可以用来自定义API的主标题
.
description
(
"XX项目SwaggerAPI管理"
)
// 可以用来描述整体的API
.
termsOfServiceUrl
(
"https://www.baidu.com"
)
// 用于定义服务的域名(跳转链接)
.
version
(
"1.0"
)
// 可以用来定义版本
.
license
(
"Swagger-的使用教程"
)
.
licenseUrl
(
"https://blog.csdn.net"
)
.
contact
(
contact
)
.
build
();
//
}
}
src/main/java/org/example/blg/controller/EquipmentController.java
0 → 100644
View file @
d79c5b8f
package
org.example.blg.controller
;
import
org.example.blg.pojo.dto.EquipmentDTO
;
import
org.example.blg.pojo.vo.EquipmentVO
;
import
org.example.blg.result.Result
;
import
org.example.blg.service.EquipmentService
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
/**
* @author : wujipeng
* @date : 2026/4/14 9:58
* @Version: 1.0
* @Desc : 描述信息
*/
@RestController
@RequestMapping
(
"/equipment"
)
public
class
EquipmentController
{
@Resource
private
EquipmentService
equipmentService
;
@PostMapping
(
"/list"
)
public
Result
<
EquipmentVO
>
list
(
@RequestBody
EquipmentDTO
equipmentDTO
)
{
return
Result
.
success
(
equipmentService
.
list
(
equipmentDTO
));
}
}
src/main/java/org/example/blg/mapper/EquipmentMapper.java
0 → 100644
View file @
d79c5b8f
package
org.example.blg.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.example.blg.pojo.dto.EquipmentDTO
;
import
org.example.blg.pojo.entity.EquipmentEntity
;
import
org.example.blg.pojo.vo.EquipmentVO
;
/**
* @author : wujipeng
* @date : 2026/4/14 9:55
* @Version: 1.0
* @Desc : 描述信息
*/
@Mapper
public
interface
EquipmentMapper
extends
BaseMapper
<
EquipmentEntity
>
{
EquipmentVO
list
(
EquipmentDTO
equipmentDTO
);
}
src/main/java/org/example/blg/pojo/dto/EquipmentDTO.java
0 → 100644
View file @
d79c5b8f
package
org.example.blg.pojo.dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
org.example.blg.pojo.entity.EquipmentEntity
;
/**
* @author : wujipeng
* @date : 2026/4/14 9:59
* @Version: 1.0
* @Desc : 描述信息
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
public
class
EquipmentDTO
extends
EquipmentEntity
{
@ApiModelProperty
(
"查询条件"
)
private
String
conditions
;
}
src/main/java/org/example/blg/pojo/entity/EquipmentEntity.java
0 → 100644
View file @
d79c5b8f
package
org.example.blg.pojo.entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
/**
* @author : wujipeng
* @date : 2026/4/14 9:47
* @Version: 1.0
* @Desc : 描述信息
*/
@Data
public
class
EquipmentEntity
{
@TableId
(
type
=
IdType
.
ASSIGN_ID
)
private
String
id
;
private
String
name
;
private
String
code
;
}
src/main/java/org/example/blg/pojo/vo/EquipmentVO.java
0 → 100644
View file @
d79c5b8f
package
org.example.blg.pojo.vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
org.example.blg.pojo.entity.EquipmentEntity
;
/**
* @author : wujipeng
* @date : 2026/4/14 10:00
* @Version: 1.0
* @Desc : 描述信息
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
public
class
EquipmentVO
extends
EquipmentEntity
{
@ApiModelProperty
(
"是否有告警"
)
private
Boolean
hasAlarm
;
}
src/main/java/org/example/blg/result/PageResult.java
View file @
d79c5b8f
package
org.example.blg.result
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.List
;
@Setter
@Getter
@Data
public
class
PageResult
<
T
>
{
/**
...
...
src/main/java/org/example/blg/service/EquipmentService.java
0 → 100644
View file @
d79c5b8f
package
org.example.blg.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
org.example.blg.pojo.dto.EquipmentDTO
;
import
org.example.blg.pojo.entity.EquipmentEntity
;
import
org.example.blg.pojo.vo.EquipmentVO
;
/**
* @author : wujipeng
* @date : 2026/4/14 9:57
* @Version: 1.0
* @Desc : 描述信息
*/
public
interface
EquipmentService
extends
IService
<
EquipmentEntity
>
{
EquipmentVO
list
(
EquipmentDTO
equipmentDTO
);
}
src/main/java/org/example/blg/service/impl/EquipmentServiceImpl.java
0 → 100644
View file @
d79c5b8f
package
org.example.blg.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.example.blg.mapper.EquipmentMapper
;
import
org.example.blg.pojo.dto.EquipmentDTO
;
import
org.example.blg.pojo.entity.EquipmentEntity
;
import
org.example.blg.pojo.vo.EquipmentVO
;
import
org.example.blg.service.EquipmentService
;
/**
* @author : wujipeng
* @date : 2026/4/14 9:57
* @Version: 1.0
* @Desc : 描述信息
*/
public
class
EquipmentServiceImpl
extends
ServiceImpl
<
EquipmentMapper
,
EquipmentEntity
>
implements
EquipmentService
{
@Override
public
EquipmentVO
list
(
EquipmentDTO
equipmentDTO
)
{
return
baseMapper
.
list
(
equipmentDTO
);
}
}
src/main/resources/application.yml
View file @
d79c5b8f
server
:
port
:
8080
port
:
18413
spring
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://192168.10.3:3307/blg?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true
url
:
jdbc:mysql://192
.
168.10.3:3307/blg?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true
username
:
root
password
:
ruzhoukj@2022
src/main/resources/org/example/blg/mapper/EquipmentMapper.xml
0 → 100644
View file @
d79c5b8f
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"org.example.blg.mapper.EquipmentMapper"
>
<select
id=
"list"
resultType=
"org.example.blg.pojo.vo.EquipmentVO"
>
select
id,
name,
code
from
equipment
<where>
<if
test=
"conditions != null and conditions != ''"
>
(name like concat('%', #{conditions}, '%') or
code like concat('%', #{conditions}, '%'))
</if>
</where>
</select>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment