Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmRoleQueryController.java
@@ -4,21 +4,26 @@
import com.vci.frameworkcore.pagemodel.SmRoleVO;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.*;
import com.vci.starter.web.util.VciBaseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * 角色查询控制器
 * @author weidy
 * @date 2020/3/4
 */
@Controller
@RestController
@RequestMapping("/roleQueryController")
@Slf4j
public class SmRoleQueryController {
    /**
@@ -34,7 +39,6 @@
     * @throws VciBaseException 查询出错的时候会抛出异常,如果是老的项目里不抛出异常
     */
    @RequestMapping(value = "/refDataGrid",method = RequestMethod.GET)
    @ResponseBody
    public BaseResult<SmRoleVO> refDataGrid(BaseQueryObject queryObject) throws VciBaseException {
        if(queryObject == null){
            queryObject = new BaseQueryObject();
@@ -46,13 +50,48 @@
    }
    /**
     * 根据用户主键获取关联的角色
     * @param userOid 用户主键
     * @param queryMap 查询条件,如果需要使用用户的属性来查询可以使用pkUser.xxxx
     * @return 角色的显示对象
     */
    @RequestMapping(value = "/listRoleByUserOid",method = RequestMethod.GET)
    public BaseResult<List<SmRoleVO>> listRoleByUserOid(String userOid, Map<String, String> queryMap){
        try {
            return BaseResult.dataList(roleQueryService.listRoleByUserOid(userOid,queryMap));
        }catch (Exception e){
            e.printStackTrace();
            String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
            log.error("根据用户主键获取,关联的角色时出现错误,原因:" + exceptionMessage);
            return BaseResult.fail("根据用户主键获取,关联的角色时出现错误,原因:" + exceptionMessage);
        }
    }
    /**
     * 分配角色:保存用户角色关联关系
     * @param userOid
     * @param roleIds
     * @return
     */
    @RequestMapping(value = "/saveRights",method = RequestMethod.POST)
    public BaseResult saveRights(String userOid, String[] roleIds){
        try {
            return roleQueryService.saveRights(userOid,roleIds) ? BaseResult.success("角色分配成功!"):BaseResult.fail("角色分配失败!");
        }catch (Exception e){
            e.printStackTrace();
            String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
            log.error("根据用户主键获取,关联的角色时出现错误,原因:" + exceptionMessage);
            return BaseResult.fail("根据用户主键获取,关联的角色时出现错误,原因:" + exceptionMessage);
        }
    }
    /**
     * 角色的树形参照
     * @param treeQueryObject 树形数据的查询对象,包括查询条件,上级主键,是否多选等,extandParamsMap中添加"showAllRoleNode"为"true"时,返回结果中会包含“所有角色”这个节点
     * @return 角色的树形参照,无上下级关系
     * @throws VciBaseException 查询出错的时候会抛出异常,如果是老的项目里不抛出异常
     */
    @RequestMapping(value = "/refTree",method = RequestMethod.GET)
    @ResponseBody
    public BaseResult<Tree> refTree(TreeQueryObject treeQueryObject) throws VciBaseException{
        List<Tree> roleTreeList = roleQueryService.refTreeRoles(treeQueryObject);
        return  BaseResult.tree(roleTreeList);