MealController.java 1.64 KB
package com.infoloop.tianting.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.infoloop.tianting.model.dto.MealDbDTO.MealDto;
import com.infoloop.tianting.model.dto.MealDbDTO.MealIdsDto;
import com.infoloop.tianting.service.MealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "餐别")
@ApiSupport(order = -1)
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class MealController {
    private final MealService mealService;

    @ApiOperation(value = "根据ids获取餐别")
    @PostMapping("/meals")
    @ResponseStatus(HttpStatus.OK)
    public List<MealDto> getMealsByIds(@Valid @RequestBody MealIdsDto mealIdsDto) {
        return mealService.getMealsByIds(mealIdsDto.getEnterpriseId(), mealIdsDto.getIds());
    }

    @ApiOperation(value = "获取enterprise所有餐别")
    @GetMapping("/enterprises/meals")
    @ResponseStatus(HttpStatus.OK)
    public List<MealDto> getAllMeals() {
        return mealService.getAllMeals();
    }

}