产品详情

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,7 +24,7 @@
<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,
@ -61,6 +61,15 @@
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>