Commit 9564182c authored by shiyu's avatar shiyu

批量二维码

parent ce646292
......@@ -14,5 +14,7 @@ public interface ItemTagQrCodeDao {
boolean update(ItemTagQrCode itemTagQrCode);
boolean updateByPrimaryKey(ItemTagQrCode itemTagQrCode);
ItemTagQrCode findByCode(String code);
}
package com.wwdz.ch.db.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
* @author shiyu
* @date 2023/09/01
* @date 2024/11/26
*/
@Data
public class Category implements Entity {
......@@ -24,6 +26,26 @@ public class Category implements Entity {
*/
private String desc;
/**
* 视频号id
*/
private String videoAppId;
/**
* 视频id
*/
private String videoId;
/**
* 视频标题
*/
private String videoTitle;
/**
* 视频主图
*/
private String mainImage;
/**
* 父类目ID
*/
......@@ -85,6 +107,10 @@ public class Category implements Entity {
sb.append(", id=").append(id);
sb.append(", name=").append(name);
sb.append(", desc=").append(desc);
sb.append(", videoAppId=").append(videoAppId);
sb.append(", videoId=").append(videoId);
sb.append(", videoTitle=").append(videoTitle);
sb.append(", mainImage=").append(mainImage);
sb.append(", pid=").append(pid);
sb.append(", icon=").append(icon);
sb.append(", level=").append(level);
......@@ -115,6 +141,10 @@ public class Category implements Entity {
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getDesc() == null ? other.getDesc() == null : this.getDesc().equals(other.getDesc()))
&& (this.getVideoAppId() == null ? other.getVideoAppId() == null : this.getVideoAppId().equals(other.getVideoAppId()))
&& (this.getVideoId() == null ? other.getVideoId() == null : this.getVideoId().equals(other.getVideoId()))
&& (this.getVideoTitle() == null ? other.getVideoTitle() == null : this.getVideoTitle().equals(other.getVideoTitle()))
&& (this.getMainImage() == null ? other.getMainImage() == null : this.getMainImage().equals(other.getMainImage()))
&& (this.getPid() == null ? other.getPid() == null : this.getPid().equals(other.getPid()))
&& (this.getIcon() == null ? other.getIcon() == null : this.getIcon().equals(other.getIcon()))
&& (this.getLevel() == null ? other.getLevel() == null : this.getLevel().equals(other.getLevel()))
......@@ -134,6 +164,10 @@ public class Category implements Entity {
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getDesc() == null) ? 0 : getDesc().hashCode());
result = prime * result + ((getVideoAppId() == null) ? 0 : getVideoAppId().hashCode());
result = prime * result + ((getVideoId() == null) ? 0 : getVideoId().hashCode());
result = prime * result + ((getVideoTitle() == null) ? 0 : getVideoTitle().hashCode());
result = prime * result + ((getMainImage() == null) ? 0 : getMainImage().hashCode());
result = prime * result + ((getPid() == null) ? 0 : getPid().hashCode());
result = prime * result + ((getIcon() == null) ? 0 : getIcon().hashCode());
result = prime * result + ((getLevel() == null) ? 0 : getLevel().hashCode());
......@@ -158,6 +192,10 @@ public class Category implements Entity {
id("id", "id", "INTEGER", false),
name("name", "name", "VARCHAR", true),
desc("desc", "desc", "VARCHAR", true),
videoAppId("video_app_id", "videoAppId", "VARCHAR", false),
videoId("video_id", "videoId", "VARCHAR", false),
videoTitle("video_title", "videoTitle", "VARCHAR", false),
mainImage("main_image", "mainImage", "VARCHAR", false),
pid("pid", "pid", "INTEGER", false),
icon("icon", "icon", "VARCHAR", false),
level("level", "level", "INTEGER", true),
......
......@@ -4,12 +4,20 @@ import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class ItemTagQrCodeRequestDto implements Entity {
private Long userId;
private Long id;
/**
* 二维码的数量
*/
private Integer codeNum;
/**
* 二维码编码
*/
......@@ -39,4 +47,9 @@ public class ItemTagQrCodeRequestDto implements Entity {
* 绑定的商品id
*/
private Long itemId;
/**
* 商品图片
*/
private List<String> images;
}
......@@ -28,6 +28,11 @@ public class ItemTagQrCodeDaoImpl implements ItemTagQrCodeDao {
return itemTagQrCodeMapper.updateByExampleSelective(itemTagQrCode, example) > 0;
}
@Override
public boolean updateByPrimaryKey(ItemTagQrCode itemTagQrCode) {
return itemTagQrCodeMapper.updateByPrimaryKeySelective(itemTagQrCode) > 0;
}
@Override
public ItemTagQrCode findByCode(String code) {
ItemTagQrCodeExample example = new ItemTagQrCodeExample();
......
......@@ -5,6 +5,10 @@
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="desc" jdbcType="VARCHAR" property="desc" />
<result column="video_app_id" jdbcType="VARCHAR" property="videoAppId" />
<result column="video_id" jdbcType="VARCHAR" property="videoId" />
<result column="video_title" jdbcType="VARCHAR" property="videoTitle" />
<result column="main_image" jdbcType="VARCHAR" property="mainImage" />
<result column="pid" jdbcType="INTEGER" property="pid" />
<result column="icon" jdbcType="VARCHAR" property="icon" />
<result column="level" jdbcType="INTEGER" property="level" />
......@@ -77,7 +81,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, `desc`, pid, icon, `level`, sort, created, updated, is_deleted, is_leaf
id, `name`, `desc`, video_app_id, video_id, video_title, main_image, pid, icon, `level`,
sort, created, updated, is_deleted, is_leaf
</sql>
<sql id="Blob_Column_List">
extra, introduction
......@@ -132,8 +137,8 @@
</foreach>
</when>
<otherwise>
id, `name`, `desc`, pid, icon, `level`, sort, created, updated, is_deleted, is_leaf,
extra, introduction
id, `name`, `desc`, video_app_id, video_id, video_title, main_image, pid, icon, `level`,
sort, created, updated, is_deleted, is_leaf, extra, introduction
</otherwise>
</choose>
from category
......@@ -166,8 +171,8 @@
</foreach>
</when>
<otherwise>
id, `name`, `desc`, pid, icon, `level`, sort, created, updated, is_deleted, is_leaf,
extra, introduction
id, `name`, `desc`, video_app_id, video_id, video_title, main_image, pid, icon, `level`,
sort, created, updated, is_deleted, is_leaf, extra, introduction
</otherwise>
</choose>
from category
......@@ -209,13 +214,15 @@
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into category (`name`, `desc`, pid,
icon, `level`, sort,
insert into category (`name`, `desc`, video_app_id,
video_id, video_title, main_image,
pid, icon, `level`, sort,
created, updated, is_deleted,
is_leaf, extra, introduction
)
values (#{name,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{pid,jdbcType=INTEGER},
#{icon,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, #{sort,jdbcType=INTEGER},
values (#{name,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{videoAppId,jdbcType=VARCHAR},
#{videoId,jdbcType=VARCHAR}, #{videoTitle,jdbcType=VARCHAR}, #{mainImage,jdbcType=VARCHAR},
#{pid,jdbcType=INTEGER}, #{icon,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, #{sort,jdbcType=INTEGER},
#{created,jdbcType=TIMESTAMP}, #{updated,jdbcType=TIMESTAMP}, #{isDeleted,jdbcType=BIT},
#{isLeaf,jdbcType=BIT}, #{extra,jdbcType=LONGVARCHAR}, #{introduction,jdbcType=LONGVARCHAR}
)
......@@ -226,16 +233,24 @@
</selectKey>
insert into category
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
`id`,
</if>
<if test="name != null">
`name`,
</if>
<if test="desc != null">
`desc`,
</if>
<if test="videoAppId != null">
video_app_id,
</if>
<if test="videoId != null">
video_id,
</if>
<if test="videoTitle != null">
video_title,
</if>
<if test="mainImage != null">
main_image,
</if>
<if test="pid != null">
pid,
</if>
......@@ -268,16 +283,24 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="desc != null">
#{desc,jdbcType=VARCHAR},
</if>
<if test="videoAppId != null">
#{videoAppId,jdbcType=VARCHAR},
</if>
<if test="videoId != null">
#{videoId,jdbcType=VARCHAR},
</if>
<if test="videoTitle != null">
#{videoTitle,jdbcType=VARCHAR},
</if>
<if test="mainImage != null">
#{mainImage,jdbcType=VARCHAR},
</if>
<if test="pid != null">
#{pid,jdbcType=INTEGER},
</if>
......@@ -316,7 +339,6 @@
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update category
<set>
......@@ -329,6 +351,18 @@
<if test="record.desc != null">
`desc` = #{record.desc,jdbcType=VARCHAR},
</if>
<if test="record.videoAppId != null">
video_app_id = #{record.videoAppId,jdbcType=VARCHAR},
</if>
<if test="record.videoId != null">
video_id = #{record.videoId,jdbcType=VARCHAR},
</if>
<if test="record.videoTitle != null">
video_title = #{record.videoTitle,jdbcType=VARCHAR},
</if>
<if test="record.mainImage != null">
main_image = #{record.mainImage,jdbcType=VARCHAR},
</if>
<if test="record.pid != null">
pid = #{record.pid,jdbcType=INTEGER},
</if>
......@@ -369,6 +403,10 @@
set id = #{record.id,jdbcType=INTEGER},
`name` = #{record.name,jdbcType=VARCHAR},
`desc` = #{record.desc,jdbcType=VARCHAR},
video_app_id = #{record.videoAppId,jdbcType=VARCHAR},
video_id = #{record.videoId,jdbcType=VARCHAR},
video_title = #{record.videoTitle,jdbcType=VARCHAR},
main_image = #{record.mainImage,jdbcType=VARCHAR},
pid = #{record.pid,jdbcType=INTEGER},
icon = #{record.icon,jdbcType=VARCHAR},
`level` = #{record.level,jdbcType=INTEGER},
......@@ -388,6 +426,10 @@
set id = #{record.id,jdbcType=INTEGER},
`name` = #{record.name,jdbcType=VARCHAR},
`desc` = #{record.desc,jdbcType=VARCHAR},
video_app_id = #{record.videoAppId,jdbcType=VARCHAR},
video_id = #{record.videoId,jdbcType=VARCHAR},
video_title = #{record.videoTitle,jdbcType=VARCHAR},
main_image = #{record.mainImage,jdbcType=VARCHAR},
pid = #{record.pid,jdbcType=INTEGER},
icon = #{record.icon,jdbcType=VARCHAR},
`level` = #{record.level,jdbcType=INTEGER},
......@@ -409,6 +451,18 @@
<if test="desc != null">
`desc` = #{desc,jdbcType=VARCHAR},
</if>
<if test="videoAppId != null">
video_app_id = #{videoAppId,jdbcType=VARCHAR},
</if>
<if test="videoId != null">
video_id = #{videoId,jdbcType=VARCHAR},
</if>
<if test="videoTitle != null">
video_title = #{videoTitle,jdbcType=VARCHAR},
</if>
<if test="mainImage != null">
main_image = #{mainImage,jdbcType=VARCHAR},
</if>
<if test="pid != null">
pid = #{pid,jdbcType=INTEGER},
</if>
......@@ -446,6 +500,10 @@
update category
set `name` = #{name,jdbcType=VARCHAR},
`desc` = #{desc,jdbcType=VARCHAR},
video_app_id = #{videoAppId,jdbcType=VARCHAR},
video_id = #{videoId,jdbcType=VARCHAR},
video_title = #{videoTitle,jdbcType=VARCHAR},
main_image = #{mainImage,jdbcType=VARCHAR},
pid = #{pid,jdbcType=INTEGER},
icon = #{icon,jdbcType=VARCHAR},
`level` = #{level,jdbcType=INTEGER},
......@@ -462,6 +520,10 @@
update category
set `name` = #{name,jdbcType=VARCHAR},
`desc` = #{desc,jdbcType=VARCHAR},
video_app_id = #{videoAppId,jdbcType=VARCHAR},
video_id = #{videoId,jdbcType=VARCHAR},
video_title = #{videoTitle,jdbcType=VARCHAR},
main_image = #{mainImage,jdbcType=VARCHAR},
pid = #{pid,jdbcType=INTEGER},
icon = #{icon,jdbcType=VARCHAR},
`level` = #{level,jdbcType=INTEGER},
......@@ -525,8 +587,8 @@
</foreach>
</when>
<otherwise>
id, `name`, `desc`, pid, icon, `level`, sort, created, updated, is_deleted, is_leaf,
extra, introduction
id, `name`, `desc`, video_app_id, video_id, video_title, main_image, pid, icon, `level`,
sort, created, updated, is_deleted, is_leaf, extra, introduction
</otherwise>
</choose>
from category
......
......@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper"
targetProject="ch-dao/src/main/java"/>
<table tableName="item_tag_qr_code" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="category" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
......@@ -53,7 +53,7 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
"/wx/storage/uploadVideo",
"/wx/appletPageConfig/**", "/wx/blindBox/**", "/wx/userSignIn/**"
//下列路径上线注释
,"/wx/sellActivity/**"
,"/wx/sellActivity/**","/wx/itemTagQrCode/**"
// ,"/wx/itemTagOperate/**", "/wx/openShop/**", "/wx/earnestRecord/**", "/wx/auctionEarnest/**", "/wx/userAccount/**"
/* ,"/wx/specialPerformance/**"
, "/wx/supplierItem/**", "/wx/shareRecord/**", "/wx/distributionOrder/**", "/wx/selfPage/**", "/wx/auctionRecord/**",
......
......@@ -2,25 +2,39 @@ package com.wwdz.ch.wx.impl;
import com.wwdz.ch.core.api.WxAppletApi;
import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.consts.DistributionEnum;
import com.wwdz.ch.core.consts.SupplierItemEnum;
import com.wwdz.ch.core.entity.SupplierItemVo;
import com.wwdz.ch.core.storage.QiniuStorage;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.QRCodeUtil;
import com.wwdz.ch.core.util.UUID;
import com.wwdz.ch.core.util.*;
import com.wwdz.ch.db.dao.CategoryDao;
import com.wwdz.ch.db.dao.ItemTagQrCodeDao;
import com.wwdz.ch.db.dao.distribution.SupplierItemDao;
import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.db.domain.ItemTagQrCode;
import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.db.domain.distribution.SupplierItem;
import com.wwdz.ch.db.dto.request.ItemTagQrCodeRequestDto;
import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto;
import com.wwdz.ch.wx.entity.request.ItemTagOperateRequestDto;
import com.wwdz.ch.wx.entity.vo.CategoryVo;
import com.wwdz.ch.wx.service.ItemTagQrCodeService;
import com.wwdz.ch.wx.service.distribution.SupplierItemService;
import com.xxdxxs.utils.EntityMapper;
import com.xxdxxs.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.IntStream;
import java.util.stream.Stream;
@Service
public class ItemTagQrCodeServiceImpl implements ItemTagQrCodeService {
......@@ -39,25 +53,37 @@ public class ItemTagQrCodeServiceImpl implements ItemTagQrCodeService {
@Autowired
SupplierItemDao supplierItemDao;
@Autowired
CategoryDao categoryDao;
@Autowired
CacheUtil cacheUtil;
@Autowired
SupplierItemService supplierItemService;
@Override
public Result createQrCode(ItemTagOperateRequestDto dto) {
public Result createQrCode(ItemTagQrCodeRequestDto dto) {
try {
Category category = categoryDao.findById(dto.getCategoryId());
Date now = new Date();
String code = UUID.fastUUID().toString(true);
ItemTagQrCode itemTagQrCode = new ItemTagQrCode();
itemTagQrCode.setCode(code);
itemTagQrCode.setCategoryId(1774);
itemTagQrCode.setCategoryName("开元通宝");
itemTagQrCode.setCreateTime(now);
//获取页面短链
String url = wxAppletApi.getUrlLink("/pages/detail/index","code=" + code);
String qrCode = QRCodeUtil.createCodeToBase64(url);
String keyName = CommConsts.UPLOAD_PRE_DIRECTORY + code;
String qrCodeUrl = qiniuStorage.storeItemQrcodeBase64Str(qrCode.trim(), keyName);
logger.info("上传的商品标签二维码url :{}", qrCodeUrl);
itemTagQrCode.setQrCode(qrCodeUrl);
itemTagQrCodeDao.insert(itemTagQrCode);
return Result.success(qrCodeUrl);
for (int i = 0; i < dto.getCodeNum(); i++) {
String code = UUID.fastUUID().toString(true);
ItemTagQrCode itemTagQrCode = new ItemTagQrCode();
itemTagQrCode.setCode(code);
itemTagQrCode.setCategoryId(dto.getCategoryId());
itemTagQrCode.setCategoryName(category.getName());
itemTagQrCode.setCreateTime(now);
//获取页面短链
String url = wxAppletApi.getUrlLink("/pages/detail/index", "code=" + code);
String qrCode = QRCodeUtil.createCodeToBase64(url);
String keyName = CommConsts.UPLOAD_PRE_DIRECTORY + code;
String qrCodeUrl = qiniuStorage.storeItemQrcodeBase64Str(qrCode.trim(), keyName);
logger.info("上传的商品标签二维码url :{}", qrCodeUrl);
itemTagQrCode.setQrCode(qrCodeUrl);
itemTagQrCodeDao.insert(itemTagQrCode);
}
return Result.success();
} catch (Exception e) {
logger.error("创建标签二维码失败", e);
}
......@@ -70,15 +96,69 @@ public class ItemTagQrCodeServiceImpl implements ItemTagQrCodeService {
try {
ItemTagQrCode itemTagQrCode = itemTagQrCodeDao.findByCode(dto.getCode());
if (itemTagQrCode != null && itemTagQrCode.getItemId() != null) {
SupplierItem supplierItem = supplierItemDao.findById(itemTagQrCode.getItemId());
SupplierItemVo supplierItemVo = new SupplierItemVo();
EntityMapper.copyAttribute(supplierItem, supplierItemVo);
return Result.success(supplierItemVo);
SupplierItemRequestDto supplierItemRequestDto = new SupplierItemRequestDto();
supplierItemRequestDto.setId(itemTagQrCode.getItemId());
supplierItemRequestDto.setItemId(itemTagQrCode.getItemId());
supplierItemRequestDto.setUserId(dto.getUserId());
Result result = supplierItemService.findCollectionItemDetail(supplierItemRequestDto);
return result;
}
return Result.success(itemTagQrCode);
int categoryId = itemTagQrCode.getCategoryId();
Category category = categoryDao.findById(categoryId);
return Result.success(category);
} catch (Exception e) {
logger.error("根据二维码code查询信息失败", e);
}
return Result.failed();
}
@Override
public Result bindItem(ItemTagQrCodeRequestDto dto) {
try {
ItemTagQrCode itemTagQrCode = itemTagQrCodeDao.findByCode(dto.getCode());
int categoryId = itemTagQrCode.getCategoryId();
//先上传商品
SupplierItem supplierItem = new SupplierItem();
//查询类目信息
Category category = categoryDao.findById(categoryId);
EntityMapper.copyAttribute(dto, supplierItem);
//查询分类的上级节点
Category parentCategory = categoryDao.findById(category.getPid());
supplierItem.setName(parentCategory.getName() + "-" + category.getName());
supplierItem.setDescription(category.getIntroduction());
supplierItem.setDistributionPrice(0L);
supplierItem.setSupplyPrice(0L);
supplierItem.setRebate(new BigDecimal("0"));
if (!CollectionUtils.isEmpty(dto.getImages())) {
supplierItem.setImages(String.join(";", dto.getImages()));
}
supplierItem.setSort(1);
supplierItem.setBuyLimitNum(-1);
supplierItem.setIsAbleSale(false);
supplierItem.setIsOnSale(false);
supplierItem.setStock(1);
supplierItem.setIsOnSale(false);
Date now = new Date();
supplierItem.setCreateTime(now);
supplierItem.setUpdateTime(now);
supplierItem.setIsDeleted(false);
supplierItem.setDistributionPrice(0L);
supplierItem.setType(DistributionEnum.DistributionTypeEnum.COLLECT.getCode());
supplierItem.setStatus(SupplierItemEnum.StatusEnum.COMMON.getCode());
supplierItem.setCreatorId(dto.getUserId());
long itemId = supplierItemDao.insert(supplierItem);
//二维码绑定商品
ItemTagQrCode updateDto = new ItemTagQrCode();
updateDto.setId(itemTagQrCode.getId());
updateDto.setItemId(itemId);
itemTagQrCodeDao.updateByPrimaryKey(updateDto);
return Result.success();
} catch (Exception e) {
logger.error("用户上传商品图片,code绑定商品", e);
}
return Result.failed();
}
}
......@@ -7,10 +7,10 @@ import com.wwdz.ch.wx.entity.request.ItemTagOperateRequestDto;
public interface ItemTagQrCodeService {
/**
* 批量生成页面二维码
* 批量生成二维码
* @return
*/
Result createQrCode(ItemTagOperateRequestDto dto);
Result createQrCode(ItemTagQrCodeRequestDto dto);
/**
......@@ -19,4 +19,12 @@ public interface ItemTagQrCodeService {
* @return
*/
Result findByCode(ItemTagQrCodeRequestDto dto);
/**
* 用户上传商品图片,code绑定商品
* @param dto
* @return
*/
Result bindItem(ItemTagQrCodeRequestDto dto);
}
package com.wwdz.ch.wx.web;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.consts.ResultCode;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.ItemTagQrCodeRequestDto;
import com.wwdz.ch.wx.service.ItemTagQrCodeService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/wx/itemTagQrCode")
public class ItemTagQrCodeController {
private static final Logger logger = LoggerFactory.getLogger(ItemTagQrCodeController.class);
@Autowired
ItemTagQrCodeService itemTagQrCodeService;
@ApiOperation(value = "上传商品到自己的藏馆,绑定二维码")
@PostMapping("/uploadItemToSelf")
public Result uploadItemToSelf(@RequestBody ItemTagQrCodeRequestDto dto) {
logger.info("上传商品到自己的藏馆,绑定二维码,请求参数:{}", JSON.toJSONString(dto));
if (dto.getUserId() == null) {
return Result.failed(ResultCode.PARAM_ERROR);
}
return itemTagQrCodeService.bindItem(dto);
}
@ApiOperation(value = "根据二维码code查询信息")
@PostMapping("/findByCode")
public Result findByCode(@RequestBody ItemTagQrCodeRequestDto dto) {
logger.info("根据二维码code查询信息,请求参数:{}", JSON.toJSONString(dto));
if (StringUtils.isEmpty(dto.getCode()) || dto.getUserId() == null) {
return Result.failed(ResultCode.PARAM_ERROR);
}
return itemTagQrCodeService.findByCode(dto);
}
@ApiOperation(value = "批量生成二维码")
@PostMapping("/createQrCode")
public Result createQrCode(@RequestBody ItemTagQrCodeRequestDto dto) {
logger.info("批量生成二维码,请求参数:{}", JSON.toJSONString(dto));
if (dto.getCategoryId() == null || dto.getCodeNum() == null) {
return Result.failed(ResultCode.PARAM_ERROR);
}
return itemTagQrCodeService.createQrCode(dto);
}
}
Markdown is supported
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