using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsType;
using BPA.SAAS.Manage.Application.DataBase.Interface;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase
{
    [ApiDescriptionSettings("Goods", Tag = "商品类型管理")]
    public class GoodsTypeServices: IDynamicApiController, ITransient
    {
        IGoodsTypeService _goodsTypeService;
        public GoodsTypeServices(IGoodsTypeService goodsTypeService)
        {
            _goodsTypeService = goodsTypeService;
        }
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost("/api/goodstype/page")]
        public async Task<PageUtil> GetGoodsTypePage(GoodsTypeQueryDto dto)
        {
            return await _goodsTypeService.GetGoodsTypePage(dto);
        }
        /// <summary>
        /// 查询类型列表（外部调用）
        /// </summary>
        /// <returns></returns>
        [HttpGet("/api/goodstype/getgoodstypelist_alm")]
        [AllowAnonymous]
        public async Task<List<dynamic>> GetGoodsTypeList_alm()
        {
            return await _goodsTypeService.GetGoodsTypeList_alm();
        }
        /// <summary>
        /// 添加商品类型
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost("/api/goodstype/add")]
        public async Task<bool> AddGoodsType(GoodsTypeDto dto)
        {
            return await  _goodsTypeService.AddGoodsType(dto);
        }
        /// <summary>
        /// 更新商品类型
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost("/api/goodstype/update")]
        public async Task<bool> UpdateGoodsType(GoodsTypeDto dto)
        {
            return await _goodsTypeService.UpdateGoodsType(dto);
        }
        /// <summary>
        /// 删除商品类型
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("/api/goodstype/delete")]
        public async Task<bool> DelGoodsType(string Id)
        {
            return await _goodsTypeService.DelGoodsType(Id);
        }
        /// <summary>
        /// 查询商品类型树结构
        /// </summary>
        /// <returns></returns>
        [HttpGet("/api/goodstype/tree")]
        public async Task<dynamic> GetGoodsTypeTree()
        {
            return await _goodsTypeService.GetGoodsTypeTree();
        }
    }
}
