package com.mvc.controller.router;

import com.mvc.model.ResultGeekerModel;
import com.mvc.model.router.TDynamicrouterModel;
import com.mvc.service.router.TDynamicrouterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

@Api(tags = "动态路由控制类")
@RequestMapping("/TDynamicrouterAction")
@Controller
public class TDynamicrouterAction {

    @Resource
    private TDynamicrouterService dynamicrouterService;

    /**
     * 查询所有路由信息
     * @param userType 用户类型(0内部,1客户)
     * @param userParam 用户参数(userType =0 时 userParam 为客户roleId,userType =1 时 userParam unitCode)
     * @return
     */
    @ApiOperation("查询所有路由信息")
    @RequestMapping(value = "/findAllDynamicrouter/{userType}/{userParam}",method = RequestMethod.GET)
    @ResponseBody
    public ResultGeekerModel findAllDynamicrouter(@PathVariable("userType") String userType,@PathVariable("userParam") String userParam){
        ResultGeekerModel resultModel;
        try {
            List<TDynamicrouterModel> resList = dynamicrouterService.findAllDynamicrouter(userType,userParam);
            resultModel=new ResultGeekerModel(resList);
        } catch (Exception e) {
            e.printStackTrace();
            resultModel=new ResultGeekerModel(e.getMessage());
        }
        return resultModel;
    }
}
