package com.jjt.emp.controller;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.jjt.common.annotation.Log;
import com.jjt.common.core.controller.BaseController;
import com.jjt.common.core.domain.AjaxResult;
import com.jjt.common.enums.BusinessType;
import com.jjt.emp.domain.TwinEmpConfig;
import com.jjt.emp.service.ITwinEmpConfigService;
import com.jjt.common.utils.poi.ExcelUtil;
import com.jjt.common.core.page.TableDataInfo;

/**
 * 密度价格配置Controller
 *
 * @author wukai
 * @date 2025-01-18
 */
@Api(tags="密度价格配置")
@RestController
@RequestMapping("/emp/empConfig")
public class TwinEmpConfigController extends BaseController{
    @Resource
    private ITwinEmpConfigService twinEmpConfigService;

    /**
     * 查询密度价格配置列表
     */
    @ApiOperation("查询密度价格配置列表")
    //@PreAuthorize("@ss.hasPermi('emp:empConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinEmpConfig twinEmpConfig)
    {
        startPage();
        List<TwinEmpConfig> list = twinEmpConfigService.selectTwinEmpConfigList(twinEmpConfig);
        return getDataTable(list);
    }

    /**
     * 导出密度价格配置列表
     */
    @ApiOperation("导出密度价格配置列表")
    //@PreAuthorize("@ss.hasPermi('emp:empConfig:export')")
    @Log(title = "密度价格配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinEmpConfig twinEmpConfig)
    {
        List<TwinEmpConfig> list = twinEmpConfigService.selectTwinEmpConfigList(twinEmpConfig);
        ExcelUtil<TwinEmpConfig> util = new ExcelUtil<TwinEmpConfig>(TwinEmpConfig.class);
        util.exportExcel(response, list, "密度价格配置数据");
    }

    /**
     * 获取密度价格配置详细信息
     */
    @ApiOperation("获取密度价格配置详细信息")
    //@PreAuthorize("@ss.hasPermi('emp:empConfig:query')")
    @GetMapping(value = "/{configId}")
    public AjaxResult getInfo(@PathVariable("configId") Long configId)
    {
        return success(twinEmpConfigService.selectTwinEmpConfigByConfigId(configId));
    }

    /**
     * 新增密度价格配置
     */
    @ApiOperation("新增密度价格配置")
    //@PreAuthorize("@ss.hasPermi('emp:empConfig:add')")
    @Log(title = "密度价格配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinEmpConfig twinEmpConfig)
    {
        return toAjax(twinEmpConfigService.insertTwinEmpConfig(twinEmpConfig));
    }

    /**
     * 修改密度价格配置
     */
    @ApiOperation("修改密度价格配置")
    //@PreAuthorize("@ss.hasPermi('emp:empConfig:edit')")
    @Log(title = "密度价格配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinEmpConfig twinEmpConfig)
    {
        return toAjax(twinEmpConfigService.updateTwinEmpConfig(twinEmpConfig));
    }

    /**
     * 删除密度价格配置
     */
    @ApiOperation("删除密度价格配置")
    //@PreAuthorize("@ss.hasPermi('emp:empConfig:remove')")
    @Log(title = "密度价格配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{configIds}")
    public AjaxResult remove(@PathVariable Long[] configIds)
    {
        return toAjax(twinEmpConfigService.deleteTwinEmpConfigByConfigIds(configIds));
    }
}
