21 changed files with 403 additions and 26 deletions
@ -0,0 +1,127 @@ |
|||
package cc.hiver.mall.shopqrcode.controller; |
|||
|
|||
import cc.hiver.core.common.utils.ResultUtil; |
|||
import cc.hiver.core.common.vo.Result; |
|||
import cc.hiver.mall.shopqrcode.entity.ShopQrcode; |
|||
import cc.hiver.mall.shopqrcode.service.ShopQrcodeService; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
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; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Slf4j |
|||
@RestController |
|||
@Api(tags = "店铺二维码接口") |
|||
@RequestMapping("/hiver/app/shopQrcode/") |
|||
@Transactional |
|||
public class ShopQrcodeController { |
|||
|
|||
@Autowired |
|||
private ShopQrcodeService shopQrcodeService; |
|||
|
|||
/** |
|||
* 新增店铺二维码 |
|||
* |
|||
* @param shopQrcode |
|||
* @return Result |
|||
* @author 王富康 |
|||
* @date 2024/8/11 |
|||
*/ |
|||
@PostMapping(value = "/addProductSn") |
|||
@ApiOperation("新增店铺二维码") |
|||
public Result addShopQrcode(@RequestBody ShopQrcode shopQrcode) { |
|||
if (StringUtils.isEmpty(shopQrcode.getQrcodeName())) { |
|||
return ResultUtil.error("二维码名称不能为空"); |
|||
} |
|||
if (StringUtils.isEmpty(shopQrcode.getQrcodePath())) { |
|||
return ResultUtil.error("二维码路径不能为空"); |
|||
} |
|||
final boolean save = shopQrcodeService.save(shopQrcode); |
|||
if (save) { |
|||
return ResultUtil.success("新增成功"); |
|||
} else { |
|||
return ResultUtil.error("新增失败"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 根据店铺id获取二维码 |
|||
* |
|||
* @param shopId |
|||
* @return Result |
|||
* @author 王富康 |
|||
* @date 2024/8/11 |
|||
*/ |
|||
@PostMapping(value = "/getShopQrcodeByShopId") |
|||
@ApiOperation("根据店铺id获取二维码") |
|||
public Result getShopQrcodeByShopId(String shopId) { |
|||
if (StringUtils.isEmpty(shopId)) { |
|||
return ResultUtil.error("店铺id不能为空"); |
|||
} |
|||
|
|||
final List<ShopQrcode> shopQrcode = shopQrcodeService.getShopQrcodeByShopId(shopId); |
|||
if (shopQrcode != null) { |
|||
return new ResultUtil<List<ShopQrcode>>().setData(shopQrcode); |
|||
} else { |
|||
return ResultUtil.error("查询失败"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 更新二维码 |
|||
* |
|||
* @param shopQrcode |
|||
* @return Result |
|||
* @author 王富康 |
|||
* @date 2024/8/11 |
|||
*/ |
|||
@PostMapping(value = "/updateShopQrcode") |
|||
@ApiOperation("更新二维码") |
|||
public Result updateShopQrcode(@RequestBody ShopQrcode shopQrcode) { |
|||
if (StringUtils.isEmpty(shopQrcode.getId())) { |
|||
return ResultUtil.error("二维码id不能为空"); |
|||
} |
|||
if (StringUtils.isEmpty(shopQrcode.getQrcodeName())) { |
|||
return ResultUtil.error("二维码名称不能为空"); |
|||
} |
|||
if (StringUtils.isEmpty(shopQrcode.getQrcodePath())) { |
|||
return ResultUtil.error("二维码路径不能为空"); |
|||
} |
|||
final boolean update = shopQrcodeService.updateById(shopQrcode); |
|||
if (update) { |
|||
return ResultUtil.success("更新成功"); |
|||
} else { |
|||
return ResultUtil.error("更新失败"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 删除二维码 |
|||
* |
|||
* @param id |
|||
* @return Result |
|||
* @author 王富康 |
|||
* @date 2024/8/11 |
|||
*/ |
|||
@PostMapping(value = "/deleteShopQrcode") |
|||
@ApiOperation("") |
|||
public Result deleteShopQrcode(String id) { |
|||
if (StringUtils.isEmpty(id)) { |
|||
return ResultUtil.error("二维码id不能为空"); |
|||
} |
|||
final boolean removeById = shopQrcodeService.removeById(id); |
|||
if (removeById) { |
|||
return ResultUtil.success("删除成功"); |
|||
} else { |
|||
return ResultUtil.error("删除失败"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package cc.hiver.mall.shopqrcode.entity; |
|||
|
|||
import cc.hiver.core.base.HiverBaseEntity; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@ApiModel(value = "货号规则") |
|||
@TableName(value = "t_shop_qrcode", autoResultMap = true) |
|||
public class ShopQrcode extends HiverBaseEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "店铺ID") |
|||
private String shopId; |
|||
@ApiModelProperty(value = "店铺名称") |
|||
private String shopName; |
|||
@ApiModelProperty(value = "二维码名称") |
|||
private String qrcodeName; |
|||
@ApiModelProperty(value = "二维码路径") |
|||
private String qrcodePath; |
|||
@ApiModelProperty(value = "二维码图片阿里云存放路径") |
|||
private String qrcodeServerPath; |
|||
|
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package cc.hiver.mall.shopqrcode.mapper; |
|||
|
|||
import cc.hiver.mall.shopqrcode.entity.ShopQrcode; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface ShopQrcodeMapper extends BaseMapper<ShopQrcode> { |
|||
|
|||
/** |
|||
* 根据店铺id获取二维码 |
|||
* |
|||
* @param shopId |
|||
* @return List<ShopQrcode> |
|||
* @author 王富康 |
|||
* @date 2024/8/11 |
|||
*/ |
|||
List<ShopQrcode> getShopQrcodeByShopId(@Param("shopId") String shopId); |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package cc.hiver.mall.shopqrcode.service; |
|||
|
|||
import cc.hiver.mall.shopqrcode.entity.ShopQrcode; |
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface ShopQrcodeService extends IService<ShopQrcode> { |
|||
|
|||
/** |
|||
* 根据店铺id获取二维码 |
|||
* |
|||
* @param shopId |
|||
* @return List<ShopQrcode> |
|||
* @author 王富康 |
|||
* @date 2024/8/11 |
|||
*/ |
|||
List<ShopQrcode> getShopQrcodeByShopId(String shopId); |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package cc.hiver.mall.shopqrcode.service.impl; |
|||
|
|||
import cc.hiver.mall.shopqrcode.entity.ShopQrcode; |
|||
import cc.hiver.mall.shopqrcode.mapper.ShopQrcodeMapper; |
|||
import cc.hiver.mall.shopqrcode.service.ShopQrcodeService; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class ShopQrcodeServiceImpl extends ServiceImpl<ShopQrcodeMapper, ShopQrcode> implements ShopQrcodeService { |
|||
|
|||
@Autowired |
|||
private ShopQrcodeMapper shopQrcodeMapper; |
|||
|
|||
/** |
|||
* 根据店铺id获取二维码 |
|||
* |
|||
* @param shopId |
|||
* @return List<ShopQrcode> |
|||
* @author 王富康 |
|||
* @date 2024/8/11 |
|||
*/ |
|||
@Override |
|||
public List<ShopQrcode> getShopQrcodeByShopId(String shopId) { |
|||
return shopQrcodeMapper.getShopQrcodeByShopId(shopId); |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?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="cc.hiver.mall.shopqrcode.mapper.ShopQrcodeMapper"> |
|||
<resultMap id="BaseResultMap" type="cc.hiver.mall.shopqrcode.entity.ShopQrcode"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
<result column="del_flag" jdbcType="INTEGER" property="delFlag" /> |
|||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> |
|||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
|||
<result column="shop_id" jdbcType="VARCHAR" property="shopId" /> |
|||
<result column="shop_name" jdbcType="VARCHAR" property="shopName" /> |
|||
<result column="qrcode_name" jdbcType="VARCHAR" property="qrcodeName" /> |
|||
<result column="qrcode_path" jdbcType="VARCHAR" property="qrcodePath" /> |
|||
<result column="qrcode_server_path" jdbcType="VARCHAR" property="qrcodeServerPath" /> |
|||
</resultMap> |
|||
|
|||
<sql id="Base_Column_List"> |
|||
id, create_by, create_time, del_flag, update_by, update_time, shop_id, shop_name, qrcode_name, |
|||
qrcode_path, qrcode_server_path |
|||
</sql> |
|||
|
|||
<!--查询当前段铺的货号规则--> |
|||
<select id="getShopQrcodeByShopId" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List"/> |
|||
from t_shop_qrcode |
|||
where shop_id = #{shopId,jdbcType=VARCHAR} |
|||
</select> |
|||
|
|||
</mapper> |
|||
Loading…
Reference in new issue