package com.td.boss.game.commallfood.controller;

import com.td.boss.common.controller.*;
import com.td.boss.common.pojo.Result;
import com.td.boss.game.commallfood.pojo.ComMallFood;
import com.td.boss.game.commallfood.vo.ComMallFoodSimpleVo;
import com.td.boss.game.commallfood.vo.ComMallFoodVo;
import com.td.boss.game.commallfood.service.ComMallFoodService;
import com.td.boss.util.CopyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/game/comMallFood/")
public class ComMallFoodController extends CommonController<ComMallFoodVo, ComMallFood, Integer> {
    @Autowired
    private ComMallFoodService comMallFoodService;



    @GetMapping("getMallFoodList")
    public Result<List<ComMallFoodSimpleVo>> getEquipmentByTypeFunction(@RequestParam(value = "userId") String userId) {

        ComMallFoodVo comMallFoodVo = new ComMallFoodVo();

        List<ComMallFoodSimpleVo> comMallFoodSimpleVoList = comMallFoodService.list(comMallFoodVo).getData().stream().map(e->{
            return  CopyUtil.copy(e, ComMallFoodSimpleVo.class);
        }).collect(Collectors.toList());

        return Result.of(comMallFoodSimpleVoList);
    }
}
