package com.huimv.admin.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huimv.admin.common.utils.Result;
import com.huimv.admin.common.utils.ResultCode;
import com.huimv.admin.entity.ProdCount;
import com.huimv.admin.service.IProdCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author author
 * @since 2023-06-15
 */
@RestController
@RequestMapping("/prod-count")
@CrossOrigin
public class ProdCountController {

    @Autowired
    private IProdCountService countService;

    @RequestMapping("/listScreen")
    public Result listScreen(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        String farmId = paramsMap.get("farmId");
        QueryWrapper<ProdCount> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("farm_id", farmId);
        ProdCount prodCount = countService.getOne(queryWrapper);
        return new Result(ResultCode.SUCCESS,prodCount);
    }
}
