Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
YouJia
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 b39333e4
authored
Oct 12, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:新增查询产品分类以及查询所有场景接口
1 parent
6375078a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
347 additions
and
0 deletions
youjia-module-store/src/main/java/com/youjia/store/controller/StoreCategoryController.java
youjia-module-store/src/main/java/com/youjia/store/dto/GoodsCategoryQueryDTO.java
youjia-module-store/src/main/java/com/youjia/store/dto/SceneQueryDTO.java
youjia-module-store/src/main/java/com/youjia/store/vo/GoodsCategoryVO.java
youjia-module-store/src/main/java/com/youjia/store/vo/SceneVO.java
youjia-module-store/src/main/java/com/youjia/store/controller/StoreCategoryController.java
0 → 100644
View file @
b39333e
package
com
.
youjia
.
store
.
controller
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.JavaType
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.youjia.common.core.PageResult
;
import
com.youjia.common.core.Result
;
import
com.youjia.framework.rop.RopClient
;
import
com.youjia.framework.rop.RopProperties
;
import
com.youjia.store.dto.GoodsCategoryQueryDTO
;
import
com.youjia.store.dto.SceneQueryDTO
;
import
com.youjia.store.vo.GoodsCategoryVO
;
import
com.youjia.store.vo.SceneVO
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Collections
;
import
java.util.List
;
/**
* 查询 D+ 业务场景分类与商品分类,供前端下拉/筛选使用。
*/
@Tag
(
name
=
"门店上架 · D+ 分类查询"
)
@RestController
@RequestMapping
(
"/store/category"
)
@RequiredArgsConstructor
public
class
StoreCategoryController
{
private
static
final
String
METHOD_GET_SCENES_BY_PARAMS
=
"dj.api.smartcarlife.scene.getScenesByParams"
;
private
static
final
String
METHOD_GOODS_CATEGORY_PAGE
=
"dj.api.goodsCategoryConfiguration.page.new"
;
private
static
final
String
[]
ARRAY_KEYS
=
{
"list"
,
"records"
,
"rows"
,
"data"
,
"items"
};
private
static
final
String
[]
TOTAL_KEYS
=
{
"total"
,
"totalCount"
,
"totalNum"
,
"count"
};
private
final
RopClient
ropClient
;
private
final
ObjectMapper
objectMapper
;
@Operation
(
summary
=
"查询业务场景分类"
)
@GetMapping
(
"/scenes"
)
public
Result
<
List
<
SceneVO
>>
getScenesByParams
(
SceneQueryDTO
query
)
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<>();
params
.
add
(
"currentPage"
,
String
.
valueOf
(
query
.
getCurrent
()));
params
.
add
(
"pageSize"
,
String
.
valueOf
(
query
.
getSize
()));
addIfPresent
(
params
,
"name"
,
query
.
getName
());
addIfPresent
(
params
,
"bizTypeCode"
,
query
.
getBizTypeCode
());
addIfPresent
(
params
,
"subTypeCode"
,
query
.
getSubTypeCode
());
addIfPresent
(
params
,
"sceneType"
,
query
.
getSceneType
());
addIfPresent
(
params
,
"businessType"
,
query
.
getBusinessType
());
addIfPresent
(
params
,
"status"
,
query
.
getStatus
());
addIfPresent
(
params
,
"baseSceneCode"
,
query
.
getBaseSceneCode
());
List
<
SceneVO
>
scenes
=
ropClient
.
invokeForResult
(
RopProperties
.
APP_SMARTCARLIFE
,
METHOD_GET_SCENES_BY_PARAMS
,
params
,
new
TypeReference
<
List
<
SceneVO
>>()
{});
return
Result
.
success
(
scenes
!=
null
?
scenes
:
Collections
.
emptyList
());
}
@Operation
(
summary
=
"查询商品分类(分页)"
)
@GetMapping
(
"/goods/page"
)
public
Result
<
PageResult
<
GoodsCategoryVO
>>
pageGoodsCategory
(
GoodsCategoryQueryDTO
query
)
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<>();
params
.
add
(
"currentPage"
,
String
.
valueOf
(
query
.
getCurrent
()));
params
.
add
(
"pageSize"
,
String
.
valueOf
(
query
.
getSize
()));
addIfPresent
(
params
,
"categoryName"
,
query
.
getCategoryName
());
JsonNode
result
=
ropClient
.
invokeForResultNode
(
RopProperties
.
APP_SMARTCARLIFE
,
METHOD_GOODS_CATEGORY_PAGE
,
params
);
return
Result
.
success
(
toPageResult
(
result
,
query
.
getCurrent
(),
query
.
getSize
(),
GoodsCategoryVO
.
class
));
}
// ------------------------------------------------------------ 内部工具
private
void
addIfPresent
(
MultiValueMap
<
String
,
String
>
params
,
String
key
,
Object
value
)
{
if
(
value
!=
null
)
{
String
str
=
String
.
valueOf
(
value
);
if
(
StringUtils
.
hasText
(
str
))
{
params
.
add
(
key
,
str
);
}
}
}
/**
* 将 D+ 分页响应宽松映射为本地 {@link PageResult}。
*
* <p>D+ 的 {@code RpcPagination} 不在本地源码中,数组字段名可能是
* {@code list / records / rows / data / items},总数字段名可能是
* {@code total / totalCount / totalNum / count},这里逐一候选匹配。</p>
*/
private
<
T
>
PageResult
<
T
>
toPageResult
(
JsonNode
node
,
Long
current
,
Long
size
,
Class
<
T
>
type
)
{
PageResult
<
T
>
page
=
new
PageResult
<>();
page
.
setCurrent
(
current
);
page
.
setSize
(
size
);
if
(
node
==
null
||
node
.
isNull
())
{
return
page
;
}
JsonNode
arrayNode
=
null
;
if
(
node
.
isArray
())
{
arrayNode
=
node
;
}
else
{
for
(
String
key
:
ARRAY_KEYS
)
{
JsonNode
child
=
node
.
get
(
key
);
if
(
child
!=
null
&&
child
.
isArray
())
{
arrayNode
=
child
;
break
;
}
}
}
if
(
arrayNode
!=
null
)
{
JavaType
listType
=
objectMapper
.
getTypeFactory
()
.
constructCollectionType
(
List
.
class
,
type
);
List
<
T
>
records
=
objectMapper
.
convertValue
(
arrayNode
,
listType
);
page
.
setRecords
(
records
);
page
.
setTotal
((
long
)
records
.
size
());
}
if
(
node
.
isObject
())
{
for
(
String
key
:
TOTAL_KEYS
)
{
JsonNode
totalNode
=
node
.
get
(
key
);
if
(
totalNode
!=
null
&&
totalNode
.
isNumber
())
{
page
.
setTotal
(
totalNode
.
asLong
());
break
;
}
}
JsonNode
pageNum
=
node
.
get
(
"pageNum"
);
if
(
pageNum
!=
null
&&
pageNum
.
isNumber
())
{
page
.
setCurrent
(
pageNum
.
asLong
());
}
JsonNode
pageSize
=
node
.
get
(
"pageSize"
);
if
(
pageSize
!=
null
&&
pageSize
.
isNumber
())
{
page
.
setSize
(
pageSize
.
asLong
());
}
}
long
total
=
page
.
getTotal
()
!=
null
?
page
.
getTotal
()
:
0L
;
long
pageSizeVal
=
page
.
getSize
()
!=
null
?
page
.
getSize
()
:
20L
;
page
.
setPages
(
total
>
0
?
(
total
+
pageSizeVal
-
1
)
/
pageSizeVal
:
0L
);
return
page
;
}
}
youjia-module-store/src/main/java/com/youjia/store/dto/GoodsCategoryQueryDTO.java
0 → 100644
View file @
b39333e
package
com
.
youjia
.
store
.
dto
;
import
com.youjia.common.core.PageQuery
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 商品分类分页查询条件。
*
* <p>对应 D+ ROP {@code dj.api.goodsCategoryConfiguration.page.new}。</p>
*/
@Getter
@Setter
@EqualsAndHashCode
(
callSuper
=
true
)
@Schema
(
description
=
"商品分类查询条件"
)
public
class
GoodsCategoryQueryDTO
extends
PageQuery
{
@Schema
(
description
=
"类目名称,模糊搜索"
)
private
String
categoryName
;
}
youjia-module-store/src/main/java/com/youjia/store/dto/SceneQueryDTO.java
0 → 100644
View file @
b39333e
package
com
.
youjia
.
store
.
dto
;
import
com.youjia.common.core.PageQuery
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 业务场景分类查询条件。
*
* <p>对应 D+ ROP {@code dj.api.smartcarlife.scene.getScenesByParams}。</p>
*/
@Getter
@Setter
@EqualsAndHashCode
(
callSuper
=
true
)
@Schema
(
description
=
"业务场景分类查询条件"
)
public
class
SceneQueryDTO
extends
PageQuery
{
@Schema
(
description
=
"场景名称,模糊匹配"
)
private
String
name
;
@Schema
(
description
=
"业务大类编码"
)
private
String
bizTypeCode
;
@Schema
(
description
=
"业务小类编码"
)
private
String
subTypeCode
;
@Schema
(
description
=
"原场景类型"
)
private
Integer
sceneType
;
@Schema
(
description
=
"原二级场景类型"
)
private
Integer
businessType
;
@Schema
(
description
=
"状态:1-启用,0-禁用"
)
private
Integer
status
;
@Schema
(
description
=
"场景标识,如 NEW_CAR_DELIVERY"
)
private
String
baseSceneCode
;
}
youjia-module-store/src/main/java/com/youjia/store/vo/GoodsCategoryVO.java
0 → 100644
View file @
b39333e
package
com
.
youjia
.
store
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.List
;
/**
* 商品分类视图。
*
* <p>对应 D+ {@code GoodsCategoryPageResponse},由 ROP {@code dj.api.goodsCategoryConfiguration.page.new} 返回。</p>
*/
@Getter
@Setter
@Schema
(
description
=
"商品分类"
)
public
class
GoodsCategoryVO
{
@Schema
(
description
=
"主键 ID"
)
private
Integer
id
;
@Schema
(
description
=
"类目类型"
)
private
Integer
categoryType
;
@Schema
(
description
=
"类目名称"
)
private
String
categoryName
;
@Schema
(
description
=
"场景类型"
)
private
Byte
sceneType
;
@Schema
(
description
=
"场景名称"
)
private
String
sceneName
;
@Schema
(
description
=
"创建人"
)
private
String
createdBy
;
@Schema
(
description
=
"创建时间"
)
private
String
createdDate
;
@Schema
(
description
=
"修改人"
)
private
String
updatedBy
;
@Schema
(
description
=
"修改时间"
)
private
String
updatedDate
;
@Schema
(
description
=
"素材商品来源:0-嘀加,1-自建商品"
)
private
Byte
goodsSource
;
@Schema
(
description
=
"父类目主键 ID"
)
private
Integer
parentId
;
@Schema
(
description
=
"类目层级,从 1 开始"
)
private
Byte
level
;
@Schema
(
description
=
"是否为系统类目:0-否,1-是"
)
private
Byte
systemCategory
;
@Schema
(
description
=
"子类目"
)
private
List
<
GoodsCategoryVO
>
children
;
}
youjia-module-store/src/main/java/com/youjia/store/vo/SceneVO.java
0 → 100644
View file @
b39333e
package
com
.
youjia
.
store
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.List
;
/**
* 业务场景分类视图。
*
* <p>对应 D+ {@code SceneDTO},由 ROP {@code dj.api.smartcarlife.scene.getScenesByParams} 返回。</p>
*/
@Getter
@Setter
@Schema
(
description
=
"业务场景分类"
)
public
class
SceneVO
{
@Schema
(
description
=
"主键 ID"
)
private
Long
id
;
@Schema
(
description
=
"场景编号"
)
private
String
num
;
@Schema
(
description
=
"场景名称"
)
private
String
name
;
@Schema
(
description
=
"场景标识,如 NEW_CAR_DELIVERY"
)
private
String
baseSceneCode
;
@Schema
(
description
=
"业务大类编码"
)
private
String
bizTypeCode
;
@Schema
(
description
=
"业务大类名称"
)
private
String
bizTypeName
;
@Schema
(
description
=
"业务小类编码"
)
private
String
subTypeCode
;
@Schema
(
description
=
"业务小类名称"
)
private
String
subTypeName
;
@Schema
(
description
=
"场景描述"
)
private
String
description
;
@Schema
(
description
=
"原场景类型"
)
private
Integer
sceneType
;
@Schema
(
description
=
"原二级场景类型"
)
private
Integer
businessType
;
@Schema
(
description
=
"状态:1-启用,0-禁用"
)
private
Integer
status
;
@Schema
(
description
=
"状态名称"
)
private
String
statusName
;
@Schema
(
description
=
"标签 ID 列表"
)
private
List
<
Long
>
tagIds
;
@Schema
(
description
=
"标签名称列表"
)
private
List
<
String
>
tagNames
;
@Schema
(
description
=
"创建人"
)
private
String
createdBy
;
@Schema
(
description
=
"创建时间"
)
private
String
createdDate
;
@Schema
(
description
=
"更新人"
)
private
String
updatedBy
;
@Schema
(
description
=
"更新时间"
)
private
String
updatedDate
;
}
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