package com.sooka.system.controller;

import java.util.List;

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.common.annotation.Log;
import com.sooka.system.domain.TgjjGtjkrxx;
import com.sooka.system.service.ITgjjGtjkrxxService;

/**
 * 共同借款人信息Controller
 * 
 * @author lei
 * @date 2021-11-16
 */
@Controller
@RequestMapping("/system/gtjkrxx")
public class TgjjGtjkrxxController extends BaseController
{
    private String prefix = "system/gtjkrxx";

    @Autowired
    private ITgjjGtjkrxxService tgjjGtjkrxxService;

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

    /**
     * 查询共同借款人信息列表
     */
    @RequiresPermissions("system:gtjkrxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TgjjGtjkrxx tgjjGtjkrxx)
    {
        startPage();
        List<TgjjGtjkrxx> list = tgjjGtjkrxxService.selectTgjjGtjkrxxList(tgjjGtjkrxx);
        return getDataTable(list);
    }

    /**
     * 导出共同借款人信息列表
     */
    @RequiresPermissions("system:gtjkrxx:export")
    @Log(title = "共同借款人信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TgjjGtjkrxx tgjjGtjkrxx)
    {
        List<TgjjGtjkrxx> list = tgjjGtjkrxxService.selectTgjjGtjkrxxList(tgjjGtjkrxx);
        ExcelUtil<TgjjGtjkrxx> util = new ExcelUtil<TgjjGtjkrxx>(TgjjGtjkrxx.class);
        return util.exportExcel(list, "gtjkrxx");
    }

    /**
     * 新增共同借款人信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存共同借款人信息
     */
    @RequiresPermissions("system:gtjkrxx:add")
    @Log(title = "共同借款人信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TgjjGtjkrxx tgjjGtjkrxx)
    {
        return toAjax(tgjjGtjkrxxService.insertTgjjGtjkrxx(tgjjGtjkrxx));
    }

    /**
     * 修改共同借款人信息
     */
    @GetMapping("/edit/{ID}")
    public String edit(@PathVariable("ID") Long ID, ModelMap mmap)
    {
        TgjjGtjkrxx tgjjGtjkrxx = tgjjGtjkrxxService.selectTgjjGtjkrxxById(ID);
        mmap.put("tgjjGtjkrxx", tgjjGtjkrxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存共同借款人信息
     */
    @RequiresPermissions("system:gtjkrxx:edit")
    @Log(title = "共同借款人信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TgjjGtjkrxx tgjjGtjkrxx)
    {
        return toAjax(tgjjGtjkrxxService.updateTgjjGtjkrxx(tgjjGtjkrxx));
    }

    /**
     * 删除共同借款人信息
     */
    @RequiresPermissions("system:gtjkrxx:remove")
    @Log(title = "共同借款人信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tgjjGtjkrxxService.deleteTgjjGtjkrxxByIds(ids));
    }
}
