package org.dromara.erp.controller;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.erp.domain.query.ErpClientQuery;
import org.dromara.erp.domain.vo.ErpClientVo;
import org.dromara.erp.service.IErpClientService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ERP 客户档案控制器
 *
 * @Author: Antigravity
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/erp/client")
public class ErpClientController {

    private final IErpClientService erpClientService;

    /**
     * 分页查询客户列表
     */
    @GetMapping("/list")
    public TableDataInfo<ErpClientVo> list(ErpClientQuery query, PageQuery pageQuery) {
        return erpClientService.queryPageList(query, pageQuery);
    }

    /**
     * 获取客户详情
     */
    @GetMapping("/{rowId}")
    public R<ErpClientVo> getInfo(@PathVariable("rowId") String rowId) {
        return R.ok(erpClientService.queryById(rowId));
    }

}
