Authored by mali

根据品类查询其尺码的集合

... ... @@ -56,4 +56,11 @@ public interface UfoSizeMapper {
* @return
*/
List<Size> getSizePageList(@Param("size") Size size, @Param("page") PageModel pageModel);
/**
* 根据品类查询所有的尺码
* @param sortId
* @return
*/
List<Size> selectAllSizeBySortId(@Param("sortId") Integer sortId);
}
... ...
... ... @@ -78,4 +78,9 @@
limit #{page.startIndex}, #{page.pageSize}
</select>
<select id="selectAllSizeBySortId" resultMap="sizeMap">
select <include refid="queryColumns"/>
from size where sort_id = #{sortId}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -49,4 +49,10 @@ public class SizeController {
LOGGER.info("getSizePageList param = {}", sizeRequestBo);
return new ApiResponse<>(sizeService.getSizePageList(sizeRequestBo));
}
@RequestMapping(value = "/queryAllSize4Goods", method = RequestMethod.GET)
public ApiResponse<Object> queryAllSize4Goods(Integer sortId) {
LOGGER.info("queryAllSize4Goods method in.");
return new ApiResponse<>(sizeService.queryAllSize4Goods(sortId));
}
}
... ...
package com.yoho.ufo.service;
import com.alibaba.fastjson.JSONObject;
import com.yohobuy.ufo.model.common.PageResponseBO;
import com.yohobuy.ufo.model.request.productcolor.ProductColorRequestBo;
import com.yohobuy.ufo.model.request.productcolor.ProductColorResponsetBo;
import com.yohobuy.ufo.model.request.size.SizeRequestBo;
import com.yohobuy.ufo.model.request.size.SizeResponseBo;
import java.util.List;
/**
* 品类接口
* @author kun.wang
... ... @@ -34,4 +37,9 @@ public interface ISizeService {
*/
PageResponseBO<SizeResponseBo> getSizePageList(SizeRequestBo sizeRequestBo);
/**
* 查询所有的颜色,下拉框使用
* @return
*/
List<JSONObject> queryAllSize4Goods(Integer sortId);
}
... ...
package com.yoho.ufo.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.ufo.dal.UfoSizeMapper;
import com.yoho.ufo.model.brand.BrandSeries;
import com.yoho.ufo.model.commoditybasicrole.size.Size;
import com.yoho.ufo.service.ISizeService;
import com.yoho.ufo.util.OrikaUtils;
... ... @@ -14,6 +16,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
... ... @@ -64,4 +67,22 @@ public class SizeServiceImpl implements ISizeService {
List<SizeResponseBo> responseBos = OrikaUtils.mapToList(sizeList, SizeResponseBo.class);
return new PageResponseBO<>(count, responseBos, pageModel.getCurrentPage(), pageModel.getPageSize());
}
/**
* 查询所有的颜色,下拉框使用
* @return
*/
public List<JSONObject> queryAllSize4Goods(Integer sortId) {
// TODO 可以添加缓存
List<Size> sizes = ufoSizeMapper.selectAllSizeBySortId(sortId);
List<JSONObject> result = new ArrayList<>();
JSONObject jsonObject;
for (Size item : sizes) {
jsonObject = new JSONObject();
jsonObject.put("id", item.getId());
jsonObject.put("text", item.getSizeName());
result.add(jsonObject);
}
return result;
}
}
... ...