dev798
parent
ed518ed484
commit
a0ab257929
|
@ -5,11 +5,9 @@ import com.muyu.product.domain.DTO.ProductTypeAttr;
|
||||||
import com.muyu.product.domain.Resp.ProductTypeResp;
|
import com.muyu.product.domain.Resp.ProductTypeResp;
|
||||||
import com.muyu.product.service.TypeService;
|
import com.muyu.product.service.TypeService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -37,12 +35,21 @@ public class TypeController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/queryTypeAttr/{flag}/{id}")
|
@GetMapping("/queryTypeAttr/{flag}/{id}")
|
||||||
|
@ApiOperation("属性/参数类型查询")
|
||||||
public AjaxResult queryType(@PathVariable Integer flag,@PathVariable Integer id){
|
public AjaxResult queryType(@PathVariable Integer flag,@PathVariable Integer id){
|
||||||
List<ProductTypeAttr> list =typeService.queryType(flag,id);
|
List<ProductTypeAttr> list =typeService.queryType(flag,id);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DeleteMapping("/{typeId}")
|
||||||
|
@ApiOperation("类型删除")
|
||||||
|
public AjaxResult deleteType(@PathVariable Integer typeId){
|
||||||
|
Integer res = typeService.deleteType(typeId);
|
||||||
|
return AjaxResult.success(res==1?"删除成功":"删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,5 @@ public interface TypeMapper {
|
||||||
|
|
||||||
List<ProductTypeAttr> queryType(@Param("flag") Integer flag, @Param("id") Integer id);
|
List<ProductTypeAttr> queryType(@Param("flag") Integer flag, @Param("id") Integer id);
|
||||||
|
|
||||||
|
Integer deleteType(Integer typeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,4 +15,6 @@ public interface TypeService {
|
||||||
List<ProductTypeResp> queryTypeAll();
|
List<ProductTypeResp> queryTypeAll();
|
||||||
|
|
||||||
List<ProductTypeAttr> queryType(Integer flag, Integer id);
|
List<ProductTypeAttr> queryType(Integer flag, Integer id);
|
||||||
|
|
||||||
|
Integer deleteType(Integer typeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.product.service.impl;
|
||||||
import com.alibaba.fastjson.JSONObject; // 导入 FastJSON 的 JSONObject 类
|
import com.alibaba.fastjson.JSONObject; // 导入 FastJSON 的 JSONObject 类
|
||||||
import com.github.pagehelper.PageHelper; // 导入 PageHelper 类
|
import com.github.pagehelper.PageHelper; // 导入 PageHelper 类
|
||||||
import com.github.pagehelper.PageInfo; // 导入 PageInfo 类
|
import com.github.pagehelper.PageInfo; // 导入 PageInfo 类
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.product.domain.DTO.ProductSkuAttr; // 导入 ProductSkuAttr 类
|
import com.muyu.product.domain.DTO.ProductSkuAttr; // 导入 ProductSkuAttr 类
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +26,8 @@ import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -47,14 +50,16 @@ public class ProductServiceImpl implements ProductService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductSkuMapper productSkuMapper;
|
private ProductSkuMapper productSkuMapper;
|
||||||
|
|
||||||
|
private ExecutorService executor = Executors.newFixedThreadPool(3);
|
||||||
|
|
||||||
|
|
||||||
public void checkProductParams(ProductReq productReq){
|
public void checkProductParams(ProductReq productReq){
|
||||||
CompletableFuture<ValidationResult>methodTypeFuture =
|
CompletableFuture<ValidationResult>methodTypeFuture =
|
||||||
CompletableFuture.supplyAsync(() -> checkMethodType(productReq));
|
CompletableFuture.supplyAsync(() -> checkMethodType(productReq),executor);
|
||||||
CompletableFuture<ValidationResult>skuIdFuture =
|
CompletableFuture<ValidationResult>skuIdFuture =
|
||||||
CompletableFuture.supplyAsync(() -> findSkuId(productReq));
|
CompletableFuture.supplyAsync(() -> findSkuId(productReq),executor);
|
||||||
CompletableFuture<ValidationResult>productNumberFuture =
|
CompletableFuture<ValidationResult>productNumberFuture =
|
||||||
CompletableFuture.supplyAsync(() -> checkProductNumber(productReq));
|
CompletableFuture.supplyAsync(() -> checkProductNumber(productReq),executor);
|
||||||
CompletableFuture<String>allValidFuture =
|
CompletableFuture<String>allValidFuture =
|
||||||
methodTypeFuture.thenCombine(skuIdFuture,
|
methodTypeFuture.thenCombine(skuIdFuture,
|
||||||
(methodTypeResult,skuIdResult)->
|
(methodTypeResult,skuIdResult)->
|
||||||
|
@ -103,6 +108,8 @@ public class ProductServiceImpl implements ProductService {
|
||||||
public void productInsert(ProductReq productReq) {
|
public void productInsert(ProductReq productReq) {
|
||||||
long start =System.currentTimeMillis();
|
long start =System.currentTimeMillis();
|
||||||
|
|
||||||
|
checkProductParams(productReq);
|
||||||
|
|
||||||
insertProduct(productReq.getProduct());
|
insertProduct(productReq.getProduct());
|
||||||
|
|
||||||
insertProductService(productReq.getProduct().getId(),productReq.getServiceIds());
|
insertProductService(productReq.getProduct().getId(),productReq.getServiceIds());
|
||||||
|
@ -112,6 +119,8 @@ public class ProductServiceImpl implements ProductService {
|
||||||
|
|
||||||
insertProductSku(productReq);
|
insertProductSku(productReq);
|
||||||
|
|
||||||
|
log.info("耗时:{}",(System.currentTimeMillis()-start));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +205,7 @@ public class ProductServiceImpl implements ProductService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertProduct(Product product) {
|
private void insertProduct(Product product) {
|
||||||
|
product.setCreateBy(SecurityUtils.getUsername());
|
||||||
productMapper.insertProduct(product);
|
productMapper.insertProduct(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,4 +29,9 @@ public class TypeServiceImpl implements TypeService {
|
||||||
public List<ProductTypeAttr> queryType(Integer flag, Integer id) {
|
public List<ProductTypeAttr> queryType(Integer flag, Integer id) {
|
||||||
return typeMapper.queryType(flag,id);
|
return typeMapper.queryType(flag,id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer deleteType(Integer typeId) {
|
||||||
|
return typeMapper.deleteType(typeId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.muyu.product.mapper.TypeMapper">
|
<mapper namespace="com.muyu.product.mapper.TypeMapper">
|
||||||
|
|
||||||
|
<delete id="deleteType">
|
||||||
|
update t_product_type set id_delete = 0 where id = #{id}
|
||||||
|
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
<!-- 添加其他操作方法如插入、更新、删除等 -->
|
<!-- 添加其他操作方法如插入、更新、删除等 -->
|
||||||
|
|
Loading…
Reference in New Issue