package com.ruoyi.web.controller.branch;

import java.util.List;
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.branch.domain.TBranchAssess;
import com.ruoyi.branch.service.ITBranchAssessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 纪律考评Controller
 * 
 * @author ruoyi
 * @date 2023-07-31
 */
@RestController
@RequestMapping("/branch/assess")
public class TBranchAssessController extends BaseController
{
    @Autowired
    private ITBranchAssessService tBranchAssessService;

    /**
     * 查询纪律考评列表
     */
    @PreAuthorize("@ss.hasPermi('branch:assess:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBranchAssess tBranchAssess)
    {
        startPage();
        List<TBranchAssess> list = tBranchAssessService.selectTBranchAssessList(tBranchAssess);
        return getDataTable(list);
    }

    /**
     * 导出纪律考评列表
     */
    @PreAuthorize("@ss.hasPermi('branch:assess:export')")
    @Log(title = "纪律考评", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBranchAssess tBranchAssess)
    {
        List<TBranchAssess> list = tBranchAssessService.selectTBranchAssessList(tBranchAssess);
        ExcelUtil<TBranchAssess> util = new ExcelUtil<TBranchAssess>(TBranchAssess.class);
        util.exportExcel(response, list, "纪律考评数据");
    }

    /**
     * 获取纪律考评详细信息
     */
    @PreAuthorize("@ss.hasPermi('branch:assess:query')")
    @GetMapping(value = "/{assessId}")
    public AjaxResult getInfo(@PathVariable("assessId") Long assessId)
    {
        return success(tBranchAssessService.selectTBranchAssessByAssessId(assessId));
    }

    /**
     * 新增纪律考评
     */
    @PreAuthorize("@ss.hasPermi('branch:assess:add')")
    @Log(title = "纪律考评", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBranchAssess tBranchAssess)
    {
        return toAjax(tBranchAssessService.insertTBranchAssess(tBranchAssess));
    }

    /**
     * 修改纪律考评
     */
    @PreAuthorize("@ss.hasPermi('branch:assess:edit')")
    @Log(title = "纪律考评", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBranchAssess tBranchAssess)
    {
        return toAjax(tBranchAssessService.updateTBranchAssess(tBranchAssess));
    }

    /**
     * 删除纪律考评
     */
    @PreAuthorize("@ss.hasPermi('branch:assess:remove')")
    @Log(title = "纪律考评", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assessIds}")
    public AjaxResult remove(@PathVariable Long[] assessIds)
    {
        return toAjax(tBranchAssessService.deleteTBranchAssessByAssessIds(assessIds));
    }
}
