19 files modified
2 files renamed
7 files added
| | |
| | | @Bean |
| | | public SecureRegistry secureRegistry() { |
| | | SecureRegistry secureRegistry = new SecureRegistry(); |
| | | // secureRegistry.setEnabled(false); |
| | | secureRegistry.setEnabled(true); |
| | | secureRegistry.excludePathPatterns("/oauth/login"); |
| | | secureRegistry.excludePathPatterns("/oauth/authorize"); |
| | | secureRegistry.excludePathPatterns("/oauth/form"); |
| | | secureRegistry.excludePathPatterns("/oauth/token"); |
| | | secureRegistry.excludePathPatterns("/blade-system/menu/routes"); |
| | | secureRegistry.excludePathPatterns("/blade-system/menu/auth-routes"); |
| | | secureRegistry.excludePathPatterns("/blade-system/menu/top-menu"); |
| | |
| | | */ |
| | | package org.springblade.auth.endpoint; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.wf.captcha.SpecCaptcha; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.common.cache.CacheNames; |
| | | import org.springblade.common.utils.HttpClientUtils; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.jwt.JwtUtil; |
| | | import org.springblade.core.jwt.props.JwtProperties; |
| | |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.core.tool.utils.WebUtil; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.security.oauth2.common.OAuth2AccessToken; |
| | |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.time.Duration; |
| | | import java.util.Base64; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.*; |
| | | |
| | | /** |
| | |
| | | return model; |
| | | } |
| | | |
| | | // /** |
| | | // * 登录页面 |
| | | // */ |
| | | // @SneakyThrows |
| | | // @GetMapping("/oauth/login") |
| | | // public void require(HttpServletResponse response) { |
| | | // response.sendRedirect("http://localhost:1888/"); |
| | | // } |
| | | /** |
| | | * 通过 code 获取 token |
| | | */ |
| | | @SneakyThrows |
| | | @GetMapping("/oauth/getTokenByCode") |
| | | public R require(HttpServletResponse response,String code) { |
| | | // 设置请求头 |
| | | Map<String, String> headerMap = new HashMap<>(); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | String clientStr = "sword:sword_secret"; |
| | | String encodedString = Base64.getEncoder().encodeToString(clientStr.getBytes()); |
| | | headerMap.put("Authorization", "Basic " + encodedString); |
| | | // url |
| | | String url = "http://localhost:8100/oauth/token"; |
| | | // 参数 |
| | | Map<String, String> param = new HashMap<>(); |
| | | param.put("code", code); |
| | | param.put("grant_type", "authorization_code"); |
| | | param.put("redirect_uri", "http://192.168.1.50:1888"); |
| | | String accessToken = HttpClientUtils.doPost(url,headerMap ,param); |
| | | System.out.println("accessToken = " + accessToken); |
| | | Map<String, String> maps = (Map<String, String>) JSON.parse(accessToken); |
| | | return R.data(maps); |
| | | } |
| | | |
| | | /** |
| | | * 授权页面 |
| | |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import io.jsonwebtoken.Claims; |
| | | import org.springblade.auth.utils.TokenUtil; |
| | | import org.springblade.core.jwt.JwtUtil; |
| | | import org.springblade.core.launch.constant.TokenConstant; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.context.SecurityContext; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; |
| | | import org.springframework.web.filter.OncePerRequestFilter; |
| | |
| | | String token = JwtUtil.getToken(auth); |
| | | Claims claims = JwtUtil.parseJWT(token); |
| | | if (!StringUtils.isBlank(token) && null!=claims) { |
| | | SecurityContext context = SecurityContextHolder.getContext(); |
| | | //判断 Token 状态 |
| | | String tenantId = String.valueOf(claims.get(TokenConstant.TENANT_ID)); |
| | | String userId = String.valueOf(claims.get(TokenConstant.USER_ID)); |
| | |
| | | import org.springblade.core.jwt.JwtUtil; |
| | | import org.springblade.core.jwt.props.JwtProperties; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.system.cache.ParamCache; |
| | | import org.springblade.system.entity.Tenant; |
| | | import org.springblade.system.feign.ISysClient; |
| | | import org.springblade.system.service.IRoleService; |
| | | import org.springblade.system.service.ITenantService; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.entity.UserInfo; |
| | | import org.springblade.system.user.enums.UserEnum; |
| | | import org.springblade.system.user.feign.IUserClient; |
| | | import org.springblade.system.user.service.IUserService; |
| | | import org.springframework.security.core.authority.AuthorityUtils; |
| | | import org.springframework.security.core.userdetails.UserDetailsService; |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.common.cache; |
| | | |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | |
| | | /** |
| | | * 缓存名 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface CacheNames { |
| | | |
| | | /** |
| | | * 返回拼接后的key |
| | | * |
| | | * @param cacheKey 缓存key |
| | | * @param cacheKeyValue 缓存key值 |
| | | * @return tenantKey |
| | | */ |
| | | static String cacheKey(String cacheKey, String cacheKeyValue) { |
| | | return cacheKey.concat(cacheKeyValue); |
| | | } |
| | | |
| | | /** |
| | | * 返回租户格式的key |
| | | * |
| | | * @param tenantId 租户编号 |
| | | * @param cacheKey 缓存key |
| | | * @param cacheKeyValue 缓存key值 |
| | | * @return tenantKey |
| | | */ |
| | | static String tenantKey(String tenantId, String cacheKey, String cacheKeyValue) { |
| | | return tenantId.concat(StringPool.COLON).concat(cacheKey).concat(cacheKeyValue); |
| | | } |
| | | |
| | | /** |
| | | * 验证码key |
| | | */ |
| | | String CAPTCHA_KEY = "blade:auth::blade:captcha:"; |
| | | |
| | | /** |
| | | * 登录失败key |
| | | */ |
| | | String USER_FAIL_KEY = "blade:user::blade:fail:"; |
| | | |
| | | } |
| File was renamed from blade-auth/src/main/java/org/springblade/system/cache/DictBizCache.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.system.cache; |
| | | package org.springblade.common.cache; |
| | | |
| | | import org.springblade.common.enums.DictBizEnum; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.system.entity.DictBiz; |
| | | import org.springblade.system.enums.DictBizEnum; |
| | | import org.springblade.system.service.IDictBizService; |
| | | |
| | | import java.util.List; |
| | |
| | | private static final String DICT_VALUE = "dictBiz:value"; |
| | | private static final String DICT_LIST = "dictBiz:list"; |
| | | |
| | | private static IDictBizService dictClient; |
| | | private static final IDictBizService dictService; |
| | | |
| | | private static IDictBizService getDictClient() { |
| | | if (dictClient == null) { |
| | | dictClient = SpringUtil.getBean(IDictBizService.class); |
| | | } |
| | | return dictClient; |
| | | static { |
| | | dictService = SpringUtil.getBean(IDictBizService.class); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static DictBiz getById(Long id) { |
| | | String keyPrefix = DICT_ID.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix, id, () -> { |
| | | DictBiz result = getDictClient().getById(id); |
| | | return result; |
| | | }); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix, id, () -> dictService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | return getValue(code.getName(), dictKey); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | |
| | | */ |
| | | public static String getValue(String code, Integer dictKey) { |
| | | String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, String.valueOf(dictKey), () -> { |
| | | String result = getDictClient().getValue(code, String.valueOf(dictKey)); |
| | | return result; |
| | | }); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, String.valueOf(dictKey), () -> dictService.getValue(code, String.valueOf(dictKey))); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static String getValue(String code, String dictKey) { |
| | | String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, dictKey, () -> { |
| | | String result = getDictClient().getValue(code, dictKey); |
| | | return result; |
| | | }); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, dictKey, () -> dictService.getValue(code, dictKey)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static List<DictBiz> getList(String code) { |
| | | String keyPrefix = DICT_LIST.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix, code, () -> { |
| | | List<DictBiz> result = getDictClient().getList(code); |
| | | return result; |
| | | }); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix, code, () -> dictService.getList(code)); |
| | | } |
| | | |
| | | } |
| File was renamed from blade-auth/src/main/java/org/springblade/system/cache/DictCache.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.system.cache; |
| | | package org.springblade.common.cache; |
| | | |
| | | import org.springblade.common.enums.DictEnum; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.system.entity.Dict; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.service.IDictService; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | private static final Boolean TENANT_MODE = Boolean.FALSE; |
| | | |
| | | private static IDictService dictClient; |
| | | private static final IDictService dictService; |
| | | |
| | | private static IDictService getDictClient() { |
| | | if (dictClient == null) { |
| | | dictClient = SpringUtil.getBean(IDictService.class); |
| | | } |
| | | return dictClient; |
| | | static { |
| | | dictService = SpringUtil.getBean(IDictService.class); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return Dict |
| | | */ |
| | | public static Dict getById(Long id) { |
| | | return CacheUtil.get(DICT_CACHE, DICT_ID, id, () -> { |
| | | Dict result = getDictClient().getById(id); |
| | | return result; |
| | | }, TENANT_MODE); |
| | | return CacheUtil.get(DICT_CACHE, DICT_ID, id, () -> dictService.getById(id), TENANT_MODE); |
| | | } |
| | | |
| | | /** |
| | |
| | | return getValue(code.getName(), dictKey); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | |
| | | * @return String |
| | | */ |
| | | public static String getValue(String code, Integer dictKey) { |
| | | return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, String.valueOf(dictKey), () -> { |
| | | String result = getDictClient().getValue(code, String.valueOf(dictKey)); |
| | | return result; |
| | | }, TENANT_MODE); |
| | | return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, String.valueOf(dictKey), () -> dictService.getValue(code, String.valueOf(dictKey)), TENANT_MODE); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return String |
| | | */ |
| | | public static String getValue(String code, String dictKey) { |
| | | return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, dictKey, () -> { |
| | | String result = getDictClient().getValue(code, dictKey); |
| | | return result; |
| | | }, TENANT_MODE); |
| | | return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, dictKey, () -> dictService.getValue(code, dictKey), TENANT_MODE); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return List<Dict> |
| | | */ |
| | | public static List<Dict> getList(String code) { |
| | | return CacheUtil.get(DICT_CACHE, DICT_LIST, code, () -> { |
| | | List<Dict> result = getDictClient().getList(code); |
| | | return result; |
| | | }, TENANT_MODE); |
| | | return CacheUtil.get(DICT_CACHE, DICT_LIST, code, () -> dictService.getList(code), TENANT_MODE); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.common.cache; |
| | | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.system.entity.Param; |
| | | import org.springblade.system.service.IParamService; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.PARAM_CACHE; |
| | | |
| | | /** |
| | | * 参数缓存工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class ParamCache { |
| | | |
| | | private static final String PARAM_ID = "param:id:"; |
| | | private static final String PARAM_VALUE = "param:value:"; |
| | | |
| | | private static final IParamService paramService; |
| | | |
| | | static { |
| | | paramService = SpringUtil.getBean(IParamService.class); |
| | | } |
| | | |
| | | /** |
| | | * 获取参数实体 |
| | | * |
| | | * @param id 主键 |
| | | * @return Param |
| | | */ |
| | | public static Param getById(Long id) { |
| | | return CacheUtil.get(PARAM_CACHE, PARAM_ID, id, () -> paramService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 获取参数配置 |
| | | * |
| | | * @param paramKey 参数值 |
| | | * @return String |
| | | */ |
| | | public static String getValue(String paramKey) { |
| | | return CacheUtil.get(PARAM_CACHE, PARAM_VALUE, paramKey, () -> paramService.getValue(paramKey)); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.common.cache; |
| | | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.system.entity.Region; |
| | | import org.springblade.system.service.IRegionService; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | | /** |
| | | * 行政区划缓存工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class RegionCache { |
| | | public static final int PROVINCE_LEVEL = 1; |
| | | public static final int CITY_LEVEL = 2; |
| | | public static final int DISTRICT_LEVEL = 3; |
| | | public static final int TOWN_LEVEL = 4; |
| | | public static final int VILLAGE_LEVEL = 5; |
| | | |
| | | private static final String REGION_CODE = "region:code:"; |
| | | |
| | | private static final IRegionService regionService; |
| | | |
| | | static { |
| | | regionService = SpringUtil.getBean(IRegionService.class); |
| | | } |
| | | |
| | | /** |
| | | * 获取行政区划实体 |
| | | * |
| | | * @param code 区划编号 |
| | | * @return Param |
| | | */ |
| | | public static Region getByCode(String code) { |
| | | return CacheUtil.get(SYS_CACHE, REGION_CODE, code, () -> regionService.getById(code)); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.common.cache; |
| | | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.system.entity.*; |
| | | import org.springblade.system.service.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | | /** |
| | | * 系统缓存 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class SysCache { |
| | | private static final String MENU_ID = "menu:id:"; |
| | | private static final String DEPT_ID = "dept:id:"; |
| | | private static final String DEPT_NAME = "dept:name:"; |
| | | private static final String DEPT_NAME_FUZZY = "dept:nameFuzzy:"; |
| | | private static final String DEPT_NAME_ID = "deptName:id:"; |
| | | private static final String DEPT_NAMES_ID = "deptNames:id:"; |
| | | private static final String DEPT_CHILD_ID = "deptChild:id:"; |
| | | private static final String DEPT_CHILDIDS_ID = "deptChildIds:id:"; |
| | | private static final String POST_ID = "post:id:"; |
| | | private static final String POST_NAME = "post:name:"; |
| | | private static final String POST_NAME_FUZZY = "post:nameFuzzy:"; |
| | | private static final String POST_NAME_ID = "postName:id:"; |
| | | private static final String POST_NAMES_ID = "postNames:id:"; |
| | | private static final String ROLE_ID = "role:id:"; |
| | | private static final String ROLE_NAME = "role:name:"; |
| | | private static final String ROLE_NAME_ID = "roleName:id:"; |
| | | private static final String ROLE_NAMES_ID = "roleNames:id:"; |
| | | private static final String ROLE_ALIAS_ID = "roleAlias:id:"; |
| | | private static final String ROLE_ALIASES_ID = "roleAliases:id:"; |
| | | public static final String TENANT_ID = "tenant:id:"; |
| | | public static final String TENANT_TENANT_ID = "tenant:tenantId:"; |
| | | public static final String TENANT_PACKAGE_ID = "tenant:packageId:"; |
| | | |
| | | private static final IMenuService menuService; |
| | | private static final IDeptService deptService; |
| | | private static final IPostService postService; |
| | | private static final IRoleService roleService; |
| | | private static final ITenantService tenantService; |
| | | private static final ITenantPackageService tenantPackageService; |
| | | |
| | | static { |
| | | menuService = SpringUtil.getBean(IMenuService.class); |
| | | deptService = SpringUtil.getBean(IDeptService.class); |
| | | postService = SpringUtil.getBean(IPostService.class); |
| | | roleService = SpringUtil.getBean(IRoleService.class); |
| | | tenantService = SpringUtil.getBean(ITenantService.class); |
| | | tenantPackageService = SpringUtil.getBean(ITenantPackageService.class); |
| | | } |
| | | |
| | | /** |
| | | * 获取菜单 |
| | | * |
| | | * @param id 主键 |
| | | * @return 菜单 |
| | | */ |
| | | public static Menu getMenu(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, MENU_ID, id, () -> menuService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门 |
| | | * |
| | | * @param id 主键 |
| | | * @return 部门 |
| | | */ |
| | | public static Dept getDept(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_ID, id, () -> deptService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param deptNames 部门名 |
| | | * @return 部门id |
| | | */ |
| | | public static String getDeptIds(String tenantId, String deptNames) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_NAME, tenantId + StringPool.DASH + deptNames, () -> deptService.getDeptIds(tenantId, deptNames)); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param deptNames 部门名模糊查询 |
| | | * @return 部门id |
| | | */ |
| | | public static String getDeptIdsByFuzzy(String tenantId, String deptNames) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_NAME_FUZZY, tenantId + StringPool.DASH + deptNames, () -> deptService.getDeptIdsByFuzzy(tenantId, deptNames)); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 部门名 |
| | | */ |
| | | public static String getDeptName(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_NAME_ID, id, () -> deptService.getById(id).getDeptName()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取部门名集合 |
| | | * |
| | | * @param deptIds 主键集合 |
| | | * @return 部门名 |
| | | */ |
| | | public static List<String> getDeptNames(String deptIds) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_NAMES_ID, deptIds, () -> deptService.getDeptNames(deptIds)); |
| | | } |
| | | |
| | | /** |
| | | * 获取子部门集合 |
| | | * |
| | | * @param deptId 主键 |
| | | * @return 子部门 |
| | | */ |
| | | public static List<Dept> getDeptChild(Long deptId) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_CHILD_ID, deptId, () -> deptService.getDeptChild(deptId)); |
| | | } |
| | | |
| | | /** |
| | | * 获取子部门ID集合 |
| | | * |
| | | * @param deptId 主键 |
| | | * @return 子部门ID |
| | | */ |
| | | public static List<Long> getDeptChildIds(Long deptId) { |
| | | if (deptId == null) { |
| | | return null; |
| | | } |
| | | List<Long> deptIdList = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class); |
| | | if (deptIdList == null) { |
| | | deptIdList = new ArrayList<>(); |
| | | List<Dept> deptChild = getDeptChild(deptId); |
| | | if (deptChild != null) { |
| | | List<Long> collect = deptChild.stream().map(Dept::getId).collect(Collectors.toList()); |
| | | deptIdList.addAll(collect); |
| | | } |
| | | deptIdList.add(deptId); |
| | | CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdList); |
| | | } |
| | | return deptIdList; |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位 |
| | | * |
| | | * @param id 主键 |
| | | * @return |
| | | */ |
| | | public static Post getPost(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, POST_ID, id, () -> postService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param postNames 岗位名 |
| | | * @return |
| | | */ |
| | | public static String getPostIds(String tenantId, String postNames) { |
| | | return CacheUtil.get(SYS_CACHE, POST_NAME, tenantId + StringPool.DASH + postNames, () -> postService.getPostIds(tenantId, postNames)); |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param postNames 岗位名模糊查询 |
| | | * @return |
| | | */ |
| | | public static String getPostIdsByFuzzy(String tenantId, String postNames) { |
| | | return CacheUtil.get(SYS_CACHE, POST_NAME_FUZZY, tenantId + StringPool.DASH + postNames, () -> postService.getPostIdsByFuzzy(tenantId, postNames)); |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 岗位名 |
| | | */ |
| | | public static String getPostName(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, POST_NAME_ID, id, () -> postService.getById(id).getPostName()); |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位名集合 |
| | | * |
| | | * @param postIds 主键集合 |
| | | * @return 岗位名 |
| | | */ |
| | | public static List<String> getPostNames(String postIds) { |
| | | return CacheUtil.get(SYS_CACHE, POST_NAMES_ID, postIds, () -> postService.getPostNames(postIds)); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色 |
| | | * |
| | | * @param id 主键 |
| | | * @return Role |
| | | */ |
| | | public static Role getRole(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_ID, id, () -> roleService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param roleNames 角色名 |
| | | * @return |
| | | */ |
| | | public static String getRoleIds(String tenantId, String roleNames) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_NAME, tenantId + StringPool.DASH + roleNames, () -> roleService.getRoleIds(tenantId, roleNames)); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 角色名 |
| | | */ |
| | | public static String getRoleName(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_NAME_ID, id, () -> roleService.getById(id).getRoleName()); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色名集合 |
| | | * |
| | | * @param roleIds 主键集合 |
| | | * @return 角色名 |
| | | */ |
| | | public static List<String> getRoleNames(String roleIds) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_NAMES_ID, roleIds, () -> roleService.getRoleNames(roleIds)); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色别名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 角色别名 |
| | | */ |
| | | public static String getRoleAlias(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_ALIAS_ID, id, () -> roleService.getById(id).getRoleAlias()); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色别名集合 |
| | | * |
| | | * @param roleIds 主键集合 |
| | | * @return 角色别名 |
| | | */ |
| | | public static List<String> getRoleAliases(String roleIds) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_ALIASES_ID, roleIds, () -> roleService.getRoleAliases(roleIds)); |
| | | } |
| | | |
| | | /** |
| | | * 获取租户 |
| | | * |
| | | * @param id 主键 |
| | | * @return Tenant |
| | | */ |
| | | public static Tenant getTenant(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, TENANT_ID, id, () -> tenantService.getById(id), Boolean.FALSE); |
| | | } |
| | | |
| | | /** |
| | | * 获取租户 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @return Tenant |
| | | */ |
| | | public static Tenant getTenant(String tenantId) { |
| | | return CacheUtil.get(SYS_CACHE, TENANT_TENANT_ID, tenantId, () -> tenantService.getByTenantId(tenantId), Boolean.FALSE); |
| | | } |
| | | |
| | | /** |
| | | * 获取租户产品包 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @return Tenant |
| | | */ |
| | | public static TenantPackage getTenantPackage(String tenantId) { |
| | | Tenant tenant = getTenant(tenantId); |
| | | return CacheUtil.get(SYS_CACHE, TENANT_PACKAGE_ID, tenantId, () -> tenantPackageService.getById(tenant.getPackageId()), Boolean.FALSE); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.common.cache; |
| | | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.service.IUserService; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE; |
| | | import static org.springblade.core.launch.constant.FlowConstant.TASK_USR_PREFIX; |
| | | |
| | | /** |
| | | * 系统缓存 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class UserCache { |
| | | private static final String USER_CACHE_ID = "user:id:"; |
| | | private static final String USER_CACHE_ACCOUNT = "user:account:"; |
| | | |
| | | private static final IUserService userService; |
| | | |
| | | static { |
| | | userService = SpringUtil.getBean(IUserService.class); |
| | | } |
| | | |
| | | /** |
| | | * 根据任务用户id获取用户信息 |
| | | * |
| | | * @param taskUserId 任务用户id |
| | | * @return |
| | | */ |
| | | public static User getUserByTaskUser(String taskUserId) { |
| | | Long userId = Func.toLong(StringUtil.removePrefix(taskUserId, TASK_USR_PREFIX)); |
| | | return getUser(userId); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户 |
| | | * |
| | | * @param userId 用户id |
| | | * @return |
| | | */ |
| | | public static User getUser(Long userId) { |
| | | return CacheUtil.get(USER_CACHE, USER_CACHE_ID, userId, () -> userService.getById(userId)); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param account 账号名 |
| | | * @return |
| | | */ |
| | | public static User getUser(String tenantId, String account) { |
| | | return CacheUtil.get(USER_CACHE, USER_CACHE_ACCOUNT, tenantId + StringPool.DASH + account, () -> userService.userByAccount(tenantId, account)); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.common.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 业务字典枚举类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DictBizEnum { |
| | | |
| | | /** |
| | | * 测试 |
| | | */ |
| | | TEST("test"), |
| | | ; |
| | | |
| | | final String name; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.common.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 系统字典枚举类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DictEnum { |
| | | |
| | | /** |
| | | * 性别 |
| | | */ |
| | | SEX("sex"), |
| | | /** |
| | | * 通知类型 |
| | | */ |
| | | NOTICE("notice"), |
| | | /** |
| | | * 菜单类型 |
| | | */ |
| | | MENU_CATEGORY("menu_category"), |
| | | /** |
| | | * 按钮功能 |
| | | */ |
| | | BUTTON_FUNC("button_func"), |
| | | /** |
| | | * 是否 |
| | | */ |
| | | YES_NO("yes_no"), |
| | | /** |
| | | * 流程类型 |
| | | */ |
| | | FLOW("flow"), |
| | | /** |
| | | * 机构类型 |
| | | */ |
| | | ORG_CATEGORY("org_category"), |
| | | /** |
| | | * 数据权限 |
| | | */ |
| | | DATA_SCOPE_TYPE("data_scope_type"), |
| | | /** |
| | | * 接口权限 |
| | | */ |
| | | API_SCOPE_TYPE("api_scope_type"), |
| | | /** |
| | | * 权限类型 |
| | | */ |
| | | SCOPE_CATEGORY("scope_category"), |
| | | /** |
| | | * 对象存储类型 |
| | | */ |
| | | OSS("oss"), |
| | | /** |
| | | * 短信服务类型 |
| | | */ |
| | | SMS("sms"), |
| | | /** |
| | | * 岗位类型 |
| | | */ |
| | | POST_CATEGORY("post_category"), |
| | | /** |
| | | * 行政区划 |
| | | */ |
| | | REGION("region"), |
| | | /** |
| | | * 用户平台 |
| | | */ |
| | | USER_TYPE("user_type"), |
| | | ; |
| | | |
| | | final String name; |
| | | |
| | | } |
| | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.*; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.BladeUser; |
| | |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.system.entity.Dept; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.service.IDeptService; |
| | |
| | | CacheUtil.clear(SYS_CACHE); |
| | | // 返回懒加载树更新节点所需字段 |
| | | Kv kv = Kv.create().set("id", String.valueOf(dept.getId())).set("tenantId", dept.getTenantId()) |
| | | .set("deptCategoryName", DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory())); |
| | | .set("deptCategoryName", DictCache.getValue(DictEnum.ORG_CATEGORY.getName(), dept.getDeptCategory())); |
| | | return R.data(kv); |
| | | } |
| | | return R.fail("操作失败"); |
| | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "前端菜单数据", notes = "前端菜单数据") |
| | | public R<List<MenuVO>> routes(BladeUser user, Long topMenuId) { |
| | | user = AuthUtil.getUser(); |
| | | List<MenuVO> list = menuService.routes((user == null) ? null : user.getRoleId(), topMenuId); |
| | | return R.data(list); |
| | | } |
| | |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.system.cache.DictBizCache; |
| | | import org.springblade.common.cache.DictBizCache; |
| | | import org.springblade.system.entity.DictBiz; |
| | | import org.springblade.system.mapper.DictBizMapper; |
| | | import org.springblade.system.service.IDictBizService; |
| | |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.system.entity.Dict; |
| | | import org.springblade.system.mapper.DictMapper; |
| | | import org.springblade.system.service.IDictService; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.common.constant.TenantConstant; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | |
| | | import org.springblade.core.tool.jackson.JsonUtil; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.system.cache.ParamCache; |
| | | import org.springblade.system.cache.SysCache; |
| | | import org.springblade.system.entity.Tenant; |
| | |
| | | data.forEach(userExcel -> { |
| | | User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class)); |
| | | // 设置用户平台 |
| | | user.setUserType(Func.toInt(DictCache.getKey(DictEnum.USER_TYPE, userExcel.getUserTypeName()), 1)); |
| | | user.setUserType(Func.toInt(DictCache.getKey(DictEnum.USER_TYPE.getName(), userExcel.getUserTypeName()), 1)); |
| | | // 设置部门ID |
| | | user.setDeptId(Func.toStrWithEmpty(SysCache.getDeptIds(userExcel.getTenantId(), userExcel.getDeptName()), StringPool.EMPTY)); |
| | | // 设置岗位ID |
| | |
| | | public List<UserExcel> exportUser(Wrapper<User> queryWrapper) { |
| | | List<UserExcel> userList = baseMapper.exportUser(queryWrapper); |
| | | userList.forEach(user -> { |
| | | user.setUserTypeName(DictCache.getValue(DictEnum.USER_TYPE, user.getUserType())); |
| | | user.setUserTypeName(DictCache.getValue(DictEnum.USER_TYPE.getName(), user.getUserType())); |
| | | user.setRoleName(StringUtil.join(SysCache.getRoleNames(user.getRoleId()))); |
| | | user.setDeptName(StringUtil.join(SysCache.getDeptNames(user.getDeptId()))); |
| | | user.setPostName(StringUtil.join(SysCache.getPostNames(user.getPostId()))); |
| | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.system.cache.SysCache; |
| | | import org.springblade.system.entity.Tenant; |
| | | import org.springblade.system.enums.DictEnum; |
| | |
| | | userVO.setRoleName(Func.join(roleName)); |
| | | userVO.setDeptName(Func.join(deptName)); |
| | | userVO.setPostName(Func.join(postName)); |
| | | userVO.setSexName(DictCache.getValue(DictEnum.SEX, user.getSex())); |
| | | userVO.setUserTypeName(DictCache.getValue(DictEnum.USER_TYPE, user.getUserType())); |
| | | userVO.setSexName(DictCache.getValue(DictEnum.SEX.getName(), user.getSex())); |
| | | userVO.setUserTypeName(DictCache.getValue(DictEnum.USER_TYPE.getName(), user.getUserType())); |
| | | return userVO; |
| | | } |
| | | |
| | |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.system.entity.ApiScope; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.vo.ApiScopeVO; |
| | |
| | | @Override |
| | | public ApiScopeVO entityVO(ApiScope dataScope) { |
| | | ApiScopeVO apiScopeVO = Objects.requireNonNull(BeanUtil.copy(dataScope, ApiScopeVO.class)); |
| | | String scopeTypeName = DictCache.getValue(DictEnum.API_SCOPE_TYPE, dataScope.getScopeType()); |
| | | String scopeTypeName = DictCache.getValue(DictEnum.API_SCOPE_TYPE.getName(), dataScope.getScopeType()); |
| | | apiScopeVO.setScopeTypeName(scopeTypeName); |
| | | return apiScopeVO; |
| | | } |
| | |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.system.entity.DataScope; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.vo.DataScopeVO; |
| | |
| | | @Override |
| | | public DataScopeVO entityVO(DataScope dataScope) { |
| | | DataScopeVO dataScopeVO = Objects.requireNonNull(BeanUtil.copy(dataScope, DataScopeVO.class)); |
| | | String scopeTypeName = DictCache.getValue(DictEnum.DATA_SCOPE_TYPE, dataScope.getScopeType()); |
| | | String scopeTypeName = DictCache.getValue(DictEnum.DATA_SCOPE_TYPE.getName(), dataScope.getScopeType()); |
| | | dataScopeVO.setScopeTypeName(scopeTypeName); |
| | | return dataScopeVO; |
| | | } |
| | |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.system.cache.SysCache; |
| | | import org.springblade.system.entity.Dept; |
| | | import org.springblade.system.enums.DictEnum; |
| | |
| | | Dept parent = SysCache.getDept(dept.getParentId()); |
| | | deptVO.setParentName(parent.getDeptName()); |
| | | } |
| | | String category = DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()); |
| | | String category = DictCache.getValue(DictEnum.ORG_CATEGORY.getName(), dept.getDeptCategory()); |
| | | deptVO.setDeptCategoryName(category); |
| | | return deptVO; |
| | | } |
| | |
| | | public List<DeptVO> listNodeVO(List<Dept> list) { |
| | | List<DeptVO> collect = list.stream().map(dept -> { |
| | | DeptVO deptVO = BeanUtil.copy(dept, DeptVO.class); |
| | | String category = DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()); |
| | | String category = DictCache.getValue(DictEnum.ORG_CATEGORY.getName(), dept.getDeptCategory()); |
| | | Objects.requireNonNull(deptVO).setDeptCategoryName(category); |
| | | return deptVO; |
| | | }).collect(Collectors.toList()); |
| | |
| | | |
| | | public List<DeptVO> listNodeLazyVO(List<DeptVO> list) { |
| | | List<DeptVO> collect = list.stream().peek(dept -> { |
| | | String category = DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()); |
| | | String category = DictCache.getValue(DictEnum.ORG_CATEGORY.getName(), dept.getDeptCategory()); |
| | | Objects.requireNonNull(dept).setDeptCategoryName(category); |
| | | }).collect(Collectors.toList()); |
| | | return ForestNodeMerger.merge(collect); |
| | |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.system.cache.DictBizCache; |
| | | import org.springblade.common.cache.DictBizCache; |
| | | import org.springblade.system.entity.DictBiz; |
| | | import org.springblade.system.vo.DictBizVO; |
| | | |
| | |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.system.entity.Dict; |
| | | import org.springblade.system.vo.DictVO; |
| | | |
| | |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.system.cache.SysCache; |
| | | import org.springblade.system.entity.Menu; |
| | | import org.springblade.system.enums.DictEnum; |
| | |
| | | Menu parent = SysCache.getMenu(menu.getParentId()); |
| | | menuVO.setParentName(parent.getName()); |
| | | } |
| | | String category = DictCache.getValue(DictEnum.MENU_CATEGORY, Func.toInt(menuVO.getCategory())); |
| | | String action = DictCache.getValue(DictEnum.BUTTON_FUNC, Func.toInt(menuVO.getAction())); |
| | | String open = DictCache.getValue(DictEnum.YES_NO, Func.toInt(menuVO.getIsOpen())); |
| | | String category = DictCache.getValue(DictEnum.MENU_CATEGORY.getName(), Func.toInt(menuVO.getCategory())); |
| | | String action = DictCache.getValue(DictEnum.BUTTON_FUNC.getName(), Func.toInt(menuVO.getAction())); |
| | | String open = DictCache.getValue(DictEnum.YES_NO.getName(), Func.toInt(menuVO.getIsOpen())); |
| | | menuVO.setCategoryName(category); |
| | | menuVO.setActionName(action); |
| | | menuVO.setIsOpenName(open); |
| | |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.system.entity.Post; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.vo.PostVO; |
| | |
| | | @Override |
| | | public PostVO entityVO(Post post) { |
| | | PostVO postVO = Objects.requireNonNull(BeanUtil.copy(post, PostVO.class)); |
| | | String categoryName = DictCache.getValue(DictEnum.POST_CATEGORY, post.getCategory()); |
| | | String categoryName = DictCache.getValue(DictEnum.POST_CATEGORY.getName(), post.getCategory()); |
| | | postVO.setCategoryName(categoryName); |
| | | return postVO; |
| | | } |
| | |
| | | oauth2: |
| | | base: |
| | | authorizeUrl: http://192.168.1.50:1888/api/oauth/authorize |
| | | # authorizeUrl: http://localhost/:8100/api/oauth/authorize |
| | | loginPage: http://192.168.1.50:1888/#/login |
| | | # loginPage: /oauth/login |
| | | loginProcessingUrl: /oauth/form |
| | |
| | | #接口放行 |
| | | skip-url: |
| | | - /test/** |
| | | - /menu/routes |
| | | - /menu/auth-routes |
| | | - /menu/top-menu |
| | | - /blade-auth/** |
| | | - /tenant/info |
| | | - /oauth/form |
| | | #授权认证配置 |
| | | auth: |
| | | - method: ALL |