Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
usedCarAuction
/
aus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 78962897
authored
Mar 18, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:检测端h5接口代码提交
1 parent
4a0884b4
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
307 additions
and
67 deletions
aus-admin/src/main/java/com/glsx/usedcar/web/rest/inspect/InspectionWorkOrderController.java
aus-config/src/main/resources/config/aus-inspector-dev.yaml
aus-core/src/main/java/com/glsx/usedcar/resp/BaseResp.java
aus-inspector/src/main/java/com/glsx/usedcar/advice/GlobalExceptionHandler.java
aus-inspector/src/main/java/com/glsx/usedcar/config/OpenApiConfig.java
aus-inspector/src/main/java/com/glsx/usedcar/config/WebConfig.java
aus-inspector/src/main/java/com/glsx/usedcar/context/InspectorContext.java
aus-inspector/src/main/java/com/glsx/usedcar/controller/AuthController.java
aus-inspector/src/main/java/com/glsx/usedcar/controller/InspectionReportController.java
aus-inspector/src/main/java/com/glsx/usedcar/controller/InspectionWorkOrderController.java
aus-inspector/src/main/java/com/glsx/usedcar/controller/InspectorController.java
aus-inspector/src/main/java/com/glsx/usedcar/controller/TestController.java
aus-inspector/src/main/java/com/glsx/usedcar/interceptor/LoginInterceptor.java
aus-inspector/src/main/java/com/glsx/usedcar/req/InspectionReportReq.java
aus-inspector/src/main/java/com/glsx/usedcar/req/InspectionWorkOrderReq.java
aus-admin/src/main/java/com/glsx/usedcar/web/rest/inspect/InspectionWorkOrderController.java
View file @
7896289
...
@@ -110,7 +110,7 @@ public class InspectionWorkOrderController {
...
@@ -110,7 +110,7 @@ public class InspectionWorkOrderController {
@Operation
(
summary
=
"获取检测工单详情"
,
description
=
"获取检测工单详情"
)
@Operation
(
summary
=
"获取检测工单详情"
,
description
=
"获取检测工单详情"
)
@
Pos
tMapping
(
"/detail/{id}"
)
@
Ge
tMapping
(
"/detail/{id}"
)
public
BaseResp
<
InspectionWODetailRespVO
>
pageList
(
@PathVariable
(
"id"
)
Long
id
)
{
public
BaseResp
<
InspectionWODetailRespVO
>
pageList
(
@PathVariable
(
"id"
)
Long
id
)
{
log
.
info
(
"获取检测工单详情: {}"
,
id
);
log
.
info
(
"获取检测工单详情: {}"
,
id
);
try
{
try
{
...
...
aus-config/src/main/resources/config/aus-inspector-dev.yaml
View file @
7896289
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
server
:
server
:
port
:
6904
port
:
6904
logging
:
logging
:
level
:
root
:
info
location
:
/Users/gonglei/aus
location
:
/Users/gonglei/aus
spring
:
spring
:
task
:
task
:
...
...
aus-core/src/main/java/com/glsx/usedcar/resp/BaseResp.java
View file @
7896289
package
com
.
glsx
.
usedcar
.
resp
;
package
com
.
glsx
.
usedcar
.
resp
;
import
lombok.Data
;
import
lombok.Data
;
import
org.summerframework.core.enums.ErrorCodeEnum
;
/**
/**
* 通用返回结果类
* 通用返回结果类
...
@@ -96,6 +97,17 @@ public class BaseResp<T> {
...
@@ -96,6 +97,17 @@ public class BaseResp<T> {
return
resp
;
return
resp
;
}
}
public
static
<
T
>
BaseResp
<
T
>
fail
(
ErrorCodeEnum
errorCodeEnum
)
{
BaseResp
<
T
>
resp
=
new
BaseResp
<>();
resp
.
setSuccess
(
false
);
resp
.
setCode
(
errorCodeEnum
.
getCode
().
toString
());
resp
.
setMessage
(
errorCodeEnum
.
getMessage
());
resp
.
setData
(
null
);
return
resp
;
}
/**
/**
* 失败响应(默认错误码+自定义错误消息)
* 失败响应(默认错误码+自定义错误消息)
* 默认错误码:999999(系统异常)
* 默认错误码:999999(系统异常)
...
...
aus-inspector/src/main/java/com/glsx/usedcar/advice/GlobalExceptionHandler.java
0 → 100644
View file @
7896289
package
com
.
glsx
.
usedcar
.
advice
;
import
com.glsx.usedcar.resp.BaseResp
;
import
lombok.extern.slf4j.Slf4j
;
import
org.hibernate.HibernateException
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.stream.Collectors
;
/**
* 全局异常处理器,捕获所有Controller层未处理的异常
*/
@Slf4j
@RestControllerAdvice
// 作用于所有@RestController
public
class
GlobalExceptionHandler
{
// 捕获所有未指定的异常(兜底)
@ExceptionHandler
(
Exception
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
// 明确返回500状态码
public
BaseResp
<
Void
>
handleAllUncaughtException
(
Exception
e
)
{
// 打印完整异常堆栈
log
.
error
(
"全局捕获未处理异常:"
,
e
);
// 返回标准化错误响应
return
BaseResp
.
fail
(
"服务器内部错误:"
+
e
.
getMessage
());
}
// 捕获参数校验异常(比如@Valid校验失败)
@ExceptionHandler
(
MethodArgumentNotValidException
.
class
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
public
BaseResp
<
Void
>
handleValidationException
(
MethodArgumentNotValidException
e
)
{
log
.
error
(
"参数校验失败:"
,
e
);
String
errorMsg
=
e
.
getBindingResult
().
getFieldErrors
().
stream
()
.
map
(
fieldError
->
fieldError
.
getField
()
+
":"
+
fieldError
.
getDefaultMessage
())
.
collect
(
Collectors
.
joining
(
","
));
return
BaseResp
.
fail
(
"参数错误:"
+
errorMsg
);
}
// 捕获JPA/Hibernate相关异常
@ExceptionHandler
(
HibernateException
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
BaseResp
<
Void
>
handleHibernateException
(
HibernateException
e
)
{
log
.
error
(
"数据库查询异常:"
,
e
);
return
BaseResp
.
fail
(
"数据库操作失败:"
+
e
.
getMessage
());
}
}
\ No newline at end of file
\ No newline at end of file
aus-inspector/src/main/java/com/glsx/usedcar/config/OpenApiConfig.java
View file @
7896289
...
@@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration;
...
@@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration;
* <pre>
* <pre>
* Knife4j/OpenAPI配置类
* Knife4j/OpenAPI配置类
* 用于启用和配置Swagger文档
* 用于启用和配置Swagger文档
* 访问地址:<a href="http://localhost:690
3/admin
/doc.html">aus-admin API文档</a>
* 访问地址:<a href="http://localhost:690
4
/doc.html">aus-admin API文档</a>
* </pre>
* </pre>
* @author yangwei
* @author yangwei
* @since 2026/2/9 18:25
* @since 2026/2/9 18:25
...
@@ -21,9 +21,9 @@ public class OpenApiConfig {
...
@@ -21,9 +21,9 @@ public class OpenApiConfig {
public
OpenAPI
customOpenApi
()
{
public
OpenAPI
customOpenApi
()
{
return
new
OpenAPI
()
return
new
OpenAPI
()
.
info
(
new
Info
()
.
info
(
new
Info
()
.
title
(
"aus-
admin
API文档"
)
.
title
(
"aus-
inspect
API文档"
)
.
version
(
"1.0.0"
)
.
version
(
"1.0.0"
)
.
description
(
"专电优拍
后台管理系统
API接口文档"
)
.
description
(
"专电优拍
检测端H5
API接口文档"
)
.
contact
(
new
Contact
()
.
contact
(
new
Contact
()
.
name
(
"开发团队"
)
.
name
(
"开发团队"
)
.
email
(
"yangwei@didihu.com.cn"
)
.
email
(
"yangwei@didihu.com.cn"
)
...
...
aus-inspector/src/main/java/com/glsx/usedcar/config/WebConfig.java
View file @
7896289
package
com
.
glsx
.
usedcar
.
config
;
package
com
.
glsx
.
usedcar
.
config
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule
;
import
com.fasterxml.jackson.datatype.jsr310.ser.*
;
import
com.glsx.usedcar.interceptor.LoginInterceptor
;
import
com.glsx.usedcar.interceptor.LoginInterceptor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.*
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
;
import
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.summerframework.cache.CachedPropertyManager
;
import
org.summerframework.cache.CachedPropertySerializerModifier
;
import
org.summerframework.orm.paging.JsonPageSerializer
;
import
org.summerframework.storage.domain.FileInfo
;
import
org.summerframework.storage.web.FileInfoSerializer
;
import
org.summerframework.web.rest.deserializer.*
;
import
java.time.*
;
import
static
org
.
summerframework
.
core
.
util
.
DateTimeUtils
.*;
import
static
org
.
summerframework
.
core
.
util
.
DateTimeUtils
.
DATE_FORMATTER
;
import
static
org
.
summerframework
.
core
.
util
.
DateTimeUtils
.
DATE_TIME_NO_SECOND_FORMATTER
;
import
static
org
.
summerframework
.
core
.
util
.
DateTimeUtils
.
TIME_FORMATTER
;
/**
/**
* Web配置:注册拦截器
* Web配置:注册拦截器
...
@@ -31,5 +51,37 @@ public class WebConfig implements WebMvcConfigurer {
...
@@ -31,5 +51,37 @@ public class WebConfig implements WebMvcConfigurer {
public
RestTemplate
restTemplate
()
{
public
RestTemplate
restTemplate
()
{
return
new
RestTemplate
();
return
new
RestTemplate
();
}
}
/**
* JSON数据 序列化、反序列化
*/
@Bean
@Primary
public
MappingJackson2HttpMessageConverter
mappingJackson2HttpMessageConverter
(
CachedPropertyManager
cachedPropertyManager
)
{
Hibernate5JakartaModule
module
=
new
Hibernate5JakartaModule
();
module
.
disable
(
Hibernate5JakartaModule
.
Feature
.
USE_TRANSIENT_ANNOTATION
);
JsonPageSerializer
jsonPageSerializer
=
new
JsonPageSerializer
();
FileInfoSerializer
fileInfoSerializer
=
new
FileInfoSerializer
();
Jackson2ObjectMapperBuilder
jacksonBuilder
=
new
Jackson2ObjectMapperBuilder
()
.
failOnUnknownProperties
(
false
)
.
serializationInclusion
(
JsonInclude
.
Include
.
NON_EMPTY
)
.
serializerByType
(
Page
.
class
,
jsonPageSerializer
)
.
serializerByType
(
FileInfo
.
class
,
fileInfoSerializer
)
.
serializerByType
(
LocalDateTime
.
class
,
new
LocalDateTimeSerializer
(
DATE_TIME_FORMATTER
))
.
serializerByType
(
LocalDate
.
class
,
new
LocalDateSerializer
(
DATE_FORMATTER
))
.
serializerByType
(
LocalTime
.
class
,
new
LocalTimeSerializer
(
TIME_FORMATTER
))
.
deserializerByType
(
LocalDateTime
.
class
,
new
LocalDateTimeAttemptDeserializer
(
DATE_TIME_NO_SECOND_FORMATTER
))
.
deserializerByType
(
LocalDate
.
class
,
new
LocalDateAttemptDeserializer
(
DATE_FORMATTER
))
.
deserializerByType
(
LocalTime
.
class
,
new
LocalTimeAttemptDeserializer
(
TIME_FORMATTER
));
MappingJackson2HttpMessageConverter
jsonConverter
=
new
MappingJackson2HttpMessageConverter
(
jacksonBuilder
.
build
());
ObjectMapper
objectMapper
=
jsonConverter
.
getObjectMapper
();
objectMapper
.
disable
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
);
objectMapper
.
registerModule
(
module
);
jsonPageSerializer
.
setObjectMapper
(
objectMapper
);
objectMapper
.
setSerializerFactory
(
objectMapper
.
getSerializerFactory
().
withSerializerModifier
(
new
CachedPropertySerializerModifier
(
cachedPropertyManager
)));
return
jsonConverter
;
}
}
}
\ No newline at end of file
\ No newline at end of file
aus-inspector/src/main/java/com/glsx/usedcar/context/InspectorContext.java
View file @
7896289
...
@@ -73,4 +73,12 @@ public class InspectorContext {
...
@@ -73,4 +73,12 @@ public class InspectorContext {
public
static
boolean
hasLogin
()
{
public
static
boolean
hasLogin
()
{
return
getInspector
()
!=
null
;
return
getInspector
()
!=
null
;
}
}
public
static
Object
getInspectorName
()
{
Inspector
inspector
=
getInspector
();
if
(
inspector
==
null
)
{
return
"未登录用户"
;
}
return
inspector
.
getName
();
}
}
}
\ No newline at end of file
\ No newline at end of file
aus-inspector/src/main/java/com/glsx/usedcar/controller/AuthController.java
View file @
7896289
...
@@ -9,6 +9,9 @@ import com.glsx.usedcar.module.inspect.entity.Inspector;
...
@@ -9,6 +9,9 @@ import com.glsx.usedcar.module.inspect.entity.Inspector;
import
com.glsx.usedcar.module.inspect.service.InspectorService
;
import
com.glsx.usedcar.module.inspect.service.InspectorService
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.util.SmsCodeUtil
;
import
com.glsx.usedcar.util.SmsCodeUtil
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
jakarta.validation.Valid
;
import
jakarta.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -21,12 +24,14 @@ import java.util.Date;
...
@@ -21,12 +24,14 @@ import java.util.Date;
import
static
com
.
glsx
.
usedcar
.
conts
.
Constants
.
LOGIN_INSPECTOR
;
import
static
com
.
glsx
.
usedcar
.
conts
.
Constants
.
LOGIN_INSPECTOR
;
/**
/**
* 认证控制器:登录/注册/测试接口
* 认证控制器:负责登录、验证码发送、退出登录等认证相关接口
* 核心能力:手机号验证码登录、短信验证码发送(带防刷)、登录态销毁
*/
*/
@Slf4j
@Slf4j
@RestController
@RestController
@RequestMapping
(
"/
api
/auth"
)
@RequestMapping
(
"/
rest
/auth"
)
@RequiredArgsConstructor
@RequiredArgsConstructor
@Tag
(
name
=
"认证接口"
,
description
=
"登录/验证码/退出登录相关接口"
)
public
class
AuthController
{
public
class
AuthController
{
private
final
JwtProvider
jwtProvider
;
private
final
JwtProvider
jwtProvider
;
private
final
SmsCodeUtil
smsCodeUtil
;
private
final
SmsCodeUtil
smsCodeUtil
;
...
@@ -35,34 +40,53 @@ public class AuthController {
...
@@ -35,34 +40,53 @@ public class AuthController {
private
int
codeExpire
;
private
int
codeExpire
;
/**
/**
* 发送验证码(带防刷控制)
* 发送短信验证码(带频率防刷控制)
* 接口规则:
* 1. 仅对已注册的检测员手机号发送
* 2. 同一手机号1分钟内仅允许发送1次验证码
* 3. 验证码有效期由配置项 sms.code-expire 控制
*
* @param req 验证码请求参数(包含待验证的手机号)
* @return 发送结果:success=true表示发送成功,false/msg提示失败原因
*/
*/
@Operation
(
summary
=
"发送登录验证码"
,
description
=
"向检测员手机号发送6位数字验证码,包含频率防刷(1分钟/次),仅支持已注册手机号"
)
@PostMapping
(
"/send-code"
)
@PostMapping
(
"/send-code"
)
public
BaseResp
<
Boolean
>
sendCode
(
@RequestBody
@Valid
VerifyCodeReq
req
)
{
public
BaseResp
<
Boolean
>
sendCode
(
@Parameter
(
description
=
"验证码请求参数(手机号格式校验:11位有效手机号)"
)
@RequestBody
@Valid
VerifyCodeReq
req
)
{
try
{
try
{
// 校验用户是否存在
Inspector
inspector
=
inspectorService
.
findByPhone
(
req
.
getPhone
());
Inspector
inspector
=
inspectorService
.
findByPhone
(
req
.
getPhone
());
if
(
inspector
==
null
)
{
if
(
inspector
==
null
)
{
return
BaseResp
.
fail
(
"用户不存在"
);
return
BaseResp
.
fail
(
"用户不存在"
);
}
}
// 校验发送频率
smsCodeUtil
.
checkSendFrequency
(
req
.
getPhone
());
smsCodeUtil
.
checkSendFrequency
(
req
.
getPhone
());
// 频率校验通过,生成并存储验证码
smsCodeUtil
.
generateAndSaveCode
(
req
.
getPhone
());
smsCodeUtil
.
generateAndSaveCode
(
req
.
getPhone
());
return
BaseResp
.
success
(
true
);
return
BaseResp
.
success
(
true
);
}
catch
(
RuntimeException
e
)
{
}
catch
(
RuntimeException
e
)
{
// 捕获防刷异常,返回友好提示
log
.
warn
(
"手机号{}发送验证码失败:{}"
,
req
.
getPhone
(),
e
.
getMessage
());
log
.
warn
(
"手机号{}发送验证码失败:{}"
,
req
.
getPhone
(),
e
.
getMessage
());
return
BaseResp
.
fail
(
"发送验证码失败
"
);
return
BaseResp
.
fail
(
"发送验证码失败
:"
+
e
.
getMessage
()
);
}
}
}
}
/**
/**
* 验证码登录
* 手机号+验证码登录接口
* 登录成功后生成JWT Token,供后续接口鉴权使用
*
* @param loginRequest 登录请求参数(手机号+6位验证码)
* @return 登录结果:包含JWT Token、手机号、Token过期时间
*/
*/
@Operation
(
summary
=
"验证码登录"
,
description
=
"检测员通过手机号+验证码登录,成功返回JWT Token(后续接口需携带Token鉴权)"
)
@PostMapping
(
"/login"
)
@PostMapping
(
"/login"
)
public
BaseResp
<
LoginByCodeResp
>
login
(
@RequestBody
LoginByCodeReq
loginRequest
)
{
public
BaseResp
<
LoginByCodeResp
>
login
(
@Parameter
(
description
=
"登录请求参数(手机号+验证码)"
)
@RequestBody
LoginByCodeReq
loginRequest
)
{
String
phone
=
loginRequest
.
getPhone
();
String
phone
=
loginRequest
.
getPhone
();
Inspector
inspector
=
inspectorService
.
findByPhone
(
phone
);
Inspector
inspector
=
inspectorService
.
findByPhone
(
phone
);
if
(
inspector
==
null
)
{
if
(
inspector
==
null
)
{
...
@@ -82,12 +106,23 @@ public class AuthController {
...
@@ -82,12 +106,23 @@ public class AuthController {
}
}
/**
/**
* 退出登录(需要Token)
* 退出登录接口(需携带有效登录Token)
* 注:当前仅返回退出成功,实际生产环境可补充Token黑名单/失效逻辑
*
* @param request HttpServletRequest:用于获取登录态中的检测员手机号
* @return 退出结果:success=true表示退出成功
*/
*/
@Operation
(
summary
=
"退出登录"
,
description
=
"检测员退出登录(需携带有效JWT Token),当前仅返回成功状态,可扩展Token失效逻辑"
)
@PostMapping
(
"/logout"
)
@PostMapping
(
"/logout"
)
@RequireLogin
@RequireLogin
// 自定义注解:校验请求头中的Token是否有效
public
BaseResp
<
Boolean
>
logout
(
HttpServletRequest
request
)
{
public
BaseResp
<
Boolean
>
logout
(
@Parameter
(
hidden
=
true
)
HttpServletRequest
request
)
{
String
phone
=
(
String
)
request
.
getAttribute
(
LOGIN_INSPECTOR
);
String
phone
=
(
String
)
request
.
getAttribute
(
LOGIN_INSPECTOR
);
log
.
info
(
"检测员{}执行退出登录操作"
,
phone
);
return
BaseResp
.
success
(
true
);
return
BaseResp
.
success
(
true
);
}
}
...
...
aus-inspector/src/main/java/com/glsx/usedcar/controller/InspectionReportController.java
View file @
7896289
package
com
.
glsx
.
usedcar
.
controller
;
package
com
.
glsx
.
usedcar
.
controller
;
import
com.glsx.usedcar.annotation.RequireLogin
;
import
com.glsx.usedcar.context.InspectorContext
;
import
com.glsx.usedcar.module.inspect.entity.InspectionReport
;
import
com.glsx.usedcar.module.inspect.entity.InspectionReport
;
import
com.glsx.usedcar.module.inspect.service.InspectionReportService
;
import
com.glsx.usedcar.module.inspect.service.InspectionReportService
;
import
com.glsx.usedcar.module.inspect.vo.InspectionReportRespVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectionReportRespVO
;
import
com.glsx.usedcar.module.security.entity.User
;
import
com.glsx.usedcar.req.InspectionReportReq
;
import
com.glsx.usedcar.resp.BaseResp
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
jakarta.validation.Valid
;
import
jakarta.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.summerframework.orm.paging.Pagination
;
import
org.summerframework.orm.paging.Pagination
;
@Slf4j
@Slf4j
@Tag
(
name
=
"检测报告接口"
,
description
=
"检测报告的增删改查、绑定解绑操作"
)
@Tag
(
name
=
"检测报告接口"
,
description
=
"检测报告的增删改查、绑定解绑操作"
)
@RestController
@RestController
@RequireLogin
@RequiredArgsConstructor
@RequiredArgsConstructor
@RequestMapping
(
"/rest/inspect/report"
)
@RequestMapping
(
"/rest/inspect/report"
)
public
class
InspectionReportController
{
public
class
InspectionReportController
{
private
final
InspectionReportService
inspectionReportService
;
private
final
InspectionReportService
inspectionReportService
;
/**
* 分页查询检测报告列表
* 支持关键词模糊查询(报告编号、工单号、VIN等),关键词过滤逻辑由Service层处理
*
* @param req 分页请求参数(包含页码、每页条数)
* @return 分页的检测报告列表
*/
@Operation
(
summary
=
"分页查询检测报告"
,
description
=
"支持关键词模糊查询(报告编号、工单号、VIN等)"
)
@Operation
(
summary
=
"分页查询检测报告"
,
description
=
"支持关键词模糊查询(报告编号、工单号、VIN等)"
)
@PostMapping
(
"/page"
)
@PostMapping
(
"/page"
)
public
Page
<
InspectionReportRespVO
>
pageList
(
@Valid
@RequestBody
Pagination
<
InspectionReport
>
pagination
,
Authentication
authentication
)
{
public
BaseResp
<
Page
<
InspectionReportRespVO
>>
pageList
(
@Valid
@RequestBody
InspectionReportReq
req
)
{
log
.
info
(
"【接口请求】分页查询检测报告,操作人={},页码={},条数={}"
,
getUserName
(
authentication
),
pagination
.
getOffset
(),
pagination
.
getLimit
());
// 1. 处理分页参数默认值(页码默认1,每页条数默认20)
try
{
int
page
=
req
.
getPage
()
==
null
||
req
.
getPage
()
<
1
?
1
:
req
.
getPage
();
Page
<
InspectionReportRespVO
>
result
=
inspectionReportService
.
pageList
(
pagination
);
int
size
=
req
.
getSize
()
==
null
||
req
.
getSize
()
<
1
?
20
:
req
.
getSize
();
return
result
;
}
catch
(
Exception
e
)
{
log
.
info
(
"【接口请求】分页查询检测报告,操作人={},页码={},条数={}"
,
log
.
error
(
"【接口响应】分页查询检测报告失败!操作人={},系统异常!"
,
getUserName
(
authentication
),
e
);
InspectorContext
.
getInspectorName
(),
page
,
size
);
return
null
;
}
}
/**
* 安全获取操作人姓名(避免空指针)
*/
private
String
getUserName
(
Authentication
authentication
)
{
try
{
try
{
return
authentication
!=
null
?
((
User
)
authentication
.
getPrincipal
()).
getUserName
()
:
"未知用户"
;
// 2. 构建分页对象(offset = (页码-1)*每页条数)
Pagination
<
InspectionReport
>
pagination
=
new
Pagination
<>((
page
-
1
)
*
size
,
size
);
// 3. 调用Service查询(若有关键词过滤,可在此添加pagination.addFilter逻辑)
Page
<
InspectionReportRespVO
>
result
=
inspectionReportService
.
pageList
(
pagination
);
return
BaseResp
.
success
(
result
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
"未知用户"
;
log
.
error
(
"【接口响应】分页查询检测报告失败!操作人={},系统异常!"
,
InspectorContext
.
getPhone
(),
e
);
return
BaseResp
.
fail
(
"系统异常: "
+
e
.
getMessage
());
}
}
}
}
}
}
\ No newline at end of file
\ No newline at end of file
aus-inspector/src/main/java/com/glsx/usedcar/controller/InspectionWorkOrderController.java
View file @
7896289
package
com
.
glsx
.
usedcar
.
controller
;
package
com
.
glsx
.
usedcar
.
controller
;
import
com.glsx.usedcar.annotation.RequireLogin
;
import
com.glsx.usedcar.module.inspect.entity.InspectionWorkOrder
;
import
com.glsx.usedcar.module.inspect.entity.InspectionWorkOrder
;
import
com.glsx.usedcar.module.inspect.service.InspectionWorkOrderService
;
import
com.glsx.usedcar.module.inspect.service.InspectionWorkOrderService
;
import
com.glsx.usedcar.module.inspect.vo.InspectionWODetailRespVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectionWODetailRespVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectionWORespVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectionWORespVO
;
import
com.glsx.usedcar.req.InspectionWorkOrderReq
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.resp.BaseResp
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
...
@@ -12,41 +14,62 @@ import lombok.RequiredArgsConstructor;
...
@@ -12,41 +14,62 @@ import lombok.RequiredArgsConstructor;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.summerframework.orm.paging.Operator
;
import
org.summerframework.orm.paging.Pagination
;
import
org.summerframework.orm.paging.Pagination
;
/**
* 检测工单控制器
* 处理检测工单的分页查询、详情查询等操作
*/
@Slf4j
@Slf4j
@Tag
(
name
=
"检测工单接口"
,
description
=
"检测工单的增删改查操作"
)
@Tag
(
name
=
"检测工单接口"
,
description
=
"检测工单的增删改查操作"
)
@RequireLogin
@RestController
@RestController
@RequiredArgsConstructor
@RequiredArgsConstructor
@RequestMapping
(
"/rest/inspect/wo"
)
@RequestMapping
(
"/rest/inspect/wo"
)
public
class
InspectionWorkOrderController
{
public
class
InspectionWorkOrderController
{
private
final
InspectionWorkOrderService
inspectionWorkOrderService
;
private
final
InspectionWorkOrderService
inspectionWorkOrderService
;
@Operation
(
summary
=
"分页检测工单"
,
description
=
"分页查询检测工单列表"
)
/**
* 分页查询检测工单列表
*
* @param req 分页请求参数(包含页码、每页条数、工单状态)
* @return 分页的检测工单列表
*/
@Operation
(
summary
=
"分页检测工单"
,
description
=
"根据工单状态分页查询检测工单列表"
)
@PostMapping
(
"/page"
)
@PostMapping
(
"/page"
)
public
Page
<
InspectionWORespVO
>
pageList
(
@Valid
@RequestBody
Pagination
<
InspectionWorkOrder
>
pagination
)
{
public
BaseResp
<
Page
<
InspectionWORespVO
>>
pageList
(
@Valid
@RequestBody
InspectionWorkOrderReq
req
)
{
log
.
info
(
"分页查询检测工单请求: offset={}, limit={}"
,
pagination
.
getOffset
(),
pagination
.
getLimit
());
try
{
try
{
int
page
=
req
.
getPage
()
==
null
||
req
.
getPage
()
<
1
?
1
:
req
.
getPage
();
int
size
=
req
.
getSize
()
==
null
||
req
.
getSize
()
<
1
?
20
:
req
.
getSize
();
Pagination
<
InspectionWorkOrder
>
pagination
=
new
Pagination
<>((
page
-
1
)
*
size
,
size
);
pagination
.
addFilter
(
"status"
,
req
.
getStatus
(),
Operator
.
eq
);
log
.
info
(
"分页查询检测工单请求: page={}, size={}, status={}"
,
page
,
size
,
req
.
getStatus
());
Page
<
InspectionWORespVO
>
result
=
inspectionWorkOrderService
.
pageList
(
pagination
);
Page
<
InspectionWORespVO
>
result
=
inspectionWorkOrderService
.
pageList
(
pagination
);
return
result
;
return
BaseResp
.
success
(
result
)
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"分页查询检测工单失败!系统异常!"
,
e
);
log
.
error
(
"分页查询检测工单失败!系统异常!"
,
e
);
return
null
;
return
BaseResp
.
fail
(
"分页查询检测工单失败:"
+
e
.
getMessage
())
;
}
}
}
}
/**
@Operation
(
summary
=
"获取检测工单详情"
,
description
=
"获取检测工单详情"
)
* 获取检测工单详情
@PostMapping
(
"/detail/{id}"
)
*
public
BaseResp
<
InspectionWODetailRespVO
>
pageList
(
@PathVariable
(
"id"
)
Long
id
)
{
* @param id 工单ID
log
.
info
(
"获取检测工单详情: {}"
,
id
);
* @return 工单详情信息
*/
@Operation
(
summary
=
"获取检测工单详情"
,
description
=
"根据工单ID获取检测工单详情"
)
@GetMapping
(
"/detail/{id}"
)
public
BaseResp
<
InspectionWODetailRespVO
>
getDetail
(
@PathVariable
(
"id"
)
Long
id
)
{
log
.
info
(
"获取检测工单详情: id={}"
,
id
);
try
{
try
{
InspectionWODetailRespVO
result
=
inspectionWorkOrderService
.
detail
(
id
);
InspectionWODetailRespVO
result
=
inspectionWorkOrderService
.
detail
(
id
);
return
BaseResp
.
success
(
result
);
return
BaseResp
.
success
(
result
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"获取检测工单详情失败!系统异常!"
,
e
);
log
.
error
(
"获取检测工单详情失败!系统异常!"
,
e
);
return
BaseResp
.
fail
(
"
系统异常:
"
+
e
.
getMessage
());
return
BaseResp
.
fail
(
"
获取检测工单详情失败:
"
+
e
.
getMessage
());
}
}
}
}
}
}
\ No newline at end of file
\ No newline at end of file
aus-inspector/src/main/java/com/glsx/usedcar/controller/InspectorController.java
View file @
7896289
package
com
.
glsx
.
usedcar
.
controller
;
package
com
.
glsx
.
usedcar
.
controller
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.glsx.usedcar.annotation.RequireLogin
;
import
com.glsx.usedcar.context.InspectorContext
;
import
com.glsx.usedcar.module.inspect.service.InspectorService
;
import
com.glsx.usedcar.module.inspect.service.InspectorService
;
import
com.glsx.usedcar.module.inspect.vo.InspectorDetailRespVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectorDetailRespVO
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.resp.BaseResp
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
jakarta.validation.constraints.NotNull
;
import
jakarta.validation.constraints.Positive
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -23,6 +22,7 @@ import org.summerframework.core.exception.BusinessCodeException;
...
@@ -23,6 +22,7 @@ import org.summerframework.core.exception.BusinessCodeException;
*/
*/
@Slf4j
@Slf4j
@Tag
(
name
=
"检测师管理接口"
,
description
=
"检测师信息的增删改查操作"
)
@Tag
(
name
=
"检测师管理接口"
,
description
=
"检测师信息的增删改查操作"
)
@RequireLogin
@RestController
@RestController
@RequiredArgsConstructor
@RequiredArgsConstructor
@RequestMapping
(
"/rest/inspect"
)
@RequestMapping
(
"/rest/inspect"
)
...
@@ -30,17 +30,12 @@ public class InspectorController {
...
@@ -30,17 +30,12 @@ public class InspectorController {
private
final
InspectorService
inspectorService
;
private
final
InspectorService
inspectorService
;
@GetMapping
(
"/detail"
)
@Operation
(
summary
=
"查询检测师详情"
,
description
=
"查询检测师账号基本信息和操作日志"
)
@Operation
(
summary
=
"查询检测师详情"
,
description
=
"查询检测师账号基本信息和操作日志"
)
@GetMapping
(
"/detail/{id}"
)
public
BaseResp
<
InspectorDetailRespVO
>
getDetail
()
{
public
BaseResp
<
InspectorDetailRespVO
>
getDetail
(
log
.
info
(
"查询检测师详情请求: ID={}"
,
InspectorContext
.
getInspectorId
());
@Parameter
(
description
=
"检测师ID"
,
required
=
true
)
@NotNull
(
message
=
"检测师ID不能为空"
)
@Positive
(
message
=
"检测师ID必须为正数"
)
@PathVariable
(
"id"
)
Long
id
)
{
log
.
info
(
"查询检测师详情请求: ID={}"
,
id
);
try
{
try
{
InspectorDetailRespVO
result
=
inspectorService
.
getDetail
(
id
);
InspectorDetailRespVO
result
=
inspectorService
.
getDetail
(
InspectorContext
.
getInspectorId
()
);
return
BaseResp
.
success
(
result
);
return
BaseResp
.
success
(
result
);
}
catch
(
BusinessCodeException
be
)
{
}
catch
(
BusinessCodeException
be
)
{
log
.
error
(
"查询检测师详情失败!业务异常!"
,
be
);
log
.
error
(
"查询检测师详情失败!业务异常!"
,
be
);
...
...
aus-inspector/src/main/java/com/glsx/usedcar/controller/TestController.java
View file @
7896289
package
com
.
glsx
.
usedcar
.
controller
;
package
com
.
glsx
.
usedcar
.
controller
;
import
com.glsx.usedcar.annotation.RequireLogin
;
import
com.glsx.usedcar.annotation.RequireLogin
;
import
com.glsx.usedcar.resp.BaseResp
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -13,13 +14,13 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -13,13 +14,13 @@ import org.springframework.web.bind.annotation.RestController;
public
class
TestController
{
public
class
TestController
{
@RequestMapping
(
"/hello"
)
@RequestMapping
(
"/hello"
)
public
String
hello
()
{
public
BaseResp
<
String
>
hello
()
{
return
"hello world"
;
return
BaseResp
.
success
(
"hello world"
)
;
}
}
@RequireLogin
@RequireLogin
@RequestMapping
(
"/hello2"
)
@RequestMapping
(
"/hello2"
)
public
String
hello2
()
{
public
BaseResp
<
String
>
hello2
()
{
return
"hello world2"
;
return
BaseResp
.
success
(
"hello world"
)
;
}
}
}
}
aus-inspector/src/main/java/com/glsx/usedcar/interceptor/LoginInterceptor.java
View file @
7896289
package
com
.
glsx
.
usedcar
.
interceptor
;
package
com
.
glsx
.
usedcar
.
interceptor
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.usedcar.annotation.RequireLogin
;
import
com.glsx.usedcar.annotation.RequireLogin
;
import
com.glsx.usedcar.context.InspectorContext
;
import
com.glsx.usedcar.context.InspectorContext
;
import
com.glsx.usedcar.module.inspect.entity.Inspector
;
import
com.glsx.usedcar.module.inspect.entity.Inspector
;
import
com.glsx.usedcar.module.inspect.service.InspectorService
;
import
com.glsx.usedcar.module.inspect.service.InspectorService
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.token.JwtProvider
;
import
com.glsx.usedcar.token.JwtProvider
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
import
jakarta.servlet.http.HttpServletResponse
;
...
@@ -15,6 +17,7 @@ import org.springframework.http.HttpStatus;
...
@@ -15,6 +17,7 @@ import org.springframework.http.HttpStatus;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.summerframework.core.enums.ErrorCodeEnum
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
...
@@ -94,7 +97,8 @@ public class LoginInterceptor implements HandlerInterceptor {
...
@@ -94,7 +97,8 @@ public class LoginInterceptor implements HandlerInterceptor {
response
.
setContentType
(
"application/json; charset=utf-8"
);
response
.
setContentType
(
"application/json; charset=utf-8"
);
response
.
setStatus
(
HttpStatus
.
UNAUTHORIZED
.
value
());
// 401状态码
response
.
setStatus
(
HttpStatus
.
UNAUTHORIZED
.
value
());
// 401状态码
try
(
PrintWriter
writer
=
response
.
getWriter
())
{
try
(
PrintWriter
writer
=
response
.
getWriter
())
{
writer
.
write
(
String
.
format
(
"{\"code\":401,\"message\":\"%s\"}"
,
message
));
BaseResp
<
Void
>
errorResponse
=
BaseResp
.
fail
(
ErrorCodeEnum
.
LOGIN_ERROR
);
writer
.
write
(
JSON
.
toJSONString
(
errorResponse
));
writer
.
flush
();
writer
.
flush
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"返回认证错误响应失败:"
,
e
);
log
.
error
(
"返回认证错误响应失败:"
,
e
);
...
...
aus-inspector/src/main/java/com/glsx/usedcar/req/InspectionReportReq.java
0 → 100644
View file @
7896289
package
com
.
glsx
.
usedcar
.
req
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.*
;
/**
* 检测报告分页请求
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"检测报告分页请求"
)
public
class
InspectionReportReq
{
@Schema
(
description
=
"每页条数,默认20"
,
example
=
"20"
)
private
Integer
size
;
@Schema
(
description
=
"页码,默认1(从1开始)"
,
example
=
"1"
)
private
Integer
page
;
}
\ No newline at end of file
\ No newline at end of file
aus-inspector/src/main/java/com/glsx/usedcar/req/InspectionWorkOrderReq.java
0 → 100644
View file @
7896289
package
com
.
glsx
.
usedcar
.
req
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.*
;
/**
* 检测工单分页请求
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"检测工单分页请求"
)
public
class
InspectionWorkOrderReq
{
@Schema
(
description
=
"每页条数,默认20"
,
example
=
"20"
)
private
Integer
size
;
@Schema
(
description
=
"页码,默认1(从1开始)"
,
example
=
"1"
)
private
Integer
page
;
/**
* 工单状态
* 1:待检测;2:检测中;3:已完成;4:已取消
*/
@Schema
(
description
=
"工单状态 1:待检测;2:检测中;3:已完成;4:已取消"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1"
)
@NotNull
(
message
=
"查询状态不能为空"
)
private
Integer
status
;
}
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment