package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

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;

import io.renren.modules.sys.entity.VisiWorkflowparamapEntity;
import io.renren.modules.sys.service.VisiWorkflowparamapService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 *管理算法参数映射关系
 *
 * @author Zhang
 * @version 3.000
 * @since JDK1.8
 *
 */
@RestController
@RequestMapping("sys/visiworkflowparamap")
public class VisiWorkflowparamapController {
    @Autowired
    private VisiWorkflowparamapService visiWorkflowparamapService;


    /**
     * 列表
     * @param params 页面配置信息
     * @return 结果
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:visiworkflowparamap:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = visiWorkflowparamapService.queryPage(params);

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


    /**
     * 信息
     * @param userId
     * @return 参数映射关系
     */
    @RequestMapping("/info/{userId}")
    @RequiresPermissions("sys:visiworkflowparamap:info")
    public R info(@PathVariable("userId") Long userId){
		VisiWorkflowparamapEntity visiWorkflowparamap = visiWorkflowparamapService.getById(userId);

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


    /**
     * 保存
     * @param visiWorkflowparamap  参数映射关系实体
     * @return 提示信息
     */
    @RequestMapping("/save")
//    @RequiresPermissions("sys:visiworkflowparamap:save")
    public R save(@RequestBody VisiWorkflowparamapEntity visiWorkflowparamap){
		visiWorkflowparamapService.save(visiWorkflowparamap);

        return R.ok();
    }


    /**
     * 修改
     * @param visiWorkflowparamap 参数映射关系实体
     * @return 提示信息
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:visiworkflowparamap:update")
    public R update(@RequestBody VisiWorkflowparamapEntity visiWorkflowparamap){
		visiWorkflowparamapService.updateById(visiWorkflowparamap);

        return R.ok();
    }


    /**
     * 删除
     * @param userIds
     * @return 提示信息
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:visiworkflowparamap:delete")
    public R delete(@RequestBody Long[] userIds){
		visiWorkflowparamapService.removeByIds(Arrays.asList(userIds));

        return R.ok();
    }

}
