Authored by caoyan

二手

package com.yohoufo.dal.product;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yohoufo.dal.product.model.SecondhandImages;
public interface SecondhandImagesMapper {
int insertBatch(@Param("records") List<SecondhandImages> record);
List<SecondhandImages> selectBySkup(Integer skup);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.product;
import org.apache.ibatis.annotations.Param;
import com.yohoufo.dal.product.model.SecondhandInfo;
public interface SecondhandInfoMapper {
int insert(@Param("record")SecondhandInfo record);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.product.model;
public class SecondhandImages {
private Integer id;
private Integer skup;
private Integer type;
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;
}
}
\ No newline at end of file
... ...
package com.yohoufo.dal.product.model;
public class SecondhandInfo {
private Integer id;
private Integer skup;
private String flawId;
private String flawAttr;
private String describeInfo;
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 String getFlawId() {
return flawId;
}
public void setFlawId(String flawId) {
this.flawId = flawId;
}
public String getFlawAttr() {
return flawAttr;
}
public void setFlawAttr(String flawAttr) {
this.flawAttr = flawAttr;
}
public String getDescribeInfo() {
return describeInfo;
}
public void setDescribeInfo(String describeInfo) {
this.describeInfo = describeInfo;
}
}
\ 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.yohoufo.dal.product.SecondhandImagesMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.SecondhandImages">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="skup" jdbcType="INTEGER" property="skup" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="is_default" jdbcType="CHAR" property="isDefault" />
<result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
</resultMap>
<insert id="insertBatch">
insert into secondhand_images (skup, type, is_default, image_url)
values
<foreach collection="records" item="item" separator=",">
(#{item.skup,jdbcType=INTEGER}, #{item.type,jdbcType=INTEGER},
#{item.isDefault,jdbcType=CHAR}, #{item.imageUrl,jdbcType=VARCHAR})
</foreach>
</insert>
<select id="selectBySkup" resultMap="BaseResultMap">
select id, skup, type, is_default, image_url
from secondhand_images where skup = #{skup,jdbcType=INTEGER};
</select>
</mapper>
\ 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.yohoufo.dal.product.SecondhandInfoMapper" >
<resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.SecondhandInfo" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="skup" property="skup" jdbcType="INTEGER" />
<result column="flaw_id" property="flawId" jdbcType="VARCHAR" />
<result column="flaw_attr" property="flawAttr" jdbcType="VARCHAR" />
<result column="describe_info" property="describe_info" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, skup, flaw_id, flaw_attr, describe_info, create_time
</sql>
<insert id="insert" useGeneratedKeys="true" keyProperty="record.id" >
insert into secondhand_info (skup, flaw_id, flaw_attr, describe_info, create_time)
values (#{record.skup,jdbcType=INTEGER}, #{record.flawId,jdbcType=VARCHAR},
#{record.flawAttr,jdbcType=VARCHAR}, #{record.describeInfo,jdbcType=VARCHAR}, unix_timestamp())
</insert>
</mapper>
\ No newline at end of file
... ...
... ... @@ -38,5 +38,4 @@ public class SecondhandProductController {
List<SecondhandFlaw> list = secondhandProductService.queryFlawListByType(type);
return new ApiResponse.ApiResponseBuilder().data(list).code(200).message("secondhandFlaw list.").build();
}
}
\ No newline at end of file
... ...
... ... @@ -3,8 +3,11 @@ package com.yohoufo.product.service;
import java.util.List;
import com.yohoufo.dal.product.model.SecondhandFlaw;
import com.yohoufo.dal.product.model.SecondhandImages;
public interface SecondhandProductService {
List<SecondhandFlaw> queryFlawListByType(Integer type);
int saveSkupInfo(Integer skup, String flawId, String flawAttr, String describeInfo, List<SecondhandImages> list);
}
... ...
... ... @@ -8,7 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yohoufo.dal.product.SecondhandFlawMapper;
import com.yohoufo.dal.product.SecondhandImagesMapper;
import com.yohoufo.dal.product.SecondhandInfoMapper;
import com.yohoufo.dal.product.model.SecondhandFlaw;
import com.yohoufo.dal.product.model.SecondhandImages;
import com.yohoufo.dal.product.model.SecondhandInfo;
import com.yohoufo.product.service.SecondhandProductService;
... ... @@ -19,11 +23,33 @@ public class SecondhandProductServiceImpl implements SecondhandProductService {
@Autowired
private SecondhandFlawMapper secondhandFlawMapper;
@Autowired
private SecondhandImagesMapper secondhandImagesMapper;
@Autowired
private SecondhandInfoMapper secondhandInfoMapper;
@Override
public List<SecondhandFlaw> queryFlawListByType(Integer type) {
return secondhandFlawMapper.selectByType(type);
}
@Override
public int saveSkupInfo(Integer skup, String flawId, String flawAttr, String describeInfo, List<SecondhandImages> list) {
//保存图片
int num = secondhandImagesMapper.insertBatch(list);
if(num == 0) {
return num;
}
SecondhandInfo record = new SecondhandInfo();
record.setSkup(skup);
record.setFlawId(flawId);
record.setFlawAttr(flawAttr);
record.setDescribeInfo(describeInfo);
return secondhandInfoMapper.insert(record);
}
}
... ...
... ... @@ -43,6 +43,8 @@ datasources:
- com.yohoufo.dal.product.ProductSelfShelvesMapper
- com.yohoufo.dal.product.ProductSelfShelvesPicMapper
- com.yohoufo.dal.product.SecondhandFlawMapper
- com.yohoufo.dal.product.SecondhandImagesMapper
- com.yohoufo.dal.product.SecondhandInfoMapper
ufo_order:
... ...
... ... @@ -43,6 +43,8 @@ datasources:
- com.yohoufo.dal.product.ProductSelfShelvesMapper
- com.yohoufo.dal.product.ProductSelfShelvesPicMapper
- com.yohoufo.dal.product.SecondhandFlawMapper
- com.yohoufo.dal.product.SecondhandImagesMapper
- com.yohoufo.dal.product.SecondhandInfoMapper
ufo_order:
servers:
... ...