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.BaseLocation;
import com.huimv.admin.service.IBaseLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2023-07-21
 */
@RestController
@RequestMapping("/base-location")
@CrossOrigin
public class BaseLocationController {
    @Autowired
    private IBaseLocationService baseLocationService;

    @PostMapping("/listAll")
    public Result listAll(@RequestBody Map<String, String> paramsMap){
        String farmId = paramsMap.get("farmId");
        String vistitType = paramsMap.get("vistitType");
        return new Result(ResultCode.SUCCESS,baseLocationService.list(new QueryWrapper<BaseLocation>().eq("farm_id",farmId).eq("vistit_type",vistitType)));
    }

    @PostMapping("/listLuggageLocation")
    public Result listLuggageLocation(@RequestBody Map<String, String> paramsMap){
        String farmId = paramsMap.get("farmId");
        return new Result(ResultCode.SUCCESS,baseLocationService.list(new QueryWrapper<BaseLocation>().eq("farm_id",farmId).eq("vistit_type",0).eq("parent_id",0)));
    }
}
