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.ObtainStatusParam;
import com.njzscloud.supervisory.tsp.pojo.TspPhotoEntity;
import com.njzscloud.supervisory.tsp.pojo.TspPhotoSaveParam;
import com.njzscloud.supervisory.tsp.pojo.TspPhotoSearchParam;
import com.njzscloud.supervisory.tsp.service.TspPhotoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 临时收纳点图片
 */
@Slf4j
@RestController
@RequestMapping("/tsp_photo")
@RequiredArgsConstructor
public class TspPhotoController {

    private final TspPhotoService tspPhotoService;

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

    /**
     * 新增
     *
     * @param tspPhotoSaveParam 数据
     */
    @PostMapping("/save")
    public R<?> save(@RequestBody TspPhotoSaveParam tspPhotoSaveParam) {
        tspPhotoService.save(tspPhotoSaveParam);
        return R.success();
    }


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

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

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

    @GetMapping("/list_photo")
    public R<TspPhotoEntity> listPhoto(TspPhotoSearchParam tspPhotoSearchParam) {
        return R.success(tspPhotoService.listPhoto(tspPhotoSearchParam));
    }

    @GetMapping("/obtain_status")
    public R<Map<String, Integer>> obtainStatus(ObtainStatusParam obtainStatusParam) {
        return R.success(tspPhotoService.obtainStatus(obtainStatusParam));
    }

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

}
