package com.ruoyi.visitor.controller;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.HexUtil;
import com.ruoyi.asset.domain.TbAssetInformation;
import com.ruoyi.asset.domain.dto.TbLocationDTO;
import com.ruoyi.asset.mapper.TbAssetInformationMapper;
import com.ruoyi.asset.service.ITbAssetInformationService;
import com.ruoyi.asset.service.ITbLocationService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/visitor")
public class VController extends BaseController {
    @Autowired
    private ITbAssetInformationService tbAssetInformationService;

    @Resource
    private ITbLocationService locationService;

    @GetMapping("/list/{number}")
    public TableDataInfo list(@PathVariable("number") String number)
    {
        TbAssetInformation tbAssetInformation = new TbAssetInformation();
        tbAssetInformation.setLocationNumber(number);
        List<TbAssetInformation> list = tbAssetInformationService.selectInfoList(tbAssetInformation);
        return getDataTable(list);
    }

    @GetMapping("/asset/list")
    public AjaxResult assetAll() {
        return success(tbAssetInformationService.selectTbAssetInformationList2(new TbAssetInformation()));
    }

    /*
    *  接口：/visitor/location/{number}
    * */
    @PostMapping(value = "/location/list")
    public AjaxResult getLocationByNumber(@RequestBody TbLocationDTO tbLocationDTO)
    {
        System.out.println(tbLocationDTO.getNumbers());
        return success(locationService.selectTbLocationListByNumbers(tbLocationDTO.getNumbers()));
    }
}
