Authored by mali

二手

package com.yoho.product.dal;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yoho.product.model.SecondhandFlaw;
public interface SecondhandFlawMapper {
List<SecondhandFlaw> selectByType(@Param("type") Integer type);
List<SecondhandFlaw> selectByIds(@Param("type") String ids);
}
\ No newline at end of file
... ...
package com.yoho.product.model;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class SecondhandFlaw {
private Integer id;
private Integer type;
private String name;
private String attr;
private Integer orderBy;
}
\ No newline at end of file
... ...
package com.yoho.product.model;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class SecondhandImages {
private Integer id;
private Integer skup;
private Integer type;
private Integer type; // '图片类型 1:固定区图片 2:勾选瑕疵图片',
private String isDefault;
private String imageUrl;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getSkup() {
return skup;
}
public void setSkup(Integer skup) {
this.skup = skup;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getIsDefault() {
return isDefault;
}
public void setIsDefault(String isDefault) {
this.isDefault = isDefault;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
private Integer code; //'图片对应码'
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yoho.product.dal.SecondhandFlawMapper">
<resultMap id="BaseResultMap" type="com.yoho.product.model.SecondhandFlaw">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="attr" jdbcType="VARCHAR" property="attr" />
<result column="order_by" jdbcType="INTEGER" property="orderBy" />
</resultMap>
<select id="selectByType" resultMap="BaseResultMap">
select id, type, name, attr, order_by
from secondhand_flaw
where type=#{type}
order by order_by
</select>
<select id="selectByIds" resultMap="BaseResultMap">
select * from secondhand_flaw where id in(${ids})
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -7,10 +7,11 @@
<result column="type" jdbcType="INTEGER" property="type" />
<result column="is_default" jdbcType="CHAR" property="isDefault" />
<result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
<result column="code" jdbcType="code" property="type" />
</resultMap>
<select id="selectBySkups" resultMap="BaseResultMap">
select id, skup, type, is_default, image_url
select id, skup, type, is_default, image_url, code
from secondhand_images where skup in
<foreach collection="skupList" item="skup" open="(" close=")" separator=",">
#{skup}
... ...
package com.yoho.ufo.service.impl;
import com.yoho.product.dal.SecondhandImagesMapper;
import com.yoho.product.model.SecondhandImages;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by li.ma on 2019/4/11.
*/
@Service
public class SecondhandImagesService {
@Autowired
private SecondhandImagesMapper secondhandImagesMapper;
public Map<Integer, List<SecondhandImages>> selectBySkups(List<Integer> skupList) {
List<SecondhandImages> secondhandImages = secondhandImagesMapper.selectBySkups(skupList);
secondhandImages.stream().forEach(item -> item.setImageUrl(item.getImageUrl()));
Map<Integer, List<SecondhandImages>> imageInfoMap = secondhandImages.stream().collect(Collectors.groupingBy(SecondhandImages::getSkup));
return imageInfoMap;
}
}
... ...
... ... @@ -13,6 +13,7 @@ datasources:
- com.yoho.product.dal.AuditRejectInfoMapper
- com.yoho.product.dal.SecondhandInfoMapper
- com.yoho.product.dal.SecondhandImagesMapper
- com.yoho.product.dal.SecondhandFlawMapper
ufo_order:
servers:
... ...
... ... @@ -13,6 +13,7 @@ datasources:
- com.yoho.product.dal.AuditRejectInfoMapper
- com.yoho.product.dal.SecondhandInfoMapper
- com.yoho.product.dal.SecondhandImagesMapper
- com.yoho.product.dal.SecondhandFlawMapper
ufo_order:
servers:
... ...