查看购物车业务功能开发

master
hahameng 7 months ago
parent 756043baac
commit 5e8650d979

@ -2,14 +2,14 @@ package com.sky.controller.user;
import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import com.sky.result.Result;
import com.sky.service.ShoppingCartService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RequestMapping("/user/shoppingCart")
@RestController
@ -32,4 +32,14 @@ public class ShoppingCartController {
return Result.success();
}
/**
*
* @return
*/
@GetMapping("/list")
public Result<List<ShoppingCart>> list(){
return Result.success(shoppingCartService.list());
}
}

@ -1,6 +1,9 @@
package com.sky.service;
import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import java.util.List;
public interface ShoppingCartService {
/**
@ -8,4 +11,11 @@ public interface ShoppingCartService {
* @param shoppingCartDTO
*/
void addShoppingCart(ShoppingCartDTO shoppingCartDTO);
/**
*
* @return
*/
List<ShoppingCart> list();
}

@ -69,4 +69,17 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
shoppingCartMapper.insert(shoppingCart);
}
}
/**
*
* @return
*/
public List<ShoppingCart> list(){
ShoppingCart shoppingCart = ShoppingCart.builder()
.userId(BaseContext.getCurrentId())
.build();
List<ShoppingCart> list = shoppingCartMapper.list(shoppingCart);
return list;
}
}

Loading…
Cancel
Save