收银后台跟进1.4
This commit is contained in:
@@ -50,6 +50,7 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
<?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="me.zhengjie.modules.productGroup.service.mapstruct.TbProductGroupMapper">
|
||||
|
||||
<resultMap type="me.zhengjie.modules.productGroup.domain.TbProductGroup" id="TbProductGroupMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="merchantId" column="merchant_id" jdbcType="VARCHAR"/>
|
||||
<result property="shopId" column="shop_id" jdbcType="VARCHAR"/>
|
||||
<result property="pic" column="pic" jdbcType="VARCHAR"/>
|
||||
<result property="isShow" column="is_show" jdbcType="INTEGER"/>
|
||||
<result property="detail" column="detail" jdbcType="VARCHAR"/>
|
||||
<result property="style" column="style" jdbcType="VARCHAR"/>
|
||||
<result property="sort" column="sort" jdbcType="INTEGER"/>
|
||||
<result property="productIds" column="product_ids" jdbcType="VARCHAR"/>
|
||||
<result property="createdAt" column="created_at" jdbcType="INTEGER"/>
|
||||
<result property="updatedAt" column="updated_at" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="TbProductGroupMap">
|
||||
select
|
||||
id, name, merchant_id, shop_id, pic, is_show, detail, style, sort, product_ids, created_at, updated_at
|
||||
from tb_product_group
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="TbProductGroupMap">
|
||||
select
|
||||
id, name, merchant_id, shop_id, pic, is_show, detail, style, sort, product_ids, created_at, updated_at
|
||||
from tb_product_group
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name = #{name}
|
||||
</if>
|
||||
<if test="merchantId != null and merchantId != ''">
|
||||
and merchant_id = #{merchantId}
|
||||
</if>
|
||||
<if test="shopId != null and shopId != ''">
|
||||
and shop_id = #{shopId}
|
||||
</if>
|
||||
<if test="pic != null and pic != ''">
|
||||
and pic = #{pic}
|
||||
</if>
|
||||
<if test="isShow != null">
|
||||
and is_show = #{isShow}
|
||||
</if>
|
||||
<if test="detail != null and detail != ''">
|
||||
and detail = #{detail}
|
||||
</if>
|
||||
<if test="style != null and style != ''">
|
||||
and style = #{style}
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
and sort = #{sort}
|
||||
</if>
|
||||
<if test="productIds != null and productIds != ''">
|
||||
and product_ids = #{productIds}
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
and created_at = #{createdAt}
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
and updated_at = #{updatedAt}
|
||||
</if>
|
||||
</where>
|
||||
limit #{pageable.offset}, #{pageable.pageSize}
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from tb_product_group
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name = #{name}
|
||||
</if>
|
||||
<if test="merchantId != null and merchantId != ''">
|
||||
and merchant_id = #{merchantId}
|
||||
</if>
|
||||
<if test="shopId != null and shopId != ''">
|
||||
and shop_id = #{shopId}
|
||||
</if>
|
||||
<if test="pic != null and pic != ''">
|
||||
and pic = #{pic}
|
||||
</if>
|
||||
<if test="isShow != null">
|
||||
and is_show = #{isShow}
|
||||
</if>
|
||||
<if test="detail != null and detail != ''">
|
||||
and detail = #{detail}
|
||||
</if>
|
||||
<if test="style != null and style != ''">
|
||||
and style = #{style}
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
and sort = #{sort}
|
||||
</if>
|
||||
<if test="productIds != null and productIds != ''">
|
||||
and product_ids = #{productIds}
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
and created_at = #{createdAt}
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
and updated_at = #{updatedAt}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_product_group(name, merchant_id, shop_id, pic, is_show, detail, style, sort, product_ids, created_at, updated_at)
|
||||
values (#{name}, #{merchantId}, #{shopId}, #{pic}, #{isShow}, #{detail}, #{style}, #{sort}, #{productIds}, #{createdAt}, #{updatedAt})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_product_group(name, merchant_id, shop_id, pic, is_show, detail, style, sort, product_ids, created_at, updated_at)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.name}, #{entity.merchantId}, #{entity.shopId}, #{entity.pic}, #{entity.isShow}, #{entity.detail}, #{entity.style}, #{entity.sort}, #{entity.productIds}, #{entity.createdAt}, #{entity.updatedAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_product_group(name, merchant_id, shop_id, pic, is_show, detail, style, sort, product_ids, created_at, updated_at)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.name}, #{entity.merchantId}, #{entity.shopId}, #{entity.pic}, #{entity.isShow}, #{entity.detail}, #{entity.style}, #{entity.sort}, #{entity.productIds}, #{entity.createdAt}, #{entity.updatedAt})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
name = values(name),
|
||||
merchant_id = values(merchant_id),
|
||||
shop_id = values(shop_id),
|
||||
pic = values(pic),
|
||||
is_show = values(is_show),
|
||||
detail = values(detail),
|
||||
style = values(style),
|
||||
sort = values(sort),
|
||||
product_ids = values(product_ids),
|
||||
created_at = values(created_at),
|
||||
updated_at = values(updated_at)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update tb_product_group
|
||||
<set>
|
||||
<if test="name != null and name != ''">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="merchantId != null and merchantId != ''">
|
||||
merchant_id = #{merchantId},
|
||||
</if>
|
||||
<if test="shopId != null and shopId != ''">
|
||||
shop_id = #{shopId},
|
||||
</if>
|
||||
<if test="pic != null and pic != ''">
|
||||
pic = #{pic},
|
||||
</if>
|
||||
<if test="isShow != null">
|
||||
is_show = #{isShow},
|
||||
</if>
|
||||
<if test="detail != null and detail != ''">
|
||||
detail = #{detail},
|
||||
</if>
|
||||
<if test="style != null and style != ''">
|
||||
style = #{style},
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
sort = #{sort},
|
||||
</if>
|
||||
<if test="productIds != null and productIds != ''">
|
||||
product_ids = #{productIds},
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
created_at = #{createdAt},
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
updated_at = #{updatedAt},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete from tb_product_group where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.product.domain;
|
||||
package me.zhengjie.modules.productInfo.product.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
@@ -292,7 +293,6 @@ public class TbProduct implements Serializable {
|
||||
@Column(name = "`tax_config_id`")
|
||||
@ApiModelProperty(value = "税率")
|
||||
private String taxConfigId;
|
||||
|
||||
public void copy(TbProduct source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package me.zhengjie.modules.productInfo.product.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
public class TbProductVo {
|
||||
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
||||
private String sourcePath;
|
||||
|
||||
|
||||
private String merchantId;
|
||||
|
||||
|
||||
private String shopId;
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
|
||||
private BigDecimal packFee;
|
||||
|
||||
|
||||
private BigDecimal lowPrice;
|
||||
|
||||
|
||||
private String unitId;
|
||||
|
||||
|
||||
private String coverImg;
|
||||
|
||||
|
||||
private String categoryId;
|
||||
|
||||
|
||||
private Integer specId;
|
||||
|
||||
|
||||
private Integer brandId;
|
||||
|
||||
|
||||
private String shortTitle;
|
||||
|
||||
|
||||
private BigDecimal lowMemberPrice;
|
||||
|
||||
|
||||
private String unitSnap;
|
||||
|
||||
|
||||
private String shareImg;
|
||||
|
||||
|
||||
private String images;
|
||||
|
||||
|
||||
private String video;
|
||||
|
||||
|
||||
private String videoCoverImg;
|
||||
|
||||
|
||||
private Integer sort;
|
||||
|
||||
|
||||
private Integer limitNumber;
|
||||
|
||||
|
||||
private Integer productScore;
|
||||
|
||||
|
||||
private Integer status;
|
||||
|
||||
|
||||
private String failMsg;
|
||||
|
||||
|
||||
private Integer isRecommend;
|
||||
|
||||
|
||||
private Integer isHot;
|
||||
|
||||
|
||||
private Integer isNew;
|
||||
|
||||
|
||||
private Integer isOnSale;
|
||||
|
||||
|
||||
private Integer isShow;
|
||||
|
||||
|
||||
private String typeEnum;
|
||||
|
||||
|
||||
private Integer isDistribute;
|
||||
|
||||
|
||||
private Integer isDel;
|
||||
|
||||
|
||||
private Integer isStock;
|
||||
|
||||
|
||||
private Integer isPauseSale;
|
||||
|
||||
|
||||
private Integer isFreeFreight;
|
||||
|
||||
|
||||
private Long freightId;
|
||||
|
||||
|
||||
private String strategyType;
|
||||
|
||||
|
||||
private Integer strategyId;
|
||||
|
||||
|
||||
private Integer isVip;
|
||||
|
||||
|
||||
private Integer isDelete;
|
||||
|
||||
|
||||
private String notice;
|
||||
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
|
||||
private Double baseSalesNumber;
|
||||
|
||||
|
||||
private Integer realSalesNumber;
|
||||
|
||||
|
||||
private Integer salesNumber;
|
||||
|
||||
private Integer thumbCount;
|
||||
|
||||
|
||||
private Integer storeCount;
|
||||
|
||||
|
||||
private Integer furnishMeal;
|
||||
|
||||
|
||||
private Integer furnishExpress;
|
||||
|
||||
|
||||
private Integer furnishDraw;
|
||||
|
||||
|
||||
private Integer furnishVir;
|
||||
|
||||
|
||||
private Integer isCombo;
|
||||
|
||||
|
||||
private String groupSnap;
|
||||
|
||||
|
||||
private Integer isShowCash;
|
||||
|
||||
|
||||
private Integer isShowMall;
|
||||
|
||||
|
||||
private Integer isNeedExamine;
|
||||
|
||||
|
||||
private Integer showOnMallStatus;
|
||||
|
||||
|
||||
private Long showOnMallTime;
|
||||
|
||||
private String showOnMallErrorMsg;
|
||||
|
||||
|
||||
private Integer enableLabel;
|
||||
|
||||
|
||||
|
||||
private String taxConfigId;
|
||||
|
||||
|
||||
|
||||
private String unitName;
|
||||
|
||||
private List<TbProductSku> skuList;
|
||||
|
||||
private HashMap<String,String> specsInfo;
|
||||
}
|
||||
@@ -13,9 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.product.repository;
|
||||
package me.zhengjie.modules.productInfo.product.repository;
|
||||
|
||||
import me.zhengjie.modules.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.product.rest;
|
||||
package me.zhengjie.modules.productInfo.product.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.modules.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.product.service.TbProductService;
|
||||
import me.zhengjie.modules.product.service.dto.TbProductQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.productInfo.product.service.TbProductService;
|
||||
import me.zhengjie.modules.productInfo.product.service.dto.TbProductQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -13,11 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.product.service;
|
||||
package me.zhengjie.modules.productInfo.product.service;
|
||||
|
||||
import me.zhengjie.modules.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.product.service.dto.TbProductDto;
|
||||
import me.zhengjie.modules.product.service.dto.TbProductQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.productInfo.product.service.dto.TbProductDto;
|
||||
import me.zhengjie.modules.productInfo.product.service.dto.TbProductQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
@@ -13,11 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.product.service.dto;
|
||||
package me.zhengjie.modules.productInfo.product.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -210,4 +213,8 @@ public class TbProductDto implements Serializable {
|
||||
|
||||
/** 税率 */
|
||||
private String taxConfigId;
|
||||
/**
|
||||
* 商品sku信息
|
||||
*/
|
||||
private List<TbProductSku> skuList;
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.product.service.dto;
|
||||
package me.zhengjie.modules.productInfo.product.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
@@ -13,29 +13,35 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.product.service.impl;
|
||||
package me.zhengjie.modules.productInfo.product.service.impl;
|
||||
|
||||
import me.zhengjie.modules.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProductVo;
|
||||
import me.zhengjie.modules.productInfo.product.repository.TbProductRepository;
|
||||
import me.zhengjie.modules.productInfo.product.service.TbProductService;
|
||||
import me.zhengjie.modules.productInfo.product.service.dto.TbProductDto;
|
||||
import me.zhengjie.modules.productInfo.product.service.dto.TbProductQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.product.service.mapstruct.TbProductMapper;
|
||||
import me.zhengjie.modules.productInfo.productSpec.domain.TbProductSpec;
|
||||
import me.zhengjie.modules.productInfo.productSpec.repository.TbProductSpecRepository;
|
||||
import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku;
|
||||
import me.zhengjie.modules.productInfo.productSku.repository.TbProductSkuRepository;
|
||||
import me.zhengjie.modules.shopUnit.domain.TbShopUnit;
|
||||
import me.zhengjie.modules.shopUnit.repository.TbShopUnitRepository;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.product.repository.TbProductRepository;
|
||||
import me.zhengjie.modules.product.service.TbProductService;
|
||||
import me.zhengjie.modules.product.service.dto.TbProductDto;
|
||||
import me.zhengjie.modules.product.service.dto.TbProductQueryCriteria;
|
||||
import me.zhengjie.modules.product.service.mapstruct.TbProductMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -49,11 +55,80 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
|
||||
private final TbProductRepository tbProductRepository;
|
||||
private final TbProductMapper tbProductMapper;
|
||||
private final TbProductSkuRepository tbProductSkuRepository;
|
||||
private final TbShopUnitRepository tbShopUnitRepository;
|
||||
private final TbProductSpecRepository tbProductSpecRepository;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbProductQueryCriteria criteria, Pageable pageable){
|
||||
//查询商品数据
|
||||
Page<TbProduct> page = tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbProductMapper::toDto));
|
||||
List<String> productId = new ArrayList<>();
|
||||
List<Integer> unitId = new ArrayList<>();
|
||||
List<Integer> specId = new ArrayList<>();
|
||||
for (TbProduct product : page.getContent()) {
|
||||
//记录商品id
|
||||
productId.add(product.getId().toString());
|
||||
//记录单位id
|
||||
if (product.getUnitId() != null){
|
||||
unitId.add(Integer.valueOf(product.getUnitId()));
|
||||
}
|
||||
//记录规格id
|
||||
specId.add(product.getSpecId());
|
||||
}
|
||||
//sku
|
||||
List<TbProductSku> tbProductSkus = tbProductSkuRepository.searchSku(productId);
|
||||
//单位
|
||||
List<TbShopUnit> tbShopUnits = new ArrayList<>();
|
||||
if (!unitId.isEmpty()){
|
||||
tbShopUnits = tbShopUnitRepository.searchUnit(unitId);
|
||||
}
|
||||
//商品规格
|
||||
List<TbProductSpec> tbProductSpecs = new ArrayList<>();
|
||||
if (!specId.isEmpty()) {
|
||||
tbProductSpecs = tbProductSpecRepository.searchSpec(specId);
|
||||
}
|
||||
//组装
|
||||
List<TbProductVo> tbProductVoList = new ArrayList<>();
|
||||
for (TbProduct product : page.getContent()) {
|
||||
List<TbProductSku> skuList = new ArrayList<>();
|
||||
TbProductVo tbProductVo = new TbProductVo();
|
||||
//sku
|
||||
for (TbProductSku sku : tbProductSkus) {
|
||||
//sku
|
||||
if (sku.getProductId().equals(product.getId().toString())){
|
||||
skuList.add(sku);
|
||||
}
|
||||
}
|
||||
tbProductVo.setSkuList(skuList);
|
||||
//单位
|
||||
if (tbShopUnits.isEmpty()){
|
||||
tbProductVo.setUnitName("");
|
||||
}else {
|
||||
for (TbShopUnit tbShopUnit : tbShopUnits) {
|
||||
if(tbShopUnit.getId().toString().equals(product.getUnitId())){
|
||||
tbProductVo.setUnitName(tbShopUnit.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
//商品规格
|
||||
if (tbProductSpecs.isEmpty()){
|
||||
tbProductVo.setSpecsInfo(new HashMap<>());
|
||||
}else {
|
||||
for (TbProductSpec spec :tbProductSpecs) {
|
||||
if (spec.getId().equals(product.getSpecId())){
|
||||
HashMap<String, String> specsMap = new HashMap<>();
|
||||
specsMap.put(spec.getName(),spec.getSpecList());
|
||||
tbProductVo.setSpecsInfo(specsMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(product, tbProductVo);
|
||||
tbProductVoList.add(tbProductVo);
|
||||
}
|
||||
System.out.println(tbProductVoList);
|
||||
return PageUtil.toPage(tbProductVoList,tbProductVoList.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -13,11 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.product.service.mapstruct;
|
||||
package me.zhengjie.modules.productInfo.product.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import me.zhengjie.modules.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.product.service.dto.TbProductDto;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.productInfo.product.service.dto.TbProductDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productGroup.domain;
|
||||
package me.zhengjie.modules.productInfo.productGroup.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
@@ -13,12 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productGroup.repository;
|
||||
package me.zhengjie.modules.productInfo.productGroup.repository;
|
||||
|
||||
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productInfo.productGroup.domain.TbProductGroup;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -13,16 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productGroup.rest;
|
||||
package me.zhengjie.modules.productInfo.productGroup.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.modules.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.product.service.TbProductService;
|
||||
import me.zhengjie.modules.product.service.dto.TbProductQueryCriteria;
|
||||
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productGroup.service.TbProductGroupService;
|
||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||
import me.zhengjie.modules.productGroup.service.vo.AddProduct;
|
||||
import me.zhengjie.modules.productInfo.product.service.TbProductService;
|
||||
import me.zhengjie.modules.productInfo.product.service.dto.TbProductQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.TbProductGroupService;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.vo.AddProduct;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -32,7 +31,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -103,6 +101,12 @@ public class TbProductGroupController {
|
||||
return new ResponseEntity<>(tbProductService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品分类增加商品
|
||||
* @param addProduct
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/addProductInfo")
|
||||
public ResponseEntity<Object> addProductInfo(@RequestBody AddProduct addProduct,@RequestAttribute(value = "userName", required = false) String userName){
|
||||
return new ResponseEntity<>(tbProductGroupService.updateProductIds(addProduct,userName),HttpStatus.OK);
|
||||
@@ -13,12 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productGroup.service;
|
||||
package me.zhengjie.modules.productInfo.productGroup.service;
|
||||
|
||||
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupDto;
|
||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||
import me.zhengjie.modules.productGroup.service.vo.AddProduct;
|
||||
import me.zhengjie.modules.productInfo.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.dto.TbProductGroupDto;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.vo.AddProduct;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@@ -84,5 +84,5 @@ public interface TbProductGroupService {
|
||||
*/
|
||||
void download(List<TbProductGroupDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
ResponseEntity<Object> updateProductIds(AddProduct addProduct,String userName);
|
||||
ResponseEntity<Object> updateProductIds(AddProduct addProduct, String userName);
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productGroup.service.dto;
|
||||
package me.zhengjie.modules.productInfo.productGroup.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productGroup.service.dto;
|
||||
package me.zhengjie.modules.productInfo.productGroup.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
@@ -13,20 +13,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productGroup.service.impl;
|
||||
package me.zhengjie.modules.productInfo.productGroup.service.impl;
|
||||
|
||||
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productGroup.service.vo.AddProduct;
|
||||
import me.zhengjie.modules.productInfo.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.vo.AddProduct;
|
||||
import me.zhengjie.modules.productInfo.productGroup.repository.TbProductGroupRepository;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.dto.TbProductGroupDto;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||
import me.zhengjie.modules.security.service.OnlineUserService;
|
||||
import me.zhengjie.modules.security.service.dto.OnlineUserDto;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.productGroup.repository.TbProductGroupRepository;
|
||||
import me.zhengjie.modules.productGroup.service.TbProductGroupService;
|
||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupDto;
|
||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||
import me.zhengjie.modules.productGroup.service.mapstruct.TbProductGroupMapper;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.TbProductGroupService;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.mapstruct.TbProductGroupMapper;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -122,15 +122,13 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> updateProductIds(AddProduct addProduct,String userName) {
|
||||
public ResponseEntity<Object> updateProductIds(AddProduct addProduct, String userName) {
|
||||
OnlineUserDto onlineUser = onlineUserService.getOne(addProduct.getKey());
|
||||
|
||||
|
||||
|
||||
if (addProduct.getIds().size()<1){
|
||||
return new ResponseEntity<>("错误", HttpStatus.NOT_ACCEPTABLE);
|
||||
}
|
||||
TbProductGroupDto productGroup = this.findById(addProduct.getProductId());
|
||||
TbProductGroupDto productGroup = this.findById(addProduct.getGroupId());
|
||||
|
||||
if (productGroup == null){
|
||||
return new ResponseEntity<>("没有找到改分类", HttpStatus.NOT_ACCEPTABLE);
|
||||
@@ -138,14 +136,14 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
TbProductGroup tbProductGroup = new TbProductGroup();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// //如果没有
|
||||
if (productGroup.getProductIds() == null) {
|
||||
if (productGroup.getProductIds() == null || "".equals(productGroup.getProductIds())) {
|
||||
for (String s : addProduct.getIds()) {
|
||||
sb.append(s);
|
||||
sb.append(",");
|
||||
}
|
||||
|
||||
tbProductGroup.setProductIds(sb.toString());
|
||||
tbProductGroup.setId(addProduct.getProductId());
|
||||
tbProductGroup.setId(addProduct.getGroupId());
|
||||
this.update(tbProductGroup);
|
||||
}else {
|
||||
//如果有
|
||||
@@ -156,7 +154,7 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
sb.append(productGroup.getProductIds());
|
||||
|
||||
tbProductGroup.setProductIds(sb.toString());
|
||||
tbProductGroup.setId(addProduct.getProductId());
|
||||
tbProductGroup.setId(addProduct.getGroupId());
|
||||
this.update(tbProductGroup);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productGroup.service.mapstruct;
|
||||
package me.zhengjie.modules.productInfo.productGroup.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import me.zhengjie.modules.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productGroup.service.dto.TbProductGroupDto;
|
||||
import me.zhengjie.modules.productInfo.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.dto.TbProductGroupDto;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.zhengjie.modules.productGroup.service.vo;
|
||||
package me.zhengjie.modules.productInfo.productGroup.service.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
public class AddProduct {
|
||||
List<String> ids;
|
||||
|
||||
Integer productId;
|
||||
Integer groupId;
|
||||
|
||||
String key;
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSku.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_product_sku")
|
||||
public class TbProductSku implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "自增id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`shop_id`")
|
||||
@ApiModelProperty(value = "shopId")
|
||||
private String shopId;
|
||||
|
||||
@Column(name = "`bar_code`")
|
||||
@ApiModelProperty(value = "条形码")
|
||||
private String barCode;
|
||||
|
||||
@Column(name = "`product_id`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "商品Id")
|
||||
private String productId;
|
||||
|
||||
@Column(name = "`origin_price`")
|
||||
@ApiModelProperty(value = "原价")
|
||||
private BigDecimal originPrice;
|
||||
|
||||
@Column(name = "`cost_price`")
|
||||
@ApiModelProperty(value = "成本价")
|
||||
private BigDecimal costPrice;
|
||||
|
||||
@Column(name = "`member_price`")
|
||||
@ApiModelProperty(value = "会员价")
|
||||
private BigDecimal memberPrice;
|
||||
|
||||
@Column(name = "`meal_price`")
|
||||
@ApiModelProperty(value = "mealPrice")
|
||||
private BigDecimal mealPrice;
|
||||
|
||||
@Column(name = "`sale_price`")
|
||||
@ApiModelProperty(value = "售价")
|
||||
private BigDecimal salePrice;
|
||||
|
||||
@Column(name = "`guide_price`")
|
||||
@ApiModelProperty(value = "进货参考价")
|
||||
private BigDecimal guidePrice;
|
||||
|
||||
@Column(name = "`strategy_price`")
|
||||
@ApiModelProperty(value = "strategyPrice")
|
||||
private BigDecimal strategyPrice;
|
||||
|
||||
@Column(name = "`stock_number`")
|
||||
@ApiModelProperty(value = "库存数量")
|
||||
private Double stockNumber;
|
||||
|
||||
@Column(name = "`spec_snap`")
|
||||
@ApiModelProperty(value = "标签镜像")
|
||||
private String specSnap;
|
||||
|
||||
@Column(name = "`cover_img`")
|
||||
@ApiModelProperty(value = "coverImg")
|
||||
private String coverImg;
|
||||
|
||||
@Column(name = "`warn_line`")
|
||||
@ApiModelProperty(value = "库存警戒线")
|
||||
private Integer warnLine;
|
||||
|
||||
@Column(name = "`weight`")
|
||||
@ApiModelProperty(value = "weight")
|
||||
private Double weight;
|
||||
|
||||
@Column(name = "`volume`")
|
||||
@ApiModelProperty(value = "volume")
|
||||
private Float volume;
|
||||
|
||||
@Column(name = "`real_sales_number`")
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Double realSalesNumber;
|
||||
|
||||
@Column(name = "`first_shared`")
|
||||
@ApiModelProperty(value = "一级分销金额")
|
||||
private BigDecimal firstShared;
|
||||
|
||||
@Column(name = "`second_shared`")
|
||||
@ApiModelProperty(value = "二级分销金额")
|
||||
private BigDecimal secondShared;
|
||||
|
||||
@Column(name = "`created_at`")
|
||||
@ApiModelProperty(value = "createdAt")
|
||||
private Long createdAt;
|
||||
|
||||
@Column(name = "`updated_at`")
|
||||
@ApiModelProperty(value = "updatedAt")
|
||||
private Long updatedAt;
|
||||
|
||||
public void copy(TbProductSku source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package me.zhengjie.modules.productInfo.productSku.domain;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
public class TbProductSkuVO {
|
||||
String realSalesNumber;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSku.repository;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Integer>, JpaSpecificationExecutor<TbProductSku> {
|
||||
|
||||
@Query("SELECT sku FROM TbProductSku sku WHERE sku.productId IN :productId")
|
||||
List<TbProductSku> searchSku(@Param("productId")List<String> productId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSku.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku;
|
||||
import me.zhengjie.modules.productInfo.productSku.service.dto.TbProductSkuQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.productSku.service.TbProductSkuService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/product/sku管理")
|
||||
@RequestMapping("/api/tbProductSku")
|
||||
public class TbProductSkuController {
|
||||
|
||||
private final TbProductSkuService tbProductSkuService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbProductSku:list')")
|
||||
public void exportTbProductSku(HttpServletResponse response, TbProductSkuQueryCriteria criteria) throws IOException {
|
||||
tbProductSkuService.download(tbProductSkuService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询/product/sku")
|
||||
@ApiOperation("查询/product/sku")
|
||||
@PreAuthorize("@el.check('tbProductSku:list')")
|
||||
public ResponseEntity<Object> queryTbProductSku(TbProductSkuQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbProductSkuService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增/product/sku")
|
||||
@ApiOperation("新增/product/sku")
|
||||
@PreAuthorize("@el.check('tbProductSku:add')")
|
||||
public ResponseEntity<Object> createTbProductSku(@Validated @RequestBody TbProductSku resources){
|
||||
return new ResponseEntity<>(tbProductSkuService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改/product/sku")
|
||||
@ApiOperation("修改/product/sku")
|
||||
@PreAuthorize("@el.check('tbProductSku:edit')")
|
||||
public ResponseEntity<Object> updateTbProductSku(@Validated @RequestBody TbProductSku resources){
|
||||
tbProductSkuService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除/product/sku")
|
||||
@ApiOperation("删除/product/sku")
|
||||
@PreAuthorize("@el.check('tbProductSku:del')")
|
||||
public ResponseEntity<Object> deleteTbProductSku(@RequestBody Integer[] ids) {
|
||||
tbProductSkuService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSku.service;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku;
|
||||
import me.zhengjie.modules.productInfo.productSku.service.dto.TbProductSkuQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.productSku.service.dto.TbProductSkuDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
public interface TbProductSkuService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbProductSkuQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbProductSkuDto>
|
||||
*/
|
||||
List<TbProductSkuDto> queryAll(TbProductSkuQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbProductSkuDto
|
||||
*/
|
||||
TbProductSkuDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbProductSkuDto
|
||||
*/
|
||||
TbProductSkuDto create(TbProductSku resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbProductSku resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbProductSkuDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.zhengjie.modules.productInfo.productSku.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
public class SkuDto {
|
||||
/**
|
||||
* 销量
|
||||
*/
|
||||
private Double realSalesNumber;
|
||||
/**
|
||||
* 库存数量
|
||||
*/
|
||||
private Double stockNumber;
|
||||
|
||||
/**
|
||||
* 原价
|
||||
*/
|
||||
private Double originPrice;
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
private Double costPrice;
|
||||
/**
|
||||
* 会员价
|
||||
*/
|
||||
private Double memberPrice;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private String productId;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSku.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@Data
|
||||
public class TbProductSkuDto implements Serializable {
|
||||
|
||||
/** 自增id */
|
||||
private Integer id;
|
||||
|
||||
private String shopId;
|
||||
|
||||
/** 条形码 */
|
||||
private String barCode;
|
||||
|
||||
/** 商品Id */
|
||||
private String productId;
|
||||
|
||||
/** 原价 */
|
||||
private BigDecimal originPrice;
|
||||
|
||||
/** 成本价 */
|
||||
private BigDecimal costPrice;
|
||||
|
||||
/** 会员价 */
|
||||
private BigDecimal memberPrice;
|
||||
|
||||
private BigDecimal mealPrice;
|
||||
|
||||
/** 售价 */
|
||||
private BigDecimal salePrice;
|
||||
|
||||
/** 进货参考价 */
|
||||
private BigDecimal guidePrice;
|
||||
|
||||
private BigDecimal strategyPrice;
|
||||
|
||||
/** 库存数量 */
|
||||
private Double stockNumber;
|
||||
|
||||
/** 标签镜像 */
|
||||
private String specSnap;
|
||||
|
||||
private String coverImg;
|
||||
|
||||
/** 库存警戒线 */
|
||||
private Integer warnLine;
|
||||
|
||||
private Double weight;
|
||||
|
||||
private Float volume;
|
||||
|
||||
/** 销量 */
|
||||
private Double realSalesNumber;
|
||||
|
||||
/** 一级分销金额 */
|
||||
private BigDecimal firstShared;
|
||||
|
||||
/** 二级分销金额 */
|
||||
private BigDecimal secondShared;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSku.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@Data
|
||||
public class TbProductSkuQueryCriteria{
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSku.service.impl;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku;
|
||||
import me.zhengjie.modules.productInfo.productSku.service.dto.TbProductSkuQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.productSku.service.mapstruct.TbProductSkuMapper;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.productInfo.productSku.repository.TbProductSkuRepository;
|
||||
import me.zhengjie.modules.productInfo.productSku.service.TbProductSkuService;
|
||||
import me.zhengjie.modules.productInfo.productSku.service.dto.TbProductSkuDto;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbProductSkuServiceImpl implements TbProductSkuService {
|
||||
|
||||
private final TbProductSkuRepository tbProductSkuRepository;
|
||||
private final TbProductSkuMapper tbProductSkuMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbProductSkuQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbProductSku> page = tbProductSkuRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbProductSkuMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbProductSkuDto> queryAll(TbProductSkuQueryCriteria criteria){
|
||||
return tbProductSkuMapper.toDto(tbProductSkuRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbProductSkuDto findById(Integer id) {
|
||||
TbProductSku tbProductSku = tbProductSkuRepository.findById(id).orElseGet(TbProductSku::new);
|
||||
ValidationUtil.isNull(tbProductSku.getId(),"TbProductSku","id",id);
|
||||
return tbProductSkuMapper.toDto(tbProductSku);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbProductSkuDto create(TbProductSku resources) {
|
||||
return tbProductSkuMapper.toDto(tbProductSkuRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbProductSku resources) {
|
||||
TbProductSku tbProductSku = tbProductSkuRepository.findById(resources.getId()).orElseGet(TbProductSku::new);
|
||||
ValidationUtil.isNull( tbProductSku.getId(),"TbProductSku","id",resources.getId());
|
||||
tbProductSku.copy(resources);
|
||||
tbProductSkuRepository.save(tbProductSku);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbProductSkuRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbProductSkuDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbProductSkuDto tbProductSku : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put(" shopId", tbProductSku.getShopId());
|
||||
map.put("条形码", tbProductSku.getBarCode());
|
||||
map.put("商品Id", tbProductSku.getProductId());
|
||||
map.put("原价", tbProductSku.getOriginPrice());
|
||||
map.put("成本价", tbProductSku.getCostPrice());
|
||||
map.put("会员价", tbProductSku.getMemberPrice());
|
||||
map.put(" mealPrice", tbProductSku.getMealPrice());
|
||||
map.put("售价", tbProductSku.getSalePrice());
|
||||
map.put("进货参考价", tbProductSku.getGuidePrice());
|
||||
map.put(" strategyPrice", tbProductSku.getStrategyPrice());
|
||||
map.put("库存数量", tbProductSku.getStockNumber());
|
||||
map.put("标签镜像", tbProductSku.getSpecSnap());
|
||||
map.put(" coverImg", tbProductSku.getCoverImg());
|
||||
map.put("库存警戒线", tbProductSku.getWarnLine());
|
||||
map.put(" weight", tbProductSku.getWeight());
|
||||
map.put(" volume", tbProductSku.getVolume());
|
||||
map.put("销量", tbProductSku.getRealSalesNumber());
|
||||
map.put("一级分销金额", tbProductSku.getFirstShared());
|
||||
map.put("二级分销金额", tbProductSku.getSecondShared());
|
||||
map.put(" createdAt", tbProductSku.getCreatedAt());
|
||||
map.put(" updatedAt", tbProductSku.getUpdatedAt());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSku.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku;
|
||||
import me.zhengjie.modules.productInfo.productSku.service.dto.TbProductSkuDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbProductSkuMapper extends BaseMapper<TbProductSkuDto, TbProductSku> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSpec.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_product_spec")
|
||||
public class TbProductSpec implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`shop_id`")
|
||||
@ApiModelProperty(value = "shopId")
|
||||
private String shopId;
|
||||
|
||||
@Column(name = "`name`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "商品属性名称")
|
||||
private String name;
|
||||
|
||||
@Column(name = "`spec_tag`")
|
||||
@ApiModelProperty(value = "规格属性")
|
||||
private String specTag;
|
||||
|
||||
@Column(name = "`spec_tag_detail`")
|
||||
@ApiModelProperty(value = "属性介绍")
|
||||
private String specTagDetail;
|
||||
|
||||
@Column(name = "`spec_list`")
|
||||
@ApiModelProperty(value = "specList")
|
||||
private String specList;
|
||||
|
||||
@Column(name = "`sort`")
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Column(name = "`created_at`")
|
||||
@ApiModelProperty(value = "createdAt")
|
||||
private Long createdAt;
|
||||
|
||||
@Column(name = "`updated_at`")
|
||||
@ApiModelProperty(value = "updatedAt")
|
||||
private Long updatedAt;
|
||||
|
||||
public void copy(TbProductSpec source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSpec.repository;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productSpec.domain.TbProductSpec;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
public interface TbProductSpecRepository extends JpaRepository<TbProductSpec, Integer>, JpaSpecificationExecutor<TbProductSpec> {
|
||||
|
||||
@Query("SELECT spec FROM TbProductSpec spec WHERE spec.id IN :ids")
|
||||
List<TbProductSpec> searchSpec(@Param("ids")List<Integer> ids);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSpec.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.modules.productInfo.productSpec.domain.TbProductSpec;
|
||||
import me.zhengjie.modules.productInfo.productSpec.service.TbProductSpecService;
|
||||
import me.zhengjie.modules.productInfo.productSpec.service.dto.TbProductSpecQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "product/spec管理")
|
||||
@RequestMapping("/api/tbProductSpec")
|
||||
public class TbProductSpecController {
|
||||
|
||||
private final TbProductSpecService tbProductSpecService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbProductSpec:list')")
|
||||
public void exportTbProductSpec(HttpServletResponse response, TbProductSpecQueryCriteria criteria) throws IOException {
|
||||
tbProductSpecService.download(tbProductSpecService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询product/spec")
|
||||
@ApiOperation("查询product/spec")
|
||||
@PreAuthorize("@el.check('tbProductSpec:list')")
|
||||
public ResponseEntity<Object> queryTbProductSpec(TbProductSpecQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbProductSpecService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增product/spec")
|
||||
@ApiOperation("新增product/spec")
|
||||
@PreAuthorize("@el.check('tbProductSpec:add')")
|
||||
public ResponseEntity<Object> createTbProductSpec(@Validated @RequestBody TbProductSpec resources){
|
||||
return new ResponseEntity<>(tbProductSpecService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改product/spec")
|
||||
@ApiOperation("修改product/spec")
|
||||
@PreAuthorize("@el.check('tbProductSpec:edit')")
|
||||
public ResponseEntity<Object> updateTbProductSpec(@Validated @RequestBody TbProductSpec resources){
|
||||
tbProductSpecService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除product/spec")
|
||||
@ApiOperation("删除product/spec")
|
||||
@PreAuthorize("@el.check('tbProductSpec:del')")
|
||||
public ResponseEntity<Object> deleteTbProductSpec(@RequestBody Integer[] ids) {
|
||||
tbProductSpecService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSpec.service;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productSpec.service.dto.TbProductSpecDto;
|
||||
import me.zhengjie.modules.productInfo.productSpec.service.dto.TbProductSpecQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.productSpec.domain.TbProductSpec;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
public interface TbProductSpecService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbProductSpecQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbProductSpecDto>
|
||||
*/
|
||||
List<TbProductSpecDto> queryAll(TbProductSpecQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbProductSpecDto
|
||||
*/
|
||||
TbProductSpecDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbProductSpecDto
|
||||
*/
|
||||
TbProductSpecDto create(TbProductSpec resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbProductSpec resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbProductSpecDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSpec.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@Data
|
||||
public class TbProductSpecDto implements Serializable {
|
||||
|
||||
/** id */
|
||||
private Integer id;
|
||||
|
||||
private String shopId;
|
||||
|
||||
/** 商品属性名称 */
|
||||
private String name;
|
||||
|
||||
/** 规格属性 */
|
||||
private String specTag;
|
||||
|
||||
/** 属性介绍 */
|
||||
private String specTagDetail;
|
||||
|
||||
private String specList;
|
||||
|
||||
/** 排序 */
|
||||
private Integer sort;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSpec.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@Data
|
||||
public class TbProductSpecQueryCriteria{
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSpec.service.impl;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productSpec.domain.TbProductSpec;
|
||||
import me.zhengjie.modules.productInfo.productSpec.repository.TbProductSpecRepository;
|
||||
import me.zhengjie.modules.productInfo.productSpec.service.TbProductSpecService;
|
||||
import me.zhengjie.modules.productInfo.productSpec.service.dto.TbProductSpecDto;
|
||||
import me.zhengjie.modules.productInfo.productSpec.service.dto.TbProductSpecQueryCriteria;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.productInfo.productSpec.service.mapstruct.TbProductSpecMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbProductSpecServiceImpl implements TbProductSpecService {
|
||||
|
||||
private final TbProductSpecRepository tbProductSpecRepository;
|
||||
private final TbProductSpecMapper tbProductSpecMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbProductSpecQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbProductSpec> page = tbProductSpecRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbProductSpecMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbProductSpecDto> queryAll(TbProductSpecQueryCriteria criteria){
|
||||
return tbProductSpecMapper.toDto(tbProductSpecRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbProductSpecDto findById(Integer id) {
|
||||
TbProductSpec tbProductSpec = tbProductSpecRepository.findById(id).orElseGet(TbProductSpec::new);
|
||||
ValidationUtil.isNull(tbProductSpec.getId(),"TbProductSpec","id",id);
|
||||
return tbProductSpecMapper.toDto(tbProductSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbProductSpecDto create(TbProductSpec resources) {
|
||||
return tbProductSpecMapper.toDto(tbProductSpecRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbProductSpec resources) {
|
||||
TbProductSpec tbProductSpec = tbProductSpecRepository.findById(resources.getId()).orElseGet(TbProductSpec::new);
|
||||
ValidationUtil.isNull( tbProductSpec.getId(),"TbProductSpec","id",resources.getId());
|
||||
tbProductSpec.copy(resources);
|
||||
tbProductSpecRepository.save(tbProductSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbProductSpecRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbProductSpecDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbProductSpecDto tbProductSpec : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put(" shopId", tbProductSpec.getShopId());
|
||||
map.put("商品属性名称", tbProductSpec.getName());
|
||||
map.put("规格属性", tbProductSpec.getSpecTag());
|
||||
map.put("属性介绍", tbProductSpec.getSpecTagDetail());
|
||||
map.put(" specList", tbProductSpec.getSpecList());
|
||||
map.put("排序", tbProductSpec.getSort());
|
||||
map.put(" createdAt", tbProductSpec.getCreatedAt());
|
||||
map.put(" updatedAt", tbProductSpec.getUpdatedAt());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSpec.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import me.zhengjie.modules.productInfo.productSpec.domain.TbProductSpec;
|
||||
import me.zhengjie.modules.productInfo.productSpec.service.dto.TbProductSpecDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-03
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbProductSpecMapper extends BaseMapper<TbProductSpecDto, TbProductSpec> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopUnit.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-02
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_shop_unit")
|
||||
public class TbShopUnit implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`name`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "单位名称")
|
||||
private String name;
|
||||
|
||||
@Column(name = "`decimals_digits`")
|
||||
@ApiModelProperty(value = "小数位(个数大于0,表示小数据精度位数)")
|
||||
private Integer decimalsDigits;
|
||||
|
||||
@Column(name = "`unit_type`")
|
||||
@ApiModelProperty(value = "单位类型(weight代表重量,小数单位,为number代表个数)")
|
||||
private String unitType;
|
||||
|
||||
@Column(name = "`is_system`")
|
||||
@ApiModelProperty(value = "0后台添加 -1系统默认 (公斤、瓶)")
|
||||
private Integer isSystem;
|
||||
|
||||
@Column(name = "`status`")
|
||||
@ApiModelProperty(value = "预留字段1-正常")
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "`merchant_id`")
|
||||
@ApiModelProperty(value = "merchantId")
|
||||
private String merchantId;
|
||||
|
||||
@Column(name = "`shop_id`")
|
||||
@ApiModelProperty(value = "店铺Id")
|
||||
private String shopId;
|
||||
|
||||
@Column(name = "`created_at`")
|
||||
@ApiModelProperty(value = "createdAt")
|
||||
private Long createdAt;
|
||||
|
||||
@Column(name = "`updated_at`")
|
||||
@ApiModelProperty(value = "updatedAt")
|
||||
private Long updatedAt;
|
||||
|
||||
public void copy(TbShopUnit source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopUnit.repository;
|
||||
|
||||
import me.zhengjie.modules.shopUnit.domain.TbShopUnit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-02
|
||||
**/
|
||||
public interface TbShopUnitRepository extends JpaRepository<TbShopUnit, Integer>, JpaSpecificationExecutor<TbShopUnit> {
|
||||
@Query("SELECT unit FROM TbShopUnit unit WHERE unit.id IN :ids")
|
||||
List<TbShopUnit> searchUnit(@Param("ids")List<Integer> ids);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopUnit.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.modules.shopUnit.domain.TbShopUnit;
|
||||
import me.zhengjie.modules.shopUnit.service.TbShopUnitService;
|
||||
import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-02
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/shop/unit管理")
|
||||
@RequestMapping("/api/tbShopUnit")
|
||||
public class TbShopUnitController {
|
||||
|
||||
private final TbShopUnitService tbShopUnitService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbShopUnit:list')")
|
||||
public void exportTbShopUnit(HttpServletResponse response, TbShopUnitQueryCriteria criteria) throws IOException {
|
||||
tbShopUnitService.download(tbShopUnitService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询/shop/unit")
|
||||
@ApiOperation("查询/shop/unit")
|
||||
@PreAuthorize("@el.check('tbShopUnit:list')")
|
||||
public ResponseEntity<Object> queryTbShopUnit(TbShopUnitQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbShopUnitService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增/shop/unit")
|
||||
@ApiOperation("新增/shop/unit")
|
||||
@PreAuthorize("@el.check('tbShopUnit:add')")
|
||||
public ResponseEntity<Object> createTbShopUnit(@Validated @RequestBody TbShopUnit resources){
|
||||
return new ResponseEntity<>(tbShopUnitService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改/shop/unit")
|
||||
@ApiOperation("修改/shop/unit")
|
||||
@PreAuthorize("@el.check('tbShopUnit:edit')")
|
||||
public ResponseEntity<Object> updateTbShopUnit(@Validated @RequestBody TbShopUnit resources){
|
||||
tbShopUnitService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除/shop/unit")
|
||||
@ApiOperation("删除/shop/unit")
|
||||
@PreAuthorize("@el.check('tbShopUnit:del')")
|
||||
public ResponseEntity<Object> deleteTbShopUnit(@RequestBody Integer[] ids) {
|
||||
tbShopUnitService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopUnit.service;
|
||||
|
||||
import me.zhengjie.modules.shopUnit.domain.TbShopUnit;
|
||||
import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitDto;
|
||||
import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author lyf
|
||||
* @date 2024-01-02
|
||||
**/
|
||||
public interface TbShopUnitService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbShopUnitQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbShopUnitDto>
|
||||
*/
|
||||
List<TbShopUnitDto> queryAll(TbShopUnitQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbShopUnitDto
|
||||
*/
|
||||
TbShopUnitDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbShopUnitDto
|
||||
*/
|
||||
TbShopUnitDto create(TbShopUnit resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbShopUnit resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbShopUnitDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopUnit.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-02
|
||||
**/
|
||||
@Data
|
||||
public class TbShopUnitDto implements Serializable {
|
||||
|
||||
/** id */
|
||||
private Integer id;
|
||||
|
||||
/** 单位名称 */
|
||||
private String name;
|
||||
|
||||
/** 小数位(个数大于0,表示小数据精度位数) */
|
||||
private Integer decimalsDigits;
|
||||
|
||||
/** 单位类型(weight代表重量,小数单位,为number代表个数) */
|
||||
private String unitType;
|
||||
|
||||
/** 0后台添加 -1系统默认 (公斤、瓶) */
|
||||
private Integer isSystem;
|
||||
|
||||
/** 预留字段1-正常 */
|
||||
private Integer status;
|
||||
|
||||
private String merchantId;
|
||||
|
||||
/** 店铺Id */
|
||||
private String shopId;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopUnit.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-02
|
||||
**/
|
||||
@Data
|
||||
public class TbShopUnitQueryCriteria{
|
||||
@Query
|
||||
private String name;
|
||||
|
||||
@Query
|
||||
private String shopId;
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopUnit.service.impl;
|
||||
|
||||
import me.zhengjie.modules.shopUnit.domain.TbShopUnit;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.shopUnit.repository.TbShopUnitRepository;
|
||||
import me.zhengjie.modules.shopUnit.service.TbShopUnitService;
|
||||
import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitDto;
|
||||
import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitQueryCriteria;
|
||||
import me.zhengjie.modules.shopUnit.service.mapstruct.TbShopUnitMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author lyf
|
||||
* @date 2024-01-02
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbShopUnitServiceImpl implements TbShopUnitService {
|
||||
|
||||
private final TbShopUnitRepository tbShopUnitRepository;
|
||||
private final TbShopUnitMapper tbShopUnitMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbShopUnitQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbShopUnit> page = tbShopUnitRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbShopUnitMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbShopUnitDto> queryAll(TbShopUnitQueryCriteria criteria){
|
||||
return tbShopUnitMapper.toDto(tbShopUnitRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbShopUnitDto findById(Integer id) {
|
||||
TbShopUnit tbShopUnit = tbShopUnitRepository.findById(id).orElseGet(TbShopUnit::new);
|
||||
ValidationUtil.isNull(tbShopUnit.getId(),"TbShopUnit","id",id);
|
||||
return tbShopUnitMapper.toDto(tbShopUnit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbShopUnitDto create(TbShopUnit resources) {
|
||||
return tbShopUnitMapper.toDto(tbShopUnitRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbShopUnit resources) {
|
||||
TbShopUnit tbShopUnit = tbShopUnitRepository.findById(resources.getId()).orElseGet(TbShopUnit::new);
|
||||
ValidationUtil.isNull( tbShopUnit.getId(),"TbShopUnit","id",resources.getId());
|
||||
tbShopUnit.copy(resources);
|
||||
tbShopUnitRepository.save(tbShopUnit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbShopUnitRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbShopUnitDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbShopUnitDto tbShopUnit : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("单位名称", tbShopUnit.getName());
|
||||
map.put("小数位(个数大于0,表示小数据精度位数)", tbShopUnit.getDecimalsDigits());
|
||||
map.put("单位类型(weight代表重量,小数单位,为number代表个数)", tbShopUnit.getUnitType());
|
||||
map.put("0后台添加 -1系统默认 (公斤、瓶)", tbShopUnit.getIsSystem());
|
||||
map.put("预留字段1-正常", tbShopUnit.getStatus());
|
||||
map.put(" merchantId", tbShopUnit.getMerchantId());
|
||||
map.put("店铺Id", tbShopUnit.getShopId());
|
||||
map.put(" createdAt", tbShopUnit.getCreatedAt());
|
||||
map.put(" updatedAt", tbShopUnit.getUpdatedAt());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopUnit.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import me.zhengjie.modules.shopUnit.domain.TbShopUnit;
|
||||
import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-02
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbShopUnitMapper extends BaseMapper<TbShopUnitDto, TbShopUnit> {
|
||||
|
||||
}
|
||||
27
product/spec/tbProductSpec.js
Normal file
27
product/spec/tbProductSpec.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: 'api/tbProductSpec',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/tbProductSpec/',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function edit(data) {
|
||||
return request({
|
||||
url: 'api/tbProductSpec',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del }
|
||||
Reference in New Issue
Block a user