package com.kxs.product.biz.controller.kxsapp;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kxs.common.core.util.R;
import com.kxs.common.security.annotation.Inner;
import com.kxs.product.api.dto.kxsapp.gd.GdReportDTO;
import com.kxs.product.api.dto.kxsapp.gd.GdReportPutDTO;
import com.kxs.product.api.model.KxsGdReport;
import com.kxs.product.api.vo.kxsapp.gd.GdReportListVO;
import com.kxs.product.api.vo.kxsapp.machine.MachineUnBindListVO;
import com.kxs.product.biz.service.KxsGdReportService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 产品模块(Gd)控制层
 *
 * @author 系统
 * @since 2024-04-23 10:44:27
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("gd")
public class GdController {

    /**
     * 服务对象
     */
    private final KxsGdReportService kxsGdReportService;



    /**
     * 广电报备-提交工单
     *
     * @param param 实体对象
     * @return 广电报备-提交工单
     */
    @Inner(value = false)
    @PostMapping("/add")
    public R add(@RequestBody @Valid GdReportPutDTO param) {

        return R.ok(kxsGdReportService.addReport(param));
    }


    /**
     * 广电报备-列表
     *
     * @param page 分页对象
     * @param status 状态
     * @param keyword 关键字
     * @return 广电报备-列表
     */
    @GetMapping("/page")
    public R page(Page<GdReportListVO> page, @RequestParam("status") Integer status, @RequestParam(value = "keyword", required = false) String keyword) {

        return R.ok(kxsGdReportService.getByPage(page, status, keyword));
    }


    /**
     * 广电报备-未绑定sn列表
     *
     * @param page 分页对象
     * @param posSn 机具号
     * @return 广电报备-列表
     */
    @GetMapping("/unGdBindList")
    public R unGdBindList(Page<MachineUnBindListVO> page, @RequestParam(value = "posSn", required = false) String posSn) {

        return R.ok(kxsGdReportService.getByUnBindPage(page, posSn));
    }


    /**
     * 广电报备-数量接口
     *
     * @return 广电报备-数量接口
     */
    @GetMapping("/dot")
    public R dot() {

        return R.ok(kxsGdReportService.dotNum());
    }


    /**
     * 广电报备-作废
     *
     * @param param 实体对象
     * @return 广电报备-作废
     */
    @PutMapping("/cancel")
    public R cancel(@RequestBody KxsGdReport param) {

        return R.ok(kxsGdReportService.cancelReport(param));
    }


    /**
     * 广电报备-报备
     *
     * @param param 实体对象
     * @return 广电报备-报备
     */
    @PutMapping("/report")
    public R report(@RequestBody @Valid GdReportDTO param) {

        return R.ok(kxsGdReportService.report(param));
    }





}

