| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.domain. TBoard; |
| | | import com.ruoyi.system.domain.TOrderMeal; |
| | | import com.ruoyi.system.service.TBoardService; |
| | | import com.ruoyi.system.service.TOrderMealService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.core.parameters.P; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | private final TBoardService boardService; |
| | | private final TokenService tokenService; |
| | | private final TOrderMealService orderMealService; |
| | | |
| | | @Autowired |
| | | public TBoardController(TBoardService boardService, TokenService tokenService) { |
| | | public TBoardController(TBoardService boardService, TokenService tokenService, TOrderMealService orderMealService) { |
| | | this. boardService = boardService; |
| | | this.tokenService = tokenService; |
| | | this.orderMealService = orderMealService; |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping(value = "/list") |
| | | public AjaxResult<List<TBoard>> list() { |
| | | Long objectId = tokenService.getLoginUser().getObjectId(); |
| | | return AjaxResult.success( boardService.list(Wrappers.lambdaQuery(TBoard.class) |
| | | .eq(TBoard::getShopId,objectId))); |
| | | List<TBoard> list = boardService.list(Wrappers.lambdaQuery(TBoard.class) |
| | | .eq(TBoard::getShopId, objectId)); |
| | | // 不等于空闲状态的 |
| | | List<Long> ids = list.stream().filter(e -> !e.getStatus().equals(1)).map(TBoard::getId).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(ids)){ |
| | | List<TOrderMeal> orderMeals = orderMealService.list(Wrappers.lambdaQuery(TOrderMeal.class) |
| | | .in(TOrderMeal::getBoardId, ids)); |
| | | for (TBoard board : list) { |
| | | List<TOrderMeal> collect = orderMeals.stream().filter(e -> board.getId().equals(e.getBoardId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(collect)){ |
| | | board.setMealType(collect.get(0).getMealType()); |
| | | board.setMealPerson(collect.get(0).getMealPerson()); |
| | | board.setOrderMoney(collect.get(0).getOrderMoney()); |
| | | } |
| | | } |
| | | } |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | /** |