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.VisiAlgorithmnodeEntity;
import io.renren.modules.sys.service.VisiAlgorithmnodeService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 *操作算法节点
 *
 * @author Zhang
 * @version 3.0.0
 * @since JDK1.8
 */
@RestController
@RequestMapping("sys/visialgorithmnode")
public class VisiAlgorithmnodeController {
    @Autowired
    private VisiAlgorithmnodeService visiAlgorithmnodeService;


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

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


    /**
     * 信息
     * @param algonodeId
     * @return 算法节点信息
     */
    @RequestMapping("/info/{algonodeId}")
    @RequiresPermissions("sys:visialgorithmnode:info")
    public R info(@PathVariable("algonodeId") Long algonodeId){
		VisiAlgorithmnodeEntity visiAlgorithmnode = visiAlgorithmnodeService.getById(algonodeId);

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


    /**
     *
     * 保存
     * @param visiAlgorithmnode 算法节点实体信息
     * @return 提示信息
     */
    @RequestMapping("/save")
//    @RequiresPermissions("sys:visialgorithmnode:save")
    public R save(@RequestBody VisiAlgorithmnodeEntity visiAlgorithmnode){
		visiAlgorithmnodeService.save(visiAlgorithmnode);

        return R.ok();
    }


    /**
     * 修改
     * @param visiAlgorithmnode 算法节点实体信息
     * @return 提示信息
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:visialgorithmnode:update")
    public R update(@RequestBody VisiAlgorithmnodeEntity visiAlgorithmnode){
		visiAlgorithmnodeService.updateById(visiAlgorithmnode);

        return R.ok();
    }


    /**
     * 删除
     * @param algonodeIds
     * @return 提示信息
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:visialgorithmnode:delete")
    public R delete(@RequestBody Long[] algonodeIds){
		visiAlgorithmnodeService.removeByIds(Arrays.asList(algonodeIds));

        return R.ok();
    }

}
