package com.ruoyi.web.modules.hub.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.modules.hub.domain.BizDataSendRecord;
import com.ruoyi.web.modules.hub.service.IBizDataSendRecordService;

/**
 * 数据资产服务中心 — 数据发送记录
 */
@RestController
@RequestMapping("/dataHub/dataSendRecord")
public class BizDataSendRecordController extends BaseController
{
    @Autowired
    private IBizDataSendRecordService bizDataSendRecordService;

    @PreAuthorize("@ss.hasPermi('dataHub:dataSendRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDataSendRecord query)
    {
        startPage();
        List<BizDataSendRecord> list = bizDataSendRecordService.selectBizDataSendRecordList(query);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('dataHub:dataSendRecord:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizDataSendRecordService.selectBizDataSendRecordById(id));
    }

    @PreAuthorize("@ss.hasPermi('dataHub:dataSendRecord:add')")
    @Log(title = "数据发送记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizDataSendRecord row)
    {
        row.setCreateBy(getUsername());
        return toAjax(bizDataSendRecordService.insertBizDataSendRecord(row));
    }

    @PreAuthorize("@ss.hasPermi('dataHub:dataSendRecord:edit')")
    @Log(title = "数据发送记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizDataSendRecord row)
    {
        row.setUpdateBy(getUsername());
        return toAjax(bizDataSendRecordService.updateBizDataSendRecord(row));
    }

    @PreAuthorize("@ss.hasPermi('dataHub:dataSendRecord:remove')")
    @Log(title = "数据发送记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizDataSendRecordService.deleteBizDataSendRecordByIds(ids, getUsername()));
    }
}
