Commit 0b0c4d06 authored by Menethil's avatar Menethil
Browse files

修改将朋友圈分享图URL写入Good表中,防止更换对象存储导致URL失效

parent 42834c54
......@@ -90,6 +90,10 @@ public class AdminGoodsController {
TransactionStatus status = txManager.getTransaction(def);
try {
//将生成的分享图片地址写入数据库
qCodeService.createGoodShareImage(goods.getId().toString(), goods.getPicUrl(), goods.getName());
goods.setShareUrl(qCodeService.getShareImageUrl(goods.getId().toString()));
// 商品基本信息表litemall_goods
goodsService.updateById(goods);
......@@ -180,6 +184,11 @@ public class AdminGoodsController {
// 商品基本信息表litemall_goods
goods.setAddTime(LocalDateTime.now());
//将生成的分享图片地址写入数据库
qCodeService.createGoodShareImage(goods.getId().toString(), goods.getPicUrl(), goods.getName());
goods.setShareUrl(qCodeService.getShareImageUrl(goods.getId().toString()));
goodsService.add(goods);
// 商品规格表litemall_goods_specification
......@@ -210,9 +219,6 @@ public class AdminGoodsController {
}
txManager.commit(status);
qCodeService.createGoodShareImage(goods.getId().toString(), goods.getPicUrl(), goods.getName());
return ResponseUtil.ok();
}
......
......@@ -61,7 +61,7 @@ public class SystemConfig extends BaseConfig {
}
public static boolean isAutoCreateShareImage() {
int autoCreate = getConfigInt("shareimage.autocreate");
int autoCreate = getConfigInt(PRE_FIX + "shareimage.autocreate");
return autoCreate == 0 ? false : true;
}
......
......@@ -123,6 +123,15 @@ public class LitemallGoods {
*/
private String picUrl;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_goods.share_url
*
* @mbg.generated
*/
private String shareUrl;
/**
*
* This field was generated by MyBatis Generator.
......@@ -468,6 +477,30 @@ public class LitemallGoods {
this.picUrl = picUrl;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_goods.share_url
*
* @return the value of litemall_goods.share_url
*
* @mbg.generated
*/
public String getShareUrl() {
return shareUrl;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_goods.share_url
*
* @param shareUrl the value for litemall_goods.share_url
*
* @mbg.generated
*/
public void setShareUrl(String shareUrl) {
this.shareUrl = shareUrl;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_goods.is_new
......@@ -707,6 +740,7 @@ public class LitemallGoods {
sb.append(", isOnSale=").append(isOnSale);
sb.append(", sortOrder=").append(sortOrder);
sb.append(", picUrl=").append(picUrl);
sb.append(", shareUrl=").append(shareUrl);
sb.append(", isNew=").append(isNew);
sb.append(", isHot=").append(isHot);
sb.append(", unit=").append(unit);
......@@ -749,6 +783,7 @@ public class LitemallGoods {
&& (this.getIsOnSale() == null ? other.getIsOnSale() == null : this.getIsOnSale().equals(other.getIsOnSale()))
&& (this.getSortOrder() == null ? other.getSortOrder() == null : this.getSortOrder().equals(other.getSortOrder()))
&& (this.getPicUrl() == null ? other.getPicUrl() == null : this.getPicUrl().equals(other.getPicUrl()))
&& (this.getShareUrl() == null ? other.getShareUrl() == null : this.getShareUrl().equals(other.getShareUrl()))
&& (this.getIsNew() == null ? other.getIsNew() == null : this.getIsNew().equals(other.getIsNew()))
&& (this.getIsHot() == null ? other.getIsHot() == null : this.getIsHot().equals(other.getIsHot()))
&& (this.getUnit() == null ? other.getUnit() == null : this.getUnit().equals(other.getUnit()))
......@@ -781,6 +816,7 @@ public class LitemallGoods {
result = prime * result + ((getIsOnSale() == null) ? 0 : getIsOnSale().hashCode());
result = prime * result + ((getSortOrder() == null) ? 0 : getSortOrder().hashCode());
result = prime * result + ((getPicUrl() == null) ? 0 : getPicUrl().hashCode());
result = prime * result + ((getShareUrl() == null) ? 0 : getShareUrl().hashCode());
result = prime * result + ((getIsNew() == null) ? 0 : getIsNew().hashCode());
result = prime * result + ((getIsHot() == null) ? 0 : getIsHot().hashCode());
result = prime * result + ((getUnit() == null) ? 0 : getUnit().hashCode());
......@@ -823,6 +859,7 @@ public class LitemallGoods {
isOnSale("is_on_sale", "isOnSale", "BIT"),
sortOrder("sort_order", "sortOrder", "SMALLINT"),
picUrl("pic_url", "picUrl", "VARCHAR"),
shareUrl("share_url", "shareUrl", "VARCHAR"),
isNew("is_new", "isNew", "BIT"),
isHot("is_hot", "isHot", "BIT"),
unit("unit", "unit", "VARCHAR"),
......
......@@ -981,6 +981,76 @@ public class LitemallGoodsExample {
return (Criteria) this;
}
public Criteria andShareUrlIsNull() {
addCriterion("share_url is null");
return (Criteria) this;
}
public Criteria andShareUrlIsNotNull() {
addCriterion("share_url is not null");
return (Criteria) this;
}
public Criteria andShareUrlEqualTo(String value) {
addCriterion("share_url =", value, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlNotEqualTo(String value) {
addCriterion("share_url <>", value, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlGreaterThan(String value) {
addCriterion("share_url >", value, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlGreaterThanOrEqualTo(String value) {
addCriterion("share_url >=", value, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlLessThan(String value) {
addCriterion("share_url <", value, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlLessThanOrEqualTo(String value) {
addCriterion("share_url <=", value, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlLike(String value) {
addCriterion("share_url like", value, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlNotLike(String value) {
addCriterion("share_url not like", value, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlIn(List<String> values) {
addCriterion("share_url in", values, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlNotIn(List<String> values) {
addCriterion("share_url not in", values, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlBetween(String value1, String value2) {
addCriterion("share_url between", value1, value2, "shareUrl");
return (Criteria) this;
}
public Criteria andShareUrlNotBetween(String value1, String value2) {
addCriterion("share_url not between", value1, value2, "shareUrl");
return (Criteria) this;
}
public Criteria andIsNewIsNull() {
addCriterion("is_new is null");
return (Criteria) this;
......
......@@ -17,6 +17,7 @@
<result column="is_on_sale" jdbcType="BIT" property="isOnSale" />
<result column="sort_order" jdbcType="SMALLINT" property="sortOrder" />
<result column="pic_url" jdbcType="VARCHAR" property="picUrl" />
<result column="share_url" jdbcType="VARCHAR" property="shareUrl" />
<result column="is_new" jdbcType="BIT" property="isNew" />
<result column="is_hot" jdbcType="BIT" property="isHot" />
<result column="unit" jdbcType="VARCHAR" property="unit" />
......@@ -143,8 +144,8 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, goods_sn, `name`, category_id, brand_id, gallery, keywords, brief, is_on_sale,
sort_order, pic_url, is_new, is_hot, unit, counter_price, retail_price, add_time,
deleted, version
sort_order, pic_url, share_url, is_new, is_hot, unit, counter_price, retail_price,
add_time, deleted, version
</sql>
<sql id="Blob_Column_List">
<!--
......@@ -209,8 +210,8 @@
</when>
<otherwise>
id, goods_sn, `name`, category_id, brand_id, gallery, keywords, brief, is_on_sale,
sort_order, pic_url, is_new, is_hot, unit, counter_price, retail_price, add_time,
deleted, version, detail
sort_order, pic_url, share_url, is_new, is_hot, unit, counter_price, retail_price,
add_time, deleted, version, detail
</otherwise>
</choose>
from litemall_goods
......@@ -274,8 +275,8 @@
</when>
<otherwise>
id, goods_sn, `name`, category_id, brand_id, gallery, keywords, brief, is_on_sale,
sort_order, pic_url, is_new, is_hot, unit, counter_price, retail_price, add_time,
deleted, version, detail
sort_order, pic_url, share_url, is_new, is_hot, unit, counter_price, retail_price,
add_time, deleted, version, detail
</otherwise>
</choose>
from litemall_goods
......@@ -310,15 +311,15 @@
insert into litemall_goods (goods_sn, `name`, category_id,
brand_id, gallery,
keywords, brief, is_on_sale,
sort_order, pic_url, is_new,
is_hot, unit, counter_price,
sort_order, pic_url, share_url,
is_new, is_hot, unit, counter_price,
retail_price, add_time, deleted,
version, detail)
values (#{goodsSn,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{categoryId,jdbcType=INTEGER},
#{brandId,jdbcType=INTEGER}, #{gallery,jdbcType=VARCHAR,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler},
#{keywords,jdbcType=VARCHAR}, #{brief,jdbcType=VARCHAR}, #{isOnSale,jdbcType=BIT},
#{sortOrder,jdbcType=SMALLINT}, #{picUrl,jdbcType=VARCHAR}, #{isNew,jdbcType=BIT},
#{isHot,jdbcType=BIT}, #{unit,jdbcType=VARCHAR}, #{counterPrice,jdbcType=DECIMAL},
#{sortOrder,jdbcType=SMALLINT}, #{picUrl,jdbcType=VARCHAR}, #{shareUrl,jdbcType=VARCHAR},
#{isNew,jdbcType=BIT}, #{isHot,jdbcType=BIT}, #{unit,jdbcType=VARCHAR}, #{counterPrice,jdbcType=DECIMAL},
#{retailPrice,jdbcType=DECIMAL}, #{addTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT},
#{version,jdbcType=INTEGER}, #{detail,jdbcType=LONGVARCHAR})
</insert>
......@@ -362,6 +363,9 @@
<if test="picUrl != null">
pic_url,
</if>
<if test="shareUrl != null">
share_url,
</if>
<if test="isNew != null">
is_new,
</if>
......@@ -421,6 +425,9 @@
<if test="picUrl != null">
#{picUrl,jdbcType=VARCHAR},
</if>
<if test="shareUrl != null">
#{shareUrl,jdbcType=VARCHAR},
</if>
<if test="isNew != null">
#{isNew,jdbcType=BIT},
</if>
......@@ -500,6 +507,9 @@
<if test="record.picUrl != null">
pic_url = #{record.picUrl,jdbcType=VARCHAR},
</if>
<if test="record.shareUrl != null">
share_url = #{record.shareUrl,jdbcType=VARCHAR},
</if>
<if test="record.isNew != null">
is_new = #{record.isNew,jdbcType=BIT},
</if>
......@@ -549,6 +559,7 @@
is_on_sale = #{record.isOnSale,jdbcType=BIT},
sort_order = #{record.sortOrder,jdbcType=SMALLINT},
pic_url = #{record.picUrl,jdbcType=VARCHAR},
share_url = #{record.shareUrl,jdbcType=VARCHAR},
is_new = #{record.isNew,jdbcType=BIT},
is_hot = #{record.isHot,jdbcType=BIT},
unit = #{record.unit,jdbcType=VARCHAR},
......@@ -579,6 +590,7 @@
is_on_sale = #{record.isOnSale,jdbcType=BIT},
sort_order = #{record.sortOrder,jdbcType=SMALLINT},
pic_url = #{record.picUrl,jdbcType=VARCHAR},
share_url = #{record.shareUrl,jdbcType=VARCHAR},
is_new = #{record.isNew,jdbcType=BIT},
is_hot = #{record.isHot,jdbcType=BIT},
unit = #{record.unit,jdbcType=VARCHAR},
......@@ -628,6 +640,9 @@
<if test="picUrl != null">
pic_url = #{picUrl,jdbcType=VARCHAR},
</if>
<if test="shareUrl != null">
share_url = #{shareUrl,jdbcType=VARCHAR},
</if>
<if test="isNew != null">
is_new = #{isNew,jdbcType=BIT},
</if>
......@@ -674,6 +689,7 @@
is_on_sale = #{isOnSale,jdbcType=BIT},
sort_order = #{sortOrder,jdbcType=SMALLINT},
pic_url = #{picUrl,jdbcType=VARCHAR},
share_url = #{shareUrl,jdbcType=VARCHAR},
is_new = #{isNew,jdbcType=BIT},
is_hot = #{isHot,jdbcType=BIT},
unit = #{unit,jdbcType=VARCHAR},
......@@ -701,6 +717,7 @@
is_on_sale = #{isOnSale,jdbcType=BIT},
sort_order = #{sortOrder,jdbcType=SMALLINT},
pic_url = #{picUrl,jdbcType=VARCHAR},
share_url = #{shareUrl,jdbcType=VARCHAR},
is_new = #{isNew,jdbcType=BIT},
is_hot = #{isHot,jdbcType=BIT},
unit = #{unit,jdbcType=VARCHAR},
......@@ -762,8 +779,8 @@
</when>
<otherwise>
id, goods_sn, `name`, category_id, brand_id, gallery, keywords, brief, is_on_sale,
sort_order, pic_url, is_new, is_hot, unit, counter_price, retail_price, add_time,
deleted, version, detail
sort_order, pic_url, share_url, is_new, is_hot, unit, counter_price, retail_price,
add_time, deleted, version, detail
</otherwise>
</choose>
from litemall_goods
......
......@@ -3,12 +3,11 @@ package org.linlinjava.litemall.wx.web;
import com.mysql.jdbc.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.qcode.QCodeService;
import org.linlinjava.litemall.core.system.SystemConfig;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.*;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.linlinjava.litemall.core.system.SystemConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -50,8 +49,6 @@ public class WxGoodsController {
private LitemallSearchHistoryService searchHistoryService;
@Autowired
private LitemallGoodsSpecificationService goodsSpecificationService;
@Autowired
private QCodeService qCodeService;
/**
......@@ -151,7 +148,7 @@ public class WxGoodsController {
data.put("brand", brand);
//商品分享图片地址
data.put("shareImage", qCodeService.getShareImageUrl(info.getId().toString()));
data.put("shareImage", info.getShareUrl());
return ResponseUtil.ok(data);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment