Authored by mali

二手

  1 +package com.yoho.product.dal;
  2 +
  3 +import java.util.List;
  4 +import org.apache.ibatis.annotations.Param;
  5 +import com.yoho.product.model.SecondhandFlaw;
  6 +
  7 +public interface SecondhandFlawMapper {
  8 +
  9 + List<SecondhandFlaw> selectByType(@Param("type") Integer type);
  10 +
  11 + List<SecondhandFlaw> selectByIds(@Param("type") String ids);
  12 +}
  1 +package com.yoho.product.model;
  2 +
  3 +import lombok.Data;
  4 +import lombok.ToString;
  5 +
  6 +@Data
  7 +@ToString
  8 +public class SecondhandFlaw {
  9 + private Integer id;
  10 +
  11 + private Integer type;
  12 +
  13 + private String name;
  14 +
  15 + private String attr;
  16 +
  17 + private Integer orderBy;
  18 +}
1 package com.yoho.product.model; 1 package com.yoho.product.model;
2 2
  3 +import lombok.Data;
  4 +import lombok.ToString;
  5 +
  6 +@Data
  7 +@ToString
3 public class SecondhandImages { 8 public class SecondhandImages {
4 private Integer id; 9 private Integer id;
5 10
6 private Integer skup; 11 private Integer skup;
7 12
8 - private Integer type; 13 + private Integer type; // '图片类型 1:固定区图片 2:勾选瑕疵图片',
9 14
10 private String isDefault; 15 private String isDefault;
11 16
12 private String imageUrl; 17 private String imageUrl;
13 18
14 - public Integer getId() {  
15 - return id;  
16 - }  
17 -  
18 - public void setId(Integer id) {  
19 - this.id = id;  
20 - }  
21 -  
22 - public Integer getSkup() {  
23 - return skup;  
24 - }  
25 -  
26 - public void setSkup(Integer skup) {  
27 - this.skup = skup;  
28 - }  
29 -  
30 - public Integer getType() {  
31 - return type;  
32 - }  
33 -  
34 - public void setType(Integer type) {  
35 - this.type = type;  
36 - }  
37 -  
38 - public String getIsDefault() {  
39 - return isDefault;  
40 - }  
41 -  
42 - public void setIsDefault(String isDefault) {  
43 - this.isDefault = isDefault;  
44 - }  
45 -  
46 - public String getImageUrl() {  
47 - return imageUrl;  
48 - }  
49 -  
50 - public void setImageUrl(String imageUrl) {  
51 - this.imageUrl = imageUrl;  
52 - }  
53 - 19 + private Integer code; //'图片对应码'
54 } 20 }
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.yoho.product.dal.SecondhandFlawMapper">
  4 + <resultMap id="BaseResultMap" type="com.yoho.product.model.SecondhandFlaw">
  5 + <id column="id" jdbcType="INTEGER" property="id" />
  6 + <result column="type" jdbcType="INTEGER" property="type" />
  7 + <result column="name" jdbcType="VARCHAR" property="name" />
  8 + <result column="attr" jdbcType="VARCHAR" property="attr" />
  9 + <result column="order_by" jdbcType="INTEGER" property="orderBy" />
  10 + </resultMap>
  11 +
  12 + <select id="selectByType" resultMap="BaseResultMap">
  13 + select id, type, name, attr, order_by
  14 + from secondhand_flaw
  15 + where type=#{type}
  16 + order by order_by
  17 + </select>
  18 +
  19 + <select id="selectByIds" resultMap="BaseResultMap">
  20 + select * from secondhand_flaw where id in(${ids})
  21 + </select>
  22 +
  23 +</mapper>
@@ -7,10 +7,11 @@ @@ -7,10 +7,11 @@
7 <result column="type" jdbcType="INTEGER" property="type" /> 7 <result column="type" jdbcType="INTEGER" property="type" />
8 <result column="is_default" jdbcType="CHAR" property="isDefault" /> 8 <result column="is_default" jdbcType="CHAR" property="isDefault" />
9 <result column="image_url" jdbcType="VARCHAR" property="imageUrl" /> 9 <result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
  10 + <result column="code" jdbcType="code" property="type" />
10 </resultMap> 11 </resultMap>
11 12
12 <select id="selectBySkups" resultMap="BaseResultMap"> 13 <select id="selectBySkups" resultMap="BaseResultMap">
13 - select id, skup, type, is_default, image_url 14 + select id, skup, type, is_default, image_url, code
14 from secondhand_images where skup in 15 from secondhand_images where skup in
15 <foreach collection="skupList" item="skup" open="(" close=")" separator=","> 16 <foreach collection="skupList" item="skup" open="(" close=")" separator=",">
16 #{skup} 17 #{skup}
  1 +package com.yoho.ufo.service.impl;
  2 +
  3 +import com.yoho.product.dal.SecondhandImagesMapper;
  4 +import com.yoho.product.model.SecondhandImages;
  5 +import org.apache.ibatis.annotations.Param;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +import java.util.List;
  10 +import java.util.Map;
  11 +import java.util.stream.Collectors;
  12 +
  13 +/**
  14 + * Created by li.ma on 2019/4/11.
  15 + */
  16 +@Service
  17 +public class SecondhandImagesService {
  18 + @Autowired
  19 + private SecondhandImagesMapper secondhandImagesMapper;
  20 +
  21 + public Map<Integer, List<SecondhandImages>> selectBySkups(List<Integer> skupList) {
  22 + List<SecondhandImages> secondhandImages = secondhandImagesMapper.selectBySkups(skupList);
  23 +
  24 + secondhandImages.stream().forEach(item -> item.setImageUrl(item.getImageUrl()));
  25 +
  26 + Map<Integer, List<SecondhandImages>> imageInfoMap = secondhandImages.stream().collect(Collectors.groupingBy(SecondhandImages::getSkup));
  27 +
  28 + return imageInfoMap;
  29 + }
  30 +}
@@ -13,6 +13,7 @@ datasources: @@ -13,6 +13,7 @@ datasources:
13 - com.yoho.product.dal.AuditRejectInfoMapper 13 - com.yoho.product.dal.AuditRejectInfoMapper
14 - com.yoho.product.dal.SecondhandInfoMapper 14 - com.yoho.product.dal.SecondhandInfoMapper
15 - com.yoho.product.dal.SecondhandImagesMapper 15 - com.yoho.product.dal.SecondhandImagesMapper
  16 + - com.yoho.product.dal.SecondhandFlawMapper
16 17
17 ufo_order: 18 ufo_order:
18 servers: 19 servers:
@@ -13,6 +13,7 @@ datasources: @@ -13,6 +13,7 @@ datasources:
13 - com.yoho.product.dal.AuditRejectInfoMapper 13 - com.yoho.product.dal.AuditRejectInfoMapper
14 - com.yoho.product.dal.SecondhandInfoMapper 14 - com.yoho.product.dal.SecondhandInfoMapper
15 - com.yoho.product.dal.SecondhandImagesMapper 15 - com.yoho.product.dal.SecondhandImagesMapper
  16 + - com.yoho.product.dal.SecondhandFlawMapper
16 17
17 ufo_order: 18 ufo_order:
18 servers: 19 servers: