package com.iformall.controller.invest;


import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.SystemServiceLog;
import com.iformall.common.InvestResultData;
import com.iformall.domain.dto.InvestDemandDto;
import com.iformall.domain.po.invest.InvestCustomerEntity;
import com.iformall.domain.vo.invest.InvestDemandQuery;
import com.iformall.domain.vo.invest.InvestDemandVo;
import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.domain.vo.invest.InvestPageResult;
import com.iformall.service.invest.InvestBizService;
import com.iformall.service.invest.InvestCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * 招商模块-客户管理
 *
 * @author
 * @email
 * @date 2019-09-23 18:40:43
 */
@Slf4j
@RestController
@RequestMapping("invest/customer")
@Api(tags = "招商模块-客户信息")
public class InvestCustomerController extends InvestBaseController{

    @Autowired
    private InvestBizService investBizService;

    @Autowired
    private InvestCustomerService investCustomerService;

    /**
     * 客户列表
     */
    @ApiOperation("客户信息列表")
    @SystemControllerLog(description = "客户信息列表")
    @GetMapping("/list/simple")
    public InvestResultData<List<InvestDemandVo>> listSimple() {
        return execute(null, p -> investBizService.queryCustomer());
    }

    /**
     * 分页列表
     */
    @SystemServiceLog
    @ApiOperation(value = "分页列表接口")
    @GetMapping("/list")
    public InvestResultData<InvestPageResult<InvestDemandVo>> list(InvestDemandQuery params) {
        return execute(params, p -> investBizService.queryPageDemand(p));
    }

    /**
     * 信息
     */
    @SystemServiceLog
    @GetMapping("/info/{id}")
    public InvestResultData<InvestDemandVo> info(@PathVariable("id") Long id) {
        return execute(id, p -> investBizService.findDemandById(p));
    }

    /**
     * 保存
     */
    @SystemServiceLog
    @PostMapping("/save")
    public InvestResultData save(@RequestBody InvestDemandDto investDemand) {
        return execute(investDemand, p -> investBizService.saveCustomerAndDemand(p));
    }

    /**
     * 修改
     */
    @SystemServiceLog
    @PostMapping("/update")
    public InvestResultData update(@RequestBody InvestDemandDto customerDto) {
        return execute(customerDto, p -> investBizService.updateCustomerAndDemand(p));
    }

}
