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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.api.CodeClient;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.core.util.Date8Util;
import com.tofly.common.core.util.StringUtil;
import com.tofly.common.oauth.exception.ToflyDeniedException;
import com.tofly.watermeter.custom.entity.KhSearch;
import com.tofly.watermeter.entity.Qfkhjbxx;
import com.tofly.watermeter.service.QfkhjbxxService;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 营销档案客户基本信息表
 *
 * @author wangjieliu
 * @date Fri Mar 19 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/qfkhjbxx")
@Api(tags = "客户基本信息表接口")
public class QfkhjbxxController {

    private final QfkhjbxxService qfkhjbxxService;


    @GetMapping("/khLike")
    @ApiOperation(value = "客户信息模糊查询；根据用户编号、电话（APP端）")
    public ResultRespone khLike(Page page , KhSearch khSearch) {
        String phone = khSearch.getPhone();
        String yhbh = khSearch.getYhbh();
        String yhxm = khSearch.getYhxm();
        String yhdz = khSearch.getYhdz();
        String sbbh = khSearch.getSbbh();
        String sfzh = khSearch.getSfzh();
        String inputcontent = khSearch.getInputcontent();
        return ResultRespone.success(qfkhjbxxService.getKhLike(page, phone, yhbh, yhxm , inputcontent,yhdz,sbbh,sfzh));
    }


    @GetMapping("/synKH")
    @ApiOperation(value = "客户信息综合查询")
    public ResultRespone synKH(String inputContent) {
        return ResultRespone.success(qfkhjbxxService.synKH(inputContent));
    }

    @GetMapping("/getUpdateAndInsert")
    @ApiOperation(value = "及时更新客户信息本地数据库(使用XXLJOB调用)")
    public ResultRespone getUpdateAndInsert() {
        return ResultRespone.success(qfkhjbxxService.getUpdateAndInsert());
    }

    /**
     * 客户查询
     *
     * @param khSearch
     * @return
     */
    @GetMapping("/commonKh")
    @ApiOperation(value = "客户查询（WEB端）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "yhbh", value = "用户编号", required = false, dataType = "String"),
            @ApiImplicitParam(name = "phone", value = "电话", required = false, dataType = "String"),
            @ApiImplicitParam(name = "yhxm", value = "用户姓名", required = false, dataType = "String")
    })
    public ResultRespone commonKh(Page<Qfkhjbxx> page, KhSearch khSearch, HttpServletResponse response) {
        return ResultRespone.success(qfkhjbxxService.commonKh(page , khSearch , response));
    }

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

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

//    /**
//     * 通过id删除营销档案客户基本信息表
//     * @param yhbh id
//     * @return ResultRespone
//     */
//    //="通过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
//     */
//    //="通过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(","))));
//    }

}
