package com.ruoyi.demo.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.demo.entity.vo.AddStatusVo;
import com.ruoyi.demo.entity.vo.ListQueryBody;
import com.ruoyi.demo.entity.vo.OpcloseTimeVo;
import com.ruoyi.demo.service.WdInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/WdInfo")
public class WdInfoController {
    @Autowired
    WdInfoService wdInfoService;

    /**
     * 网点数量新增情况
     *
     * @param body 地址码和网点类型码查询请求体
     * @return
     */
    @PostMapping("/addStatus")
    public R addStatus(ListQueryBody body) {
        List<String> addrCode = body.getAddrCode();
        List<String> typeCode = body.getTypeCode(); // 网点类型
        List<AddStatusVo> addStatusVos = wdInfoService.searchAddStatus(addrCode, typeCode);
        return R.ok(addStatusVos);
    }

    /**
     * 各地区网点开店时间分布情况
     *
     * @param body 地址码和网点类型（犇云）码查询请求体
     * @return
     */
    @PostMapping("/opentime")
    public R openTime(@RequestBody ListQueryBody body) {
        List<String> addrCodes = body.getAddrCode();
        List<String> typeCodeBys = body.getTypeCodeBy();
        List<OpcloseTimeVo> vos = wdInfoService.searchOpenTimes(addrCodes, typeCodeBys);
        return R.ok(vos);
    }

    /**
     * 各地区网点关店时间分布情况
     *
     * @param body 地址码和网点类型（犇云）码查询请求体
     * @return
     */
    @PostMapping("/closetime")
    public R closeTime(@RequestBody ListQueryBody body) {
        List<String> addrCodes = body.getAddrCode();
        List<String> typeCodeBys = body.getTypeCodeBy();
        List<OpcloseTimeVo> vos = wdInfoService.searchCloseTimes(addrCodes, typeCodeBys);
        return R.ok(vos);
    }
}
