产品详情

master
lzq 2026-01-21 14:59:48 +08:00
parent a93c0588c0
commit 9650d2144e
5 changed files with 50 additions and 42 deletions

View File

@ -58,7 +58,7 @@ public class GoodsController {
* *
*/ */
@GetMapping("/detail") @GetMapping("/detail")
public R<GoodsEntity> detail(@RequestParam("id") Long id) { public R<SearchGoodsResult> detail(@RequestParam("id") Long id) {
return R.success(goodsService.detail(id)); return R.success(goodsService.detail(id));
} }

View File

@ -16,6 +16,8 @@ import org.apache.ibatis.annotations.Param;
@Mapper @Mapper
public interface GoodsMapper extends BaseMapper<GoodsEntity> { public interface GoodsMapper extends BaseMapper<GoodsEntity> {
IPage<SearchGoodsResult> paging(Page<Object> page, @Param("ew") QueryWrapper<Object> ew); IPage<SearchGoodsResult> paging(Page<Object> page, @Param("ew") QueryWrapper<Object> ew);
SearchGoodsResult detail(@Param("ew") QueryWrapper<Object> ew);
} }

View File

@ -22,7 +22,7 @@ public interface GoodsService extends IService<GoodsEntity> {
void del(List<Long> ids); void del(List<Long> ids);
GoodsEntity detail(Long id); SearchGoodsResult detail(Long id);
PageResult<SearchGoodsResult> paging(PageParam pageParam, GoodsEntity goodsEntity); PageResult<SearchGoodsResult> paging(PageParam pageParam, GoodsEntity goodsEntity);

View File

@ -85,11 +85,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, GoodsEntity> impl
} }
@Override @Override
public GoodsEntity detail(Long id) { public SearchGoodsResult detail(Long id) {
GoodsEntity goodsEntity = this.getById(id); return baseMapper.detail(Wrappers.query().eq("a.id", id));
goodsEntity.setExpenseItem(expenseItemService.getOne(Wrappers.<ExpenseItemEntity>lambdaQuery()
.eq(ExpenseItemEntity::getGoodsId, id)));
return this.getById(id);
} }
@Override @Override

View File

@ -24,43 +24,52 @@
<result property="goodsScope" column="goods_scope" typeHandler="com.njzscloud.common.mp.support.handler.j.JsonTypeHandler"/> <result property="goodsScope" column="goods_scope" typeHandler="com.njzscloud.common.mp.support.handler.j.JsonTypeHandler"/>
</association> </association>
</resultMap> </resultMap>
<select id="paging" resultMap="SearchGoodsResultMap"> <sql id="SearchGoodsResultSql">
SELECT a.id, SELECT a.id,
a.goods_category_id, a.goods_category_id,
a.sn, a.sn,
a.goods_name, a.goods_name,
a.spec_params, a.spec_params,
a.picture, a.picture,
a.unit, a.unit,
a.sort, a.sort,
a.canuse, a.canuse,
a.memo, a.memo,
a.create_time, a.create_time,
b.biz_type, b.biz_type,
b.category_name, b.category_name,
b.picture b_picture, b.picture b_picture,
b.sort b_sort, b.sort b_sort,
b.create_time b_create_time, b.create_time b_create_time,
c.id c_id, c.id c_id,
c.expense_item_category, c.expense_item_category,
c.expense_item_name, c.expense_item_name,
c.expense_strategy, c.expense_strategy,
c.unit c_unit, c.unit c_unit,
c.tax_rate, c.tax_rate,
c.payer, c.payer,
c.unit_price, c.unit_price,
c.initial_price, c.initial_price,
c.initial_quantity, c.initial_quantity,
c.every_quantity, c.every_quantity,
c.user_scope, c.user_scope,
c.station_scope, c.station_scope,
c.goods_scope, c.goods_scope,
c.canuse c_canuse, c.canuse c_canuse,
c.memo c_memo, c.memo c_memo,
c.create_time c_create_time c.create_time c_create_time
FROM gds_goods a FROM gds_goods a
INNER JOIN gds_goods_category b ON a.goods_category_id = b.id INNER JOIN gds_goods_category b ON a.goods_category_id = b.id
LEFT JOIN fin_expense_item c ON c.goods_id = a.id LEFT JOIN fin_expense_item c ON c.goods_id = a.id
</sql>
<select id="paging" resultMap="SearchGoodsResultMap">
<include refid="SearchGoodsResultSql"/>
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
${ew.customSqlSegment}
</if>
</select>
<select id="detail" resultMap="SearchGoodsResultMap">
<include refid="SearchGoodsResultSql"/>
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
${ew.customSqlSegment} ${ew.customSqlSegment}
</if> </if>