package com.jsowell.web.controller.thirdparty;

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

import com.jsowell.common.util.poi.ExcelUtil;
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
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.jsowell.common.annotation.Log;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.core.domain.AjaxResult;
import com.jsowell.common.enums.BusinessType;
import com.jsowell.common.core.page.TableDataInfo;

/**
 * 对接平台配置信息Controller
 * @deprecated 平台密钥信息整合到Thirdparty_Secret_Info
 * @author jsowell
 * @date 2023-05-27
 */
@RestController
@RequestMapping("/thirdParty/thirdPartyConfig")
public class ThirdPartyPlatformConfigController extends BaseController {
    @Autowired
    private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;

    /**
     * 查询对接平台配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('thirdParty:thirdPartyConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(ThirdPartyPlatformConfig thirdPartyPlatformConfig) {
        startPage();
        List<ThirdPartyPlatformConfig> list = thirdPartyPlatformConfigService.selectThirdPartyPlatformConfigList(thirdPartyPlatformConfig);
        return getDataTable(list);
    }

    /**
     * 导出对接平台配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('thirdParty:thirdPartyConfig:export')")
    @Log(title = "对接平台配置信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ThirdPartyPlatformConfig thirdPartyPlatformConfig) {
        List<ThirdPartyPlatformConfig> list = thirdPartyPlatformConfigService.selectThirdPartyPlatformConfigList(thirdPartyPlatformConfig);
        ExcelUtil<ThirdPartyPlatformConfig> util = new ExcelUtil<ThirdPartyPlatformConfig>(ThirdPartyPlatformConfig.class);
        util.exportExcel(response, list, "对接平台配置信息数据");
    }

    /**
     * 获取对接平台配置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('thirdParty:thirdPartyConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(thirdPartyPlatformConfigService.selectThirdPartyPlatformConfigById(id));
    }

    /**
     * 新增对接平台配置信息
     */
    @PreAuthorize("@ss.hasPermi('thirdParty:thirdPartyConfig:add')")
    @Log(title = "对接平台配置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ThirdPartyPlatformConfig thirdPartyPlatformConfig) {
        return toAjax(thirdPartyPlatformConfigService.insertThirdPartyPlatformConfig(thirdPartyPlatformConfig));
    }

    /**
     * 修改对接平台配置信息
     */
    @PreAuthorize("@ss.hasPermi('thirdParty:thirdPartyConfig:edit')")
    @Log(title = "对接平台配置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ThirdPartyPlatformConfig thirdPartyPlatformConfig) {
        return toAjax(thirdPartyPlatformConfigService.updateThirdPartyPlatformConfig(thirdPartyPlatformConfig));
    }

    /**
     * 删除对接平台配置信息
     */
    @PreAuthorize("@ss.hasPermi('thirdParty:thirdPartyConfig:remove')")
    @Log(title = "对接平台配置信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(thirdPartyPlatformConfigService.deleteThirdPartyPlatformConfigByIds(ids));
    }
}
