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.ServletUtils;
import com.sooka.common.utils.poi.ExcelUtil;
import com.sooka.common.utils.uuid.UUID;
import com.sooka.system.domain.SysUser;
import com.sooka.system.domain.TULog;
import com.sooka.system.service.ITULogService;
import com.util.HttpUtil;
import com.util.UserInfoUtil;
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.TGuijiLibraryBaseinfo;
import com.sooka.system.service.ITGuijiLibraryBaseinfoService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;


/**
 * 人员基本信息Controller
 *
 * @author lei
 * @date 2021-10-20
 */
@Controller
@RequestMapping("/system/library/baseinfo")
public class TGuijiLibraryBaseinfoController extends BaseController
{
    private String prefix = "system/library/baseinfo";

    @Autowired
    private ITGuijiLibraryBaseinfoService tGuijiLibraryBaseinfoService;

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

    @Resource
    private UserInfoUtil userInfoUtil;

    @Resource
    ITULogService ituLogService;

    /**
     * 查询人员基本信息列表
     */
    @RequiresPermissions("system:baseinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiLibraryBaseinfo tGuijiLibraryBaseinfo)
    {

        startPage();

        List<TGuijiLibraryBaseinfo> list = tGuijiLibraryBaseinfoService.selectTGuijiLibraryBaseinfoList(tGuijiLibraryBaseinfo);
        return getDataTable(list);
    }

    /**
     * 导出人员基本信息列表
     */
    @RequiresPermissions("system:baseinfo:export")
    @Log(title = "人员基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiLibraryBaseinfo tGuijiLibraryBaseinfo)
    {
        List<TGuijiLibraryBaseinfo> list = tGuijiLibraryBaseinfoService.selectTGuijiLibraryBaseinfoList(tGuijiLibraryBaseinfo);
        ExcelUtil<TGuijiLibraryBaseinfo> util = new ExcelUtil<TGuijiLibraryBaseinfo>(TGuijiLibraryBaseinfo.class);
        return util.exportExcel(list, "baseinfo");
    }

    /**
     * 新增人员基本信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存人员基本信息
     */
    @RequiresPermissions("system:baseinfo:add")
    @Log(title = "人员基本信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiLibraryBaseinfo tGuijiLibraryBaseinfo)
    {
        return toAjax(tGuijiLibraryBaseinfoService.insertTGuijiLibraryBaseinfo(tGuijiLibraryBaseinfo));
    }

    /**
     * 修改人员基本信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiLibraryBaseinfo tGuijiLibraryBaseinfo = tGuijiLibraryBaseinfoService.selectTGuijiLibraryBaseinfoById(id);
        mmap.put("tGuijiLibraryBaseinfo", tGuijiLibraryBaseinfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存人员基本信息
     */
    @RequiresPermissions("system:baseinfo:edit")
    @Log(title = "人员基本信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiLibraryBaseinfo tGuijiLibraryBaseinfo)
    {
        return toAjax(tGuijiLibraryBaseinfoService.updateTGuijiLibraryBaseinfo(tGuijiLibraryBaseinfo));
    }

    /**
     * 删除人员基本信息
     */
    @RequiresPermissions("system:baseinfo:remove")
    @Log(title = "人员基本信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tGuijiLibraryBaseinfoService.deleteTGuijiLibraryBaseinfoByIds(ids));
    }

    /**
     * 查询读者人员基本信息详细
     */
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiLibraryBaseinfo tGuijiLibraryBaseinfo = tGuijiLibraryBaseinfoService.selectTGuijiLibraryBaseinfoById(id);
        mmap.put("tGuijiLibraryBaseinfo", tGuijiLibraryBaseinfo);
        return prefix + "/detail";
    }
}
