package com.sooka.system.medicine.industry.controller;


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 com.sooka.system.domain.TGuijiLibraryBorrow;
import com.sooka.system.medicine.industry.domain.TGuijiMedicineIndustry;
import com.sooka.system.medicine.industry.service.ITGuijiMedicineIndustryService;
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.*;

import java.util.List;

/**
 * 规上工业经济数据Controller
 *
 * @author lei
 * @date 2022-08-22
 */
@Controller
@RequestMapping("/system/medicine/industry")
public class TGuijiMedicineIndustryController extends BaseController
{
    private String prefix = "system/medicine/industry";

    @Autowired
    private ITGuijiMedicineIndustryService tGuijiMedicineIndustryService;

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

    /**
     * 查询规上工业经济数据列表
     */
    @RequiresPermissions("system:industry:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiMedicineIndustry tGuijiMedicineIndustry)
    {
        startPage();
        List<TGuijiMedicineIndustry> list = tGuijiMedicineIndustryService.selectTGuijiMedicineIndustryList(tGuijiMedicineIndustry);
        return getDataTable(list);
    }

    /**
     * 导出规上工业经济数据列表
     */
    @RequiresPermissions("system:industry:export")
    @Log(title = "规上工业经济数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiMedicineIndustry tGuijiMedicineIndustry)
    {
        List<TGuijiMedicineIndustry> list = tGuijiMedicineIndustryService.selectTGuijiMedicineIndustryList(tGuijiMedicineIndustry);
        ExcelUtil<TGuijiMedicineIndustry> util = new ExcelUtil<TGuijiMedicineIndustry>(TGuijiMedicineIndustry.class);
        return util.exportExcel(list, "industry");
    }

    /**
     * 新增规上工业经济数据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存规上工业经济数据
     */
    @RequiresPermissions("system:industry:add")
    @Log(title = "规上工业经济数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiMedicineIndustry tGuijiMedicineIndustry)
    {
        return toAjax(tGuijiMedicineIndustryService.insertTGuijiMedicineIndustry(tGuijiMedicineIndustry));
    }

    /**
     * 修改规上工业经济数据
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiMedicineIndustry tGuijiMedicineIndustry = tGuijiMedicineIndustryService.selectTGuijiMedicineIndustryById(id);
        mmap.put("tGuijiMedicineIndustry", tGuijiMedicineIndustry);
        return prefix + "/edit";
    }

    /**
     * 修改保存规上工业经济数据
     */
    @RequiresPermissions("system:industry:edit")
    @Log(title = "规上工业经济数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiMedicineIndustry tGuijiMedicineIndustry)
    {
        return toAjax(tGuijiMedicineIndustryService.updateTGuijiMedicineIndustry(tGuijiMedicineIndustry));
    }

    /**
     * 删除规上工业经济数据
     */
    @RequiresPermissions("system:industry:remove")
    @Log(title = "规上工业经济数据", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tGuijiMedicineIndustryService.deleteTGuijiMedicineIndustryByIds(ids));
    }

    /**
     * 规上工业经济数据详情
     */
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiMedicineIndustry tGuijiMedicineIndustry = tGuijiMedicineIndustryService.selectTGuijiMedicineIndustryById(id);
        mmap.put("tGuijiMedicineIndustry", tGuijiMedicineIndustry);
        return prefix + "/detail";
    }
}
