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.TGuijiNaturalresourcesQlrjbxx;
import com.sooka.system.service.ITGuijiNaturalresourcesQlrjbxxService;

/**
 * 个人基本信息Controller
 *
 * @author wangjinsheng
 * @date 2021-10-28
 */
@Controller
@RequestMapping("/system/grjbxx")
public class TGuijiNaturalresourcesQlrjbxxController extends BaseController {
    private String prefix = "system/grjbxx";

    @Autowired
    private ITGuijiNaturalresourcesQlrjbxxService tGuijiNaturalresourcesQlrjbxxService;

     //个人
    @RequiresPermissions("system:grjbxx:view")
    @GetMapping()
    public String grjbxx(ModelMap map) {
        map.put("flag","gr");
        return prefix + "/grjbxx";
    }

    //企业
    @RequiresPermissions("system:grjbxx:view")
    @GetMapping("/qyjbxx")
    public String qyjbxx(ModelMap map) {
        map.put("flag","qy");
        return prefix + "/grjbxx";
    }


    //其他
    @RequiresPermissions("system:grjbxx:view")
    @GetMapping("/qtjbxx")
    public String qtjbxx(ModelMap map) {
        map.put("flag","qt");
        return prefix + "/grjbxx";
    }

    /**
     * 查询个人基本信息列表
     */
    @RequiresPermissions("system:grjbxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiNaturalresourcesQlrjbxx tGuijiNaturalresourcesQlrjbxx) {
        startPage();
        tGuijiNaturalresourcesQlrjbxx.setQlrxz("个人");
        List<TGuijiNaturalresourcesQlrjbxx> list = tGuijiNaturalresourcesQlrjbxxService.selectTGuijiNaturalresourcesQlrjbxxList(tGuijiNaturalresourcesQlrjbxx);
        return getDataTable(list);
    }

    /**
     * 查询企业基本信息列表
     */
    @RequiresPermissions("system:grjbxx:list")
    @PostMapping("/qyList")
    @ResponseBody
    public TableDataInfo qyList(TGuijiNaturalresourcesQlrjbxx tGuijiNaturalresourcesQlrjbxx) {
        startPage();
        tGuijiNaturalresourcesQlrjbxx.setQlrxz("企业");
        List<TGuijiNaturalresourcesQlrjbxx> list = tGuijiNaturalresourcesQlrjbxxService.selectTGuijiNaturalresourcesQlrjbxxList(tGuijiNaturalresourcesQlrjbxx);
        return getDataTable(list);
    }

    /**
     * 查询其他基本信息列表
     */
    @RequiresPermissions("system:grjbxx:list")
    @PostMapping("/qtList")
    @ResponseBody
    public TableDataInfo qtList(TGuijiNaturalresourcesQlrjbxx tGuijiNaturalresourcesQlrjbxx) {
        startPage();
        tGuijiNaturalresourcesQlrjbxx.setQlrxz("");
        List<TGuijiNaturalresourcesQlrjbxx> list = tGuijiNaturalresourcesQlrjbxxService.selectTGuijiNaturalresourcesQlrjbxxList(tGuijiNaturalresourcesQlrjbxx);
        return getDataTable(list);
    }

    /**
     * 导出个人基本信息列表
     */
    @RequiresPermissions("system:grjbxx:export")
    @Log(title = "个人基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiNaturalresourcesQlrjbxx tGuijiNaturalresourcesQlrjbxx) {
        List<TGuijiNaturalresourcesQlrjbxx> list = tGuijiNaturalresourcesQlrjbxxService.selectTGuijiNaturalresourcesQlrjbxxList(tGuijiNaturalresourcesQlrjbxx);
        ExcelUtil<TGuijiNaturalresourcesQlrjbxx> util = new ExcelUtil<TGuijiNaturalresourcesQlrjbxx>(TGuijiNaturalresourcesQlrjbxx.class);
        return util.exportExcel(list, "grjbxx");
    }

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

    /**
     * 新增保存个人基本信息
     */
    @RequiresPermissions("system:grjbxx:add")
    @Log(title = "个人基本信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiNaturalresourcesQlrjbxx tGuijiNaturalresourcesQlrjbxx) {
        return toAjax(tGuijiNaturalresourcesQlrjbxxService.insertTGuijiNaturalresourcesQlrjbxx(tGuijiNaturalresourcesQlrjbxx));
    }

    /**
     * 修改个人基本信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap) {
        TGuijiNaturalresourcesQlrjbxx tGuijiNaturalresourcesQlrjbxx = tGuijiNaturalresourcesQlrjbxxService.selectTGuijiNaturalresourcesQlrjbxxById(id);
        mmap.put("tGuijiNaturalresourcesQlrjbxx", tGuijiNaturalresourcesQlrjbxx);
        return prefix + "/detail";
    }

    /**
     * 修改保存个人基本信息
     */
    @RequiresPermissions("system:grjbxx:edit")
    @Log(title = "个人基本信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiNaturalresourcesQlrjbxx tGuijiNaturalresourcesQlrjbxx) {
        return toAjax(tGuijiNaturalresourcesQlrjbxxService.updateTGuijiNaturalresourcesQlrjbxx(tGuijiNaturalresourcesQlrjbxx));
    }

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