using Microsoft.AspNetCore.Mvc;
using OASystem.Domain.Dtos.CRM;
using OASystem.Domain.Entities.Customer;
using OASystem.Infrastructure.Repositories.CRM;
using static OASystem.Domain.Dtos.CRM.NewClientDataQueryDto;
namespace OASystem.API.Controllers
{
///
/// 市场客户资料
///
[Route("api/[controller]/[action]")]
public class MarketCustomerResourcesController : ControllerBase
{
private readonly NewClientDataRepository _clientDataRepository;
///
/// 初始化
///
public MarketCustomerResourcesController(NewClientDataRepository clientDataRepository)
{
this._clientDataRepository = clientDataRepository;
}
///
/// 查询客户资料数据
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryNewClientData(NewClientDataQueryDto dto)
{
JsonView jw = new JsonView();
try
{
Result resultData = await _clientDataRepository.QueryNewClientData(dto);
if (resultData.Code == 0)
{
jw = JsonView(true, resultData.Msg, resultData.Data);
}
else
{
jw = JsonView(false, resultData.Msg, resultData.Data);
}
}
catch (Exception)
{
jw = JsonView(false, "程序错误!");
}
return Ok(jw);
}
///
/// 客户资料操作(Status:1.新增,2.修改)
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task NewClientOp(NewClientOpDto dto)
{
try
{
Domain.Result result = await _clientDataRepository.NewClientOp(dto);
if (result.Code != 0)
{
return Ok(JsonView(false, result.Msg));
}
return Ok(JsonView(true, result.Msg));
}
catch (Exception)
{
return Ok(JsonView(false, "程序错误!"));
}
}
///
/// 新客户资料操作(删除)
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task NewClientDel(DelBaseDto dto)
{
var res = await _clientDataRepository.DelNewClientData(dto);
if (res.Code != 0)
{
return Ok(JsonView(false, "删除失败"));
}
return Ok(JsonView(true, "删除成功!"));
}
///
/// 获取下拉列表数据和单条数据信息
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QuerySelectAndSingleData(QuerySingleDto dto)
{
JsonView jw = new JsonView();
var result = await _clientDataRepository.QuerySelectAndSingleData(dto);
if (result.Code == 0)
{
jw = JsonView(true, result.Msg,result.Data);
}
else
{
jw = JsonView(false, result.Msg);
}
return Ok(jw);
}
///
/// 获取现有负责人
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryUserSelect()
{
try
{
Result resTable = _clientDataRepository.QueryUserSelect();
return Ok(JsonView(true, resTable.Msg, resTable.Data));
}
catch (Exception)
{
return Ok(JsonView(false, "程序错误!"));
}
}
///
/// 获取出团数据
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryNumberGroups()
{
var result = await _clientDataRepository.QueryNumberGroups();
if (result.Code != 0)
{
return Ok(JsonView(false, result.Msg));
}
return Ok(JsonView(true, result.Msg,result.Data));
}
}
}