package com.goer.project.model.modelVersionChanges.controller;

import java.util.List;
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.goer.framework.aspectj.lang.annotation.Log;
import com.goer.framework.aspectj.lang.enums.BusinessType;
import com.goer.project.model.modelVersionChanges.domain.ModelVersionChanges;
import com.goer.project.model.modelVersionChanges.service.IModelVersionChangesService;
import com.goer.framework.web.controller.BaseController;
import com.goer.framework.web.domain.AjaxResult;
import com.goer.common.utils.poi.ExcelUtil;
import com.goer.framework.web.page.TableDataInfo;

/**
 * 模型对象版本修改内容Controller
 * 
 * @author goer
 * @date 2022-01-17
 */
@Controller
@RequestMapping("/model/modelVersionChanges")
public class ModelVersionChangesController extends BaseController
{
    private String prefix = "model/modelVersionChanges";

    @Autowired
    private IModelVersionChangesService modelVersionChangesService;

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

    /**
     * 查询模型对象版本修改内容列表
     */
    @RequiresPermissions("model:modelVersionChanges:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ModelVersionChanges modelVersionChanges)
    {
        startPage();
        List<ModelVersionChanges> list = modelVersionChangesService.selectModelVersionChangesList(modelVersionChanges);
        return getDataTable(list);
    }

    /**
     * 导出模型对象版本修改内容列表
     */
    @RequiresPermissions("model:modelVersionChanges:export")
    @Log(title = "模型对象版本修改内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ModelVersionChanges modelVersionChanges)
    {
        List<ModelVersionChanges> list = modelVersionChangesService.selectModelVersionChangesList(modelVersionChanges);
        ExcelUtil<ModelVersionChanges> util = new ExcelUtil<ModelVersionChanges>(ModelVersionChanges.class);
        return util.exportExcel(list, "模型对象版本修改内容数据");
    }

    /**
     * 新增模型对象版本修改内容
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存模型对象版本修改内容
     */
    @RequiresPermissions("model:modelVersionChanges:add")
    @Log(title = "模型对象版本修改内容", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ModelVersionChanges modelVersionChanges)
    {
        return toAjax(modelVersionChangesService.insertModelVersionChanges(modelVersionChanges));
    }

    /**
     * 修改模型对象版本修改内容
     */
    @RequiresPermissions("model:modelVersionChanges:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ModelVersionChanges modelVersionChanges = modelVersionChangesService.selectModelVersionChangesById(id);
        mmap.put("modelVersionChanges", modelVersionChanges);
        return prefix + "/edit";
    }

    /**
     * 修改保存模型对象版本修改内容
     */
    @RequiresPermissions("model:modelVersionChanges:edit")
    @Log(title = "模型对象版本修改内容", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ModelVersionChanges modelVersionChanges)
    {
        return toAjax(modelVersionChangesService.updateModelVersionChanges(modelVersionChanges));
    }

    /**
     * 删除模型对象版本修改内容
     */
    @RequiresPermissions("model:modelVersionChanges:remove")
    @Log(title = "模型对象版本修改内容", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(modelVersionChangesService.deleteModelVersionChangesByIds(ids));
    }
}
