//package com.jay.monitor.data.server.controllers;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.jay.monitor.data.core.utils.ResponseUtils;
//import com.jay.monitor.data.core.model.response.ListResponseModel;
//import com.jay.monitor.data.core.model.response.ObjectResponseModel;
//import com.jay.monitor.data.core.model.response.ResponseCommonModel;
//import com.jay.monitor.data.server.models.entity.BackstageRoute;
//import com.jay.monitor.data.server.models.request.route.BackstageRoutePageRequest;
//import com.jay.monitor.data.server.models.request.route.RouteDataRequest;
////import com.jay.monitor.data.server.services.impl.DefaultBackstageRouteService;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Date;
//import java.util.List;
//
///**
// * 后台路由管理
// *
// * @author liukx
// * @Date 2019-02-28 15:16
// */
//@Controller
//@RequestMapping(value = "/backstageRoute")
//public class RouteController {
//
//    final static private String page = "/route/";
//    @Autowired
//    private DefaultBackstageRouteService routesService;
//
//
//    @RequestMapping(value = "/list.html", method = RequestMethod.GET)
//    public String list() throws Exception {
//        return page + "routeList";
//    }
//
//    @RequestMapping(value = "/update.html", method = RequestMethod.GET)
//    public String update(@RequestParam("id") Integer id, Model model) throws Exception {
//        ResponseUtils.checkParamNull(id, "id");
//        BackstageRoute entity = routesService.getById(id + "");
//        model.addAttribute("obj", entity);
//        return page + "update";
//    }
//
//
//    @RequestMapping(value = "/refresh.html", method = RequestMethod.GET)
//    public String refreshHtml(Model model) throws Exception {
//        List<String> routes = routesService.getRoutes();
//        model.addAttribute("routes", routes);
//        return page + "refresh";
//    }
//
//    /**
//     * 添加后台路由管理管理模块
//     *
//     * @param request 请求参数
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping(value = "/insert", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
//    @ResponseBody
//    public ResponseCommonModel insertBackstageRoute(@RequestBody BackstageRoute request) throws Exception {
//        int result = routesService.insert(request);
//        ResponseCommonModel response = new ResponseCommonModel();
//        if (result < 0) {
//            response.setSuccess(false);
//        }
//        return response;
//    }
//
//    @RequestMapping(value = "/refresh", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
//    @ResponseBody
//    public ResponseCommonModel refresh(@RequestBody RouteDataRequest dataRequest) throws Exception {
//        ResponseCommonModel responseCommonModel = routesService.executeRefresh(dataRequest);
//        return responseCommonModel;
//    }
//
//    @RequestMapping(value = "/list", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
//    @ResponseBody
//    public ObjectResponseModel<BackstageRoute> findBackstageRouteList(@RequestBody BackstageRoutePageRequest request) throws Exception {
//        BackstageRoute entity = new BackstageRoute();
//        BeanUtils.copyProperties(request, entity);
//        // 将参数对应的全部匹配赋值
//        QueryWrapper queryWrapper = new QueryWrapper(entity);
//        Page<BackstageRoute> page = new Page<>(request.getPageNo(), request.getPageSize());
//        IPage pageInfo = routesService.page(page, queryWrapper);
//        ObjectResponseModel objectResponseModel = new ObjectResponseModel();
//        objectResponseModel.setSingle(pageInfo);
//        // 将查询出来的参数传递给对外的实体
////        BeanUtils.copyProperties(backEntityPageModel, pageModel1);
//        return objectResponseModel;
//    }
//
//    @RequestMapping(value = "/getObjectById", method = RequestMethod.GET)
//    @ResponseBody
//    public ObjectResponseModel<BackstageRoute> getObjectById(@RequestParam("id") Integer id) throws Exception {
//        BackstageRoute result = routesService.getById(id + "");
//        ObjectResponseModel<BackstageRoute> model = new ObjectResponseModel<BackstageRoute>();
//        model.setSingle(result);
//        return model;
//    }
//
//    @RequestMapping(value = "/getObjectByList", method = RequestMethod.POST)
//    @ResponseBody
//    public ListResponseModel<BackstageRoute> getObjectByList(@RequestBody BackstageRoute request) throws Exception {
//        QueryWrapper queryWrapper = new QueryWrapper(request);
//        List<BackstageRoute> result = routesService.listObjs(queryWrapper);
//        ListResponseModel<BackstageRoute> model = new ListResponseModel<BackstageRoute>();
//        model.setList(result);
//        return model;
//    }
//
//    @RequestMapping(value = "/update", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
//    @ResponseBody
//    public ResponseCommonModel updateBackstageRouteInfo(@RequestBody BackstageRoute request) throws Exception {
//        request.setUpdated(new Date());
//        boolean b = routesService.updateById(request);
//        ResponseCommonModel response = new ResponseCommonModel();
//        if (b) {
//            response.setSuccess(false);
//        }
//        return response;
//    }
//}
