package com.sooka.system.controller;

import java.util.List;
import com.sooka.common.annotation.Log;
import com.sooka.common.core.controller.BaseController;
import com.sooka.common.core.domain.AjaxResult;
import com.sooka.common.core.page.TableDataInfo;
import com.sooka.common.enums.BusinessType;
import com.sooka.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.sooka.system.domain.TGuijiHealthcommissionTjxx;
import com.sooka.system.service.ITGuijiHealthcommissionTjxxService;

/**
 * 体检信息表Controller
 * 
 * @author lei
 * @date 2021-11-09
 */
@Controller
@RequestMapping("/system/tjxx")
public class TGuijiHealthcommissionTjxxController extends BaseController
{
    private String prefix = "system/tjxx";

    @Autowired
    private ITGuijiHealthcommissionTjxxService tGuijiHealthcommissionTjxxService;

    @RequiresPermissions("system:tjxx:view")
    @GetMapping()
    public String tjxx()
    {
        return prefix + "/tjxx";
    }

    /**
     * 查询体检信息表列表
     */
    @RequiresPermissions("system:tjxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiHealthcommissionTjxx tGuijiHealthcommissionTjxx)
    {
        startPage();
        List<TGuijiHealthcommissionTjxx> list = tGuijiHealthcommissionTjxxService.selectTGuijiHealthcommissionTjxxList(tGuijiHealthcommissionTjxx);
        return getDataTable(list);
    }

    /**
     * 导出体检信息表列表
     */
    @RequiresPermissions("system:tjxx:export")
    @Log(title = "体检信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiHealthcommissionTjxx tGuijiHealthcommissionTjxx)
    {
        List<TGuijiHealthcommissionTjxx> list = tGuijiHealthcommissionTjxxService.selectTGuijiHealthcommissionTjxxList(tGuijiHealthcommissionTjxx);
        ExcelUtil<TGuijiHealthcommissionTjxx> util = new ExcelUtil<TGuijiHealthcommissionTjxx>(TGuijiHealthcommissionTjxx.class);
        return util.exportExcel(list, "tjxx");
    }

    /**
     * 新增体检信息表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存体检信息表
     */
    @RequiresPermissions("system:tjxx:add")
    @Log(title = "体检信息表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiHealthcommissionTjxx tGuijiHealthcommissionTjxx)
    {
        return toAjax(tGuijiHealthcommissionTjxxService.insertTGuijiHealthcommissionTjxx(tGuijiHealthcommissionTjxx));
    }

    /**
     * 修改体检信息表
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiHealthcommissionTjxx tGuijiHealthcommissionTjxx = tGuijiHealthcommissionTjxxService.selectTGuijiHealthcommissionTjxxById(id);
        mmap.put("tGuijiHealthcommissionTjxx", tGuijiHealthcommissionTjxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存体检信息表
     */
    @RequiresPermissions("system:tjxx:edit")
    @Log(title = "体检信息表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiHealthcommissionTjxx tGuijiHealthcommissionTjxx)
    {
        return toAjax(tGuijiHealthcommissionTjxxService.updateTGuijiHealthcommissionTjxx(tGuijiHealthcommissionTjxx));
    }

    /**
     * 删除体检信息表
     */
    @RequiresPermissions("system:tjxx:remove")
    @Log(title = "体检信息表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tGuijiHealthcommissionTjxxService.deleteTGuijiHealthcommissionTjxxByIds(ids));
    }
}
