package com.njzscloud.supervisory.tsp.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.tsp.pojo.TempStoragePointEntity;
import com.njzscloud.supervisory.tsp.pojo.TempStoragePointStatisticsResult;
import com.njzscloud.supervisory.tsp.service.TempStoragePointService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 临时收纳点
 */
@Slf4j
@RestController
@RequestMapping("/temp_storage_point")
@RequiredArgsConstructor
public class TempStoragePointController {

    private final TempStoragePointService tempStoragePointService;

    /**
     * 新增
     *
     * @param tempStoragePointEntity 数据
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody TempStoragePointEntity tempStoragePointEntity) {
        tempStoragePointService.add(tempStoragePointEntity);
        return R.success();
    }

    /**
     * 修改
     *
     * @param tempStoragePointEntity 数据
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody TempStoragePointEntity tempStoragePointEntity) {
        tempStoragePointService.modify(tempStoragePointEntity);
        return R.success();
    }

    /**
     * 删除
     *
     * @param ids Ids
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        tempStoragePointService.del(ids);
        return R.success();
    }

    /**
     * 详情
     *
     * @param id Id
     * @return TempStoragePointEntity 结果
     */
    @GetMapping("/detail")
    public R<TempStoragePointEntity> detail(@RequestParam Long id) {
        return R.success(tempStoragePointService.detail(id));
    }

    @GetMapping("/statistics")
    public R<TempStoragePointStatisticsResult> statistics() {
        return R.success(tempStoragePointService.statistics());
    }

    /**
     * 分页查询
     *
     * @param tempStoragePointEntity 筛选条件
     * @param pageParam              分页参数
     * @return PageResult&lt;TempStoragePointEntity&gt; 分页结果
     */
    @GetMapping("/paging")
    public R<PageResult<TempStoragePointEntity>> paging(PageParam pageParam, TempStoragePointEntity tempStoragePointEntity) {
        return R.success(tempStoragePointService.paging(pageParam, tempStoragePointEntity));
    }

}
