商品详情接口修改
This commit is contained in:
1 parent
2d7914a856
commit
461cfaa18e
5 files changed
+49
-7
No files matched your search
@@ -158,5 +158,35 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<warName>${artifactId}</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${artifactId}</finalName>
|
||||
</build>
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
@@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
@MapperScan(basePackages = {"com.ruoyi.app.common.persistence.dao"})
|
||||
//@MapperScan(basePackages = {"com.ruoyi.app.common.persistence.dao"})
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,14 +81,17 @@ public class MallController {
|
||||
@GetMapping("/shop/mall-goods-detail")
|
||||
@ApiOperation(value = "商品详情",notes = "商品详情")
|
||||
public R goodsDetail(@RequestParam(value = "goods_id",defaultValue = "0") int goodsId){
|
||||
int userId = userOperator.getUser().getId();
|
||||
Map<String, StoreSpecGoodsPrice> specPrice = goodsService.goodsSpecPrice(goodsId);
|
||||
GoodsDTO goodsDetail = goodsMapper.toDto(goodsService.getById(goodsId));
|
||||
Map<String, SpecItemDTO> specs = goodsService.goodsSpec(goodsId);
|
||||
Map<String, List<SpecItemDTO>> specs = goodsService.goodsSpec(goodsId);
|
||||
boolean isCollect = goodsService.isCollect(goodsId,userId);
|
||||
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("detail",goodsDetail);
|
||||
map.put("spec_price",specPrice);
|
||||
map.put("specs",specs);
|
||||
map.put("isCollect",isCollect);
|
||||
return R.success(map);
|
||||
}
|
||||
|
||||
|
||||
+14
-4
@@ -133,18 +133,28 @@ public class GoodsServiceImpl extends ServiceImpl<StoreGoodsMapper, StoreGoods>
|
||||
return listMap;
|
||||
}
|
||||
|
||||
public Map<String, SpecItemDTO> goodsSpec(int goodsId){
|
||||
public Map<String, List<SpecItemDTO>> goodsSpec(int goodsId){
|
||||
|
||||
String keys = storeSpecGoodsPriceMapper.goodsSpecKey(goodsId);
|
||||
String[] strArr = keys.split("_");
|
||||
Map<String,SpecItemDTO> itemMap = new HashMap<>();
|
||||
List<ItemDTO> items = storeSpecGoodsPriceMapper.goodsSpec(Arrays.asList(strArr));
|
||||
Map<String,List<SpecItemDTO>> itemMap = new HashMap<>();
|
||||
List<ItemDTO> items = storeSpecGoodsPriceMapper
|
||||
.goodsSpec(Arrays.asList(strArr));
|
||||
|
||||
List<SpecItemDTO> listItem = null;
|
||||
for (ItemDTO itemDTO : items) {
|
||||
SpecItemDTO specItemDTO = new SpecItemDTO();
|
||||
specItemDTO.setItemId(itemDTO.getId());
|
||||
specItemDTO.setItem(itemDTO.getItem());
|
||||
itemMap.put(itemDTO.getName(),specItemDTO);
|
||||
|
||||
if(!itemMap.containsKey(itemDTO.getName())){
|
||||
listItem = new ArrayList<>();
|
||||
}
|
||||
listItem.add(specItemDTO);
|
||||
|
||||
itemMap.put(itemDTO.getName(),listItem);
|
||||
}
|
||||
System.out.println(itemMap);
|
||||
return itemMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ public class StoreGoodsServiceImpl implements IStoreGoodsService
|
||||
for(Map.Entry<String, Map<String,String>> entry : specDataMap.entrySet()){
|
||||
String mapKey = entry.getKey();
|
||||
Map map = entry.getValue();
|
||||
//System.out.println(mapKey+":"+map);
|
||||
storeSpecGoodsPrice.setKey(mapKey);
|
||||
// List<StoreSpecGoodsPrice> storeSpecGoodsPrices = storeSpecGoodsPriceService
|
||||
// .selectStoreSpecGoodsPriceList(storeSpecGoodsPrice);
|
||||
|
||||
Reference in new issue
Block a user