package com.yuchen.saas.park.service.controller.basic;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.entity.park.PmgBatParkSnapshotNewspaper;
import com.yuchen.saas.park.api.vo.park.PmgbatParkRoomVo;
import com.yuchen.saas.park.api.vo.park.SnapshotNewspaperDetailVo;
import com.yuchen.saas.park.api.vo.park.SnapshotNewspaperPageVo;
import com.yuchen.saas.park.api.vo.request.PmgBatParkSnapshotNewspaperAddRequest;
import com.yuchen.saas.park.api.vo.request.PmgBatParkSnapshotNewspaperDealRequest;
import com.yuchen.saas.park.service.service.IPmgBatParkSnapshotNewspaperService;
import com.yuchen.saas.parking.api.entity.PmgBatParkParking;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;


/**
 * <p>
 * 随手拍管理表 前端控制器
 * </p>
 *
 * @author cxj
 * @since 2023-07-20
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/pmgBatParkSnapshotNewspaper")
@Validated
@Api(value = "随手拍", tags = "随手拍")
public class PmgBatParkSnapshotNewspaperController {

    private final IPmgBatParkSnapshotNewspaperService baseService;

    /**
     * 要加白名单,可不用登录
     *
     * @param addRequest
     * @return
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "7.15临时版本-小程序随手拍提交", notes = "7.15临时版本-小程序随手拍提交")
    public R submit(@Valid @RequestBody PmgBatParkSnapshotNewspaperAddRequest addRequest) {
        return R.status(baseService.submit(addRequest));
    }

    @GetMapping("/pageByApp")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "7.15临时版本-小程序随手拍报记录", notes = "7.15临时版本-小程序随手拍报记录")
    public R<IPage<PmgBatParkSnapshotNewspaper>> pageByApp(@ApiParam(value = "拍报类型:0其他,1违规停车占道,2设备异常故障,3环境卫生问题,4违规不良行为") @RequestParam(value = "newspaperType", required = false) Integer newspaperType,
                                                           @ApiParam(value = "处理状态:0待处理,1已处理") @RequestParam(value = "handleState", required = false) Integer handleState,
                                                           @ApiParam(value = "开始日期") @RequestParam(value = "beginDate", required = false) String beginDate,
                                                           @ApiParam(value = "结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                                           @ApiParam(value = "openId") @RequestParam(value = "openId", required = true) @NotBlank String openId,
                                                           @ApiParam(value = "当前页") @RequestParam(value = "current") int current,
                                                           @ApiParam(value = "每页记录数") @RequestParam(value = "size") int size) {
        return R.data(baseService.pageByApp(newspaperType, handleState, beginDate, endDate, openId, current, size));
    }

    @GetMapping("/queryPage")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "7.15临时版本-pc随手拍报记录分页查询", notes = "7.15临时版本-pc随手拍报记录分页查询")
    public R<IPage<SnapshotNewspaperPageVo>> queryPage(@ApiParam(value = "管理区类型:1园区,2停车场,3充电站") @RequestParam(value = "type", required = false) Integer type,
                                                       @ApiParam(value = "管理区id") @RequestParam(value = "code", required = false) Long code,
                                                       @ApiParam(value = "拍报类型:0其他,1违规停车占道,2设备异常故障,3环境卫生问题,4违规不良行为") @RequestParam(value = "newspaperType", required = false) Integer newspaperType,
                                                       @ApiParam(value = "处理状态:0待处理,1已处理") @RequestParam(value = "handleState", required = false) Integer handleState,
                                                       @ApiParam(value = "开始日期") @RequestParam(value = "beginDate", required = false) String beginDate,
                                                       @ApiParam(value = "结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                                                       @ApiParam(value = "当前页") @RequestParam(value = "current") int current,
                                                       @ApiParam(value = "每页记录数") @RequestParam(value = "size") int size) {
        return R.data(baseService.queryPage(type, code, newspaperType, handleState, beginDate, endDate, current, size));
    }

    @PostMapping("/deal")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "7.15临时版本-PC序随手拍处理(批量处理或单独处理)", notes = "7.15临时版本-PC序随手拍处理(批量处理或单独处理)")
    public R deal(@Valid @RequestBody PmgBatParkSnapshotNewspaperDealRequest dealRequest) {
        return R.data(baseService.deal(dealRequest));
    }

    @GetMapping("/getDetailById")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "7.15临时版本-pc随手拍报记录详情", notes = "7.15临时版本-pc随手拍报记录详情")
    public R<SnapshotNewspaperDetailVo> getDetailById(@ApiParam(value = "id") @RequestParam(value = "id") @NotNull Long id) {
        return R.data(baseService.getDetailById(id));
    }

    @GetMapping("/export")
    @ApiOperation(value = " 7.15临时版本-pc随手拍报记录导出", notes = " pc随手拍报记录导出")
    public void export(@ApiParam(value = "管理区类型:1园区,2停车场,3充电站") @RequestParam(value = "type", required = false) Integer type,
                       @ApiParam(value = "管理区id") @RequestParam(value = "code", required = false) Long code,
                       @ApiParam(value = "拍报类型:0其他,1违规停车占道,2设备异常故障,3环境卫生问题,4违规不良行为") @RequestParam(value = "newspaperType", required = false) Integer newspaperType,
                       @ApiParam(value = "处理状态:0待处理,1已处理") @RequestParam(value = "handleState", required = false) Integer handleState,
                       @ApiParam(value = "开始日期") @RequestParam(value = "beginDate", required = false) String beginDate,
                       @ApiParam(value = "结束日期") @RequestParam(value = "endDate", required = false) String endDate,
                      HttpServletResponse response) {
        baseService.export(type, code, newspaperType, handleState, beginDate, endDate, response);
    }


}
