|
|
|
@ -1,13 +1,22 @@ |
|
|
|
package cn.chjyj.szwh.service.impl; |
|
|
|
|
|
|
|
import cn.chjyj.szwh.bean.GoodsDetail; |
|
|
|
import cn.chjyj.szwh.exception.ChException; |
|
|
|
import cn.chjyj.szwh.mapper.GoodsDetailMapper; |
|
|
|
import cn.chjyj.szwh.service.GoodsDetailService; |
|
|
|
import cn.chjyj.szwh.utils.ProperUtils; |
|
|
|
import cn.chjyj.szwh.utils.RequestUtils; |
|
|
|
import cn.chjyj.szwh.utils.SignUtils; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class GoodsDetailServiceImpl implements GoodsDetailService { |
|
|
|
// 日志
|
|
|
|
private static Log log = LogFactory.getLog(GoodsDetailServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private GoodsDetailMapper goodsDetailMapper; |
|
|
|
|
|
|
|
@ -15,4 +24,27 @@ public class GoodsDetailServiceImpl implements GoodsDetailService { |
|
|
|
public GoodsDetail getGoodsDetailBygid(Integer goodDetailId) { |
|
|
|
return goodsDetailMapper.getGoodsDetailBygid(goodDetailId); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int getRemoteGoodsImageAndUpdate(String image, Integer id) { |
|
|
|
String remote_goodsurl= ProperUtils.getSzwhProp("REAL_URL")+ "/dist/api/v2/preview?url="+image; |
|
|
|
// 签名
|
|
|
|
String sign= SignUtils.createSign("distribute"); |
|
|
|
JSONObject jsonObject = RequestUtils.doGetUrlData(remote_goodsurl,"dist_token",sign); |
|
|
|
log.debug("remote result:"+jsonObject); |
|
|
|
String retcode = jsonObject.getString("resultCode"); |
|
|
|
if(!"00000000".equalsIgnoreCase(retcode)){ |
|
|
|
log.warn("remote result code :"+retcode); |
|
|
|
throw new ChException("数据获取失败"); |
|
|
|
} |
|
|
|
|
|
|
|
//返回的图片数据
|
|
|
|
String imgdata= jsonObject.getString("data"); |
|
|
|
GoodsDetail goodsDetail = new GoodsDetail(); |
|
|
|
goodsDetail.setId(id); |
|
|
|
goodsDetail.setGoodsImage(imgdata); |
|
|
|
// 执行更新操作
|
|
|
|
goodsDetailMapper.updateGoodsDetail(goodsDetail); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|