package com.dgtly.order.controller;

import java.util.List;

import com.dgtly.order.domain.OrderSalesGroup;
import com.dgtly.order.service.IOrderSalesGroupService;
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.dgtly.common.core.controller.BaseController;
import com.dgtly.common.core.domain.AjaxResult;
import com.dgtly.common.utils.poi.ExcelUtil;
import com.dgtly.common.core.page.TableDataInfo;

/**
 * 【销售分部目标达成】Controller
 * 
 * @author dgtly
 * @date 2020-12-01
 */
@Controller
@RequestMapping("/order/orderSalesGroup")
public class OrderSalesGroupController extends BaseController
{
    private String prefix = "order/orderSalesGroup";

    @Autowired
    private IOrderSalesGroupService orderSalesGroupService;

    @RequiresPermissions("order:orderSalesGroup:view")
    @GetMapping()
    public String group()
    {
        return prefix + "/groupList";
    }

    /**
     * 查询【销售分部目标达成】列表
     */
    @RequiresPermissions("order:orderSalesGroup:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(OrderSalesGroup orderSalesGroup)
    {
        startPage();
        List<OrderSalesGroup> list = orderSalesGroupService.selectOrderSalesGroupList(orderSalesGroup);
        return getDataTable(list);
    }

    /**
     * 导出【销售分部目标达成】列表
     */
    @RequiresPermissions("order:orderSalesGroup:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(OrderSalesGroup orderSalesGroup)
    {
        List<OrderSalesGroup> list = orderSalesGroupService.selectOrderSalesGroupList(orderSalesGroup);
        ExcelUtil<OrderSalesGroup> util = new ExcelUtil<OrderSalesGroup>(OrderSalesGroup.class);
        return util.exportExcel(list, "销售分组目标达成");
    }

    /**
     * 修改【销售分部目标达成】
     */
    @GetMapping("/info/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        OrderSalesGroup orderSalesGroup = orderSalesGroupService.selectOrderSalesGroupById(id);
        mmap.put("orderSalesGroup", orderSalesGroup);
        return prefix + "/detail";
    }

}
