package com.yanzhu.manage.controller;

import com.yanzhu.common.core.utils.poi.ExcelUtil;
import com.yanzhu.common.core.web.controller.BaseController;
import com.yanzhu.common.core.web.domain.AjaxResult;
import com.yanzhu.common.core.web.page.TableDataInfo;
import com.yanzhu.common.log.annotation.Log;
import com.yanzhu.common.log.enums.BusinessType;
import com.yanzhu.common.security.annotation.RequiresPermissions;
import com.yanzhu.manage.domain.ProProjectInfoSubdeptsGroup;
import com.yanzhu.manage.service.IProProjectInfoSubdeptsGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 分包单位班组Controller
 * 
 * @author JiangYuqi
 * @date 2024-08-25
 */
@RestController
@RequestMapping("/proProjectInfoSubdeptsGroup")
public class ProProjectInfoSubdeptsGroupController extends BaseController
{
    @Autowired
    private IProProjectInfoSubdeptsGroupService proProjectInfoSubdeptsGroupService;

    /**
     * 查询分包单位班组列表
     */
    @RequiresPermissions("manage:proProjectInfoSubdeptsGroup:list")
    @GetMapping("/list")
    public TableDataInfo list(ProProjectInfoSubdeptsGroup proProjectInfoSubdeptsGroup)
    {
        startPage();
        List<ProProjectInfoSubdeptsGroup> list = proProjectInfoSubdeptsGroupService.selectProProjectInfoSubdeptsGroupList(proProjectInfoSubdeptsGroup);
        return getDataTable(list);
    }

    /**
     * 导出分包单位班组列表
     */
    @RequiresPermissions("manage:proProjectInfoSubdeptsGroup:export")
    @Log(title = "分包单位班组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProProjectInfoSubdeptsGroup proProjectInfoSubdeptsGroup)
    {
        List<ProProjectInfoSubdeptsGroup> list = proProjectInfoSubdeptsGroupService.selectProProjectInfoSubdeptsGroupList(proProjectInfoSubdeptsGroup);
        ExcelUtil<ProProjectInfoSubdeptsGroup> util = new ExcelUtil<ProProjectInfoSubdeptsGroup>(ProProjectInfoSubdeptsGroup.class);
        util.exportExcel(response, list, "分包单位班组数据");
    }

    /**
     * 获取分包单位班组详细信息
     */
    @RequiresPermissions("manage:proProjectInfoSubdeptsGroup:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(proProjectInfoSubdeptsGroupService.selectProProjectInfoSubdeptsGroupById(id));
    }

    /**
     * 新增分包单位班组
     */
    @RequiresPermissions("manage:proProjectInfoSubdeptsGroup:add")
    @Log(title = "分包单位班组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProProjectInfoSubdeptsGroup proProjectInfoSubdeptsGroup)
    {
        return toAjax(proProjectInfoSubdeptsGroupService.insertProProjectInfoSubdeptsGroup(proProjectInfoSubdeptsGroup));
    }

    /**
     * 修改分包单位班组
     */
    @RequiresPermissions("manage:proProjectInfoSubdeptsGroup:edit")
    @Log(title = "分包单位班组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProProjectInfoSubdeptsGroup proProjectInfoSubdeptsGroup)
    {
        return toAjax(proProjectInfoSubdeptsGroupService.updateProProjectInfoSubdeptsGroup(proProjectInfoSubdeptsGroup));
    }

    /**
     * 删除分包单位班组
     */
    @RequiresPermissions("manage:proProjectInfoSubdeptsGroup:remove")
    @Log(title = "分包单位班组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(proProjectInfoSubdeptsGroupService.deleteProProjectInfoSubdeptsGroupByIds(ids));
    }
}
