package com.dcsoft.system.face.controller;

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

import com.dcsoft.system.face.domain.FaceClasses;
import com.dcsoft.system.face.service.IFaceClassesService;
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.dcsoft.common.log.annotation.Log;
import com.dcsoft.common.log.enums.BusinessType;
import com.dcsoft.common.security.annotation.RequiresPermissions;

import com.dcsoft.common.core.web.controller.BaseController;
import com.dcsoft.common.core.web.domain.AjaxResult;
import com.dcsoft.common.core.utils.poi.ExcelUtil;
import com.dcsoft.common.core.web.page.TableDataInfo;

/**
 * 班级信息Controller
 *
 * @author dcsoft
 * @date 2023-05-22
 */
@RestController
@RequestMapping("/classes")
public class FaceClassesController extends BaseController
{
    @Autowired
    private IFaceClassesService faceClassesService;

    /**
     * 查询班级信息列表
     */
    @RequiresPermissions("face:classes:list")
    @GetMapping("/list")
    public TableDataInfo list(FaceClasses faceClasses)
    {
        startPage();
        List<FaceClasses> list = faceClassesService.selectFaceClassesList(faceClasses);
        return getDataTable(list);
    }

    /**
     * 导出班级信息列表
     */
    @RequiresPermissions("face:classes:export")
    @Log(title = "班级信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FaceClasses faceClasses)
    {
        List<FaceClasses> list = faceClassesService.selectFaceClassesList(faceClasses);
        ExcelUtil<FaceClasses> util = new ExcelUtil<FaceClasses>(FaceClasses.class);
        util.exportExcel(response, list, "班级信息数据");
    }

    /**
     * 获取班级信息详细信息
     */
    @RequiresPermissions("face:classes:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(faceClassesService.selectFaceClassesById(id));
    }

    /**
     * 新增班级信息
     */
    @RequiresPermissions("face:classes:add")
    @Log(title = "班级信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FaceClasses faceClasses)
    {
        return toAjax(faceClassesService.insertFaceClasses(faceClasses));
    }

    /**
     * 修改班级信息
     */
    @RequiresPermissions("face:classes:edit")
    @Log(title = "班级信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FaceClasses faceClasses)
    {
        return toAjax(faceClassesService.updateFaceClasses(faceClasses));
    }

    /**
     * 删除班级信息
     */
    @RequiresPermissions("face:classes:remove")
    @Log(title = "班级信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(faceClassesService.deleteFaceClassesByIds(ids));
    }
}
