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.ProProjectInfoSubdepts;
import com.yanzhu.manage.service.IProProjectInfoSubdeptsService;
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("/proProjectInfoSubdepts")
public class ProProjectInfoSubdeptsController extends BaseController
{
    @Autowired
    private IProProjectInfoSubdeptsService proProjectInfoSubdeptsService;

    /**
     * 查询分包单位列表
     */
    @RequiresPermissions("manage:proProjectInfoSubdepts:list")
    @GetMapping("/list")
    public TableDataInfo list(ProProjectInfoSubdepts proProjectInfoSubdepts)
    {
        startPage();
        List<ProProjectInfoSubdepts> list = proProjectInfoSubdeptsService.selectProProjectInfoSubdeptsList(proProjectInfoSubdepts);
        return getDataTable(list);
    }

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

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

    /**
     * 新增分包单位
     */
    @RequiresPermissions("manage:proProjectInfoSubdepts:add")
    @Log(title = "分包单位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProProjectInfoSubdepts proProjectInfoSubdepts)
    {
        return toAjax(proProjectInfoSubdeptsService.insertProProjectInfoSubdepts(proProjectInfoSubdepts));
    }

    /**
     * 修改分包单位
     */
    @RequiresPermissions("manage:proProjectInfoSubdepts:edit")
    @Log(title = "分包单位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProProjectInfoSubdepts proProjectInfoSubdepts)
    {
        return toAjax(proProjectInfoSubdeptsService.updateProProjectInfoSubdepts(proProjectInfoSubdepts));
    }

    /**
     * 修改分包单位
     */
    @RequiresPermissions("manage:proProjectInfoSubdepts:edit")
    @Log(title = "分包单位", businessType = BusinessType.UPDATE)
    @PutMapping("/editInfos")
    public AjaxResult editInfos(@RequestBody ProProjectInfoSubdepts proProjectInfoSubdepts)
    {
        return toAjax(proProjectInfoSubdeptsService.updateProProjectInfoSubdeptsEntity(proProjectInfoSubdepts));
    }

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

    /**
     * 查询分包单位列表
     */
    @GetMapping("/findAll")
    public AjaxResult findAll(ProProjectInfoSubdepts proProjectInfoSubdepts)
    {
        List<ProProjectInfoSubdepts> list = proProjectInfoSubdeptsService.selectProProjectInfoSubdeptsList(proProjectInfoSubdepts);
        return success(list);
    }
}
