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.TgjjHmdxx;
import com.sooka.system.service.ITgjjHmdxxService;

/**
 * 黑名单信息Controller
 * 
 * @author lei
 * @date 2021-11-16
 */
@Controller
@RequestMapping("/system/hmdxx")
public class TgjjHmdxxController extends BaseController
{
    private String prefix = "system/hmdxx";

    @Autowired
    private ITgjjHmdxxService tgjjHmdxxService;

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

    /**
     * 查询黑名单信息列表
     */
    @RequiresPermissions("system:hmdxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TgjjHmdxx tgjjHmdxx)
    {
        startPage();
        List<TgjjHmdxx> list = tgjjHmdxxService.selectTgjjHmdxxList(tgjjHmdxx);
        return getDataTable(list);
    }

    /**
     * 导出黑名单信息列表
     */
    @RequiresPermissions("system:hmdxx:export")
    @Log(title = "黑名单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TgjjHmdxx tgjjHmdxx)
    {
        List<TgjjHmdxx> list = tgjjHmdxxService.selectTgjjHmdxxList(tgjjHmdxx);
        ExcelUtil<TgjjHmdxx> util = new ExcelUtil<TgjjHmdxx>(TgjjHmdxx.class);
        return util.exportExcel(list, "hmdxx");
    }

    /**
     * 新增黑名单信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存黑名单信息
     */
    @RequiresPermissions("system:hmdxx:add")
    @Log(title = "黑名单信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TgjjHmdxx tgjjHmdxx)
    {
        return toAjax(tgjjHmdxxService.insertTgjjHmdxx(tgjjHmdxx));
    }

    /**
     * 修改黑名单信息
     */
    @GetMapping("/edit/{ID}")
    public String edit(@PathVariable("ID") Long ID, ModelMap mmap)
    {
        TgjjHmdxx tgjjHmdxx = tgjjHmdxxService.selectTgjjHmdxxById(ID);
        mmap.put("tgjjHmdxx", tgjjHmdxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存黑名单信息
     */
    @RequiresPermissions("system:hmdxx:edit")
    @Log(title = "黑名单信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TgjjHmdxx tgjjHmdxx)
    {
        return toAjax(tgjjHmdxxService.updateTgjjHmdxx(tgjjHmdxx));
    }

    /**
     * 删除黑名单信息
     */
    @RequiresPermissions("system:hmdxx:remove")
    @Log(title = "黑名单信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tgjjHmdxxService.deleteTgjjHmdxxByIds(ids));
    }
}
