package com.dcsoft.system.kq.controller;

import java.text.ParseException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dcsoft.common.log.annotation.Log;
import com.dcsoft.common.log.enums.BusinessType;
import com.dcsoft.common.security.annotation.RequiresPermissions;
import com.dcsoft.system.kq.domain.KqGatherMonth;
import com.dcsoft.system.kq.service.IKqGatherMonthService;
import com.dcsoft.common.core.web.controller.BaseController;
import com.dcsoft.common.core.web.domain.AjaxResult;
import com.dcsoft.common.core.utils.poi.ExcelUtil;
import com.dcsoft.common.core.web.page.TableDataInfo;

/**
 * 月汇总Controller
 *
 * @author dcsoft
 * @date 2023-08-01
 */
@RestController
@RequestMapping("/gatherMonth")
public class KqGatherMonthController extends BaseController
{
    @Autowired
    private IKqGatherMonthService kqGatherMonthService;

    /**
     * 查询月汇总列表
     */
    @RequiresPermissions("kq:gatherMonth:list")
    @GetMapping("/list")
    public TableDataInfo list(KqGatherMonth kqGatherMonth) throws ParseException {
        startPage();
        List<KqGatherMonth> list = kqGatherMonthService.selectKqGatherMonthList(kqGatherMonth);
        return getDataTable(list);
    }

    /**
     * 导出月汇总列表
     */
    @RequiresPermissions("kq:gatherMonth:export")
    @Log(title = "月汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KqGatherMonth kqGatherMonth) throws ParseException {
        List<KqGatherMonth> list = kqGatherMonthService.selectKqGatherMonthList(kqGatherMonth);
        ExcelUtil<KqGatherMonth> util = new ExcelUtil<KqGatherMonth>(KqGatherMonth.class);
        util.exportExcel(response, list, "月汇总数据");
    }

    /**
     * 获取月汇总详细信息
     */
    @RequiresPermissions("kq:gatherMonth:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(kqGatherMonthService.selectKqGatherMonthById(id));
    }

    /**
     * 新增月汇总
     */
    @RequiresPermissions("kq:gatherMonth:add")
    @Log(title = "月汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KqGatherMonth kqGatherMonth)
    {
        return toAjax(kqGatherMonthService.insertKqGatherMonth(kqGatherMonth));
    }

    /**
     * 修改月汇总
     */
    @RequiresPermissions("kq:gatherMonth:edit")
    @Log(title = "月汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KqGatherMonth kqGatherMonth)
    {
        return toAjax(kqGatherMonthService.updateKqGatherMonth(kqGatherMonth));
    }

    /**
     * 删除月汇总
     */
    @RequiresPermissions("kq:gatherMonth:remove")
    @Log(title = "月汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kqGatherMonthService.deleteKqGatherMonthByIds(ids));
    }
    /*
      * 修改月汇总
     */
    @Log(title = "月汇总", businessType = BusinessType.INSERT)
    @PutMapping("/create")
    public AjaxResult create(@RequestBody KqGatherMonth kqGatherMonth)
    {

        return toAjax(kqGatherMonthService.createKqGatherMonth(kqGatherMonth));
    }

}
