package com.fs.his.controller;

import java.util.List;

import com.fs.his.domain.MerchantAppConfig;
import com.fs.his.service.IMerchantAppConfigService;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 商户应用配置Controller
 *
 * @author fs
 * @date 2025-12-05
 */
@RestController
@RequestMapping("/his/merchantAppConfig")
public class MerchantAppConfigController extends BaseController
{
    @Autowired
    private IMerchantAppConfigService merchantAppConfigService;

    /**
     * 查询商户应用配置列表
     */
    @PreAuthorize("@ss.hasPermi('his:merchantAppConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(MerchantAppConfig merchantAppConfig)
    {
        startPage();
        List<MerchantAppConfig> list = merchantAppConfigService.selectMerchantAppConfigList(merchantAppConfig);
        return getDataTable(list);
    }

    /**
     * 导出商户应用配置列表
     */
    @PreAuthorize("@ss.hasPermi('his:merchantAppConfig:export')")
    @Log(title = "商户应用配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MerchantAppConfig merchantAppConfig)
    {
        List<MerchantAppConfig> list = merchantAppConfigService.selectMerchantAppConfigList(merchantAppConfig);
        ExcelUtil<MerchantAppConfig> util = new ExcelUtil<MerchantAppConfig>(MerchantAppConfig.class);
        return util.exportExcel(list, "商户应用配置数据");
    }

    /**
     * 获取商户应用配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:merchantAppConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(merchantAppConfigService.selectMerchantAppConfigById(id));
    }

    /**
     * 新增商户应用配置
     */
    @PreAuthorize("@ss.hasPermi('his:merchantAppConfig:add')")
    @Log(title = "商户应用配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MerchantAppConfig merchantAppConfig)
    {
        merchantAppConfig.setCreatedBy(getUsername());
        merchantAppConfig.setUpdatedBy(getUsername());
        return toAjax(merchantAppConfigService.insertMerchantAppConfig(merchantAppConfig));
    }

    /**
     * 修改商户应用配置
     */
    @PreAuthorize("@ss.hasPermi('his:merchantAppConfig:edit')")
    @Log(title = "商户应用配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MerchantAppConfig merchantAppConfig)
    {
        merchantAppConfig.setUpdatedBy(getUsername());
        return toAjax(merchantAppConfigService.updateMerchantAppConfig(merchantAppConfig));
    }

    /**
     * 删除商户应用配置
     */
    @PreAuthorize("@ss.hasPermi('his:merchantAppConfig:remove')")
    @Log(title = "商户应用配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long ids)
    {
        return toAjax(merchantAppConfigService.deleteMerchantAppConfigById(ids));
    }
}
