feat(商城): 首页

金刚位跳转代码优化
master
wayn 4 years ago
parent cf067781fa
commit a600d1c641

@ -44,8 +44,7 @@ public class ColumnController extends BaseController {
ColumnVO columnVO = new ColumnVO();
try {
BeanUtils.copyProperties(columnVO, item);
int count = iColumnGoodsRelationService.count(new QueryWrapper<ColumnGoodsRelation>()
.eq("column_id", item.getId()));
Integer count = iColumnGoodsRelationService.getGoodsNum(item.getId());
columnVO.setGoodsNum(count);
} catch (IllegalAccessException e) {
e.printStackTrace();

@ -13,4 +13,5 @@ import com.wayn.common.core.domain.shop.ColumnGoodsRelation;
*/
public interface ColumnGoodsRelationMapper extends BaseMapper<ColumnGoodsRelation> {
Integer getGoodsNum(Long columnId);
}

@ -13,4 +13,10 @@ import com.wayn.common.core.domain.shop.ColumnGoodsRelation;
*/
public interface IColumnGoodsRelationService extends IService<ColumnGoodsRelation> {
/**
*
* @param columnId ID
* @return
*/
Integer getGoodsNum(Long columnId);
}

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wayn.common.core.domain.shop.ColumnGoodsRelation;
import com.wayn.common.core.mapper.shop.ColumnGoodsRelationMapper;
import com.wayn.common.core.service.shop.IColumnGoodsRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@ -17,4 +18,11 @@ import org.springframework.stereotype.Service;
@Service
public class ColumnGoodsRelationServiceImpl extends ServiceImpl<ColumnGoodsRelationMapper, ColumnGoodsRelation> implements IColumnGoodsRelationService {
@Autowired
private ColumnGoodsRelationMapper columnGoodsRelationMapper;
@Override
public Integer getGoodsNum(Long columnId) {
return columnGoodsRelationMapper.getGoodsNum(columnId);
}
}

@ -11,8 +11,13 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id,
select id,
column_id, goods_id
from shop_column_goods_relation
</sql>
<select id="getGoodsNum" resultType="java.lang.Integer">
SELECT count(1)
FROM (SELECT COUNT(1) FROM shop_column_goods_relation WHERE column_id = #{columnId} GROUP BY goods_id) a
</select>
</mapper>

Loading…
Cancel
Save