using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.ServiceApp.ShpGeo;
using OpenAuth.App.ServiceApp.ShpGeo.Request;
using OpenAuth.App.ServiceApp.ShpGeo.Utils;
using OpenAuth.Repository.Domain;

namespace OpenAuth.WebApi.Controllers.ServiceControllers;

[Route("api/[controller]/[action]")]
[ApiController]
public class GeoStyleController : ControllerBase
{
    private readonly GeoStyleApp _geoStyleApp;

    public GeoStyleController(GeoStyleApp geoStyleApp)
    {
        this._geoStyleApp = geoStyleApp;
    }

    /// <summary>
    /// 增加geo样式
    /// </summary>
    /// <param name="geoStyle"></param>
    /// <returns></returns>
    [HttpPost]
    public Response<bool> Add(GeoStyleReq geoStyle)
    {
        return _geoStyleApp.Add(geoStyle);
    }

    /// <summary>
    /// 列表
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public async Task<Response<PageInfo<List<GeoStyle>>>> Page([FromQuery] GeoStylePageReq req)
    {
        return await _geoStyleApp.Page(req);
    }

    // todo 图层绑定样式
    [HttpPost]
    public Response<bool> BindLayer(string layerName, string styleId)
    {
        return _geoStyleApp.BindLayer(layerName, styleId);
    }
}