/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.watermeter.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.watermeter.entity.Qfcbcqgl;
import com.tofly.watermeter.service.QfcbcqglService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 存储崔欠工作管理信息
 *
 * @author admin
 * @date Mon Aug 29 00:00:00 CST 2022
 */
@RestController
@AllArgsConstructor
@RequestMapping("/qfcbcqgl")
@Api(tags = "存储崔欠工作管理信息接口")
public class QfcbcqglController {

    private final QfcbcqglService qfcbcqglService;

    /**
     * 分页查询
     *
     * @param page     分页对象
     * @param qfcbcqgl 存储崔欠工作管理信息
     * @return
     */
//    @GetMapping("/page")
//    @ApiOperation(value = "分页查询")
//    public ResultRespone getQfcbcqglPage(Page page, @ModelAttribute Qfcbcqgl qfcbcqgl) {
//        return ResultRespone.success(qfcbcqglService.page(page, Wrappers.query(qfcbcqgl)));
//    }


    /**
     * 通过id查询存储崔欠工作管理信息
     *
     * @param id id
     * @return ResultRespone
     */
    @GetMapping("/{id}")
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    public ResultRespone getById(@PathVariable("id") Long id) {
        return ResultRespone.success(qfcbcqglService.getById(id));
    }

    /**
     * 新增存储崔欠工作管理信息
     *
     * @param qfcbcqgl 存储崔欠工作管理信息
     * @return ResultRespone
     */
    @ApiOperation(value = "新增存储崔欠工作管理信息")
    @PostMapping
    public ResultRespone save(Qfcbcqgl qfcbcqgl, @RequestParam(value = "fileList", required = false) List<MultipartFile> fileList) {
        return ResultRespone.success(qfcbcqglService.insertInfo(qfcbcqgl, fileList));
    }

    @GetMapping("/countInfo")
    @ApiOperation("统计催欠信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "templateExpert", value = "1 导出", dataType = "string"),
            @ApiImplicitParam(name = "input", value = "关键字查询", dataType = "string"),
            @ApiImplicitParam(name = "start", value = "开始 yyyy-MM-dd", dataType = "string"),
            @ApiImplicitParam(name = "end", value = "结束 yyyy-MM-dd", dataType = "string")
    })
    public ResultRespone countInfo(HttpServletResponse response, Page page, Long templateExpert, String input, String start, String end) {
        return ResultRespone.success(qfcbcqglService.countInfo(response,page, templateExpert, input, start, end));
    }

    @GetMapping("/queryInfoByCode")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "用户编号", required = true, dataType = "string"),
            @ApiImplicitParam(name = "node", value = "阶段多个’,‘拼接", dataType = "string"),
            @ApiImplicitParam(name = "start", value = "开始 yyyy-MM-dd hh:mm:ss", dataType = "string"),
            @ApiImplicitParam(name = "end", value = "结束 yyyy-MM-dd hh:mm:ss", dataType = "string")
    })
    @ApiOperation("客户编号查询催欠信息")
    public ResultRespone queryInfoByCode(String code, String start, String end, String node) {
        return ResultRespone.success(qfcbcqglService.queryInfoByCode(code, start, end, node));
    }

    /**
     * 修改存储崔欠工作管理信息
     *
     * @param qfcbcqgl 存储崔欠工作管理信息
     * @return ResultRespone
     */
    @ApiOperation(value = "修改存储崔欠工作管理信息")
    @PutMapping("/update")
    public ResultRespone updateById(@RequestBody Qfcbcqgl qfcbcqgl) {
        qfcbcqgl.setAuditTime(new Date());
        return ResultRespone.success(qfcbcqglService.updateById(qfcbcqgl));
    }

    /**
     * 通过id删除存储崔欠工作管理信息
     *
     * @param id id
     * @return ResultRespone
     */
//    @ToFlyAppLog(title = "通过id删除存储崔欠工作管理信息")
//    @ApiOperation(value = "通过ID删除存储崔欠工作管理信息")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
//    })
//    @DeleteMapping("/{id}")
//    public ResultRespone removeById(@PathVariable Long id) {
//        return ResultRespone.success(qfcbcqglService.removeById(id));
//    }

    /**
     * 通过id批量删除存储崔欠工作管理信息
     *
     * @param ids id
     * @return ResultRespone
     */
    @ApiOperation(value = "通过ID批量删除存储崔欠工作管理信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds")
    public ResultRespone removeById(String ids) {
        return ResultRespone.success(qfcbcqglService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
