package com.fastbee.data.controller.userRecharge;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.rechargecard.domain.NgMerchants;
import com.fastbee.rechargecard.domain.dto.NgMerchantsDto;
import com.fastbee.rechargecard.service.INgMerchantsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fastbee.common.annotation.Log;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.enums.BusinessType;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 商户信息Controller
 *
 * @author kerwincui
 * @date 2024-12-27
 */
@RestController
@RequestMapping("/iot/merchants")
@Api(tags = "商户信息")
public class NgMerchantsController extends BaseController
{
    @Autowired
    private INgMerchantsService ngMerchantsService;

/**
 * 查询商户信息列表
 */
@PreAuthorize("@ss.hasPermi('iot:merchants:list')")
@GetMapping("/list")
@ApiOperation("查询商户信息列表")
    public TableDataInfo list(NgMerchants ngMerchants)
    {
        startPage();
        List<NgMerchantsDto> ngMerchantsDtoList = ngMerchantsService.selectNgMerchantsList(ngMerchants);
        return getDataTable(ngMerchantsDtoList);
    }

    /**
     * 导出商户信息列表
     */
    @ApiOperation("导出商户信息列表")
    @PreAuthorize("@ss.hasPermi('iot:merchants:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, NgMerchants ngMerchants)
    {
        //List<NgMerchants> list = ngMerchantsService.selectNgMerchantsList(ngMerchants);
//        ExcelUtil<NgMerchants> util = new ExcelUtil<NgMerchants>(NgMerchants.class);
//        util.exportExcel(response, list, "商户信息数据");

    }

    /**
     * 获取商户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('iot:merchants:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取商户信息详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ngMerchantsService.selectNgMerchantsById(id));
    }

    /**
     * 新增商户信息
     */
    @PreAuthorize("@ss.hasPermi('iot:merchants:add')")
    @PostMapping
    @ApiOperation("新增商户信息")
    public AjaxResult add(@RequestBody NgMerchants ngMerchants)
    {
        return toAjax(ngMerchantsService.insertNgMerchants(ngMerchants));
    }

    /**
     * 修改商户信息
     */
    @PreAuthorize("@ss.hasPermi('iot:merchants:edit')")
    @PutMapping
    @ApiOperation("修改商户信息")
    public AjaxResult edit(@RequestBody NgMerchants ngMerchants)
    {
        return toAjax(ngMerchantsService.updateNgMerchants(ngMerchants));
    }

    /**
     * 删除商户信息
     */
    @PreAuthorize("@ss.hasPermi('iot:merchants:remove')")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除商户信息")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ngMerchantsService.deleteNgMerchantsByIds(ids));
    }
}
