package com.ruoyi.basic.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.basic.domain.HwLanguage;
import com.ruoyi.basic.service.IHwLanguageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 语言信息Controller
 * 
 * @author xins
 * @date 2023-08-24
 */
@RestController
@RequestMapping("/language")
public class HwLanguageController extends BaseController
{
    @Autowired
    private IHwLanguageService hwLanguageService;

    /**
     * @param: hwLanguage
     * @description 获取语言信息列表供选择使用（下拉列表等）
     * @author xins
     * @date 2023-09-07 9:57
     * @return AjaxResult 
     */
    @GetMapping("/getLanguages")
    public AjaxResult getLanguages(HwLanguage hwLanguage)
    {
        return success(hwLanguageService.selectHwLanguageList(hwLanguage));
    }



    /**
     * 查询语言信息列表
     */
    @RequiresPermissions("basic:language:list")
    @GetMapping("/list")
    public TableDataInfo list(HwLanguage hwLanguage)
    {
        startPage();
        List<HwLanguage> list = hwLanguageService.selectHwLanguageList(hwLanguage);
        return getDataTable(list);
    }

    /**
     * 导出语言信息列表
     */
    @RequiresPermissions("basic:language:export")
    @Log(title = "语言信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HwLanguage hwLanguage)
    {
        List<HwLanguage> list = hwLanguageService.selectHwLanguageList(hwLanguage);
        ExcelUtil<HwLanguage> util = new ExcelUtil<HwLanguage>(HwLanguage.class);
        util.exportExcel(response, list, "语言信息数据");
    }

    /**
     * 获取语言信息详细信息
     */
    @RequiresPermissions("basic:language:query")
    @GetMapping(value = "/{languageId}")
    public AjaxResult getInfo(@PathVariable("languageId") Long languageId)
    {
        return success(hwLanguageService.selectHwLanguageByLanguageId(languageId));
    }

    /**
     * 新增语言信息
     */
    @RequiresPermissions("basic:language:add")
    @Log(title = "语言信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HwLanguage hwLanguage)
    {
        return toAjax(hwLanguageService.insertHwLanguage(hwLanguage));
    }

    /**
     * 修改语言信息
     */
    @RequiresPermissions("basic:language:edit")
    @Log(title = "语言信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HwLanguage hwLanguage)
    {
        return toAjax(hwLanguageService.updateHwLanguage(hwLanguage));
    }

    /**
     * 删除语言信息
     */
    @RequiresPermissions("basic:language:remove")
    @Log(title = "语言信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{languageIds}")
    public AjaxResult remove(@PathVariable Long[] languageIds)
    {
        return toAjax(hwLanguageService.deleteHwLanguageByLanguageIds(languageIds));
    }
}
