package com.ruoyi.frequency.klkaccount.controller;

import java.util.List;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.frequency.klkaccount.entity.KlkAccount;
import com.ruoyi.frequency.klkaccount.service.KlkAccountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 拉卡拉平台账号信息Controller
 * 
 * @author liwenlong
 * @date 2024-05-07
 */
@RestController
@RequestMapping("/frequency/klkaccount")
public class KlkAccountController extends BaseController
{
    @Autowired
    private KlkAccountService klkAccountService;

    /**
     * 查询拉卡拉平台账号信息列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:klkaccount:list')")
    @GetMapping("/list")
    public TableDataInfo<KlkAccount> list(KlkAccount klkAccount)
    {
        startPage();
        List<KlkAccount> list = klkAccountService.selectKlkAccountList(klkAccount);
        return getDataTable(list);
    }

    /**
     * 导出拉卡拉平台账号信息列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:klkaccount:export')")
    @Log(title = "拉卡拉平台账号信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(KlkAccount klkAccount)
    {
        List<KlkAccount> list = klkAccountService.selectKlkAccountList(klkAccount);
        ExcelUtil<KlkAccount> util = new ExcelUtil<KlkAccount>(KlkAccount.class);
        return util.exportExcel(list, "拉卡拉平台账号信息数据");
    }

    /**
     * 获取拉卡拉平台账号信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:klkaccount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<KlkAccount> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(klkAccountService.selectKlkAccountById(id));
    }

    /**
     * 新增拉卡拉平台账号信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:klkaccount:add')")
    @Log(title = "拉卡拉平台账号信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KlkAccount klkAccount)
    {
        return toAjax(klkAccountService.insertKlkAccount(klkAccount));
    }

    /**
     * 修改拉卡拉平台账号信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:klkaccount:edit')")
    @Log(title = "拉卡拉平台账号信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KlkAccount klkAccount)
    {
        return toAjax(klkAccountService.updateKlkAccount(klkAccount));
    }

    /**
     * 删除拉卡拉平台账号信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:klkaccount:remove')")
    @Log(title = "拉卡拉平台账号信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(klkAccountService.deleteKlkAccountByIds(ids,delFlag));
    }
}
