@Override
public ItemModel getItemById(Integer id) {
ItemDo itemDo = itemDoMapper.selectByPrimaryKey(id);
if (itemDo == null) {
return null;
}
//操作获得库存的数量
//!!!!!返回为空指针
ItemStockDo itemStockDo = itemStockDoMapper.selectByItemId(itemDo.getId());
//将dataObject->Model
ItemModel itemModel = convertFromObject(itemDo, itemStockDo);
return itemModel;
}
<select id="selectByItemId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from item_stock
where item_id = #{itemId,jdbcType=INTEGER}
</select>