Authored by mali

基础商品支持详情

  1 +package com.yoho.product;
  2 +
  3 +import com.yoho.product.model.UfoProductIntro;
  4 +
  5 +/**
  6 + * Created by li.ma on 2018/12/7.
  7 + */
  8 +public interface UfoProductIntroMapper {
  9 + UfoProductIntro selectByPrimaryKey(Integer productId);
  10 +
  11 + int insertProductDesc(UfoProductIntro productIntro);
  12 +}
  1 +package com.yoho.product.model;
  2 +
  3 +/**
  4 + * Created by li.ma on 2018/12/7.
  5 + */
  6 +public class UfoProductIntro {
  7 + private Integer productId;
  8 + private String productIntro;
  9 +
  10 + public UfoProductIntro(Integer productId, String productIntro) {
  11 + this.productId = productId;
  12 + this.productIntro = productIntro;
  13 + }
  14 +
  15 + public UfoProductIntro() {
  16 + }
  17 +
  18 + public Integer getProductId() {
  19 + return this.productId;
  20 + }
  21 +
  22 + public void setProductId(Integer productId) {
  23 + this.productId = productId;
  24 + }
  25 +
  26 + public String getProductIntro() {
  27 + return this.productIntro;
  28 + }
  29 +
  30 + public void setProductIntro(String productIntro) {
  31 + this.productIntro = productIntro == null?null:productIntro.trim();
  32 + }
  33 +}
  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.UfoProductIntroMapper" >
  4 + <resultMap id="BaseResultMap" type="com.yoho.product.model.UfoProductIntro" >
  5 + <id column="product_id" property="productId" jdbcType="INTEGER" />
  6 + </resultMap>
  7 + <resultMap id="ResultMapWithBLOBs" type="com.yoho.product.model.UfoProductIntro" extends="BaseResultMap" >
  8 + <result column="product_intro" property="productIntro" jdbcType="LONGVARCHAR" />
  9 + </resultMap>
  10 + <sql id="Base_Column_List" >
  11 + product_id
  12 + </sql>
  13 + <sql id="Blob_Column_List" >
  14 + product_intro
  15 + </sql>
  16 + <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
  17 + select
  18 + <include refid="Base_Column_List" />
  19 + ,
  20 + <include refid="Blob_Column_List" />
  21 + from product_intro
  22 + where product_id = #{productId,jdbcType=INTEGER}
  23 + </select>
  24 +
  25 + <insert id="insertProductDesc" parameterType="com.yoho.product.model.UfoProductIntro" >
  26 + insert into product_intro (product_id, product_intro)
  27 + values (#{productId,jdbcType=INTEGER}, #{productIntro,jdbcType=LONGVARCHAR}) ON DUPLICATE KEY UPDATE product_intro=#{productIntro,jdbcType=LONGVARCHAR}
  28 + </insert>
  29 +
  30 +</mapper>
  1 +package com.yoho.ufo.convert;
  2 +
  3 +import com.yoho.product.model.UfoProductIntro;
  4 +import com.yohobuy.ufo.model.request.product.UfoProductIntroBo;
  5 +
  6 +/**
  7 + * Created by li.ma on 2018/12/7.
  8 + */
  9 +public class ProductIntroConvert {
  10 + public static UfoProductIntroBo convertBo(UfoProductIntro productIntro) {
  11 + if (null == productIntro) {
  12 + return null;
  13 + }
  14 +
  15 + UfoProductIntroBo productIntroBo = new UfoProductIntroBo();
  16 + productIntroBo.setProductId(productIntro.getProductId());
  17 + productIntroBo.setProductIntro(productIntro.getProductIntro());
  18 + return productIntroBo;
  19 + }
  20 +}
  1 +package com.yoho.ufo.service.impl;
  2 +
  3 +import com.yoho.product.UfoProductIntroMapper;
  4 +import com.yoho.product.model.UfoProductIntro;
  5 +import com.yoho.ufo.convert.ProductIntroConvert;
  6 +import com.yohobuy.ufo.model.request.product.UfoProductIntroBo;
  7 +import org.apache.commons.lang3.StringUtils;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Service;
  10 +
  11 +/**
  12 + * Created by li.ma on 2018/12/7.
  13 + * 商品详情页接口
  14 + */
  15 +@Service
  16 +public class ProductIntroService {
  17 + @Autowired
  18 + private UfoProductIntroMapper productIntroMapper;
  19 +
  20 + public String selectProductIntroById(Integer productId) {
  21 + UfoProductIntro productIntro = productIntroMapper.selectByPrimaryKey(productId);
  22 + UfoProductIntroBo ufoProductIntroBo = ProductIntroConvert.convertBo(productIntro);
  23 + return null == ufoProductIntroBo ? null : ufoProductIntroBo.getProductIntro();
  24 + }
  25 +
  26 + public void insertProductDesc(Integer productId, String productIntro) {
  27 + if (null == productId || StringUtils.isEmpty(productIntro)) {
  28 + return;
  29 + }
  30 + productIntroMapper.insertProductDesc(new UfoProductIntro(productId, productIntro));
  31 + }
  32 +}
@@ -78,6 +78,8 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw @@ -78,6 +78,8 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
78 private UfoProductColorMapper colorMapper; 78 private UfoProductColorMapper colorMapper;
79 @Autowired 79 @Autowired
80 private UfoBrandSeriesMapper brandSeriesMapper; 80 private UfoBrandSeriesMapper brandSeriesMapper;
  81 + @Autowired
  82 + private ProductIntroService productIntroService;
81 @Override 83 @Override
82 public ApiResponse<Void> addOrUpdate(ProductRequestBo bo, boolean isCheckUrl) { 84 public ApiResponse<Void> addOrUpdate(ProductRequestBo bo, boolean isCheckUrl) {
83 checkProductInfo(bo, isCheckUrl); 85 checkProductInfo(bo, isCheckUrl);
@@ -130,6 +132,8 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw @@ -130,6 +132,8 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
130 } 132 }
131 } 133 }
132 } 134 }
  135 +
  136 + productIntroService.insertProductDesc(productId, bo.getProductIntro());
133 return new ApiResponse<Void>(null); 137 return new ApiResponse<Void>(null);
134 } 138 }
135 139
@@ -302,6 +306,8 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw @@ -302,6 +306,8 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
302 } 306 }
303 bo.setSuggestPriceList(suggestPriceList); 307 bo.setSuggestPriceList(suggestPriceList);
304 } 308 }
  309 +
  310 + bo.setProductIntro(productIntroService.selectProductIntroById(product.getId()));
305 return new ApiResponse<ProductEditResponceBo>(bo); 311 return new ApiResponse<ProductEditResponceBo>(bo);
306 } 312 }
307 313