package com.product.admin.controller;

import com.product.admin.config.CmnConst;
import com.product.admin.config.SystemCode;
import com.product.admin.service.CodeService;
import com.product.admin.service.SystemMenusService;
import com.product.admin.service.idel.ISystemMenusService;
import com.product.admin.util.ResultInfo;
import com.product.common.lang.StringUtils;
import com.product.core.cache.DataPoolCacheImpl;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.dao.BaseDao;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.core.permission.PermissionService;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.module.sys.config.SystemErrorCode;
import com.product.module.sys.entity.SystemUser;
import com.product.module.sys.service.UserService;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * Copyright LX-BASE
 *
 * @Title: SystemMenusController
 * @Project: LX-BASE-SERVER
 * @Date: 2020-06-06 14:00
 * @Author: ZhouJie
 * @Description: 鑿滃崟绠$悊
 */
@RestController
@RequestMapping("/api/system/menu")
public class SystemMenusController extends AbstractBaseController {

    @Autowired
    UserService userService;
    @Autowired
    private SystemMenusService systemMenusService;
    @Autowired
    CodeService codeService;
    @Autowired
    BaseDao baseDao;
    /**
     * 鏁版嵁鏉冮檺楠岃瘉
     */
    @Autowired
    PermissionService permissionService;


    /**
     * 鑾峰彇绯荤粺璺敱
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/router/{verion}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String getRoutes(HttpServletRequest request) {
        try {
            // xupengcheng 2021骞�3鏈�10鏃�14:16:17
            return ResultInfo.success(systemMenusService.routerService.getRouter());
        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(e.getCode(), e.getMessage());
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_ROUTER_ACQUIRE_FAIL.getValue(), SystemCode.SYSTEM_ROUTER_ACQUIRE_FAIL.getText());
        }
    }

    /**
     * 鏍规嵁鍔熻兘鎸夐挳鏍囪瘑鑾峰彇璺敱
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/router-skip/{verion}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String getFunctionSkip(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
            if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_FUNCTION_BUTTONS.equals(fse.getTableName())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            // 鍒ゆ柇鍒嗛〉鍙傛暟鏄惁姝e父
            if (StringUtils.isEmpty(fse.getString(CmnConst.FUNCTION_UUID))
                    || StringUtils.isEmpty(fse.getString(CmnConst.BUTTON_NAME))) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
                return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
            }
            return ResultInfo.success(systemMenusService.routerService.functionSkip(fse.getString(CmnConst.FUNCTION_UUID), fse.getString(CmnConst.BUTTON_NAME)));
        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(e.getCode(), e.getMessage());
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_ROUTER_ACQUIRE_FAIL.getValue(), SystemCode.SYSTEM_ROUTER_ACQUIRE_FAIL.getText());
        }
    }

    /**
     * 瀵艰埅鏍忚彍鍗�
     * xupengcheng
     *
     * @return
     */
    @RequestMapping(value = "/tree-list-menu/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String treeMenu(HttpServletRequest request) {
        try {
            // xupencheng
            SystemUser user = SpringMVCContextHolder.getCurrentUser();
            if (CmnConst.UPDATE_MENU.equals(user.getUpdateType()) || CmnConst.UPDATE_MENU_USER.equals(user.getUpdateType())) {
                if (CmnConst.UPDATE_MENU_USER.equals(user.getUpdateType())) {
                    user.setUpdateType(CmnConst.UPDATE_USER);
                } else {
                    user.setUpdateType(null);
                }
                //token涓庣敤鎴峰叧鑱旓紝鏀惧叆缂撳瓨涓�
                DataPoolCacheImpl.getInstance().updateSessionUser(user);
            }
            return ResultInfo.success(systemMenusService.getMenu());
        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return error(e.getCode(), e.getMessageInfo());
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
        }
    }


    /**
     * @Date: 2020-06-10 09:08
     * @Author: ZhouJie
     * @Description: 鑿滃崟鍒楄〃
     */
    @RequestMapping(value = "/list-menu/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String listMenu(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
            if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_MENUS.equals(fse.getTableName())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            SystemUser user = SpringMVCContextHolder.getCurrentUser();
            if (CmnConst.UPDATE_MENU.equals(user.getUpdateType()) || CmnConst.UPDATE_MENU_USER.equals(user.getUpdateType())) {
                if (CmnConst.UPDATE_MENU_USER.equals(user.getUpdateType())) {
                    user.setUpdateType(CmnConst.UPDATE_USER);
                } else {
                    user.setUpdateType(null);
                }
                //token涓庣敤鎴峰叧鑱旓紝鏀惧叆缂撳瓨涓�
                DataPoolCacheImpl.getInstance().updateSessionUser(user);
            }
            return ResultInfo.success(systemMenusService.treeMenu());
        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(e);
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
        }

    }

    @PostMapping("/menu-directory/{version}")
    @ApiVersion(1)
    public String getMenuDirectory() {
        try {
            return OK_List(systemMenusService.getMenuDirectory());
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            return error(new BaseException(e));
        }
    }

    @PostMapping("/menu-function/{version}")
    @ApiVersion(1)
    public String getMenuFunction(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(systemMenusService.getMenuFunction(fse));
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            return error(new BaseException(e));
        }
    }

    @PostMapping("/menu-children/{version}")
    @ApiVersion(1)
    public String getMenuChildren(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(systemMenusService.getMenuChildren(fse));
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            return error(new BaseException(e));
        }
    }


    /**
     * @Date: 2020-06-09 17:50
     * @Author: ZhouJie
     * @Description: 鏌ョ湅鑿滃崟璇︽儏
     */
    @RequestMapping(value = "/find-menu/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String findMenu(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            //鏁版嵁鎿嶄綔鐨勬潈闄愰獙璇�
            if (!permissionService.validDataPermission(fse, CoreConst.DATA_PERMISSION_VALID_TYPE_USER)) {
                SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(),
                        SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText());
                return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText());
            }
            if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_MENUS.equals(fse.getTableName())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            FieldSetEntity fss = systemMenusService.findMenu(fse);
            return OK_List(fss);
        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(e);
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
        }
    }

    /**
     * @Date: 2020-06-09 17:52
     * @Author: ZhouJie
     * @Description: 鏂板鑿滃崟
     */
    @RequestMapping(value = "/add-menu/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String addMenu(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_MENUS.equals(fse.getTableName())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            ISystemMenusService service = (ISystemMenusService) getProxyInstance(systemMenusService);
            FieldSetEntity fs = service.addMenu(fse);
            systemMenusService.refreshOnlineUserMenu(fse.getString(CmnConst.FUNCTION_UUID));
            return OK_List(fs);
        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(e);
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_MENU_ADD_FAIL.getValue(), SystemCode.SYSTEM_MENU_ADD_FAIL.getText());
        }
    }

    /**
     * @Date: 2020-06-09 17:43
     * @Author: ZhouJie
     * @Description: 淇敼鑿滃崟
     */
    @RequestMapping(value = "/update-menu/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String updateMenu(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            String uuids = fse.getString("uuid");
            //鍛ㄦ澃 2020骞�12鏈�17鏃� 涓婂崍11:16
            if (StringUtils.isEmpty(uuids)) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            //鏁版嵁鎿嶄綔鐨勬潈闄愰獙璇�
//			if(!permissionService.validDataPermission(CmnConst.PRODUCT_SYS_MENUS,uuids,CoreConst.DATA_PERMISSION_VALID_TYPE_USER)) {
//				SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(),
//						SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText());
//				return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText());
//			}
            if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_MENUS.equals(fse.getTableName())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            ISystemMenusService service = (ISystemMenusService) getProxyInstance(systemMenusService);
            boolean success = service.updateMenu(fse);
            if (success) {
                return OK();
            }
            SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_MENU_UPDATE_FAIL.getValue(), SystemCode.SYSTEM_MENU_UPDATE_FAIL.getText());
            return error(SystemCode.SYSTEM_MENU_UPDATE_FAIL.getValue(),
                    SystemCode.SYSTEM_MENU_UPDATE_FAIL.getText());

        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            e.printStackTrace();
            return this.error(e);
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            e.printStackTrace();
            return this.error(SystemCode.SYSTEM_MENU_UPDATE_FAIL.getValue(),
                    SystemCode.SYSTEM_MENU_UPDATE_FAIL.getText());
        }
    }

    /**
     * @Date: 2020-06-09 17:48
     * @Author: ZhouJie
     * @Description: 鍒犻櫎鑿滃崟
     */
    @RequestMapping(value = "/delete-menu/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String deleteMenu(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            RequestParameterEntity reqp = null;
            if (bean != null) {
                reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            String uuids = fse.getString("uuid");
            //鍛ㄦ澃 2020骞�12鏈�17鏃� 涓婂崍11:16
            if (StringUtils.isEmpty(uuids)) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_PROMPT_DELETE_FAIL.getValue(), SystemCode.SYSTEM_PROMPT_DELETE_FAIL.getText());
                return this.error(SystemCode.SYSTEM_PROMPT_DELETE_FAIL.getValue(),
                        SystemCode.SYSTEM_PROMPT_DELETE_FAIL.getText());
            }
            if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_MENUS.equals(fse.getTableName())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            ISystemMenusService service = (ISystemMenusService) getProxyInstance(systemMenusService);
            boolean success = service.deleteMenus(fse);
            if (success) {
                return OK();
            }
            SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_MENU_DELETE_FAIL.getValue(),
                    SystemCode.SYSTEM_MENU_DELETE_FAIL.getText());
            return error(SystemCode.SYSTEM_MENU_DELETE_FAIL.getValue(),
                    SystemCode.SYSTEM_MENU_DELETE_FAIL.getText());
        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(e);
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_MENU_DELETE_FAIL.getValue(),
                    SystemCode.SYSTEM_MENU_DELETE_FAIL.getText());
        }
    }

    /**
     * @Date: 2020-10-27 10:48
     * @Author: ZhouJie
     * @Description: 鑾峰彇褰撳墠鐧诲綍浜虹殑鎵€鏈夎彍鍗�
     */
    @RequestMapping(value = "/list-user-menus/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String listUserMenu(HttpServletRequest request) {
        try {
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            FieldSetEntity fse = null;
            RequestParameterEntity reqp = null;
            if (bean != null) {
                reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            // 鎸囧畾璐﹀彿鐨勭敤鎴�
            SystemUser user = null;
            if (fse.getString(CmnConst.USER_ACCOUNT) != null)
                user = userService.getSystemUserByName(fse.getString(CmnConst.USER_ACCOUNT));
            if (user == null)// 褰撳墠鐢ㄦ埛
                user = SpringMVCContextHolder.getCurrentUser();
            Object language_code = reqp.getOther().get(CoreConst.SYSTEM_LANGUAGE_CODE_);
            Object client_type = reqp.getOther().get(CoreConst.SYSTEM_CLIENT_TYPE_);
            if (client_type == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_LOGIN_PARA_ERROR.getValue(),
                        SystemErrorCode.SYSTEM_LOGIN_PARA_ERROR.getText()
                                + CoreConst.SYSTEM_CLIENT_TYPE_);
                return this.error(SystemErrorCode.SYSTEM_LOGIN_PARA_ERROR.getValue(),
                        SystemErrorCode.SYSTEM_LOGIN_PARA_ERROR.getText()
                                + CoreConst.SYSTEM_CLIENT_TYPE_);
            } else if (language_code == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_LOGIN_PARA_ERROR.getValue(),
                        SystemErrorCode.SYSTEM_LOGIN_PARA_ERROR.getText()
                                + CoreConst.SYSTEM_LANGUAGE_CODE_);
                return this.error(SystemErrorCode.SYSTEM_LOGIN_PARA_ERROR.getValue(),
                        SystemErrorCode.SYSTEM_LOGIN_PARA_ERROR.getText()
                                + CoreConst.SYSTEM_LANGUAGE_CODE_);
            }
            List<Map<Object, Object>> menulist = systemMenusService.getMenuTreeByuserUuid(user, client_type,
                    language_code);
            // xupencheng updateTime 2020骞�11鏈�30鏃�10:19:43 璋冪敤鑿滃崟鏇存柊user鐘舵€�
            if (!StringUtils.isEmpty(fse.getString(CmnConst.USER_UPDATE)) && "true".equals(fse.getString(CmnConst.USER_UPDATE)) && user != null) {
                if (CmnConst.UPDATE_MENU.equals(user.getUpdateType()) || CmnConst.UPDATE_MENU_USER.equals(user.getUpdateType())) {
                    if (CmnConst.UPDATE_MENU_USER.equals(user.getUpdateType())) {
                        user.setUpdateType(CmnConst.UPDATE_USER);
                    } else {
                        user.setUpdateType(null);
                    }
                    //token涓庣敤鎴峰叧鑱旓紝鏀惧叆缂撳瓨涓�
                    DataPoolCacheImpl.getInstance().updateSessionUser(user);
                }
            }
            return ResultInfo.success(menulist);
        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(e);
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_ACQUIRE_PARAM_FAIL.getValue(),
                    SystemCode.SYSTEM_ACQUIRE_PARAM_FAIL.getText());
        }
    }

}