MealController.java
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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();
}
}