package com.dk.mdm.controller.mst;

import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.model.pojo.mst.Customer;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.query.mst.CustomerQuery;
import com.dk.mdm.model.response.mst.CustomerResponse;
import com.dk.mdm.model.vo.mst.CustomerVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import com.dk.mdm.service.mst.CustomerService;

import java.util.List;

@Api(tags = "客户资料API接口")
@RestController
@RequestMapping("/mst/customer")
public class CustomerController{

    public BaseService<Customer> getService() {
        return customerService;
    }

    @Autowired
    private CustomerService customerService;


    /**
     * @desc : 条件查询
     * @author : 于继渤
     * @date : 2024/2/26 10:36
     */
    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<CustomerResponse>> selectByCond(@RequestBody CustomerQuery customerQuery) {
        return customerService.selectByCond(customerQuery);
    }

    /**
     * @desc : 新建
     * @author : 于继渤
     * @date : 2023/1/5 9:39
     */
    @ApiOperation( value = "新建", notes = "v" )
    @PostMapping({"insert"})
    public ResponseResultVO<?> insert(@RequestBody CustomerVO customerVO) {
        return customerService.insert(customerVO);
    }

    /**
     * @desc : 编辑
     * @author : 于继渤
     * @date : 2023/1/5 9:39
     */
    @ApiOperation( value = "编辑", notes = "编辑" )
    @PostMapping({"update"})
    public ResponseResultVO<?> update(@RequestBody CustomerVO customerVO) {
        return customerService.update(customerVO);
    }


    /**
     * @desc : 查看
     * @author : 于继渤
     * @date : 2024/3/6 10:36
     */
    @PostMapping({"/{id}"})
    public ResponseResultVO<?> selectByIdRespone(@PathVariable String id) {
        return customerService.selectByIdRespone(id);
    }


    @ApiOperation(value = "不分页", notes = "分页、关联、条件查询")
    @PostMapping({"select_by_cond_no_page"})
    public ResponseResultVO<List<CustomerResponse>> selectByCondNoPage(@RequestBody CustomerQuery customerQuery) {
        return customerService.selectByCondNoPage(customerQuery);
    }
}
