Commit 43cb7208 by 崔彦峰

feat(GoodsListing): 添加服务项目ID字段支持

- 在 GoodsListingProductDetail 实体类中新增 serviceItemId 字段
- 在 GoodsListingProductBaseMapper.xml 中映射 service_item_id 列
- 在 GoodsListingProductDetailMapper.xml 中添加 service_item_id 结果映射
- 更新查询语句以包含 service_item_id 字段
- 为 serviceItemId 字段添加注释和 API 文档说明
1 parent ec8044ba
...@@ -185,6 +185,14 @@ public class GoodsListingProductDetail implements Serializable { ...@@ -185,6 +185,14 @@ public class GoodsListingProductDetail implements Serializable {
private String serviceItem; private String serviceItem;
/** /**
* 服务项目id
*/
@ApiModelProperty(name = "serviceItemId", notes = "服务项目id")
@Column(name = "service_item_id")
private Integer serviceItemId;
/**
* 产品成本获取方式 1-自定义成本 2-默认带入产品成本 * 产品成本获取方式 1-自定义成本 2-默认带入产品成本
*/ */
@ApiModelProperty(name = "upgradeProductCostStyle", notes = "产品成本获取方式 1-自定义成本 2-默认带入产品成本") @ApiModelProperty(name = "upgradeProductCostStyle", notes = "产品成本获取方式 1-自定义成本 2-默认带入产品成本")
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
<result column="inventory_type" property="inventoryType" jdbcType="TINYINT" /> <result column="inventory_type" property="inventoryType" jdbcType="TINYINT" />
<result column="merchant_goods_code" property="merchantGoodsCode"/> <result column="merchant_goods_code" property="merchantGoodsCode"/>
<result column="service_item" property="serviceItem" jdbcType="VARCHAR" /> <result column="service_item" property="serviceItem" jdbcType="VARCHAR" />
<result column="service_item_id" property="serviceItemId" jdbcType="INTEGER" />
<result column="upgrade_product_cost_style" property="upgradeProductCostStyle" jdbcType="TINYINT" /> <result column="upgrade_product_cost_style" property="upgradeProductCostStyle" jdbcType="TINYINT" />
<result column="third_party_cost_style" property="thirdPartyCostStyle" jdbcType="TINYINT" /> <result column="third_party_cost_style" property="thirdPartyCostStyle" jdbcType="TINYINT" />
</collection> </collection>
...@@ -87,7 +88,7 @@ ...@@ -87,7 +88,7 @@
glpb.package_alias,glpb.sales_proportion_percent, glpb.shelf_style, glpb.old_merchant_goods_code, glpb.is_gift_cost, glpb.package_alias,glpb.sales_proportion_percent, glpb.shelf_style, glpb.old_merchant_goods_code, glpb.is_gift_cost,
glpd.upgrade_goods_id, glpd.upgrade_commodity_code, glpd.upgrade_goods_name, glpd.upgrade_goods_id, glpd.upgrade_commodity_code, glpd.upgrade_goods_name,
glpd.goods_alias, glpd.position, glpd.sell_price, glpd.min_sell_price, glpd.upgrade_product_cost, glpd.recovery_cost, glpd.goods_alias, glpd.position, glpd.sell_price, glpd.min_sell_price, glpd.upgrade_product_cost, glpd.recovery_cost,
glpd.gift_cost, glpd.third_party_cost, glpd.inventory_type,glpd.merchant_goods_code, glpd.service_item, glpd.upgrade_product_cost_style, glpd.third_party_cost_style glpd.gift_cost, glpd.third_party_cost, glpd.inventory_type,glpd.merchant_goods_code, glpd.service_item, glpd.service_item_id, glpd.upgrade_product_cost_style, glpd.third_party_cost_style
from dj_car_life_goods_listing_product_base glpb from dj_car_life_goods_listing_product_base glpb
left join dj_car_life_goods_listing_product_detail glpd on glpd.product_base_id=glpb.id and glpd.deleted_flag='N' left join dj_car_life_goods_listing_product_detail glpd on glpd.product_base_id=glpb.id and glpd.deleted_flag='N'
where glpb.deleted_flag='N' and glpb.id = #{id} where glpb.deleted_flag='N' and glpb.id = #{id}
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" /> <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" /> <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
<result column="service_item" property="serviceItem" jdbcType="VARCHAR" /> <result column="service_item" property="serviceItem" jdbcType="VARCHAR" />
<result column="service_item_id" property="serviceItemId" jdbcType="INTEGER" />
<result column="upgrade_product_cost_style" property="upgradeProductCostStyle" jdbcType="TINYINT" /> <result column="upgrade_product_cost_style" property="upgradeProductCostStyle" jdbcType="TINYINT" />
<result column="third_party_cost_style" property="thirdPartyCostStyle" jdbcType="TINYINT" /> <result column="third_party_cost_style" property="thirdPartyCostStyle" jdbcType="TINYINT" />
</resultMap> </resultMap>
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
goods_type,goods_type_name, goods_type,goods_type_name,
goods_alias, position, sell_price, min_sell_price, upgrade_product_cost, recovery_cost, goods_alias, position, sell_price, min_sell_price, upgrade_product_cost, recovery_cost,
gift_cost, third_party_cost, inventory_type, created_by, created_date, updated_by, gift_cost, third_party_cost, inventory_type, created_by, created_date, updated_by,
updated_date, deleted_flag, service_item, upgrade_product_cost_style, third_party_cost_style updated_date, deleted_flag, service_item, service_item_id, upgrade_product_cost_style, third_party_cost_style
</sql> </sql>
<select id="list" parameterType="cn.com.glsx.dj.goods.listing.dto.GoodsListingProductDetailDTO" resultMap="DTOResultMap"> <select id="list" parameterType="cn.com.glsx.dj.goods.listing.dto.GoodsListingProductDetailDTO" resultMap="DTOResultMap">
...@@ -54,7 +55,7 @@ ...@@ -54,7 +55,7 @@
glpd.upgrade_commodity_code, glpd.upgrade_goods_name, glpd.goods_type,glpd.goods_type_name, glpd.upgrade_commodity_code, glpd.upgrade_goods_name, glpd.goods_type,glpd.goods_type_name,
glpd.goods_alias, glpd.position, glpd.sell_price, glpd.min_sell_price, glpd.upgrade_product_cost, glpd.recovery_cost, glpd.goods_alias, glpd.position, glpd.sell_price, glpd.min_sell_price, glpd.upgrade_product_cost, glpd.recovery_cost,
glpd.gift_cost, glpd.third_party_cost, glpd.inventory_type, glpd.created_by, glpd.created_date, glpd.updated_by, glpd.gift_cost, glpd.third_party_cost, glpd.inventory_type, glpd.created_by, glpd.created_date, glpd.updated_by,
glpd.updated_date, glpd.deleted_flag, glpd.service_item, glpd.upgrade_product_cost_style, glpd.third_party_cost_style, glpd.updated_date, glpd.deleted_flag, glpd.service_item, glpd.service_item_id, glpd.upgrade_product_cost_style, glpd.third_party_cost_style,
glpb.product_type,glpb.product_name,glpb.package_code glpb.product_type,glpb.product_name,glpb.package_code
from dj_car_life_goods_listing_product_detail glpd from dj_car_life_goods_listing_product_detail glpd
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议,如果必要,给出代码示例(仅限 Top 3)

    1. 潜在的遗漏:是否缺失了 Insert / Update 语句的映射更新?(功能实现的正确性)

    • 问题描述:在 GoodsListingProductDetailMapper.xml 中,本次变更补充了 resultMap、Base_Column_List 以及 select 查询语句中的 service_item_id 字段。但是,代码差异中未体现对 <insert> 和 <update> 标签的修改。
    • 影响分析:如果项目中使用了自定义的 XML 来处理新增和更新操作(而不是完全依赖 TkMyBatis / MyBatis-Plus 的通用 Mapper),遗漏该字段将导致新增加的 serviceItemId 无法被持久化到数据库中。
    • 优化建议:请全局检查相关的 Mapper XML 文件。如果存在自定义的 <insert> 或 <update> 语句,请务必同步添加 service_item_id 的映射。如果项目统一使用框架底层的通用 Mapper 进行写操作,则此条可忽略。

    2. 部署依赖:数据库表结构的同步变更(稳定性与健壮性)

    • 问题描述:代码中引入了新的数据库列 service_item_id。
    • 影响分析:MyBatis 在执行包含新字段的 SQL 时,如果底层数据库表(dj_car_life_goods_listing_product_detail 等)尚未执行对应的 ALTER TABLE 添加该列,会导致线上环境抛出 SQLSyntaxErrorException (Unknown column) 异常,直接引发接口不可用。
    • 优化建议:确保在提交代码的同时,配套的 DDL(数据库变更脚本)已经准备就绪,并在代码发布前或发布时同步执行。

    3. 规范性:Swagger 注解属性的常规用法(最佳实践)

    • 问题描述:在 GoodsListingProductDetail.java 中,使用了 @ApiModelProperty(name = "serviceItemId", notes = "服务项目id")。
    • 影响分析:无功能性影响。但在 Swagger (Springfox) 的常规实践中,name 属性用于重写字段名称(通常不需要,默认即为属性名),而简短的字段说明通常使用 value 属性,notes 一般用于较长的详细说明。
    • 优化建议:为了保持代码的简洁和主流规范,建议将其简化为使用 value 属性。 java // 建议修改为: @ApiModelProperty(value = "服务项目id") @Column(name = "service_item_id") private Integer serviceItemId;

    二、评分明细

    • 功能实现的正确性与健壮性(40/40分): 代码逻辑正确,成功将新字段映射到实体与查询中。特别验证项通过:MyBatis 语句中均使用的是 LEFT JOIN,没有违规使用子查询;变动的类属于实体/DTO 层,未变动 Dubbo Remote 接口的参数,无危险实现。
    • 安全性与潜在风险(30/30分): 仅涉及常规字段的添加,SQL 均使用静态列名或安全的别名引用,不存在 SQL 注入风险,未引发越权或敏感信息泄露隐患。
    • 最佳实践与可维护性(18/20分): 代码结构清晰,使用了包装类 Integer 避免了基本类型的默认值问题,注释完整。扣除的2分在于 Swagger 注解的属性使用可以更加精简标准,以及需确认是否遗漏了自定义的写操作 SQL。
    • 性能与资源利用(5/5分): 在现有查询中增加一个整型字段,对数据库 I/O 和内存开销的增加微乎其微,无性能瓶颈。
    • 提交信息质量(5/5分): Commit message 格式规范(符合 Angular 规范),清晰地描述了修改的内容、涉及的文件以及目的,追溯性极强。

    总分:98分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!