package com.zkqy.web.controller.bpm;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
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.zkqy.common.annotation.Log;
import com.zkqy.common.core.controller.BaseController;
import com.zkqy.common.core.domain.AjaxResult;
import com.zkqy.common.enums.BusinessType;
import com.zkqy.system.entity.BpmNodeHandleUser;
import com.zkqy.system.service.IBpmNodeHandleUserService;
import com.zkqy.common.utils.poi.ExcelUtil;
import com.zkqy.common.core.page.TableDataInfo;

/**
 * 节点处理用户Controller
 *
 * @author hzh
 * @date 2023-10-26
 */
@RestController
@RequestMapping("/system/nodeuser")
@Api(value = "/system/nodeuser", description = "节点处理用户-接口")
public class BpmNodeHandleUserController extends BaseController {
    @Autowired
    private IBpmNodeHandleUserService bpmNodeHandleUserService;

    /**
     * 查询节点处理用户列表
     */
    @PreAuthorize("@ss.hasPermi('system:user:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询节点处理用户列表")
    public TableDataInfo list(BpmNodeHandleUser bpmNodeHandleUser) {
        startPage();
        List<BpmNodeHandleUser> list = bpmNodeHandleUserService.selectBpmNodeHandleUserList(bpmNodeHandleUser);
        return getDataTable(list);
    }

    /**
     * 导出节点处理用户列表
     */
    @PreAuthorize("@ss.hasPermi('system:user:export')")
    @Log(title = "节点处理用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出节点处理用户列表")
    public void export(HttpServletResponse response, BpmNodeHandleUser bpmNodeHandleUser) {
        List<BpmNodeHandleUser> list = bpmNodeHandleUserService.selectBpmNodeHandleUserList(bpmNodeHandleUser);
        ExcelUtil<BpmNodeHandleUser> util = new ExcelUtil<BpmNodeHandleUser>(BpmNodeHandleUser.class);
        util.exportExcel(response, list, "节点处理用户数据");
    }

    /**
     * 获取节点处理用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:user:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取节点处理用户详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(bpmNodeHandleUserService.selectBpmNodeHandleUserById(id));
    }

    /**
     * 新增节点处理用户
     */
    @PreAuthorize("@ss.hasPermi('system:user:add')")
    @Log(title = "节点处理用户", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增节点处理用户")
    public AjaxResult add(@RequestBody List<BpmNodeHandleUser> bpmNodeHandleUser) {
        return toAjax(bpmNodeHandleUserService.insertBpmNodeHandleUser(bpmNodeHandleUser));
    }

    /**
     * 修改节点处理用户
     */
    @PreAuthorize("@ss.hasPermi('system:user:edit')")
    @Log(title = "节点处理用户", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改节点处理用户")
    public AjaxResult edit(@RequestBody List<BpmNodeHandleUser> bpmNodeHandleUser) {
        return toAjax(bpmNodeHandleUserService.updateBpmNodeHandleUser(bpmNodeHandleUser));
    }

    /**
     * 删除节点处理用户
     */
    @PreAuthorize("@ss.hasPermi('system:user:remove')")
    @Log(title = "节点处理用户", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除节点处理用户")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bpmNodeHandleUserService.deleteBpmNodeHandleUserByIds(ids));
    }
}
