package com.yiqi.web.controller.system;

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

import com.yiqi.common.constant.UrlConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.yiqi.common.annotation.Log;
import com.yiqi.common.core.controller.BaseController;
import com.yiqi.common.core.domain.AjaxResult;
import com.yiqi.common.enums.BusinessType;
import com.yiqi.system.domain.SysDataGroupInfo;
import com.yiqi.system.service.ISysDataGroupInfoService;
import com.yiqi.common.utils.poi.ExcelUtil;
import com.yiqi.common.core.page.TableDataInfo;

/**
 * 组合数据详情Controller
 *
 * @author douya
 * @date 2024-10-29
 */
@Api(tags = "管理后台 - 组合数据详情")
@RestController
@RequestMapping(UrlConstants.managerApi + "/system/groupData")
public class SysDataGroupInfoController extends BaseController {

    @Autowired
    private ISysDataGroupInfoService sysDataGroupInfoService;


    /**
     * 查询组合数据详情列表
     */
    @PreAuthorize("@ss.hasPermi('system:groupData:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询组合数据详情列表")
    public TableDataInfo list(SysDataGroupInfo sysDataGroupInfo) {
        startPage();
        List<SysDataGroupInfo> list = sysDataGroupInfoService.selectSysDataGroupInfoList(sysDataGroupInfo);
        return getDataTable(list);
    }

    /**
     * 导出组合数据详情列表
     */
    @PreAuthorize("@ss.hasPermi('system:groupData:export')")
    @Log(title = "组合数据详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出组合数据详情列表")
    public void export(HttpServletResponse response, SysDataGroupInfo sysDataGroupInfo) {
        List<SysDataGroupInfo> list = sysDataGroupInfoService.selectSysDataGroupInfoList(sysDataGroupInfo);
        ExcelUtil<SysDataGroupInfo> util = new ExcelUtil<SysDataGroupInfo>(SysDataGroupInfo.class);
        util.exportExcel(response, list, "组合数据详情数据");
    }

    /**
     * 获取组合数据详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:groupData:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取组合数据详情详细信息")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return success(sysDataGroupInfoService.selectSysDataGroupInfoById(id));
    }

    /**
     * 新增组合数据详情
     */
    @PreAuthorize("@ss.hasPermi('system:groupData:add')")
    @Log(title = "组合数据详情", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增组合数据详情")
    public AjaxResult add(@RequestBody SysDataGroupInfo sysDataGroupInfo) {
        sysDataGroupInfo.setCreateById(getUserId());
        sysDataGroupInfo.setCreateBy(getUsername());
        return toAjax(sysDataGroupInfoService.insertSysDataGroupInfo(sysDataGroupInfo));
    }

    /**
     * 修改组合数据详情
     */
    @PreAuthorize("@ss.hasPermi('system:groupData:edit')")
    @Log(title = "组合数据详情", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改组合数据详情")
    public AjaxResult edit(@RequestBody SysDataGroupInfo sysDataGroupInfo) {
        sysDataGroupInfo.setUpdateById(getUserId());
        sysDataGroupInfo.setUpdateBy(getUsername());
        return toAjax(sysDataGroupInfoService.updateSysDataGroupInfo(sysDataGroupInfo));
    }

    /**
     * 删除组合数据详情
     */
    @PreAuthorize("@ss.hasPermi('system:groupData:remove')")
    @Log(title = "组合数据详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除组合数据详情")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(sysDataGroupInfoService.deleteSysDataGroupInfoByIds(ids));
    }

    /**
     * 修改组合数据详情状态
     */
    @PreAuthorize("@ss.hasPermi('system:groupData:edit')")
    @Log(title = "组合数据详情", businessType = BusinessType.UPDATE)
    @PostMapping(value = "updateStatus")
    @ApiOperation(value = "修改组合数据详情状态")
    public AjaxResult updateSysDataGroupInfoStatus(@RequestBody SysDataGroupInfo sysDataGroupInfo) {
        return toAjax(sysDataGroupInfoService.updateSysDataGroupInfoStatus(sysDataGroupInfo));
    }

}
