///*
// * Author: wangjian
// * 生成controller
// */
//package com.tofly.base.controller;
//
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.tofly.base.entity.BaseSys;
//import com.tofly.base.entity.UserRole;
//import com.tofly.base.service.UserRoleService;
//import com.tofly.common.core.entity.ResultRespone;
//import com.tofly.common.log.annotation.ToFlyAppLog;
//import com.tofly.base.entity.BaseRolesys;
//import com.tofly.base.service.BaseRolesysService;
//import com.tofly.common.oauth.util.SecurityUtils;
//import lombok.AllArgsConstructor;
//import org.springframework.web.bind.annotation.*;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import org.springframework.web.bind.annotation.ModelAttribute;
//
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// *
// *
// * @author wangjian
// * @date Mon Jun 22 00:00:00 CST 2020
// */
//@RestController
//@AllArgsConstructor
//@RequestMapping("/baserolesys")
//@Api(tags="角色绑定系统接口")
//public class BaseRolesysController {
//
//    private final  BaseRolesysService baseRolesysService;
//    private final  UserRoleService userRoleService;
//
////    /**
////    * 分页查询
////    * @param page 分页对象
////    * @param baseRolesys
////    * @return
////    */
////    @GetMapping("/page" )
////    @ApiOperation(value = "分页查询")
////    public ResultRespone getBaseRolesysPage(Page page, @ModelAttribute BaseRolesys baseRolesys) {
////      return ResultRespone.success(baseRolesysService.page(page, Wrappers.query(baseRolesys)));
////    }
//
//
////    /**
////     * 通过id查询
////     * @param id id
////     * @return ResultRespone
////     */
////    @GetMapping("/{id}" )
////    @ApiOperation(value = "通过ID查询")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
////    })
////    public ResultRespone getById(@PathVariable("id" ) Long id) {
////      return ResultRespone.success(baseRolesysService.getById(id));
////    }
//
//    @GetMapping("/list" )
//    @ApiOperation(value = "查询角色系统信息")
//    public ResultRespone list(@ModelAttribute BaseRolesys baseRolesys) {
//        List<BaseRolesys> list = baseRolesysService.list(Wrappers.query(baseRolesys));
//        List<Map> collect = list.stream().map(baseRolesys1 -> {
//            Map map = new HashMap();
//            map.put("sysid", baseRolesys1.getSysid());
//            map.put("sysids", baseRolesys1.getSysids().split(","));
//            return map;
//        }).collect(Collectors.toList());
//        return ResultRespone.success(collect);
//    }
//
//    @GetMapping("/userlist" )
//    @ApiOperation(value = "查询用户系统信息")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "sysId", value = "子系统id", required = true, dataType = "String")
//    })
//    public ResultRespone userlist(String sysId) {
//        List<UserRole> list = userRoleService.list(Wrappers.<UserRole>lambdaQuery()
//                .eq(UserRole::getUserId, SecurityUtils.getUserId()));
//
//        List<BaseRolesys> list1 = baseRolesysService.list(Wrappers.<BaseRolesys>lambdaQuery()
//                .eq(BaseRolesys::getSysid, sysId)
//                .in(BaseRolesys::getRoleId, Arrays.asList(list.stream().mapToLong(UserRole::getRoleId).toArray())));
//        Set<String> set=new HashSet<>();
//        list1.stream().forEach(baserole->{
//            String sysids = baserole.getSysids();
//            String[] split = sysids.split(",");
//            set.addAll(Arrays.asList(split));
//        });
//        return ResultRespone.success(set);
//    }
//
//    /**
//     * 新增
//     * @param baseRolesys
//     * @return ResultRespone
//     */
//    @ToFlyAppLog(title="更新角色系统" )
//    @ApiOperation(value = "更新角色系统")
//    @PostMapping
//    public ResultRespone save(@RequestBody BaseRolesys baseRolesys) {
//        BaseRolesys baseSys1=baseRolesysService.getOne(Wrappers.<BaseRolesys>lambdaQuery()
//                .eq(BaseRolesys::getSysid,baseRolesys.getSysid())
//                .eq(BaseRolesys::getRoleId,baseRolesys.getRoleId()));
//        if(baseSys1==null){
//            return ResultRespone.success(baseRolesysService.save(baseRolesys));
//        }
//        baseRolesys.setId(baseSys1.getId());
//        return ResultRespone.success(baseRolesysService.updateById(baseRolesys));
//    }
//
////    /**
////     * 修改
////     * @param baseRolesys
////     * @return ResultRespone
////     */
////    @ToFlyAppLog(title="修改" )
////    @ApiOperation(value = "修改")
////    @PutMapping
////    public ResultRespone updateById(@RequestBody BaseRolesys baseRolesys) {
////      return ResultRespone.success(baseRolesysService.updateById(baseRolesys));
////    }
//
//    /**
//     * 通过id删除
//     * @param id id
//     * @return ResultRespone
//     */
////    @ToFlyAppLog(title="通过id删除" )
////    @ApiOperation(value = "通过ID删除")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
////    })
////    @DeleteMapping("/{id}" )
////    public ResultRespone removeById(@PathVariable Long id) {
////      return ResultRespone.success(baseRolesysService.removeById(id));
////    }
//
//    /**
//     * 通过id批量删除
//     * @param ids id
//     * @return ResultRespone
//     */
////    @ToFlyAppLog(title="通过id批量删除" )
////    @ApiOperation(value = "通过ID批量删除")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
////    })
////    @DeleteMapping("/deleteByIds" )
////    public ResultRespone removeById(String ids) {
////        return ResultRespone.success(baseRolesysService.removeByIds(Arrays.asList(ids.split(","))));
////    }
//}
