package com.ruoyi.adjust.controller;

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

import org.springframework.security.access.prepost.PreAuthorize;
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 java.util.Arrays;

import com.ruoyi.common.core.controller.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.adjust.domain.DAdjustSyncLog;
import com.ruoyi.adjust.service.IDAdjustSyncLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据调整同步记录Controller
 *
 * @author ruoyi
 * @date 2023-04-19
 */
@RestController
@RequestMapping("/adjust/dAdjustSyncLog")
public class DAdjustSyncLogController extends BaseController {
    private final IDAdjustSyncLogService dAdjustSyncLogService;

    public DAdjustSyncLogController(IDAdjustSyncLogService dAdjustSyncLogService) {
        this.dAdjustSyncLogService = dAdjustSyncLogService;
    }


    /**
     * 查询数据调整同步记录列表
     *
     * @param dAdjustSyncLog 数据调整同步记录
     * @return 数据调整同步记录集合
     * @date 2023-04-19
     */
    @PreAuthorize("@ss.hasPermi('adjust:dAdjustSyncLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(DAdjustSyncLog dAdjustSyncLog) {
        startPage();
        List<DAdjustSyncLog> list = dAdjustSyncLogService.queryList(dAdjustSyncLog);
        return getDataTable(list);
    }


    /**
     * 导出数据调整同步记录列表
     *
     * @param dAdjustSyncLog 数据调整同步记录
     * @date 2023-04-19
     */
    @PreAuthorize("@ss.hasPermi('adjust:dAdjustSyncLog:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DAdjustSyncLog dAdjustSyncLog) {
        List<DAdjustSyncLog> list = dAdjustSyncLogService.list(new QueryWrapper<>());
        ExcelUtil<DAdjustSyncLog> util = new ExcelUtil<>(DAdjustSyncLog. class);
        util.exportExcel(response, list, "数据调整同步记录数据");
    }

    /**
     * 获取数据调整同步记录详细信息
     *
     * @param id 主键id
     * @return 结果
     * @date 2023-04-19
     */
    @PreAuthorize("@ss.hasPermi('adjust:dAdjustSyncLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(dAdjustSyncLogService.getById(id));
    }


    /**
     * 新增数据调整同步记录信息
     *
     * @param dAdjustSyncLog 数据调整同步记录
     * @return 结果
     * @date 2023-04-19
     */
    @PreAuthorize("@ss.hasPermi('adjust:dAdjustSyncLog:add')")
    @Log(title = "数据调整同步记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DAdjustSyncLog dAdjustSyncLog) {
        return toAjax(dAdjustSyncLogService.save(dAdjustSyncLog));
    }


    /**
     * 修改数据调整同步记录信息
     *
     * @param dAdjustSyncLog 数据调整同步记录
     * @return 结果
     * @date 2023-04-19
     */
    @PreAuthorize("@ss.hasPermi('adjust:dAdjustSyncLog:edit')")
    @Log(title = "数据调整同步记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DAdjustSyncLog dAdjustSyncLog) {
        return toAjax(dAdjustSyncLogService.updateById(dAdjustSyncLog));
    }


    /**
     * 删除数据调整同步记录信息
     *
     * @param ids 主键ids
     * @return 结果
     * @date 2023-04-19
     */
    @PreAuthorize("@ss.hasPermi('adjust:dAdjustSyncLog:remove')")
    @Log(title = "数据调整同步记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(dAdjustSyncLogService.removeByIds(Arrays.asList(ids)));
    }


}
