package com.usky.park.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.park.domain.DataStHistory;
import com.usky.park.service.DataStHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 无人驿站历史数据 前端控制器
 * </p>
 *
 * @author fu
 * @since 2023-11-29
 */
@RestController
@RequestMapping("/dataStHistory")
public class DataStHistoryController {

    @Autowired
    private DataStHistoryService dataStHistoryService;


    /**
     * 新增
     *
     * @param dataStHistory
     * @param appKey
     * @return
     */
    @PostMapping("/add")
    public void add(@RequestBody DataStHistory dataStHistory,
                    @RequestHeader("appKey") String appKey) {
        dataStHistoryService.add(dataStHistory, appKey);
    }
    /**
     * 分页查询
     * @param pickupStatus
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/pageQuery")
    public ApiResult<CommonPage<DataStHistory>> pageQuery(
            @RequestParam(value = "pickupStatus", required = false, defaultValue = "-1") Integer pickupStatus,//设置默认值为-1，则查询所有包裹（未取件优先展示）
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return ApiResult.success(dataStHistoryService.pageList(pickupStatus, pageNum, pageSize));
    }
}

