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.TGuijiHealthcommissionXx;
import com.sooka.system.service.ITGuijiHealthcommissionXxService;

/**
 * 献血者信息Controller
 * 
 * @author lei
 * @date 2021-11-09
 */
@Controller
@RequestMapping("/system/xx")
public class TGuijiHealthcommissionXxController extends BaseController
{
    private String prefix = "system/xx";

    @Autowired
    private ITGuijiHealthcommissionXxService tGuijiHealthcommissionXxService;

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

    /**
     * 查询献血者信息列表
     */
    @RequiresPermissions("system:xx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiHealthcommissionXx tGuijiHealthcommissionXx)
    {
        startPage();
        List<TGuijiHealthcommissionXx> list = tGuijiHealthcommissionXxService.selectTGuijiHealthcommissionXxList(tGuijiHealthcommissionXx);
        return getDataTable(list);
    }

    /**
     * 导出献血者信息列表
     */
    @RequiresPermissions("system:xx:export")
    @Log(title = "献血者信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiHealthcommissionXx tGuijiHealthcommissionXx)
    {
        List<TGuijiHealthcommissionXx> list = tGuijiHealthcommissionXxService.selectTGuijiHealthcommissionXxList(tGuijiHealthcommissionXx);
        ExcelUtil<TGuijiHealthcommissionXx> util = new ExcelUtil<TGuijiHealthcommissionXx>(TGuijiHealthcommissionXx.class);
        return util.exportExcel(list, "xx");
    }

    /**
     * 新增献血者信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存献血者信息
     */
    @RequiresPermissions("system:xx:add")
    @Log(title = "献血者信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiHealthcommissionXx tGuijiHealthcommissionXx)
    {
        return toAjax(tGuijiHealthcommissionXxService.insertTGuijiHealthcommissionXx(tGuijiHealthcommissionXx));
    }

    /**
     * 修改献血者信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiHealthcommissionXx tGuijiHealthcommissionXx = tGuijiHealthcommissionXxService.selectTGuijiHealthcommissionXxById(id);
        mmap.put("tGuijiHealthcommissionXx", tGuijiHealthcommissionXx);
        return prefix + "/edit";
    }

    /**
     * 修改保存献血者信息
     */
    @RequiresPermissions("system:xx:edit")
    @Log(title = "献血者信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiHealthcommissionXx tGuijiHealthcommissionXx)
    {
        return toAjax(tGuijiHealthcommissionXxService.updateTGuijiHealthcommissionXx(tGuijiHealthcommissionXx));
    }

    /**
     * 删除献血者信息
     */
    @RequiresPermissions("system:xx:remove")
    @Log(title = "献血者信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tGuijiHealthcommissionXxService.deleteTGuijiHealthcommissionXxByIds(ids));
    }
}
