Authored by mali

基础商品支持详情

package com.yoho.product;
import com.yoho.product.model.UfoProductIntro;
/**
* Created by li.ma on 2018/12/7.
*/
public interface UfoProductIntroMapper {
UfoProductIntro selectByPrimaryKey(Integer productId);
int insertProductDesc(UfoProductIntro productIntro);
}
... ...
package com.yoho.product.model;
/**
* Created by li.ma on 2018/12/7.
*/
public class UfoProductIntro {
private Integer productId;
private String productIntro;
public UfoProductIntro(Integer productId, String productIntro) {
this.productId = productId;
this.productIntro = productIntro;
}
public UfoProductIntro() {
}
public Integer getProductId() {
return this.productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public String getProductIntro() {
return this.productIntro;
}
public void setProductIntro(String productIntro) {
this.productIntro = productIntro == null?null:productIntro.trim();
}
}
... ...
<?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.UfoProductIntroMapper" >
<resultMap id="BaseResultMap" type="com.yoho.product.model.UfoProductIntro" >
<id column="product_id" property="productId" jdbcType="INTEGER" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.yoho.product.model.UfoProductIntro" extends="BaseResultMap" >
<result column="product_intro" property="productIntro" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
product_id
</sql>
<sql id="Blob_Column_List" >
product_intro
</sql>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from product_intro
where product_id = #{productId,jdbcType=INTEGER}
</select>
<insert id="insertProductDesc" parameterType="com.yoho.product.model.UfoProductIntro" >
insert into product_intro (product_id, product_intro)
values (#{productId,jdbcType=INTEGER}, #{productIntro,jdbcType=LONGVARCHAR}) ON DUPLICATE KEY UPDATE product_intro=#{productIntro,jdbcType=LONGVARCHAR}
</insert>
</mapper>
\ No newline at end of file
... ...
package com.yoho.ufo.convert;
import com.yoho.product.model.UfoProductIntro;
import com.yohobuy.ufo.model.request.product.UfoProductIntroBo;
/**
* Created by li.ma on 2018/12/7.
*/
public class ProductIntroConvert {
public static UfoProductIntroBo convertBo(UfoProductIntro productIntro) {
if (null == productIntro) {
return null;
}
UfoProductIntroBo productIntroBo = new UfoProductIntroBo();
productIntroBo.setProductId(productIntro.getProductId());
productIntroBo.setProductIntro(productIntro.getProductIntro());
return productIntroBo;
}
}
... ...
package com.yoho.ufo.service.impl;
import com.yoho.product.UfoProductIntroMapper;
import com.yoho.product.model.UfoProductIntro;
import com.yoho.ufo.convert.ProductIntroConvert;
import com.yohobuy.ufo.model.request.product.UfoProductIntroBo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by li.ma on 2018/12/7.
* 商品详情页接口
*/
@Service
public class ProductIntroService {
@Autowired
private UfoProductIntroMapper productIntroMapper;
public String selectProductIntroById(Integer productId) {
UfoProductIntro productIntro = productIntroMapper.selectByPrimaryKey(productId);
UfoProductIntroBo ufoProductIntroBo = ProductIntroConvert.convertBo(productIntro);
return null == ufoProductIntroBo ? null : ufoProductIntroBo.getProductIntro();
}
public void insertProductDesc(Integer productId, String productIntro) {
if (null == productId || StringUtils.isEmpty(productIntro)) {
return;
}
productIntroMapper.insertProductDesc(new UfoProductIntro(productId, productIntro));
}
}
... ...
... ... @@ -78,6 +78,8 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
private UfoProductColorMapper colorMapper;
@Autowired
private UfoBrandSeriesMapper brandSeriesMapper;
@Autowired
private ProductIntroService productIntroService;
@Override
public ApiResponse<Void> addOrUpdate(ProductRequestBo bo, boolean isCheckUrl) {
checkProductInfo(bo, isCheckUrl);
... ... @@ -130,6 +132,8 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
}
}
}
productIntroService.insertProductDesc(productId, bo.getProductIntro());
return new ApiResponse<Void>(null);
}
... ... @@ -302,6 +306,8 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
}
bo.setSuggestPriceList(suggestPriceList);
}
bo.setProductIntro(productIntroService.selectProductIntroById(product.getId()));
return new ApiResponse<ProductEditResponceBo>(bo);
}
... ...