Commit 77f1e999 by 潘诗林

feat:一销二销,客户画像标签信息查询

1 parent c27126f8
package cn.com.glsx.dj.strategy.consts;
public class CommonConstants {
/**
* 消费力标签
*/
public static final String TAG_CATEGORY_CONSUMPTION = "INIT_C1";
/**
* 产品标签
*/
public static final String TAG_CATEGORY_PRODUCT = "INIT_C2";
/**
*行为标签
*/
public static final String TAG_CATEGORY_BEHAVIOR = "INIT_C3";
}
......@@ -42,4 +42,23 @@ public interface TagCategoryRemote {
@ApiParam(name = "request", notes = "请求对象", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("根据分类代码查询分类下所有维度及其枚举")
RpcResponse<TagCategoryDimensionRespDTO> queryCategoryWithDimensions(TagCategoryDimensionQueryReqDTO request);
/**
* 根据类别代码查询类别名称
*
* @param categoryCode 类别代码
* @return 类别响应
*/
@ApiMethod("根据类别代码查询类别")
@ApiParam(name = "categoryCode", notes = "类别代码", dataType = ApiParam.DataTypeEnum.STRING, required = true)
@ApiResponse("类别信息")
RpcResponse<TagCategoryRespDTO> getByCode(String categoryCode);
/**
* 根据类别代码列表批量查询类别
*/
@ApiMethod("根据类别代码列表批量查询类别")
@ApiParam(name = "categoryCodes", notes = "类别代码列表", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("类别列表")
RpcResponse<List<TagCategoryRespDTO>> getByCodes(List<String> categoryCodes);
}
......@@ -47,4 +47,12 @@ public interface TagDimensionRemote {
@ApiParam(name = "request", notes = "请求对象", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("根据维度代码查询枚举列表")
RpcResponse<TagDimensionEnumRespDTO> queryDimensionWithEnums(TagDimensionEnumQueryReqDTO request);
/**
* 根据维度代码列表批量查询维度
*/
@ApiMethod("根据维度代码列表批量查询维度")
@ApiParam(name = "dimensionCodes", notes = "维度代码列表", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("维度列表")
RpcResponse<List<TagDimensionRespDTO>> getByCodes(List<String> dimensionCodes);
}
......@@ -8,6 +8,8 @@ import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import java.util.List;
/**
* 标签枚举值Remote接口
* @author yangwei_by_claude
......@@ -31,4 +33,36 @@ public interface TagEnumRemote {
@ApiParam(name = "request", notes = "请求对象", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("更新标签枚举值")
RpcResponse<Void> updateEnum(TagEnumUpdateReqDTO request);
/**
* 根据枚举代码查询枚举值
*
* @param enumCode 枚举代码
* @return 枚举值响应
*/
@ApiMethod("根据枚举代码查询枚举值")
@ApiParam(name = "enumCode", notes = "枚举代码", dataType = ApiParam.DataTypeEnum.STRING, required = true)
@ApiResponse("枚举值信息")
RpcResponse<TagEnumRespDTO> getByCode(String enumCode);
/**
* 根据类别代码查询其下所有枚举值
* <p>
* 通过 类别 → 维度(含子类别维度) → 枚举 的关联链路,查询该类别下所有可用的枚举值
*
* @param categoryCode 类别代码
* @return 枚举值列表(含维度名称和类别路径)
*/
@ApiMethod("根据类别代码查询所有枚举值")
@ApiParam(name = "categoryCode", notes = "类别代码", dataType = ApiParam.DataTypeEnum.STRING, required = true)
@ApiResponse("枚举值列表")
RpcResponse<List<TagEnumRespDTO>> listByCategoryCode(String categoryCode);
/**
* 根据枚举代码列表批量查询枚举值
*/
@ApiMethod("根据枚举代码列表批量查询枚举值")
@ApiParam(name = "enumCodes", notes = "枚举代码列表", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("枚举值列表")
RpcResponse<List<TagEnumRespDTO>> getByCodes(List<String> enumCodes);
}
......@@ -56,4 +56,9 @@ public interface TagCategoryMapper extends OreMapper<TagCategory> {
*/
TagCategory selectByCategoryCode(@Param("categoryCode") String categoryCode);
/**
* 根据类别代码列表批量查询
*/
List<TagCategory> selectByCategoryCodes(@Param("categoryCodes") List<String> categoryCodes);
}
......@@ -41,4 +41,9 @@ public interface TagDimensionMapper extends OreMapper<TagDimension> {
* 根据维度代码查询维度
*/
TagDimension selectByDimensionCode(@Param("dimensionCode") String dimensionCode);
/**
* 根据维度代码列表批量查询维度
*/
List<TagDimension> selectByDimensionCodes(@Param("dimensionCodes") List<String> dimensionCodes);
}
......@@ -41,4 +41,22 @@ public interface TagEnumMapper extends OreMapper<TagEnum> {
* 根据维度ID查询所有枚举值(不分页)
*/
List<TagEnum> selectByDimensionId(@Param("dimensionId") Integer dimensionId);
/**
* 根据枚举代码查询枚举值
*/
TagEnum selectByEnumCode(@Param("enumCode") String enumCode);
/**
* 根据枚举代码列表批量查询枚举值
*/
List<TagEnum> selectByEnumCodes(@Param("enumCodes") List<String> enumCodes);
/**
* 根据类别代码查询其下所有枚举值
* <p>
* 通过 dj_car_life_tag_dimension 关联到 dj_car_life_tag_category,
* 查询该类别(含子类别)下所有维度关联的枚举值
*/
List<TagEnum> selectByCategoryCode(@Param("categoryCode") String categoryCode);
}
......@@ -21,7 +21,7 @@ import java.util.List;
* @since 2026/06/17
*/
@Slf4j
@DubboService
@DubboService(version = "8.8.8")
@RequiredArgsConstructor
public class CustomerTagProfileRemoteImpl implements CustomerTagProfileRemote {
......
......@@ -88,4 +88,30 @@ public class TagCategoryRemoteImpl implements TagCategoryRemote {
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<TagCategoryRespDTO> getByCode(String categoryCode) {
try {
return RpcResponse.success(tagCategoryService.getByCode(categoryCode));
} catch (RpcServiceException e) {
log.error("根据类别代码查询类别 occur RpcServiceException", e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("根据类别代码查询类别 occur Exception", e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<List<TagCategoryRespDTO>> getByCodes(List<String> categoryCodes) {
try {
return RpcResponse.success(tagCategoryService.getByCodes(categoryCodes));
} catch (RpcServiceException e) {
log.error("批量查询类别 occur RpcServiceException", e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("批量查询类别 occur Exception", e);
return RpcResponse.error(e);
}
}
}
......@@ -116,4 +116,17 @@ public class TagDimensionRemoteImpl implements TagDimensionRemote {
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<List<TagDimensionRespDTO>> getByCodes(List<String> dimensionCodes) {
try {
return RpcResponse.success(tagDimensionService.getByCodes(dimensionCodes));
} catch (RpcServiceException e) {
log.error("批量查询维度 occur RpcServiceException", e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("批量查询维度 occur Exception", e);
return RpcResponse.error(e);
}
}
}
......@@ -11,6 +11,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import java.util.List;
/**
* 标签枚举值Remote实现
* @author yangwei_by_claude
......@@ -74,4 +76,43 @@ public class TagEnumRemoteImpl implements TagEnumRemote {
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<TagEnumRespDTO> getByCode(String enumCode) {
try {
return RpcResponse.success(tagEnumService.getByCode(enumCode));
} catch (RpcServiceException e) {
log.error("根据枚举代码查询枚举值 occur RpcServiceException", e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("根据枚举代码查询枚举值 occur Exception", e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<List<TagEnumRespDTO>> listByCategoryCode(String categoryCode) {
try {
return RpcResponse.success(tagEnumService.listByCategoryCode(categoryCode));
} catch (RpcServiceException e) {
log.error("根据类别代码查询枚举值 occur RpcServiceException", e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("根据类别代码查询枚举值 occur Exception", e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<List<TagEnumRespDTO>> getByCodes(List<String> enumCodes) {
try {
return RpcResponse.success(tagEnumService.getByCodes(enumCodes));
} catch (RpcServiceException e) {
log.error("批量查询枚举值 occur RpcServiceException", e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("批量查询枚举值 occur Exception", e);
return RpcResponse.error(e);
}
}
}
......@@ -334,6 +334,27 @@ public class TagCategoryService {
return dto;
}
/**
* 根据类别代码查询类别
*/
public TagCategoryRespDTO getByCode(String categoryCode) {
TagCategory category = Optional.ofNullable(tagCategoryMapper.selectByCategoryCode(categoryCode))
.filter(c -> DeleteFlagEnum.N.getValue().equals(c.getDeletedFlag()))
.orElseThrow(() -> new RpcServiceException(TagErrorEnum.CATEGORY_NOT_EXISTS));
return convertToRespDTO(category);
}
/**
* 根据类别代码列表批量查询类别
*/
public List<TagCategoryRespDTO> getByCodes(List<String> categoryCodes) {
if (categoryCodes == null || categoryCodes.isEmpty()) {
return Collections.emptyList();
}
List<TagCategory> list = tagCategoryMapper.selectByCategoryCodes(categoryCodes);
return list.stream().map(this::convertToRespDTO).collect(Collectors.toList());
}
private TagCategoryRespDTO convertToRespDTO(TagCategory entity) {
TagCategoryRespDTO dto = new TagCategoryRespDTO();
dto.setId(entity.getId());
......
......@@ -276,6 +276,40 @@ public class TagDimensionService {
}
/**
* 根据维度代码列表批量查询维度(含分类名称和路径)
*/
public List<TagDimensionRespDTO> getByCodes(List<String> dimensionCodes) {
if (dimensionCodes == null || dimensionCodes.isEmpty()) {
return Collections.emptyList();
}
List<TagDimension> list = tagDimensionMapper.selectByDimensionCodes(dimensionCodes);
if (list.isEmpty()) {
return Collections.emptyList();
}
// 一次性加载全部分类用于 buildFullPath
Map<Integer, TagCategory> allCategoryMap = tagCategoryMapper.selectAllCategories().stream()
.collect(Collectors.toMap(TagCategory::getId, c -> c));
return list.stream().map(dim -> {
TagDimensionRespDTO dto = new TagDimensionRespDTO();
dto.setId(dim.getId());
dto.setDimensionCode(dim.getDimensionCode());
dto.setDimensionName(dim.getDimensionName());
dto.setCategoryId(dim.getCategoryId());
dto.setSortOrder(dim.getSortOrder());
dto.setCanEdit(dim.getCanEdit());
dto.setCanAddEnum(dim.getCanAddEnum());
TagCategory cat = allCategoryMap.get(dim.getCategoryId());
if (cat != null) {
dto.setCategoryName(cat.getCategoryName());
dto.setCategoryFullPath(tagCategoryService.buildFullPath(cat, allCategoryMap));
}
return dto;
}).collect(Collectors.toList());
}
/**
* TagEnum 实体转 TagEnumRespDTO
*/
private TagEnumRespDTO convertToEnumRespDTO(TagEnum entity) {
......
......@@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Optional;
......@@ -163,4 +164,52 @@ public class TagEnumService {
tagEnum.setUpdatedDate(new Date());
tagEnumMapper.updateByPrimaryKeySelective(tagEnum);
}
/**
* 根据枚举代码查询枚举值
*/
public TagEnumRespDTO getByCode(String enumCode) {
TagEnum entity = Optional.ofNullable(tagEnumMapper.selectByEnumCode(enumCode))
.filter(e -> DeleteFlagEnum.N.getValue().equals(e.getDeletedFlag()))
.orElseThrow(() -> new RpcServiceException(TagErrorEnum.ENUM_NOT_EXISTS));
return convertToDTO(entity);
}
/**
* 根据枚举代码列表批量查询枚举值
*/
public List<TagEnumRespDTO> getByCodes(List<String> enumCodes) {
if (enumCodes == null || enumCodes.isEmpty()) {
return Collections.emptyList();
}
List<TagEnum> list = tagEnumMapper.selectByEnumCodes(enumCodes);
return list.stream().map(this::convertToDTO).collect(Collectors.toList());
}
/**
* 根据类别代码查询其下所有枚举值
*/
public List<TagEnumRespDTO> listByCategoryCode(String categoryCode) {
List<TagEnum> list = tagEnumMapper.selectByCategoryCode(categoryCode);
if (list.isEmpty()) {
return Collections.emptyList();
}
return list.stream().map(this::convertToDTO).collect(Collectors.toList());
}
private TagEnumRespDTO convertToDTO(TagEnum entity) {
TagEnumRespDTO dto = new TagEnumRespDTO();
dto.setId(entity.getId());
dto.setEnumCode(entity.getEnumCode());
dto.setEnumName(entity.getEnumName());
dto.setDimensionId(entity.getDimensionId());
dto.setScore(entity.getScore());
dto.setSortOrder(entity.getSortOrder());
dto.setEnumNameCanEdit(entity.getEnumNameCanEdit());
dto.setScoreCanEdit(entity.getScoreCanEdit());
dto.setRemark(entity.getRemark());
dto.setCreatedDate(entity.getCreatedDate());
dto.setUpdatedDate(entity.getUpdatedDate());
return dto;
}
}
......@@ -98,6 +98,17 @@
</if>
</select>
<!-- 根据类别代码列表批量查询 -->
<select id="selectByCategoryCodes" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
FROM dj_car_life_tag_category
WHERE deleted_flag = 'N'
AND category_code IN
<foreach collection="categoryCodes" item="code" open="(" separator="," close=")">
#{code}
</foreach>
</select>
<!-- 根据分类代码查询分类 -->
<select id="selectByCategoryCode" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
......
......@@ -93,4 +93,20 @@
WHERE d.dimension_code = #{dimensionCode} AND d.deleted_flag = 'N'
</select>
<!-- 根据维度代码列表批量查询维度(含分类名称) -->
<select id="selectByDimensionCodes" resultMap="BaseResultMap">
SELECT d.id, d.dimension_code, d.dimension_name, d.category_id, d.sort_order,
d.can_edit, d.can_add_enum, d.deleted_flag, d.created_by, d.created_date, d.updated_by, d.updated_date,
c.category_name,
(SELECT COUNT(1) FROM dj_car_life_tag_enum e
WHERE e.dimension_id = d.id AND e.deleted_flag = 'N') AS enum_count
FROM dj_car_life_tag_dimension d
LEFT JOIN dj_car_life_tag_category c ON d.category_id = c.id
WHERE d.deleted_flag = 'N'
AND d.dimension_code IN
<foreach collection="dimensionCodes" item="code" open="(" separator="," close=")">
#{code}
</foreach>
</select>
</mapper>
......@@ -76,4 +76,35 @@
ORDER BY sort_order ASC
</select>
<!-- 根据枚举代码查询枚举值 -->
<select id="selectByEnumCode" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
FROM dj_car_life_tag_enum
WHERE enum_code = #{enumCode} AND deleted_flag = 'N'
</select>
<!-- 根据枚举代码列表批量查询枚举值 -->
<select id="selectByEnumCodes" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
FROM dj_car_life_tag_enum
WHERE deleted_flag = 'N'
AND enum_code IN
<foreach collection="enumCodes" item="code" open="(" separator="," close=")">
#{code}
</foreach>
</select>
<!-- 根据类别代码查询其下所有枚举值(通过维度表关联) -->
<select id="selectByCategoryCode" resultMap="BaseResultMap">
SELECT e.id, e.enum_code, e.enum_name, e.dimension_id, e.score, e.sort_order,
e.enum_name_can_edit, e.score_can_edit, e.remark, e.deleted_flag,
e.created_by, e.created_date, e.updated_by, e.updated_date
FROM dj_car_life_tag_enum e
INNER JOIN dj_car_life_tag_dimension d ON e.dimension_id = d.id AND d.deleted_flag = 'N'
INNER JOIN dj_car_life_tag_category c ON d.category_id = c.id AND c.deleted_flag = 'N'
WHERE e.deleted_flag = 'N'
AND c.category_code = #{categoryCode}
ORDER BY d.sort_order ASC, e.sort_order ASC
</select>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!