package com.lz.modules.app.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.lz.common.utils.PageUtils;
import com.lz.common.utils.R;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.resp.Step;
import com.lz.modules.flow.entity.Flow;
import com.lz.modules.flow.entity.FlowDepartment;
import com.lz.modules.flow.entity.FlowManager;
import com.lz.modules.flow.entity.FlowRelation;
import com.lz.modules.flow.model.FlowDto;
import com.lz.modules.flow.model.StaffRoleDto;
import com.lz.modules.flow.service.FlowDepartmentService;
import com.lz.modules.flow.service.FlowManagerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 流程管理表
 *
 * @author zgh
 * @email zgh@ldxinyong.com
 * @date 2020-09-22 17:25:35
 */
@RestController
@RequestMapping("user/lzflowmanager")
public class FlowManagerController {
    @Autowired
    private FlowManagerService flowManagerService;

    @Autowired
    private FlowDepartmentService flowDepartmentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("user:lzflowmanager:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = flowManagerService.queryPage(params);

        return R.ok().put("page", page);
    }

    @RequestMapping("/menu/list")
    public List<FlowDto> menuList(){
        List<FlowDto> flowDtoList = flowManagerService.getFowList();
        return flowDtoList;
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("user:lzflowmanager:info")
    public R info(@PathVariable("id") Long id){
			FlowManager lzFlowManager = flowManagerService.selectFlowManagerById(id);

        return R.ok().put("lzFlowManager", lzFlowManager);
    }

    /**
     * 信息
     */
    @RequestMapping("/get/flowInfo/{staffId}")
    public R flowInfo(@PathVariable("staffId") Long staffId){
        return  flowDepartmentService.selectFlowManager(staffId);


    }



    /**
     * 信息
     */
    @RequestMapping("/get/flow/{id}")
    public R flow(@PathVariable("id") Long staffId){






        return R.ok();
    }


    /**
     * 信息
     */
    @RequestMapping("/save/flow")
    public R saveFlow(Long id ,String data){

        return R.ok();
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("user:lzflowmanager:save")
    public R save(@RequestBody FlowManager lzFlowManager){
			flowManagerService.insertFlowManager(lzFlowManager);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("user:lzflowmanager:update")
    public R update(@RequestBody FlowManager lzFlowManager){
			flowManagerService.updateById(lzFlowManager);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("user:lzflowmanager:delete")
    public R delete(@RequestBody Long[] ids){
			flowManagerService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }


}
