package com.ruoyi.mall.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
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.mall.domain.MallCareerSalary;
import com.ruoyi.mall.service.IMallCareerSalaryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 职业薪资Controller
 *
 * @author LCL
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/mall/mallCareerSalary")
public class MallCareerSalaryController extends BaseController
{
    @Resource
    private IMallCareerSalaryService mallCareerSalaryService;

    /**
     * 查询职业薪资列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCareerSalary:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallCareerSalary mallCareerSalary)
    {
        startPage();
        List<MallCareerSalary> list = mallCareerSalaryService.selectMallCareerSalaryList(mallCareerSalary);
        return getDataTable(list);
    }

    /**
     * 导出职业薪资列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCareerSalary:export')")
    @Log(title = "职业薪资", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallCareerSalary mallCareerSalary)
    {
        List<MallCareerSalary> list = mallCareerSalaryService.selectMallCareerSalaryList(mallCareerSalary);
        ExcelUtil<MallCareerSalary> util = new ExcelUtil<MallCareerSalary>(MallCareerSalary.class);
        util.exportExcel(response, list, "职业薪资数据");
    }

    /**
     * 获取职业薪资详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCareerSalary:query')")
    @GetMapping(value = "/{careerSalaryId}")
    public AjaxResult getInfo(@PathVariable("careerSalaryId") Long careerSalaryId)
    {
        return AjaxResult.success(mallCareerSalaryService.selectMallCareerSalaryByCareerSalaryId(careerSalaryId));
    }

    /**
     * 新增职业薪资
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCareerSalary:add')")
    @Log(title = "职业薪资", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallCareerSalary mallCareerSalary)
    {
        return toAjax(mallCareerSalaryService.insertMallCareerSalary(mallCareerSalary));
    }

    /**
     * 修改职业薪资
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCareerSalary:edit')")
    @Log(title = "职业薪资", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallCareerSalary mallCareerSalary)
    {
        return toAjax(mallCareerSalaryService.updateMallCareerSalary(mallCareerSalary));
    }

    /**
     * 删除职业薪资
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCareerSalary:remove')")
    @Log(title = "职业薪资", businessType = BusinessType.DELETE)
	@DeleteMapping("/{careerSalaryIds}")
    public AjaxResult remove(@PathVariable Long[] careerSalaryIds)
    {
        return toAjax(mallCareerSalaryService.deleteMallCareerSalaryByCareerSalaryIds(careerSalaryIds));
    }
}
