/*
 * 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.log.annotation.ToFlyAppLog;
import com.tofly.xrtymis.custom.service.QfkhjbxxService;
import com.tofly.xrtymis.entity.Qfkhjbxx;
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;
/**
 * 营销档案客户基本信息表
 *
 * @author fuchenlin
 * @date Mon Mar 22 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/qfkhjbxx")
@Api(tags="营销档案客户基本信息表接口")
public class QfkhjbxxController {

    private final QfkhjbxxService qfkhjbxxService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param qfkhjbxx 营销档案客户基本信息表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getQfkhjbxxPage(Page page, @ModelAttribute Qfkhjbxx qfkhjbxx) {
      return ResultRespone.success(qfkhjbxxService.page(page, Wrappers.query(qfkhjbxx)));
    }


    /**
     * 通过id查询营销档案客户基本信息表
     * @param yhbh id
     * @return ResultRespone
     */
    @GetMapping("/{yhbh}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "yhbh", value = "ID", required = true, dataType = "String")
    })
    public ResultRespone getById(@PathVariable("yhbh" ) String yhbh) {
      return ResultRespone.success(qfkhjbxxService.getById(yhbh));
    }

    /**
     * 新增营销档案客户基本信息表
     * @param qfkhjbxx 营销档案客户基本信息表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增营销档案客户基本信息表" )
    @ApiOperation(value = "新增营销档案客户基本信息表")
    @PostMapping
    public ResultRespone save(@RequestBody Qfkhjbxx qfkhjbxx) {
      return ResultRespone.success(qfkhjbxxService.save(qfkhjbxx));
    }

    /**
     * 修改营销档案客户基本信息表
     * @param qfkhjbxx 营销档案客户基本信息表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改营销档案客户基本信息表" )
    @ApiOperation(value = "修改营销档案客户基本信息表")
    @PutMapping
    public ResultRespone updateById(@RequestBody Qfkhjbxx qfkhjbxx) {
      return ResultRespone.success(qfkhjbxxService.updateById(qfkhjbxx));
    }

    /**
     * 通过id删除营销档案客户基本信息表
     * @param yhbh id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id删除营销档案客户基本信息表" )
    @ApiOperation(value = "通过ID删除营销档案客户基本信息表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "yhbh", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{yhbh}" )
    public ResultRespone removeById(@PathVariable String yhbh) {
      return ResultRespone.success(qfkhjbxxService.removeById(yhbh));
    }

    /**
     * 通过id批量删除营销档案客户基本信息表
     * @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 removeByIds(String ids) {
        return ResultRespone.success(qfkhjbxxService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
