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

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.core.util.StringUtil;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.xrtymis.custom.service.GdhftjService;
import com.tofly.xrtymis.entity.Gdhftj;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * ${comments}
 *
 * @author fcl
 * @date Wed May 12 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/gdhftj")
@Api(tags="工单回访统计")
public class GdhftjController {

    private final GdhftjService gdhftjService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param gdhftj ${comments}
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getGdhftjPage(Page page, @ModelAttribute Gdhftj gdhftj) {
      return ResultRespone.success(gdhftjService.page(page, Wrappers.query(gdhftj)));
    }


    /**
     * 通过id查询${comments}
     * @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(gdhftjService.getById(id));
    }

    /**
     * 新增${comments}
     * @param gdhftj ${comments}
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增" )
    @ApiOperation(value = "新增")
    @PostMapping
    public ResultRespone save(@RequestBody Gdhftj gdhftj) {
      return ResultRespone.success(gdhftjService.save(gdhftj));
    }

    /**
     * 修改${comments}
     * @param gdhftj ${comments}
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改" )
    @ApiOperation(value = "修改")
    @PutMapping("update")
    public ResultRespone updateById(@RequestBody Gdhftj gdhftj) {
      return ResultRespone.success(gdhftjService.updateById(gdhftj));
    }

    /**
     * 通过id删除${comments}
     * @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(gdhftjService.removeById(id));
    }

    /**
     * 通过id批量删除${comments}
     * @param ids id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id批量删除" )
    @ApiOperation(value = "通过ID批量删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeById(String ids) {
        return ResultRespone.success(gdhftjService.removeByIds(Arrays.asList(ids.split(","))));
    }

    /**
     * 修改比例重新计算
     * @param gdhftj ${comments}
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改比例重新计算" )
    @ApiOperation(value = "修改比例重新计算")
    @PutMapping("updateProportion")
    public ResultRespone updateProportion(@RequestBody Gdhftj gdhftj) {
        return gdhftjService.updateProportion(gdhftj);
    }
}
