user,role,tenant 接口接入 auth 模块
5 files modified
1 files renamed
45 files copied
102 files added
| | |
| | | <artifactId>activation</artifactId> |
| | | <version>1.1.1</version> |
| | | </dependency>--> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>org.springblade</groupId>--> |
| | | <!-- <artifactId>blade-core-boot</artifactId>--> |
| | | <!-- </dependency>--> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-excel</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| File was renamed from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.social.props.SocialProperties; |
| | | import org.springblade.system.user.feign.IUserClient; |
| | | import org.springblade.system.user.service.IUserService; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | |
| | | |
| | | private final BladeRedis bladeRedis; |
| | | |
| | | private final IUserClient userClient; |
| | | private final IUserService userClient; |
| | | |
| | | private final SocialProperties socialProperties; |
| | | |
| | |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.social.props.SocialProperties; |
| | | import org.springblade.system.user.feign.IUserClient; |
| | | import org.springblade.system.user.service.IUserService; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; |
| | | import org.springframework.security.oauth2.provider.CompositeTokenGranter; |
| | |
| | | /** |
| | | * 自定义tokenGranter |
| | | */ |
| | | public static TokenGranter getTokenGranter(final AuthenticationManager authenticationManager, final AuthorizationServerEndpointsConfigurer endpoints, BladeRedis bladeRedis, IUserClient userClient, SocialProperties socialProperties) { |
| | | public static TokenGranter getTokenGranter(final AuthenticationManager authenticationManager, final AuthorizationServerEndpointsConfigurer endpoints, BladeRedis bladeRedis, IUserService userClient, SocialProperties socialProperties) { |
| | | // 默认tokenGranter集合 |
| | | List<TokenGranter> granters = new ArrayList<>(Collections.singletonList(endpoints.getTokenGranter())); |
| | | // 增加验证码模式 |
| | |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.entity.UserInfo; |
| | | import org.springblade.system.user.entity.UserOauth; |
| | | import org.springblade.system.user.feign.IUserClient; |
| | | import org.springblade.system.user.service.IUserService; |
| | | import org.springframework.security.authentication.AbstractAuthenticationToken; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.Authentication; |
| | |
| | | private static final String GRANT_TYPE = "social"; |
| | | private static final Integer AUTH_SUCCESS_CODE = 2000; |
| | | |
| | | private final IUserClient userClient; |
| | | private final IUserService userClient; |
| | | private final SocialProperties socialProperties; |
| | | |
| | | protected SocialTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, IUserClient userClient, SocialProperties socialProperties) { |
| | | protected SocialTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, IUserService userClient, SocialProperties socialProperties) { |
| | | super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE); |
| | | this.userClient = userClient; |
| | | this.socialProperties = socialProperties; |
| | |
| | | userOauth.setUuid(authUser.getUuid()); |
| | | |
| | | // 远程调用,获取认证信息 |
| | | R<UserInfo> result = userClient.userAuthInfo(userOauth); |
| | | UserInfo userInfo = userClient.userInfo(userOauth); |
| | | BladeUserDetails bladeUserDetails; |
| | | if (result.isSuccess()) { |
| | | User user = result.getData().getUser(); |
| | | Kv detail = result.getData().getDetail(); |
| | | if (null!=userInfo) { |
| | | User user = userInfo.getUser(); |
| | | Kv detail = userInfo.getDetail(); |
| | | if (user == null || user.getId() == null) { |
| | | throw new InvalidGrantException("social grant failure, user is null"); |
| | | } |
| | | bladeUserDetails = new BladeUserDetails(user.getId(), |
| | | tenantId, result.getData().getOauthId(), user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(result.getData().getRoles()), Func.toStr(userOauth.getAvatar(), TokenUtil.DEFAULT_AVATAR), |
| | | tenantId, userInfo.getOauthId(), user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(userInfo.getRoles()), Func.toStr(userOauth.getAvatar(), TokenUtil.DEFAULT_AVATAR), |
| | | userOauth.getUsername(), AuthConstant.ENCRYPT + user.getPassword(), detail, true, true, true, true, |
| | | AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles()))); |
| | | AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(userInfo.getRoles()))); |
| | | } else { |
| | | throw new InvalidGrantException("social grant failure, feign client return error"); |
| | | } |
| | |
| | | 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; |
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
| | |
| | | public static final Integer FAIL_COUNT = 5; |
| | | public static final String FAIL_COUNT_VALUE = "account.failCount"; |
| | | |
| | | private final IUserClient userClient; |
| | | private final ISysClient sysClient; |
| | | private final IUserService userClient; |
| | | private final ITenantService tenantService; |
| | | private final IRoleService sysClient; |
| | | |
| | | private final BladeRedis bladeRedis; |
| | | private final JwtProperties jwtProperties; |
| | |
| | | } |
| | | |
| | | // 获取租户信息 |
| | | R<Tenant> tenant = sysClient.getTenant(tenantId); |
| | | if (tenant.isSuccess()) { |
| | | if (TokenUtil.judgeTenant(tenant.getData())) { |
| | | Tenant tenant = tenantService.getByTenantId(tenantId); |
| | | if (null!=tenant) { |
| | | if (TokenUtil.judgeTenant(tenant)) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT_PERMISSION); |
| | | } |
| | | } else { |
| | |
| | | String userType = Func.toStr(request.getHeader(TokenUtil.USER_TYPE_HEADER_KEY), TokenUtil.DEFAULT_USER_TYPE); |
| | | |
| | | // 远程调用返回数据 |
| | | R<UserInfo> result; |
| | | UserInfo userInfo; |
| | | // 根据不同用户类型调用对应的接口返回数据,用户可自行拓展 |
| | | if (userType.equals(UserEnum.WEB.getName())) { |
| | | result = userClient.userInfo(tenantId, username, UserEnum.WEB.getName()); |
| | | userInfo = userClient.userInfo(tenantId, username, UserEnum.WEB); |
| | | } else if (userType.equals(UserEnum.APP.getName())) { |
| | | result = userClient.userInfo(tenantId, username, UserEnum.APP.getName()); |
| | | userInfo = userClient.userInfo(tenantId, username, UserEnum.APP); |
| | | } else { |
| | | result = userClient.userInfo(tenantId, username, UserEnum.OTHER.getName()); |
| | | userInfo = userClient.userInfo(tenantId, username, UserEnum.OTHER); |
| | | } |
| | | |
| | | // 判断返回信息 |
| | | if (result.isSuccess()) { |
| | | UserInfo userInfo = result.getData(); |
| | | if (null!=userInfo) { |
| | | User user = userInfo.getUser(); |
| | | // 用户不存在,但提示用户名与密码错误并锁定账号 |
| | | if (user == null || user.getId() == null) { |
| | |
| | | } |
| | | // 多角色情况下指定单角色 |
| | | if (Func.isNotEmpty(headerRole) && user.getRoleId().contains(headerRole)) { |
| | | R<List<String>> roleResult = sysClient.getRoleAliases(headerRole); |
| | | if (roleResult.isSuccess()) { |
| | | userInfo.setRoles(roleResult.getData()); |
| | | List<String> roleResult = sysClient.getRoleAliases(headerRole); |
| | | if (roleResult.size()>0) { |
| | | userInfo.setRoles(roleResult); |
| | | } |
| | | user.setRoleId(headerRole); |
| | | } |
| | |
| | | return new BladeUserDetails(user.getId(), |
| | | user.getTenantId(), StringPool.EMPTY, user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(userInfo.getRoles()), Func.toStr(user.getAvatar(), TokenUtil.DEFAULT_AVATAR), |
| | | username, AuthConstant.ENCRYPT + user.getPassword(), userInfo.getDetail(), true, true, true, true, |
| | | AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles()))); |
| | | AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(userInfo.getRoles()))); |
| | | } else { |
| | | throw new UsernameNotFoundException(result.getMsg()); |
| | | throw new UsernameNotFoundException("没有找到用户信息"); |
| | | } |
| | | } |
| | | |
| 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.system.cache; |
| | | |
| | | 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; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; |
| | | |
| | | /** |
| | | * 业务字典缓存工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DictBizCache { |
| | | |
| | | private static final String DICT_ID = "dictBiz:id"; |
| | | private static final String DICT_VALUE = "dictBiz:value"; |
| | | private static final String DICT_LIST = "dictBiz:list"; |
| | | |
| | | private static IDictBizService dictClient; |
| | | |
| | | private static IDictBizService getDictClient() { |
| | | if (dictClient == null) { |
| | | dictClient = SpringUtil.getBean(IDictBizService.class); |
| | | } |
| | | return dictClient; |
| | | } |
| | | |
| | | /** |
| | | * 获取字典实体 |
| | | * |
| | | * @param id 主键 |
| | | * @return DictBiz |
| | | */ |
| | | 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; |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号枚举 |
| | | * @param dictKey Integer型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(DictBizEnum code, Integer dictKey) { |
| | | return getValue(code.getName(), dictKey); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey Integer型字典键 |
| | | * @return String |
| | | */ |
| | | 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; |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号枚举 |
| | | * @param dictKey String型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(DictBizEnum code, String dictKey) { |
| | | return getValue(code.getName(), dictKey); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey String型字典键 |
| | | * @return String |
| | | */ |
| | | 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; |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典集合 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return List<DictBiz> |
| | | */ |
| | | 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; |
| | | }); |
| | | } |
| | | |
| | | } |
| 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.system.cache; |
| | | |
| | | 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; |
| | | import java.util.Optional; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; |
| | | |
| | | /** |
| | | * 字典缓存工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DictCache { |
| | | |
| | | private static final String DICT_ID = "dict:id:"; |
| | | private static final String DICT_KEY = "dict:key:"; |
| | | private static final String DICT_VALUE = "dict:value:"; |
| | | private static final String DICT_LIST = "dict:list:"; |
| | | |
| | | private static final Boolean TENANT_MODE = Boolean.FALSE; |
| | | |
| | | private static IDictService dictClient; |
| | | |
| | | private static IDictService getDictClient() { |
| | | if (dictClient == null) { |
| | | dictClient = SpringUtil.getBean(IDictService.class); |
| | | } |
| | | return dictClient; |
| | | } |
| | | |
| | | /** |
| | | * 获取字典实体 |
| | | * |
| | | * @param id 主键 |
| | | * @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); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号枚举 |
| | | * @param dictValue 字典值 |
| | | * @return String |
| | | */ |
| | | public static String getKey(DictEnum code, String dictValue) { |
| | | return getKey(code.getName(), dictValue); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典键 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictValue 字典值 |
| | | * @return String |
| | | */ |
| | | public static String getKey(String code, String dictValue) { |
| | | return CacheUtil.get(DICT_CACHE, DICT_KEY + code + StringPool.COLON, dictValue, () -> { |
| | | List<Dict> list = getList(code); |
| | | Optional<String> key = list.stream().filter( |
| | | dict -> dict.getDictValue().equalsIgnoreCase(dictValue) |
| | | ).map(Dict::getDictKey).findFirst(); |
| | | return key.orElse(StringPool.EMPTY); |
| | | }, TENANT_MODE); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号枚举 |
| | | * @param dictKey Integer型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(DictEnum code, Integer dictKey) { |
| | | return getValue(code.getName(), dictKey); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey Integer型字典键 |
| | | * @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); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号枚举 |
| | | * @param dictKey String型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(DictEnum code, String dictKey) { |
| | | return getValue(code.getName(), dictKey); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey String型字典键 |
| | | * @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); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典集合 |
| | | * |
| | | * @param code 字典编号 |
| | | * @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); |
| | | } |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_scope_api") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "ApiScope对象", description = "ApiScope对象") |
| | | public class ApiScope extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 菜单主键 |
| | | */ |
| | | @ApiModelProperty(value = "菜单主键") |
| | | private Long menuId; |
| | | /** |
| | | * 资源编号 |
| | | */ |
| | | @ApiModelProperty(value = "资源编号") |
| | | private String resourceCode; |
| | | /** |
| | | * 接口权限名称 |
| | | */ |
| | | @ApiModelProperty(value = "接口权限名称") |
| | | private String scopeName; |
| | | /** |
| | | * 接口权限字段 |
| | | */ |
| | | @ApiModelProperty(value = "接口权限字段") |
| | | private String scopePath; |
| | | /** |
| | | * 接口权限类型 |
| | | */ |
| | | @ApiModelProperty(value = "接口权限类型") |
| | | private Integer scopeType; |
| | | /** |
| | | * 接口权限备注 |
| | | */ |
| | | @ApiModelProperty(value = "接口权限备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_client") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Client对象", description = "Client对象") |
| | | public class AuthClient extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 客户端id |
| | | */ |
| | | @ApiModelProperty(value = "客户端id") |
| | | private String clientId; |
| | | /** |
| | | * 客户端密钥 |
| | | */ |
| | | @ApiModelProperty(value = "客户端密钥") |
| | | private String clientSecret; |
| | | /** |
| | | * 资源集合 |
| | | */ |
| | | @ApiModelProperty(value = "资源集合") |
| | | private String resourceIds; |
| | | /** |
| | | * 授权范围 |
| | | */ |
| | | @ApiModelProperty(value = "授权范围") |
| | | private String scope; |
| | | /** |
| | | * 授权类型 |
| | | */ |
| | | @ApiModelProperty(value = "授权类型") |
| | | private String authorizedGrantTypes; |
| | | /** |
| | | * 回调地址 |
| | | */ |
| | | @ApiModelProperty(value = "回调地址") |
| | | private String webServerRedirectUri; |
| | | /** |
| | | * 权限 |
| | | */ |
| | | @ApiModelProperty(value = "权限") |
| | | private String authorities; |
| | | /** |
| | | * 令牌过期秒数 |
| | | */ |
| | | @ApiModelProperty(value = "令牌过期秒数") |
| | | private Integer accessTokenValidity; |
| | | /** |
| | | * 刷新令牌过期秒数 |
| | | */ |
| | | @ApiModelProperty(value = "刷新令牌过期秒数") |
| | | private Integer refreshTokenValidity; |
| | | /** |
| | | * 附加说明 |
| | | */ |
| | | @JsonIgnore |
| | | @ApiModelProperty(value = "附加说明") |
| | | private String additionalInformation; |
| | | /** |
| | | * 自动授权 |
| | | */ |
| | | @ApiModelProperty(value = "自动授权") |
| | | private String autoapprove; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_scope_data") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "DataScope对象", description = "DataScope对象") |
| | | public class DataScope extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 菜单主键 |
| | | */ |
| | | @ApiModelProperty(value = "菜单主键") |
| | | private Long menuId; |
| | | /** |
| | | * 资源编号 |
| | | */ |
| | | @ApiModelProperty(value = "资源编号") |
| | | private String resourceCode; |
| | | /** |
| | | * 数据权限名称 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限名称") |
| | | private String scopeName; |
| | | /** |
| | | * 数据权限可见字段 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限可见字段") |
| | | private String scopeField; |
| | | /** |
| | | * 数据权限类名 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限类名") |
| | | private String scopeClass; |
| | | /** |
| | | * 数据权限字段 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限字段") |
| | | private String scopeColumn; |
| | | /** |
| | | * 数据权限类型 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限类型") |
| | | private Integer scopeType; |
| | | /** |
| | | * 数据权限值域 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限值域") |
| | | private String scopeValue; |
| | | /** |
| | | * 数据权限备注 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_dept") |
| | | @ApiModel(value = "Dept对象", description = "Dept对象") |
| | | public class Dept implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | @ApiModelProperty(value = "租户ID") |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 父主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "父主键") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 机构名 |
| | | */ |
| | | @ApiModelProperty(value = "机构名") |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 机构全称 |
| | | */ |
| | | @ApiModelProperty(value = "机构全称") |
| | | private String fullName; |
| | | |
| | | /** |
| | | * 祖级机构主键 |
| | | */ |
| | | @ApiModelProperty(value = "祖级机构主键") |
| | | private String ancestors; |
| | | |
| | | /** |
| | | * 机构类型 |
| | | */ |
| | | @ApiModelProperty(value = "机构类型") |
| | | private Integer deptCategory; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 是否已删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty(value = "是否已删除") |
| | | private Integer isDeleted; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_dict") |
| | | @ApiModel(value = "Dict对象", description = "Dict对象") |
| | | public class Dict implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "父主键") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 字典码 |
| | | */ |
| | | @ApiModelProperty(value = "字典码") |
| | | private String code; |
| | | |
| | | /** |
| | | * 字典值 |
| | | */ |
| | | @ApiModelProperty(value = "字典值") |
| | | private String dictKey; |
| | | |
| | | /** |
| | | * 字典名称 |
| | | */ |
| | | @ApiModelProperty(value = "字典名称") |
| | | private String dictValue; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 字典备注 |
| | | */ |
| | | @ApiModelProperty(value = "字典备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 是否已封存 |
| | | */ |
| | | @ApiModelProperty(value = "是否已封存") |
| | | private Integer isSealed; |
| | | |
| | | /** |
| | | * 是否已删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty(value = "是否已删除") |
| | | private Integer isDeleted; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_dict_biz") |
| | | @ApiModel(value = "DictBiz对象", description = "DictBiz对象") |
| | | public class DictBiz implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | @ApiModelProperty(value = "租户ID") |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 父主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "父主键") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 字典码 |
| | | */ |
| | | @ApiModelProperty(value = "字典码") |
| | | private String code; |
| | | |
| | | /** |
| | | * 字典值 |
| | | */ |
| | | @ApiModelProperty(value = "字典值") |
| | | private String dictKey; |
| | | |
| | | /** |
| | | * 字典名称 |
| | | */ |
| | | @ApiModelProperty(value = "字典名称") |
| | | private String dictValue; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 字典备注 |
| | | */ |
| | | @ApiModelProperty(value = "字典备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 是否已封存 |
| | | */ |
| | | @ApiModelProperty(value = "是否已封存") |
| | | private Integer isSealed; |
| | | |
| | | /** |
| | | * 是否已删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty(value = "是否已删除") |
| | | private Integer isDeleted; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springblade.core.tool.utils.Func; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_menu") |
| | | @ApiModel(value = "Menu对象", description = "Menu对象") |
| | | public class Menu implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 菜单父主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "菜单父主键") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 菜单编号 |
| | | */ |
| | | @ApiModelProperty(value = "菜单编号") |
| | | private String code; |
| | | |
| | | /** |
| | | * 菜单名称 |
| | | */ |
| | | @ApiModelProperty(value = "菜单名称") |
| | | private String name; |
| | | |
| | | /** |
| | | * 菜单别名 |
| | | */ |
| | | @ApiModelProperty(value = "菜单别名") |
| | | private String alias; |
| | | |
| | | /** |
| | | * 请求地址 |
| | | */ |
| | | @ApiModelProperty(value = "请求地址") |
| | | private String path; |
| | | |
| | | /** |
| | | * 菜单资源 |
| | | */ |
| | | @ApiModelProperty(value = "菜单资源") |
| | | private String source; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 菜单类型 |
| | | */ |
| | | @ApiModelProperty(value = "菜单类型") |
| | | private Integer category; |
| | | |
| | | /** |
| | | * 操作按钮类型 |
| | | */ |
| | | @ApiModelProperty(value = "操作按钮类型") |
| | | private Integer action; |
| | | |
| | | /** |
| | | * 是否打开新页面 |
| | | */ |
| | | @ApiModelProperty(value = "是否打开新页面") |
| | | private Integer isOpen; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 是否已删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty(value = "是否已删除") |
| | | private Integer isDeleted; |
| | | |
| | | |
| | | @Override |
| | | public boolean equals(Object obj) { |
| | | if (this == obj) { |
| | | return true; |
| | | } |
| | | if (obj == null) { |
| | | return false; |
| | | } |
| | | Menu other = (Menu) obj; |
| | | if (Func.equals(this.getId(), other.getId())) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public int hashCode() { |
| | | return Objects.hash(id, parentId, 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_param") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Param对象", description = "Param对象") |
| | | public class Param extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 参数名 |
| | | */ |
| | | @ApiModelProperty(value = "参数名") |
| | | private String paramName; |
| | | |
| | | /** |
| | | * 参数键 |
| | | */ |
| | | @ApiModelProperty(value = "参数键") |
| | | private String paramKey; |
| | | |
| | | /** |
| | | * 参数值 |
| | | */ |
| | | @ApiModelProperty(value = "参数值") |
| | | private String paramValue; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | /** |
| | | * 岗位表实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_post") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Post对象", description = "岗位表") |
| | | public class Post extends TenantEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 类型 |
| | | */ |
| | | @ApiModelProperty(value = "类型") |
| | | private Integer category; |
| | | /** |
| | | * 岗位编号 |
| | | */ |
| | | @ApiModelProperty(value = "岗位编号") |
| | | private String postCode; |
| | | /** |
| | | * 岗位名称 |
| | | */ |
| | | @ApiModelProperty(value = "岗位名称") |
| | | private String postName; |
| | | /** |
| | | * 岗位排序 |
| | | */ |
| | | @ApiModelProperty(value = "岗位排序") |
| | | private Integer sort; |
| | | /** |
| | | * 岗位描述 |
| | | */ |
| | | @ApiModelProperty(value = "岗位描述") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 行政区划表实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_region") |
| | | @ApiModel(value = "Region对象", description = "行政区划表") |
| | | public class Region implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 区划编号 |
| | | */ |
| | | @TableId(value = "code", type = IdType.INPUT) |
| | | @ApiModelProperty(value = "区划编号") |
| | | private String code; |
| | | /** |
| | | * 父区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "父区划编号") |
| | | private String parentCode; |
| | | /** |
| | | * 祖区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "祖区划编号") |
| | | private String ancestors; |
| | | /** |
| | | * 区划名称 |
| | | */ |
| | | @ApiModelProperty(value = "区划名称") |
| | | private String name; |
| | | /** |
| | | * 省级区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "省级区划编号") |
| | | private String provinceCode; |
| | | /** |
| | | * 省级名称 |
| | | */ |
| | | @ApiModelProperty(value = "省级名称") |
| | | private String provinceName; |
| | | /** |
| | | * 市级区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "市级区划编号") |
| | | private String cityCode; |
| | | /** |
| | | * 市级名称 |
| | | */ |
| | | @ApiModelProperty(value = "市级名称") |
| | | private String cityName; |
| | | /** |
| | | * 区级区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "区级区划编号") |
| | | private String districtCode; |
| | | /** |
| | | * 区级名称 |
| | | */ |
| | | @ApiModelProperty(value = "区级名称") |
| | | private String districtName; |
| | | /** |
| | | * 镇级区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "镇级区划编号") |
| | | private String townCode; |
| | | /** |
| | | * 镇级名称 |
| | | */ |
| | | @ApiModelProperty(value = "镇级名称") |
| | | private String townName; |
| | | /** |
| | | * 村级区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "村级区划编号") |
| | | private String villageCode; |
| | | /** |
| | | * 村级名称 |
| | | */ |
| | | @ApiModelProperty(value = "村级名称") |
| | | private String villageName; |
| | | /** |
| | | * 层级 |
| | | */ |
| | | @ApiModelProperty(value = "层级") |
| | | private Integer regionLevel; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_role") |
| | | @ApiModel(value = "Role对象", description = "Role对象") |
| | | public class Role implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | @ApiModelProperty(value = "租户ID") |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 父主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "父主键") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 角色名 |
| | | */ |
| | | @ApiModelProperty(value = "角色名") |
| | | private String roleName; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 角色别名 |
| | | */ |
| | | @ApiModelProperty(value = "角色别名") |
| | | private String roleAlias; |
| | | |
| | | /** |
| | | * 是否已删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty(value = "是否已删除") |
| | | private Integer isDeleted; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_role_menu") |
| | | @ApiModel(value = "RoleMenu对象", description = "RoleMenu对象") |
| | | public class RoleMenu implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "菜单id") |
| | | private Long menuId; |
| | | |
| | | /** |
| | | * 角色id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "角色id") |
| | | private Long roleId; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_role_scope") |
| | | @ApiModel(value = "RoleScope对象", description = "RoleScope对象") |
| | | public class RoleScope implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 权限类型 |
| | | */ |
| | | @ApiModelProperty(value = "权限类型") |
| | | private Integer scopeCategory; |
| | | |
| | | /** |
| | | * 权限id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "权限id") |
| | | private Long scopeId; |
| | | |
| | | /** |
| | | * 角色id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "角色id") |
| | | private Long roleId; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.NullSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_tenant") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Tenant对象", description = "Tenant对象") |
| | | public class Tenant extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | @ApiModelProperty(value = "租户ID") |
| | | private String tenantId; |
| | | /** |
| | | * 租户名称 |
| | | */ |
| | | @ApiModelProperty(value = "租户名称") |
| | | private String tenantName; |
| | | /** |
| | | * 域名地址 |
| | | */ |
| | | @ApiModelProperty(value = "域名地址") |
| | | private String domainUrl; |
| | | /** |
| | | * 系统背景 |
| | | */ |
| | | @ApiModelProperty(value = "系统背景") |
| | | private String backgroundUrl; |
| | | /** |
| | | * 联系人 |
| | | */ |
| | | @ApiModelProperty(value = "联系人") |
| | | private String linkman; |
| | | /** |
| | | * 联系电话 |
| | | */ |
| | | @ApiModelProperty(value = "联系电话") |
| | | private String contactNumber; |
| | | /** |
| | | * 联系地址 |
| | | */ |
| | | @ApiModelProperty(value = "联系地址") |
| | | private String address; |
| | | /** |
| | | * 账号额度 |
| | | */ |
| | | @ApiModelProperty(value = "账号额度") |
| | | private Integer accountNumber; |
| | | /** |
| | | * 过期时间 |
| | | */ |
| | | @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) |
| | | @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) |
| | | @ApiModelProperty(value = "过期时间") |
| | | private Date expireTime; |
| | | /** |
| | | * 产品包ID |
| | | */ |
| | | @JsonSerialize(nullsUsing = NullSerializer.class) |
| | | @ApiModelProperty(value = "产品包ID") |
| | | private Long packageId; |
| | | /** |
| | | * 数据源ID |
| | | */ |
| | | @JsonSerialize(nullsUsing = NullSerializer.class) |
| | | @ApiModelProperty(value = "数据源ID") |
| | | private Long datasourceId; |
| | | /** |
| | | * 授权码 |
| | | */ |
| | | @ApiModelProperty(value = "授权码") |
| | | private String licenseKey; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * 租户产品表实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_tenant_package") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "TenantPackage对象", description = "租户产品表") |
| | | public class TenantPackage extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 产品包名称 |
| | | */ |
| | | @ApiModelProperty(value = "产品包名称") |
| | | private String packageName; |
| | | /** |
| | | * 菜单ID |
| | | */ |
| | | @ApiModelProperty(value = "菜单ID") |
| | | private String menuId; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| 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.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | /** |
| | | * 顶部菜单表实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_top_menu") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "TopMenu对象", description = "顶部菜单表") |
| | | public class TopMenu extends TenantEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 顶部菜单编号 |
| | | */ |
| | | @ApiModelProperty(value = "顶部菜单编号") |
| | | private String code; |
| | | /** |
| | | * 顶部菜单名 |
| | | */ |
| | | @ApiModelProperty(value = "顶部菜单名") |
| | | private String name; |
| | | /** |
| | | * 顶部菜单资源 |
| | | */ |
| | | @ApiModelProperty(value = "顶部菜单资源") |
| | | private String source; |
| | | /** |
| | | * 顶部菜单排序 |
| | | */ |
| | | @ApiModelProperty(value = "顶部菜单排序") |
| | | private Integer sort; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package org.springblade.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * TopMenuSetting |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_top_menu_setting") |
| | | public class TopMenuSetting { |
| | | |
| | | /** |
| | | * 主键id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 顶部菜单id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long topMenuId; |
| | | |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long menuId; |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/enums/DictBizEnum.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.enums; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 业务字典枚举类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DictBizEnum { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | /** |
| | | * 测试 |
| | | */ |
| | | 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.system.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; |
| | | |
| | | } |
| 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.system.excel; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * RegionExcel |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @ColumnWidth(16) |
| | | @HeadRowHeight(20) |
| | | @ContentRowHeight(18) |
| | | public class RegionExcel implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ExcelProperty("区划编号") |
| | | private String code; |
| | | |
| | | @ExcelProperty("父区划编号") |
| | | private String parentCode; |
| | | |
| | | @ExcelProperty("祖区划编号") |
| | | private String ancestors; |
| | | |
| | | @ExcelProperty("区划名称") |
| | | private String name; |
| | | |
| | | @ExcelProperty("省级区划编号") |
| | | private String provinceCode; |
| | | |
| | | @ExcelProperty("省级名称") |
| | | private String provinceName; |
| | | |
| | | @ExcelProperty("市级区划编号") |
| | | private String cityCode; |
| | | |
| | | @ExcelProperty("市级名称") |
| | | private String cityName; |
| | | |
| | | @ExcelProperty("区级区划编号") |
| | | private String districtCode; |
| | | |
| | | @ExcelProperty("区级名称") |
| | | private String districtName; |
| | | |
| | | @ExcelProperty("镇级区划编号") |
| | | private String townCode; |
| | | |
| | | @ExcelProperty("镇级名称") |
| | | private String townName; |
| | | |
| | | @ExcelProperty("村级区划编号") |
| | | private String villageCode; |
| | | |
| | | @ExcelProperty("村级名称") |
| | | private String villageName; |
| | | |
| | | @ExcelProperty("层级") |
| | | private Integer regionLevel; |
| | | |
| | | @ExcelProperty("排序") |
| | | private Integer sort; |
| | | |
| | | @ExcelProperty("备注") |
| | | private String remark; |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/excel/RegionImporter.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.excel; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.core.excel.support.ExcelImporter; |
| | | import org.springblade.system.service.IRegionService; |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 行政区划数据导入类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | @RequiredArgsConstructor |
| | | public class RegionImporter implements ExcelImporter<RegionExcel> { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | private final IRegionService service; |
| | | private final Boolean isCovered; |
| | | |
| | | @Override |
| | | public void save(List<RegionExcel> data) { |
| | | service.importRegion(data, isCovered); |
| | | } |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/mapper/ApiScopeMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.ApiScope; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface ApiScopeMapper extends BaseMapper<ApiScope> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.ApiScopeMapper"> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/mapper/AuthClientMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.AuthClient; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface AuthClientMapper extends BaseMapper<AuthClient> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.AuthClientMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="clientResultMap" type="org.springblade.system.entity.AuthClient"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="client_id" property="clientId"/> |
| | | <result column="client_secret" property="clientSecret"/> |
| | | <result column="resources_ids" property="resourceIds"/> |
| | | <result column="scope" property="scope"/> |
| | | <result column="authorized_grant_types" property="authorizedGrantTypes"/> |
| | | <result column="web_server_redirect_uri" property="webServerRedirectUri"/> |
| | | <result column="authorities" property="authorities"/> |
| | | <result column="access_token_validity" property="accessTokenValidity"/> |
| | | <result column="refresh_token_validity" property="refreshTokenValidity"/> |
| | | <result column="additional_information" property="additionalInformation"/> |
| | | <result column="autoapprove" property="autoapprove"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/mapper/DataScopeMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.DataScope; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface DataScopeMapper extends BaseMapper<DataScope> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.DataScopeMapper"> |
| | | |
| | | </mapper> |
| 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.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.Dept; |
| | | import org.springblade.system.vo.DeptVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * DeptMapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface DeptMapper extends BaseMapper<Dept> { |
| | | |
| | | /** |
| | | * 懒加载部门列表 |
| | | * |
| | | * @param tenantId |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<DeptVO> lazyList(String tenantId, Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 获取树形节点 |
| | | * |
| | | * @param tenantId |
| | | * @return |
| | | */ |
| | | List<DeptVO> tree(String tenantId); |
| | | |
| | | /** |
| | | * 懒加载获取树形节点 |
| | | * |
| | | * @param tenantId |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | List<DeptVO> lazyTree(String tenantId, Long parentId); |
| | | |
| | | /** |
| | | * 获取部门名 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<String> getDeptNames(Long[] ids); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.DeptMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="deptResultMap" type="org.springblade.system.entity.Dept"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="dept_name" property="deptName"/> |
| | | <result column="full_name" property="fullName"/> |
| | | <result column="ancestors" property="ancestors"/> |
| | | <result column="dept_category" property="deptCategory"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="deptVOResultMap" type="org.springblade.system.vo.DeptVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="dept_name" property="deptName"/> |
| | | <result column="full_name" property="fullName"/> |
| | | <result column="ancestors" property="ancestors"/> |
| | | <result column="dept_category" property="deptCategory"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="has_children" property="hasChildren"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="title" property="title"/> |
| | | <result column="value" property="value"/> |
| | | <result column="key" property="key"/> |
| | | <result column="has_children" property="hasChildren"/> |
| | | </resultMap> |
| | | |
| | | <select id="lazyList" resultMap="deptVOResultMap"> |
| | | SELECT |
| | | dept.* , |
| | | ( |
| | | SELECT |
| | | CASE WHEN count(1) > 0 THEN 1 ELSE 0 END |
| | | FROM |
| | | blade_dept |
| | | WHERE |
| | | parent_id = dept.id and is_deleted = 0 |
| | | ) AS "has_children" |
| | | FROM |
| | | blade_dept dept |
| | | WHERE dept.is_deleted = 0 |
| | | <if test="param1!=null and param1!=''"> |
| | | and dept.tenant_id = #{param1} |
| | | </if> |
| | | <if test="param2!=null"> |
| | | and dept.parent_id = #{param2} |
| | | </if> |
| | | <if test="param3.deptName!=null and param3.deptName!=''"> |
| | | and dept.dept_name like concat(concat('%', #{param3.deptName}),'%') |
| | | </if> |
| | | <if test="param3.fullName!=null and param3.fullName!=''"> |
| | | and dept.full_name like concat(concat('%', #{param3.fullName}),'%') |
| | | </if> |
| | | ORDER BY dept.sort |
| | | </select> |
| | | |
| | | <select id="tree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, dept_name as title, id as "value", id as "key" from blade_dept where is_deleted = 0 |
| | | <if test="_parameter!=null and _parameter!=''"> |
| | | and tenant_id = #{_parameter} |
| | | </if> |
| | | ORDER BY sort |
| | | </select> |
| | | |
| | | <select id="lazyTree" resultMap="treeNodeResultMap" > |
| | | SELECT |
| | | dept.id, |
| | | dept.parent_id, |
| | | dept.dept_name AS title, |
| | | dept.id AS "value", |
| | | dept.id AS "key", |
| | | ( |
| | | SELECT |
| | | CASE WHEN count(1) > 0 THEN 1 ELSE 0 END |
| | | FROM |
| | | blade_dept |
| | | WHERE |
| | | parent_id = dept.id and is_deleted = 0 |
| | | ) AS "has_children" |
| | | FROM |
| | | blade_dept dept |
| | | WHERE |
| | | dept.parent_id = #{param2} AND dept.is_deleted = 0 |
| | | <if test="param1!=null and param1!=''"> |
| | | and dept.tenant_id = #{param1} |
| | | </if> |
| | | ORDER BY dept.sort |
| | | </select> |
| | | |
| | | <select id="getDeptNames" resultType="java.lang.String"> |
| | | SELECT |
| | | dept_name |
| | | FROM |
| | | blade_dept |
| | | WHERE |
| | | id IN |
| | | <foreach collection="array" item="ids" index="index" open="(" close=")" separator=","> |
| | | #{ids} |
| | | </foreach> |
| | | and is_deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |
| 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.system.mapper; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.DictBiz; |
| | | import org.springblade.system.vo.DictBizVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface DictBizMapper extends BaseMapper<DictBiz> { |
| | | |
| | | /** |
| | | * 获取字典表对应中文 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey 字典序号 |
| | | * @return |
| | | */ |
| | | String getValue(String code, String dictKey); |
| | | |
| | | /** |
| | | * 获取字典表 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return |
| | | */ |
| | | List<DictBiz> getList(String code); |
| | | |
| | | /** |
| | | * 获取树形节点 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictBizVO> tree(); |
| | | |
| | | /** |
| | | * 获取树形节点 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictBizVO> parentTree(); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.DictBizMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="dictResultMap" type="org.springblade.system.entity.DictBiz"> |
| | | <id column="id" property="id"/> |
| | | <result column="tenant_id" property="tenantId"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="code" property="code"/> |
| | | <result column="dict_key" property="dictKey"/> |
| | | <result column="dict_value" property="dictValue"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="title" property="title"/> |
| | | <result column="value" property="value"/> |
| | | <result column="key" property="key"/> |
| | | </resultMap> |
| | | |
| | | <select id="getValue" resultType="java.lang.String"> |
| | | select |
| | | dict_value |
| | | from blade_dict_biz where code = #{param1} and dict_key = #{param2} and is_deleted = 0 |
| | | </select> |
| | | |
| | | <!-- oracle 版本 --> |
| | | <!--<select id="getValue" resultType="java.lang.String"> |
| | | select |
| | | dict_value |
| | | from blade_dict_biz where code = #{param1, jdbcType=VARCHAR} and dict_key = #{param2} and dict_key >= 0 rownum 1 |
| | | </select>--> |
| | | |
| | | <select id="getList" resultMap="dictResultMap"> |
| | | select id, tenant_id, parent_id, code, dict_key, dict_value, sort, remark from blade_dict_biz where code = #{param1} and parent_id > 0 and is_sealed = 0 and is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="tree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, dict_value as title, id as "value", id as "key" from blade_dict_biz where is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="parentTree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, dict_value as title, id as "value", id as "key" from blade_dict_biz where is_deleted = 0 and parent_id = 0 |
| | | </select> |
| | | |
| | | </mapper> |
| 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.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.system.entity.Dict; |
| | | import org.springblade.system.vo.DictVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface DictMapper extends BaseMapper<Dict> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param dict |
| | | * @return |
| | | */ |
| | | List<DictVO> selectDictPage(IPage page, DictVO dict); |
| | | |
| | | /** |
| | | * 获取字典表对应中文 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey 字典序号 |
| | | * @return |
| | | */ |
| | | String getValue(String code, String dictKey); |
| | | |
| | | /** |
| | | * 获取字典表 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return |
| | | */ |
| | | List<Dict> getList(String code); |
| | | |
| | | /** |
| | | * 获取树形节点 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictVO> tree(); |
| | | |
| | | /** |
| | | * 获取树形节点 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictVO> parentTree(); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.DictMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="dictResultMap" type="org.springblade.system.entity.Dict"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="code" property="code"/> |
| | | <result column="dict_key" property="dictKey"/> |
| | | <result column="dict_value" property="dictValue"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="title" property="title"/> |
| | | <result column="value" property="value"/> |
| | | <result column="key" property="key"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectDictPage" resultMap="dictResultMap"> |
| | | select * from blade_dict where is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="getValue" resultType="java.lang.String"> |
| | | select |
| | | dict_value |
| | | from blade_dict where code = #{param1} and dict_key = #{param2} and is_deleted = 0 |
| | | </select> |
| | | |
| | | <!-- oracle 版本 --> |
| | | <!--<select id="getValue" resultType="java.lang.String"> |
| | | select |
| | | dict_value |
| | | from blade_dict where code = #{param1, jdbcType=VARCHAR} and dict_key = #{param2} and dict_key >= 0 rownum 1 |
| | | </select>--> |
| | | |
| | | <select id="getList" resultMap="dictResultMap"> |
| | | select id, parent_id, code, dict_key, dict_value, sort, remark from blade_dict where code = #{param1} and parent_id > 0 and is_sealed = 0 and is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="tree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, dict_value as title, id as "value", id as "key" from blade_dict where is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="parentTree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, dict_value as title, id as "value", id as "key" from blade_dict where is_deleted = 0 and parent_id = 0 |
| | | </select> |
| | | |
| | | </mapper> |
| 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.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.core.tool.node.TreeNode; |
| | | import org.springblade.system.dto.MenuDTO; |
| | | import org.springblade.system.entity.Menu; |
| | | import org.springblade.system.vo.MenuVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * MenuMapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface MenuMapper extends BaseMapper<Menu> { |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<MenuVO> lazyList(Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 懒加载菜单列表 |
| | | * |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<MenuVO> lazyMenuList(Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> tree(); |
| | | |
| | | /** |
| | | * 授权树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTree(); |
| | | |
| | | /** |
| | | * 授权树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTreeByRole(List<Long> roleId); |
| | | |
| | | /** |
| | | * 顶部菜单树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTopTree(); |
| | | |
| | | /** |
| | | * 顶部菜单树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTopTreeByRole(List<Long> roleId); |
| | | |
| | | /** |
| | | * 数据权限授权树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantDataScopeTree(); |
| | | |
| | | /** |
| | | * 接口权限授权树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantApiScopeTree(); |
| | | |
| | | /** |
| | | * 数据权限授权树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantDataScopeTreeByRole(List<Long> roleId); |
| | | |
| | | /** |
| | | * 接口权限授权树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantApiScopeTreeByRole(List<Long> roleId); |
| | | |
| | | /** |
| | | * 所有菜单 |
| | | * |
| | | * @return |
| | | */ |
| | | List<Menu> allMenu(); |
| | | |
| | | /** |
| | | * 权限配置菜单 |
| | | * |
| | | * @param roleId |
| | | * @param topMenuId |
| | | * @return |
| | | */ |
| | | List<Menu> roleMenu(List<Long> roleId, Long topMenuId); |
| | | |
| | | /** |
| | | * 权限配置菜单 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<Menu> roleMenuByRoleId(List<Long> roleId); |
| | | |
| | | /** |
| | | * 权限配置菜单 |
| | | * |
| | | * @param topMenuId |
| | | * @return |
| | | */ |
| | | List<Menu> roleMenuByTopMenuId(Long topMenuId); |
| | | |
| | | /** |
| | | * 菜单树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<Menu> routes(List<Long> roleId); |
| | | |
| | | /** |
| | | * 按钮树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<Menu> allButtons(); |
| | | |
| | | /** |
| | | * 按钮树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<Menu> buttons(List<Long> roleId); |
| | | |
| | | /** |
| | | * 获取配置的角色权限 |
| | | * |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<MenuDTO> authRoutes(List<Long> roleIds); |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.MenuMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="menuResultMap" type="org.springblade.system.entity.Menu"> |
| | | <id column="id" property="id"/> |
| | | <result column="code" property="code"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="name" property="name"/> |
| | | <result column="alias" property="alias"/> |
| | | <result column="path" property="path"/> |
| | | <result column="source" property="source"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="category" property="category"/> |
| | | <result column="action" property="action"/> |
| | | <result column="is_open" property="isOpen"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="menuVOResultMap" type="org.springblade.system.vo.MenuVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="code" property="code"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="name" property="name"/> |
| | | <result column="alias" property="alias"/> |
| | | <result column="path" property="path"/> |
| | | <result column="source" property="source"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="category" property="category"/> |
| | | <result column="action" property="action"/> |
| | | <result column="is_open" property="isOpen"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="has_children" property="hasChildren"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="title" property="title"/> |
| | | <result column="value" property="value"/> |
| | | <result column="key" property="key"/> |
| | | </resultMap> |
| | | |
| | | <select id="lazyList" resultMap="menuVOResultMap"> |
| | | SELECT |
| | | menu.*, |
| | | ( |
| | | SELECT |
| | | CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END |
| | | FROM |
| | | blade_menu |
| | | WHERE |
| | | parent_id = menu.id AND is_deleted = 0 |
| | | ) AS "has_children" |
| | | FROM |
| | | blade_menu menu |
| | | WHERE menu.is_deleted = 0 |
| | | <if test="param1!=null"> |
| | | and menu.parent_id = #{param1} |
| | | </if> |
| | | <if test="param2.name!=null and param2.name!=''"> |
| | | and menu.name like concat(concat('%', #{param2.name}),'%') |
| | | </if> |
| | | <if test="param2.code!=null and param2.code!=''"> |
| | | and menu.code like concat(concat('%', #{param2.code}),'%') |
| | | </if> |
| | | <if test="param2.alias!=null and param2.alias!=''"> |
| | | and menu.alias like concat(concat('%', #{param2.alias}),'%') |
| | | </if> |
| | | ORDER BY menu.sort |
| | | </select> |
| | | |
| | | <select id="lazyMenuList" resultMap="menuVOResultMap"> |
| | | SELECT |
| | | menu.*, |
| | | ( |
| | | SELECT |
| | | CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END |
| | | FROM |
| | | blade_menu |
| | | WHERE |
| | | parent_id = menu.id AND is_deleted = 0 AND category = 1 |
| | | ) AS "has_children" |
| | | FROM |
| | | blade_menu menu |
| | | WHERE menu.is_deleted = 0 AND menu.category = 1 |
| | | <if test="param1!=null"> |
| | | and menu.parent_id = #{param1} |
| | | </if> |
| | | <if test="param2.name!=null and param2.name!=''"> |
| | | and menu.name like concat(concat('%', #{param2.name}),'%') |
| | | </if> |
| | | <if test="param2.code!=null and param2.code!=''"> |
| | | and menu.code like concat(concat('%', #{param2.code}),'%') |
| | | </if> |
| | | <if test="param2.alias!=null and param2.alias!=''"> |
| | | and menu.alias like concat(concat('%', #{param2.alias}),'%') |
| | | </if> |
| | | ORDER BY menu.sort |
| | | </select> |
| | | |
| | | <select id="tree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, name as title, id as "value", id as "key" from blade_menu where is_deleted = 0 and category = 1 |
| | | </select> |
| | | |
| | | <select id="allMenu" resultMap="menuResultMap"> |
| | | select * from blade_menu where is_deleted = 0 and category = 1 |
| | | </select> |
| | | |
| | | <select id="roleMenu" resultMap="menuResultMap"> |
| | | select * from blade_menu where is_deleted = 0 and id IN |
| | | ( SELECT menu_id FROM blade_role_menu WHERE role_id IN |
| | | <foreach collection="param1" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | <if test="param2!=null and param2>0"> |
| | | AND id IN |
| | | ( |
| | | SELECT menu_id FROM blade_top_menu_setting WHERE top_menu_id = #{param2} |
| | | ) |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="roleMenuByRoleId" resultMap="menuResultMap"> |
| | | select * from blade_menu where is_deleted = 0 and id IN |
| | | ( SELECT menu_id FROM blade_role_menu WHERE role_id IN |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | </select> |
| | | |
| | | <select id="roleMenuByTopMenuId" resultMap="menuResultMap"> |
| | | select * from blade_menu where is_deleted = 0 and id IN |
| | | ( |
| | | SELECT menu_id FROM blade_top_menu_setting WHERE top_menu_id = #{param1} |
| | | ) |
| | | </select> |
| | | |
| | | <select id="routes" resultMap="menuResultMap"> |
| | | SELECT |
| | | * |
| | | FROM |
| | | blade_menu |
| | | WHERE |
| | | is_deleted = 0 and category = 1 |
| | | and id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> ) |
| | | </select> |
| | | |
| | | <select id="allButtons" resultMap="menuResultMap"> |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | CODE, |
| | | NAME, |
| | | alias, |
| | | path, |
| | | source, |
| | | action, |
| | | sort |
| | | FROM |
| | | blade_menu |
| | | WHERE |
| | | ( |
| | | category = 2 OR id IN ( SELECT parent_id FROM blade_menu WHERE is_deleted = 0 AND category = 2 ) |
| | | ) |
| | | AND is_deleted = 0 |
| | | ORDER BY sort |
| | | </select> |
| | | |
| | | <select id="buttons" resultMap="menuResultMap"> |
| | | SELECT * FROM ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | code, |
| | | name, |
| | | alias, |
| | | path, |
| | | source, |
| | | action, |
| | | sort |
| | | FROM |
| | | blade_menu |
| | | WHERE |
| | | is_deleted = 0 and id IN ( |
| | | SELECT parent_id FROM blade_menu |
| | | WHERE ( category = 2 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) ) ) |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | code, |
| | | name, |
| | | alias, |
| | | path, |
| | | source, |
| | | action, |
| | | sort |
| | | FROM |
| | | blade_menu |
| | | WHERE |
| | | is_deleted = 0 and category = 2 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach>) |
| | | ) menu ORDER BY sort |
| | | </select> |
| | | |
| | | <select id="grantTree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, name as title, id as "value", id as "key" from blade_menu where is_deleted = 0 order by sort |
| | | </select> |
| | | |
| | | <select id="grantTreeByRole" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, name as title, id as "value", id as "key" from blade_menu where is_deleted = 0 |
| | | and id in ( select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> ) |
| | | or id in ( |
| | | select parent_id from blade_menu where is_deleted = 0 |
| | | and id in ( select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> ) |
| | | ) |
| | | order by sort |
| | | </select> |
| | | |
| | | <select id="grantTopTree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, name as title, id as "value", id as "key" from blade_menu where category = 1 and is_deleted = 0 order by sort |
| | | </select> |
| | | |
| | | <select id="grantTopTreeByRole" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, name as title, id as "value", id as "key" from blade_menu where category = 1 and is_deleted = 0 |
| | | and id in ( select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> ) |
| | | or id in ( |
| | | select parent_id from blade_menu where is_deleted = 0 |
| | | and id in ( select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> ) |
| | | ) |
| | | order by sort |
| | | </select> |
| | | |
| | | <select id="grantDataScopeTree" resultMap="treeNodeResultMap"> |
| | | SELECT |
| | | * |
| | | FROM |
| | | ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME AS title, |
| | | id AS "value", |
| | | id AS "key" |
| | | FROM |
| | | blade_menu |
| | | WHERE |
| | | category = 1 |
| | | AND is_deleted = 0 |
| | | AND id IN ( SELECT menu_id FROM blade_scope_data WHERE is_deleted = 0 AND menu_id IS NOT NULL ) |
| | | ) menu |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT |
| | | id, |
| | | menu_id AS parent_id, |
| | | scope_name AS title, |
| | | id AS "value", |
| | | id AS "key" |
| | | FROM |
| | | blade_scope_data |
| | | WHERE |
| | | is_deleted = 0 |
| | | AND menu_id IS NOT NULL |
| | | </select> |
| | | |
| | | <select id="grantApiScopeTree" resultMap="treeNodeResultMap"> |
| | | SELECT |
| | | * |
| | | FROM |
| | | ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME AS title, |
| | | id AS "value", |
| | | id AS "key" |
| | | FROM |
| | | blade_menu |
| | | WHERE |
| | | category = 1 |
| | | AND is_deleted = 0 |
| | | AND id IN ( SELECT menu_id FROM blade_scope_api WHERE is_deleted = 0 AND menu_id IS NOT NULL ) |
| | | ) menu |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT |
| | | id, |
| | | menu_id AS parent_id, |
| | | scope_name AS title, |
| | | id AS "value", |
| | | id AS "key" |
| | | FROM |
| | | blade_scope_api |
| | | WHERE |
| | | is_deleted = 0 |
| | | AND menu_id IS NOT NULL |
| | | </select> |
| | | |
| | | <select id="grantDataScopeTreeByRole" resultMap="treeNodeResultMap"> |
| | | SELECT |
| | | * |
| | | FROM |
| | | ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME AS title, |
| | | id AS "value", |
| | | id AS "key" |
| | | FROM |
| | | blade_menu |
| | | WHERE |
| | | category = 1 |
| | | AND is_deleted = 0 |
| | | AND id IN ( SELECT menu_id FROM blade_scope_data WHERE is_deleted = 0 AND menu_id IS NOT NULL ) |
| | | AND ( |
| | | id IN ( |
| | | select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | OR id IN ( |
| | | select parent_id from blade_menu where is_deleted = 0 |
| | | and id in ( select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> ) |
| | | ) |
| | | ) |
| | | ) menu |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT |
| | | id, |
| | | menu_id AS parent_id, |
| | | scope_name AS title, |
| | | id AS "value", |
| | | id AS "key" |
| | | FROM |
| | | blade_scope_data |
| | | WHERE |
| | | is_deleted = 0 |
| | | AND ( |
| | | menu_id IN ( |
| | | select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | OR menu_id IN ( |
| | | select parent_id from blade_menu where is_deleted = 0 |
| | | and id in ( select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> ) |
| | | ) |
| | | ) |
| | | AND menu_id IS NOT NULL |
| | | </select> |
| | | |
| | | <select id="grantApiScopeTreeByRole" resultMap="treeNodeResultMap"> |
| | | SELECT |
| | | * |
| | | FROM |
| | | ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME AS title, |
| | | id AS "value", |
| | | id AS "key" |
| | | FROM |
| | | blade_menu |
| | | WHERE |
| | | category = 1 |
| | | AND is_deleted = 0 |
| | | AND id IN ( SELECT menu_id FROM blade_scope_api WHERE is_deleted = 0 AND menu_id IS NOT NULL ) |
| | | AND ( |
| | | id IN ( |
| | | select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | OR id IN ( |
| | | select parent_id from blade_menu where is_deleted = 0 |
| | | and id in ( |
| | | select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> ) |
| | | ) |
| | | ) |
| | | ) menu |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT |
| | | id, |
| | | menu_id AS parent_id, |
| | | scope_name AS title, |
| | | id AS "value", |
| | | id AS "key" |
| | | FROM |
| | | blade_scope_api |
| | | WHERE |
| | | is_deleted = 0 |
| | | AND |
| | | ( |
| | | menu_id IN ( |
| | | select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | OR menu_id IN ( |
| | | select parent_id from blade_menu where is_deleted = 0 |
| | | and id in ( select menu_id from blade_role_menu where role_id in |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> ) |
| | | ) |
| | | ) |
| | | AND menu_id IS NOT NULL |
| | | </select> |
| | | |
| | | <select id="authRoutes" resultType="org.springblade.system.dto.MenuDTO"> |
| | | SELECT |
| | | GROUP_CONCAT(r.role_alias) as alias, |
| | | m.path |
| | | FROM |
| | | blade_role_menu rm |
| | | LEFT JOIN blade_menu m ON rm.menu_id = m.id |
| | | LEFT JOIN blade_role r ON rm.role_id = r.id |
| | | WHERE |
| | | rm.role_id IN |
| | | <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | AND m.path IS NOT NULL and m.is_deleted = 0 |
| | | GROUP BY m.path |
| | | </select> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/mapper/ParamMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.Param; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface ParamMapper extends BaseMapper<Param> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.ParamMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="paramResultMap" type="org.springblade.system.entity.Param"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="param_name" property="paramName"/> |
| | | <result column="param_key" property="paramKey"/> |
| | | <result column="param_value" property="paramValue"/> |
| | | <result column="remark" property="remark"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| 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.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.system.entity.Post; |
| | | import org.springblade.system.vo.PostVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 岗位表 Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface PostMapper extends BaseMapper<Post> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param post |
| | | * @return |
| | | */ |
| | | List<PostVO> selectPostPage(IPage page, PostVO post); |
| | | |
| | | /** |
| | | * 获取岗位名 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<String> getPostNames(Long[] ids); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.PostMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="postResultMap" type="org.springblade.system.entity.Post"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_dept" property="createDept"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="category" property="category"/> |
| | | <result column="post_code" property="postCode"/> |
| | | <result column="post_name" property="postName"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="remark" property="remark"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="selectPostPage" resultMap="postResultMap"> |
| | | select * from blade_post where is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="getPostNames" resultType="java.lang.String"> |
| | | SELECT |
| | | post_name |
| | | FROM |
| | | blade_post |
| | | WHERE |
| | | id IN |
| | | <foreach collection="array" item="ids" index="index" open="(" close=")" separator=","> |
| | | #{ids} |
| | | </foreach> |
| | | and is_deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |
| 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.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.system.entity.Region; |
| | | import org.springblade.system.excel.RegionExcel; |
| | | import org.springblade.system.vo.RegionVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 行政区划表 Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface RegionMapper extends BaseMapper<Region> { |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentCode |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<RegionVO> lazyList(String parentCode, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentCode |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<RegionVO> lazyTree(String parentCode, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 导出区划数据 |
| | | * |
| | | * @param queryWrapper |
| | | * @return |
| | | */ |
| | | List<RegionExcel> exportRegion(@Param("ew") Wrapper<Region> queryWrapper); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.RegionMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="regionResultMap" type="org.springblade.system.entity.Region"> |
| | | <id column="code" property="code"/> |
| | | <result column="parent_code" property="parentCode"/> |
| | | <result column="ancestors" property="ancestors"/> |
| | | <result column="name" property="name"/> |
| | | <result column="province_code" property="provinceCode"/> |
| | | <result column="province_name" property="provinceName"/> |
| | | <result column="city_code" property="cityCode"/> |
| | | <result column="city_name" property="cityName"/> |
| | | <result column="district_code" property="districtCode"/> |
| | | <result column="district_name" property="districtName"/> |
| | | <result column="town_code" property="townCode"/> |
| | | <result column="town_name" property="townName"/> |
| | | <result column="village_code" property="villageCode"/> |
| | | <result column="village_name" property="villageName"/> |
| | | <result column="level" property="regionLevel"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="remark" property="remark"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="regionVOResultMap" type="org.springblade.system.vo.RegionVO"> |
| | | <id column="code" property="code"/> |
| | | <result column="parent_code" property="parentCode"/> |
| | | <result column="ancestors" property="ancestors"/> |
| | | <result column="name" property="name"/> |
| | | <result column="province_code" property="provinceCode"/> |
| | | <result column="province_name" property="provinceName"/> |
| | | <result column="city_code" property="cityCode"/> |
| | | <result column="city_name" property="cityName"/> |
| | | <result column="district_code" property="districtCode"/> |
| | | <result column="district_name" property="districtName"/> |
| | | <result column="town_code" property="townCode"/> |
| | | <result column="town_name" property="townName"/> |
| | | <result column="village_code" property="villageCode"/> |
| | | <result column="village_name" property="villageName"/> |
| | | <result column="level" property="regionLevel"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="has_children" property="hasChildren"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="title" property="title"/> |
| | | <result column="value" property="value"/> |
| | | <result column="key" property="key"/> |
| | | <result column="has_children" property="hasChildren"/> |
| | | </resultMap> |
| | | |
| | | <select id="lazyList" resultMap="regionVOResultMap"> |
| | | SELECT |
| | | region.*, |
| | | ( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM blade_region WHERE parent_code = region.code ) AS "has_children" |
| | | FROM |
| | | blade_region region |
| | | <where> |
| | | <if test="param1!=null"> |
| | | and region.parent_code = #{param1} |
| | | </if> |
| | | <if test="param2.code!=null and param2.code!=''"> |
| | | and region.code like concat(concat('%', #{param2.code}),'%') |
| | | </if> |
| | | <if test="param2.name!=null and param2.name!=''"> |
| | | and region.name like concat(concat('%', #{param2.name}),'%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="lazyTree" resultMap="treeNodeResultMap"> |
| | | SELECT |
| | | region.code AS "id", |
| | | region.parent_code AS "parent_id", |
| | | region.name AS "title", |
| | | region.code AS "value", |
| | | region.code AS "key", |
| | | ( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM blade_region WHERE parent_code = region.code ) AS "has_children" |
| | | FROM |
| | | blade_region region |
| | | <where> |
| | | <if test="param1!=null"> |
| | | and region.parent_code = #{param1} |
| | | </if> |
| | | <if test="param2.code!=null and param2.code!=''"> |
| | | and region.code like concat(concat('%', #{param2.code}),'%') |
| | | </if> |
| | | <if test="param2.name!=null and param2.name!=''"> |
| | | and region.name like concat(concat('%', #{param2.name}),'%') |
| | | </if> |
| | | </where> |
| | | ORDER BY region.code |
| | | </select> |
| | | |
| | | <select id="exportRegion" resultType="org.springblade.system.excel.RegionExcel"> |
| | | SELECT * FROM blade_region ${ew.customSqlSegment} |
| | | </select> |
| | | |
| | | </mapper> |
| 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.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.system.entity.Role; |
| | | import org.springblade.system.vo.RoleVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface RoleMapper extends BaseMapper<Role> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param role |
| | | * @return |
| | | */ |
| | | List<RoleVO> selectRolePage(IPage page, RoleVO role); |
| | | |
| | | /** |
| | | * 获取树形节点 |
| | | * |
| | | * @param tenantId |
| | | * @param excludeRole |
| | | * @return |
| | | */ |
| | | List<RoleVO> tree(String tenantId, String excludeRole); |
| | | |
| | | /** |
| | | * 获取角色名 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<String> getRoleNames(Long[] ids); |
| | | |
| | | /** |
| | | * 获取角色名 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<String> getRoleAliases(Long[] ids); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.RoleMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="roleResultMap" type="org.springblade.system.entity.Role"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="role_name" property="roleName"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="role_alias" property="roleAlias"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="title" property="title"/> |
| | | <result column="value" property="value"/> |
| | | <result column="key" property="key"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectRolePage" resultMap="roleResultMap"> |
| | | select * from blade_role where is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="tree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, role_name as title, id as "value", id as "key" from blade_role where is_deleted = 0 |
| | | <if test="param1!=null"> |
| | | and tenant_id = #{param1} |
| | | </if> |
| | | <if test="param2!=null"> |
| | | and role_alias <> #{param2} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getRoleNames" resultType="java.lang.String"> |
| | | SELECT |
| | | role_name |
| | | FROM |
| | | blade_role |
| | | WHERE |
| | | id IN |
| | | <foreach collection="array" item="ids" index="index" open="(" close=")" separator=","> |
| | | #{ids} |
| | | </foreach> |
| | | and is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="getRoleAliases" resultType="java.lang.String"> |
| | | SELECT |
| | | role_alias |
| | | FROM |
| | | blade_role |
| | | WHERE |
| | | id IN |
| | | <foreach collection="array" item="ids" index="index" open="(" close=")" separator=","> |
| | | #{ids} |
| | | </foreach> |
| | | and is_deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/mapper/RoleMenuMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.system.entity.RoleMenu; |
| | | import org.springblade.system.vo.RoleMenuVO; |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | public interface RoleMenuMapper extends BaseMapper<RoleMenu> { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | /** |
| | | * 自定义分页 |
| | | * @param page |
| | | * @param roleMenu |
| | | * @return |
| | | */ |
| | | List<RoleMenuVO> selectRoleMenuPage(IPage page, RoleMenuVO roleMenu); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.RoleMenuMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="roleMenuResultMap" type="org.springblade.system.entity.RoleMenu"> |
| | | <id column="id" property="id"/> |
| | | <result column="menu_id" property="menuId"/> |
| | | <result column="role_id" property="roleId"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectRoleMenuPage" resultMap="roleMenuResultMap"> |
| | | select * from blade_role_menu where is_deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/mapper/RoleScopeMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.RoleScope; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface RoleScopeMapper extends BaseMapper<RoleScope> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.RoleScopeMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="roleMenuResultMap" type="org.springblade.system.entity.RoleScope"> |
| | | <id column="id" property="id"/> |
| | | <result column="scope_id" property="scopeId"/> |
| | | <result column="role_id" property="roleId"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/mapper/TenantMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.system.entity.Tenant; |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | public interface TenantMapper extends BaseMapper<Tenant> { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param tenant |
| | | * @return |
| | | */ |
| | | List<Tenant> selectTenantPage(IPage page, Tenant tenant); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.TenantMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="tenantResultMap" type="org.springblade.system.entity.Tenant"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="tenant_id" property="tenantId"/> |
| | | <result column="tenant_name" property="tenantName"/> |
| | | <result column="domain_url" property="domainUrl"/> |
| | | <result column="background_url" property="backgroundUrl"/> |
| | | <result column="linkman" property="linkman"/> |
| | | <result column="contact_number" property="contactNumber"/> |
| | | <result column="address" property="address"/> |
| | | <result column="account_number" property="accountNumber"/> |
| | | <result column="expire_time" property="expireTime"/> |
| | | <result column="license_key" property="licenseKey"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="selectTenantPage" resultMap="tenantResultMap"> |
| | | select * from blade_tenant where is_deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/mapper/TenantPackageMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.TenantPackage; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 租户产品表 Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface TenantPackageMapper extends BaseMapper<TenantPackage> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.TenantPackageMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="tenantPackageResultMap" type="org.springblade.system.entity.TenantPackage"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_dept" property="createDept"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="package_name" property="packageName"/> |
| | | <result column="menu_id" property="menuId"/> |
| | | <result column="remark" property="remark"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/mapper/TopMenuMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.TopMenu; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 顶部菜单表 Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface TopMenuMapper extends BaseMapper<TopMenu> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.TopMenuMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="topMenuResultMap" type="org.springblade.system.entity.TopMenu"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_dept" property="createDept"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="code" property="code"/> |
| | | <result column="name" property="name"/> |
| | | <result column="source" property="source"/> |
| | | <result column="sort" property="sort"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/mapper/TopMenuSettingMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.TopMenuSetting; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface TopMenuSettingMapper extends BaseMapper<TopMenuSetting> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.mapper.TopMenuSettingMapper"> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/IApiScopeService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.system.entity.ApiScope; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface IApiScopeService extends BaseService<ApiScope> { |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/IAuthClientService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.system.entity.AuthClient; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface IAuthClientService extends BaseService<AuthClient> { |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/IDataScopeService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.system.entity.DataScope; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface IDataScopeService extends BaseService<DataScope> { |
| | | |
| | | } |
| 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.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.system.entity.Dept; |
| | | import org.springblade.system.vo.DeptVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IDeptService extends IService<Dept> { |
| | | |
| | | /** |
| | | * 懒加载部门列表 |
| | | * |
| | | * @param tenantId |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<DeptVO> lazyList(String tenantId, Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @param tenantId |
| | | * @return |
| | | */ |
| | | List<DeptVO> tree(String tenantId); |
| | | |
| | | /** |
| | | * 懒加载树形结构 |
| | | * |
| | | * @param tenantId |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | List<DeptVO> lazyTree(String tenantId, Long parentId); |
| | | |
| | | /** |
| | | * 获取部门ID |
| | | * |
| | | * @param tenantId |
| | | * @param deptNames |
| | | * @return |
| | | */ |
| | | String getDeptIds(String tenantId, String deptNames); |
| | | |
| | | /** |
| | | * 获取部门ID |
| | | * |
| | | * @param tenantId |
| | | * @param deptNames |
| | | * @return |
| | | */ |
| | | String getDeptIdsByFuzzy(String tenantId, String deptNames); |
| | | |
| | | /** |
| | | * 获取部门名 |
| | | * |
| | | * @param deptIds |
| | | * @return |
| | | */ |
| | | List<String> getDeptNames(String deptIds); |
| | | |
| | | /** |
| | | * 获取子部门 |
| | | * |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | List<Dept> getDeptChild(Long deptId); |
| | | |
| | | /** |
| | | * 删除部门 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean removeDept(String ids); |
| | | |
| | | /** |
| | | * 提交 |
| | | * |
| | | * @param dept |
| | | * @return |
| | | */ |
| | | boolean submit(Dept dept); |
| | | |
| | | /** |
| | | * 部门信息查询 |
| | | * |
| | | * @param deptName |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | List<DeptVO> search(String deptName, Long parentId); |
| | | |
| | | } |
| 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.system.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.system.entity.DictBiz; |
| | | import org.springblade.system.vo.DictBizVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IDictBizService extends IService<DictBiz> { |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictBizVO> tree(); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictBizVO> parentTree(); |
| | | |
| | | /** |
| | | * 获取字典表对应中文 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey 字典序号 |
| | | * @return |
| | | */ |
| | | String getValue(String code, String dictKey); |
| | | |
| | | /** |
| | | * 获取字典表 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return |
| | | */ |
| | | List<DictBiz> getList(String code); |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * |
| | | * @param dict |
| | | * @return |
| | | */ |
| | | boolean submit(DictBiz dict); |
| | | |
| | | /** |
| | | * 删除字典 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean removeDict(String ids); |
| | | |
| | | /** |
| | | * 顶级列表 |
| | | * |
| | | * @param dict |
| | | * @param query |
| | | * @return |
| | | */ |
| | | IPage<DictBizVO> parentList(Map<String, Object> dict, Query query); |
| | | |
| | | /** |
| | | * 子列表 |
| | | * |
| | | * @param dict |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | List<DictBizVO> childList(Map<String, Object> dict, Long parentId); |
| | | |
| | | } |
| 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.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.system.entity.Dict; |
| | | import org.springblade.system.vo.DictVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IDictService extends IService<Dict> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param dict |
| | | * @return |
| | | */ |
| | | IPage<DictVO> selectDictPage(IPage<DictVO> page, DictVO dict); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictVO> tree(); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictVO> parentTree(); |
| | | |
| | | /** |
| | | * 获取字典表对应中文 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey 字典序号 |
| | | * @return |
| | | */ |
| | | String getValue(String code, String dictKey); |
| | | |
| | | /** |
| | | * 获取字典表 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return |
| | | */ |
| | | List<Dict> getList(String code); |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * |
| | | * @param dict |
| | | * @return |
| | | */ |
| | | boolean submit(Dict dict); |
| | | |
| | | /** |
| | | * 删除字典 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean removeDict(String ids); |
| | | |
| | | /** |
| | | * 顶级列表 |
| | | * |
| | | * @param dict |
| | | * @param query |
| | | * @return |
| | | */ |
| | | IPage<DictVO> parentList(Map<String, Object> dict, Query query); |
| | | |
| | | /** |
| | | * 子列表 |
| | | * |
| | | * @param dict |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | List<DictVO> childList(Map<String, Object> dict, Long parentId); |
| | | |
| | | } |
| 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.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.tool.node.TreeNode; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.system.entity.Menu; |
| | | import org.springblade.system.vo.MenuVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IMenuService extends IService<Menu> { |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<MenuVO> lazyList(Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 懒加载菜单列表 |
| | | * |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<MenuVO> lazyMenuList(Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 菜单树形结构 |
| | | * |
| | | * @param roleId |
| | | * @param topMenuId |
| | | * @return |
| | | */ |
| | | List<MenuVO> routes(String roleId, Long topMenuId); |
| | | |
| | | /** |
| | | * 按钮树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<MenuVO> buttons(String roleId); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> tree(); |
| | | |
| | | /** |
| | | * 授权树形结构 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTree(BladeUser user); |
| | | |
| | | /** |
| | | * 顶部菜单树形结构 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTopTree(BladeUser user); |
| | | |
| | | /** |
| | | * 数据权限授权树形结构 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantDataScopeTree(BladeUser user); |
| | | |
| | | /** |
| | | * 接口权限授权树形结构 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantApiScopeTree(BladeUser user); |
| | | |
| | | /** |
| | | * 默认选中节点 |
| | | * |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<String> roleTreeKeys(String roleIds); |
| | | |
| | | /** |
| | | * 默认选中节点 |
| | | * |
| | | * @param topMenuIds |
| | | * @return |
| | | */ |
| | | List<String> topTreeKeys(String topMenuIds); |
| | | |
| | | /** |
| | | * 默认选中节点 |
| | | * |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<String> dataScopeTreeKeys(String roleIds); |
| | | |
| | | /** |
| | | * 默认选中节点 |
| | | * |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<String> apiScopeTreeKeys(String roleIds); |
| | | |
| | | /** |
| | | * 获取配置的角色权限 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<Kv> authRoutes(BladeUser user); |
| | | |
| | | /** |
| | | * 删除菜单 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean removeMenu(String ids); |
| | | |
| | | /** |
| | | * 提交 |
| | | * |
| | | * @param menu |
| | | * @return |
| | | */ |
| | | boolean submit(Menu menu); |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/IParamService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.system.entity.Param; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | public interface IParamService extends BaseService<Param> { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | /** |
| | | * 获取参数值 |
| | | * |
| | | * @param paramKey 参数key |
| | | * @return String |
| | | */ |
| | | String getValue(String 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.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.system.entity.Post; |
| | | import org.springblade.system.vo.PostVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 岗位表 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IPostService extends BaseService<Post> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param post |
| | | * @return |
| | | */ |
| | | IPage<PostVO> selectPostPage(IPage<PostVO> page, PostVO post); |
| | | |
| | | /** |
| | | * 获取岗位ID |
| | | * |
| | | * @param tenantId |
| | | * @param postNames |
| | | * @return |
| | | */ |
| | | String getPostIds(String tenantId, String postNames); |
| | | |
| | | /** |
| | | * 获取岗位ID |
| | | * |
| | | * @param tenantId |
| | | * @param postNames |
| | | * @return |
| | | */ |
| | | String getPostIdsByFuzzy(String tenantId, String postNames); |
| | | |
| | | /** |
| | | * 获取岗位名 |
| | | * |
| | | * @param postIds |
| | | * @return |
| | | */ |
| | | List<String> getPostNames(String postIds); |
| | | |
| | | } |
| 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.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.system.entity.Region; |
| | | import org.springblade.system.excel.RegionExcel; |
| | | import org.springblade.system.vo.RegionVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 行政区划表 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IRegionService extends IService<Region> { |
| | | |
| | | /** |
| | | * 提交 |
| | | * |
| | | * @param region |
| | | * @return |
| | | */ |
| | | boolean submit(Region region); |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | boolean removeRegion(String id); |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentCode |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<RegionVO> lazyList(String parentCode, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentCode |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<RegionVO> lazyTree(String parentCode, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 导入区划数据 |
| | | * |
| | | * @param data |
| | | * @param isCovered |
| | | * @return |
| | | */ |
| | | void importRegion(List<RegionExcel> data, Boolean isCovered); |
| | | |
| | | /** |
| | | * 导出区划数据 |
| | | * |
| | | * @param queryWrapper |
| | | * @return |
| | | */ |
| | | List<RegionExcel> exportRegion(Wrapper<Region> queryWrapper); |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/IRoleMenuService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.system.entity.RoleMenu; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface IRoleMenuService extends IService<RoleMenu> { |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/IRoleScopeService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.system.entity.RoleScope; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface IRoleScopeService extends IService<RoleScope> { |
| | | |
| | | } |
| 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.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.system.entity.Role; |
| | | import org.springblade.system.vo.RoleVO; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IRoleService extends IService<Role> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param role |
| | | * @return |
| | | */ |
| | | IPage<RoleVO> selectRolePage(IPage<RoleVO> page, RoleVO role); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @param tenantId |
| | | * @return |
| | | */ |
| | | List<RoleVO> tree(String tenantId); |
| | | |
| | | /** |
| | | * 权限配置 |
| | | * |
| | | * @param roleIds 角色id集合 |
| | | * @param menuIds 菜单id集合 |
| | | * @param dataScopeIds 数据权限id集合 |
| | | * @param apiScopeIds 接口权限id集合 |
| | | * @return 是否成功 |
| | | */ |
| | | boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds); |
| | | |
| | | /** |
| | | * 获取角色ID |
| | | * |
| | | * @param tenantId |
| | | * @param roleNames |
| | | * @return |
| | | */ |
| | | String getRoleIds(String tenantId, String roleNames); |
| | | |
| | | /** |
| | | * 获取角色名 |
| | | * |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<String> getRoleNames(String roleIds); |
| | | |
| | | /** |
| | | * 获取角色名 |
| | | * |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<String> getRoleAliases(String roleIds); |
| | | |
| | | /** |
| | | * 提交 |
| | | * |
| | | * @param role |
| | | * @return |
| | | */ |
| | | boolean submit(Role role); |
| | | |
| | | /** |
| | | * 角色信息查询 |
| | | * |
| | | * @param roleName |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | List<RoleVO> search(String roleName, Long parentId); |
| | | |
| | | /** |
| | | * 删除角色 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean removeRole(String ids); |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/ITenantPackageService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.system.entity.TenantPackage; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 租户产品表 服务类 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface ITenantPackageService extends BaseService<TenantPackage> { |
| | | |
| | | } |
| 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.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.system.entity.Tenant; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface ITenantService extends BaseService<Tenant> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param tenant |
| | | * @return |
| | | */ |
| | | IPage<Tenant> selectTenantPage(IPage<Tenant> page, Tenant tenant); |
| | | |
| | | /** |
| | | * 根据租户编号获取实体 |
| | | * |
| | | * @param tenantId |
| | | * @return |
| | | */ |
| | | Tenant getByTenantId(String tenantId); |
| | | |
| | | /** |
| | | * 新增 |
| | | * |
| | | * @param tenant |
| | | * @return |
| | | */ |
| | | boolean submitTenant(Tenant tenant); |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean removeTenant(List<Long> ids); |
| | | |
| | | /** |
| | | * 配置租户授权 |
| | | * |
| | | * @param accountNumber |
| | | * @param expireTime |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean setting(Integer accountNumber, Date expireTime, String ids); |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/ITopMenuService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service; |
| | | |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.system.entity.TopMenu; |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 顶部菜单表 服务类 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | public interface ITopMenuService extends BaseService<TopMenu> { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | /** |
| | | * 顶部菜单配置 |
| | | * |
| | | * @param topMenuIds 顶部菜单id集合 |
| | | * @param menuIds 菜单id集合 |
| | | * @return 是否成功 |
| | | */ |
| | | boolean grant(@NotEmpty List<Long> topMenuIds, @NotEmpty List<Long> menuIds); |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/ITopMenuSettingService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.system.entity.TopMenuSetting; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface ITopMenuSettingService extends IService<TopMenuSetting> { |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/impl/ApiScopeServiceImpl.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service.impl; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.system.entity.ApiScope; |
| | | import org.springblade.system.mapper.ApiScopeMapper; |
| | | import org.springblade.system.service.IApiScopeService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Service |
| | | public class ApiScopeServiceImpl extends BaseServiceImpl<ApiScopeMapper, ApiScope> implements IApiScopeService { |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/impl/AuthClientServiceImpl.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service.impl; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.system.entity.AuthClient; |
| | | import org.springblade.system.mapper.AuthClientMapper; |
| | | import org.springblade.system.service.IAuthClientService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Service |
| | | public class AuthClientServiceImpl extends BaseServiceImpl<AuthClientMapper, AuthClient> implements IAuthClientService { |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/impl/DataScopeServiceImpl.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service.impl; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.system.entity.DataScope; |
| | | import org.springblade.system.mapper.DataScopeMapper; |
| | | import org.springblade.system.service.IDataScopeService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Service |
| | | public class DataScopeServiceImpl extends BaseServiceImpl<DataScopeMapper, DataScope> implements IDataScopeService { |
| | | |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | //import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | 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.SysCache; |
| | | import org.springblade.system.entity.Dept; |
| | | import org.springblade.system.mapper.DeptMapper; |
| | | import org.springblade.system.service.IDeptService; |
| | | import org.springblade.system.vo.DeptVO; |
| | | import org.springblade.system.wrapper.DeptWrapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements IDeptService { |
| | | |
| | | private static final String TENANT_ID = "tenantId"; |
| | | private static final String PARENT_ID = "parentId"; |
| | | |
| | | @Override |
| | | public List<DeptVO> lazyList(String tenantId, Long parentId, Map<String, Object> param) { |
| | | // 设置租户ID |
| | | if (AuthUtil.isAdministrator()) { |
| | | tenantId = StringPool.EMPTY; |
| | | } |
| | | String paramTenantId = Func.toStr(param.get(TENANT_ID)); |
| | | if (Func.isNotEmpty(paramTenantId) && AuthUtil.isAdministrator()) { |
| | | tenantId = paramTenantId; |
| | | } |
| | | // 判断点击搜索但是没有查询条件的情况 |
| | | if (Func.isEmpty(param.get(PARENT_ID)) && param.size() == 1) { |
| | | parentId = 0L; |
| | | } |
| | | // 判断数据权限控制,非超管角色只可看到本级及以下数据 |
| | | if (Func.toLong(parentId) == 0L && !AuthUtil.isAdministrator()) { |
| | | Long deptId = Func.firstLong(AuthUtil.getDeptId()); |
| | | Dept dept = SysCache.getDept(deptId); |
| | | if (dept.getParentId() != 0) { |
| | | parentId = dept.getParentId(); |
| | | } |
| | | } |
| | | // 判断点击搜索带有查询条件的情况 |
| | | if (Func.isEmpty(param.get(PARENT_ID)) && param.size() > 1 && Func.toLong(parentId) == 0L) { |
| | | parentId = null; |
| | | } |
| | | return baseMapper.lazyList(tenantId, parentId, param); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<DeptVO> tree(String tenantId) { |
| | | return ForestNodeMerger.merge(baseMapper.tree(tenantId)); |
| | | } |
| | | |
| | | @Override |
| | | public List<DeptVO> lazyTree(String tenantId, Long parentId) { |
| | | if (AuthUtil.isAdministrator()) { |
| | | tenantId = StringPool.EMPTY; |
| | | } |
| | | return ForestNodeMerger.merge(baseMapper.lazyTree(tenantId, parentId)); |
| | | } |
| | | |
| | | @Override |
| | | public String getDeptIds(String tenantId, String deptNames) { |
| | | List<Dept> deptList = baseMapper.selectList(Wrappers.<Dept>query().lambda().eq(Dept::getTenantId, tenantId).in(Dept::getDeptName, Func.toStrList(deptNames))); |
| | | if (deptList != null && deptList.size() > 0) { |
| | | return deptList.stream().map(dept -> Func.toStr(dept.getId())).distinct().collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String getDeptIdsByFuzzy(String tenantId, String deptNames) { |
| | | LambdaQueryWrapper<Dept> queryWrapper = Wrappers.<Dept>query().lambda().eq(Dept::getTenantId, tenantId); |
| | | queryWrapper.and(wrapper -> { |
| | | List<String> names = Func.toStrList(deptNames); |
| | | names.forEach(name -> wrapper.like(Dept::getDeptName, name).or()); |
| | | }); |
| | | List<Dept> deptList = baseMapper.selectList(queryWrapper); |
| | | if (deptList != null && deptList.size() > 0) { |
| | | return deptList.stream().map(dept -> Func.toStr(dept.getId())).distinct().collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getDeptNames(String deptIds) { |
| | | return baseMapper.getDeptNames(Func.toLongArray(deptIds)); |
| | | } |
| | | |
| | | @Override |
| | | public List<Dept> getDeptChild(Long deptId) { |
| | | return baseMapper.selectList(Wrappers.<Dept>query().lambda().like(Dept::getAncestors, deptId)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeDept(String ids) { |
| | | Long cnt = baseMapper.selectCount(Wrappers.<Dept>query().lambda().in(Dept::getParentId, Func.toLongList(ids))); |
| | | if (cnt > 0L) { |
| | | // throw new ServiceException("请先删除子节点!"); |
| | | } |
| | | return removeByIds(Func.toLongList(ids)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean submit(Dept dept) { |
| | | if (Func.isEmpty(dept.getParentId())) { |
| | | dept.setTenantId(AuthUtil.getTenantId()); |
| | | dept.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID)); |
| | | } |
| | | if (dept.getParentId() > 0) { |
| | | Dept parent = getById(dept.getParentId()); |
| | | if (Func.toLong(dept.getParentId()) == Func.toLong(dept.getId())) { |
| | | // throw new ServiceException("父节点不可选择自身!"); |
| | | } |
| | | dept.setTenantId(parent.getTenantId()); |
| | | String ancestors = parent.getAncestors() + StringPool.COMMA + dept.getParentId(); |
| | | dept.setAncestors(ancestors); |
| | | } |
| | | dept.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | return saveOrUpdate(dept); |
| | | } |
| | | |
| | | @Override |
| | | public List<DeptVO> search(String deptName, Long parentId) { |
| | | String tenantId = AuthUtil.getTenantId(); |
| | | LambdaQueryWrapper<Dept> queryWrapper = Wrappers.<Dept>query().lambda(); |
| | | if (Func.isNotEmpty(tenantId)) { |
| | | queryWrapper.eq(Dept::getTenantId, tenantId); |
| | | } |
| | | if (Func.isNotEmpty(deptName)) { |
| | | queryWrapper.like(Dept::getDeptName, deptName); |
| | | } |
| | | if (Func.isNotEmpty(parentId) && parentId > 0L) { |
| | | queryWrapper.eq(Dept::getParentId, parentId); |
| | | } |
| | | List<Dept> deptList = baseMapper.selectList(queryWrapper); |
| | | return DeptWrapper.build().listNodeVO(deptList); |
| | | } |
| | | |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | //import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | 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.system.entity.DictBiz; |
| | | import org.springblade.system.mapper.DictBizMapper; |
| | | import org.springblade.system.service.IDictBizService; |
| | | import org.springblade.system.vo.DictBizVO; |
| | | import org.springblade.system.wrapper.DictBizWrapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class DictBizServiceImpl extends ServiceImpl<DictBizMapper, DictBiz> implements IDictBizService { |
| | | |
| | | @Override |
| | | public List<DictBizVO> tree() { |
| | | return ForestNodeMerger.merge(baseMapper.tree()); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictBizVO> parentTree() { |
| | | return ForestNodeMerger.merge(baseMapper.parentTree()); |
| | | } |
| | | |
| | | @Override |
| | | public String getValue(String code, String dictKey) { |
| | | return Func.toStr(baseMapper.getValue(code, dictKey), StringPool.EMPTY); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictBiz> getList(String code) { |
| | | return baseMapper.getList(code); |
| | | } |
| | | |
| | | @Override |
| | | public boolean submit(DictBiz dict) { |
| | | LambdaQueryWrapper<DictBiz> lqw = Wrappers.<DictBiz>query().lambda().eq(DictBiz::getCode, dict.getCode()).eq(DictBiz::getDictKey, dict.getDictKey()); |
| | | Long cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(DictBiz::getId, dict.getId())); |
| | | if (cnt > 0L) { |
| | | // throw new ServiceException("当前字典键值已存在!"); |
| | | } |
| | | // 修改顶级字典后同步更新下属字典的编号 |
| | | if (Func.isNotEmpty(dict.getId()) && dict.getParentId().longValue() == BladeConstant.TOP_PARENT_ID) { |
| | | DictBiz parent = DictBizCache.getById(dict.getId()); |
| | | this.update(Wrappers.<DictBiz>update().lambda().set(DictBiz::getCode, dict.getCode()).eq(DictBiz::getCode, parent.getCode()).ne(DictBiz::getParentId, BladeConstant.TOP_PARENT_ID)); |
| | | } |
| | | if (Func.isEmpty(dict.getParentId())) { |
| | | dict.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | } |
| | | dict.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | CacheUtil.clear(DICT_CACHE); |
| | | return saveOrUpdate(dict); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeDict(String ids) { |
| | | Long cnt = baseMapper.selectCount(Wrappers.<DictBiz>query().lambda().in(DictBiz::getParentId, Func.toLongList(ids))); |
| | | if (cnt > 0L) { |
| | | // throw new ServiceException("请先删除子节点!"); |
| | | } |
| | | return removeByIds(Func.toLongList(ids)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<DictBizVO> parentList(Map<String, Object> dict, Query query) { |
| | | IPage<DictBiz> page = this.page(Condition.getPage(query), Condition.getQueryWrapper(dict, DictBiz.class).lambda().eq(DictBiz::getParentId, CommonConstant.TOP_PARENT_ID).orderByAsc(DictBiz::getSort)); |
| | | return DictBizWrapper.build().pageVO(page); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictBizVO> childList(Map<String, Object> dict, Long parentId) { |
| | | if (parentId < 0) { |
| | | return new ArrayList<>(); |
| | | } |
| | | dict.remove("parentId"); |
| | | DictBiz parentDict = DictBizCache.getById(parentId); |
| | | List<DictBiz> list = this.list(Condition.getQueryWrapper(dict, DictBiz.class).lambda().ne(DictBiz::getId, parentId).eq(DictBiz::getCode, parentDict.getCode()).orderByAsc(DictBiz::getSort)); |
| | | return DictBizWrapper.build().listNodeVO(list); |
| | | } |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | //import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | 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.system.entity.Dict; |
| | | import org.springblade.system.mapper.DictMapper; |
| | | import org.springblade.system.service.IDictService; |
| | | import org.springblade.system.vo.DictVO; |
| | | import org.springblade.system.wrapper.DictWrapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; |
| | | |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements IDictService { |
| | | |
| | | @Override |
| | | public IPage<DictVO> selectDictPage(IPage<DictVO> page, DictVO dict) { |
| | | return page.setRecords(baseMapper.selectDictPage(page, dict)); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictVO> tree() { |
| | | return ForestNodeMerger.merge(baseMapper.tree()); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictVO> parentTree() { |
| | | return ForestNodeMerger.merge(baseMapper.parentTree()); |
| | | } |
| | | |
| | | @Override |
| | | public String getValue(String code, String dictKey) { |
| | | return Func.toStr(baseMapper.getValue(code, dictKey), StringPool.EMPTY); |
| | | } |
| | | |
| | | @Override |
| | | public List<Dict> getList(String code) { |
| | | return baseMapper.getList(code); |
| | | } |
| | | |
| | | @Override |
| | | public boolean submit(Dict dict) { |
| | | LambdaQueryWrapper<Dict> lqw = Wrappers.<Dict>query().lambda().eq(Dict::getCode, dict.getCode()).eq(Dict::getDictKey, dict.getDictKey()); |
| | | Long cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(Dict::getId, dict.getId())); |
| | | if (cnt > 0L) { |
| | | // throw new ServiceException("当前字典键值已存在!"); |
| | | } |
| | | // 修改顶级字典后同步更新下属字典的编号 |
| | | if (Func.isNotEmpty(dict.getId()) && dict.getParentId().longValue() == BladeConstant.TOP_PARENT_ID) { |
| | | Dict parent = DictCache.getById(dict.getId()); |
| | | this.update(Wrappers.<Dict>update().lambda().set(Dict::getCode, dict.getCode()).eq(Dict::getCode, parent.getCode()).ne(Dict::getParentId, BladeConstant.TOP_PARENT_ID)); |
| | | } |
| | | if (Func.isEmpty(dict.getParentId())) { |
| | | dict.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | } |
| | | dict.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | CacheUtil.clear(DICT_CACHE, Boolean.FALSE); |
| | | return saveOrUpdate(dict); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeDict(String ids) { |
| | | Long cnt = baseMapper.selectCount(Wrappers.<Dict>query().lambda().in(Dict::getParentId, Func.toLongList(ids))); |
| | | if (cnt > 0L) { |
| | | // throw new ServiceException("请先删除子节点!"); |
| | | } |
| | | return removeByIds(Func.toLongList(ids)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<DictVO> parentList(Map<String, Object> dict, Query query) { |
| | | IPage<Dict> page = this.page(Condition.getPage(query), Condition.getQueryWrapper(dict, Dict.class).lambda().eq(Dict::getParentId, CommonConstant.TOP_PARENT_ID).orderByAsc(Dict::getSort)); |
| | | return DictWrapper.build().pageVO(page); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictVO> childList(Map<String, Object> dict, Long parentId) { |
| | | if (parentId < 0) { |
| | | return new ArrayList<>(); |
| | | } |
| | | dict.remove("parentId"); |
| | | Dict parentDict = DictCache.getById(parentId); |
| | | List<Dict> list = this.list(Condition.getQueryWrapper(dict, Dict.class).lambda().ne(Dict::getId, parentId).eq(Dict::getCode, parentDict.getCode()).orderByAsc(Dict::getSort)); |
| | | return DictWrapper.build().listNodeVO(list); |
| | | } |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | //import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.node.TreeNode; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.system.cache.SysCache; |
| | | import org.springblade.system.dto.MenuDTO; |
| | | import org.springblade.system.entity.*; |
| | | import org.springblade.system.mapper.MenuMapper; |
| | | import org.springblade.system.service.IMenuService; |
| | | import org.springblade.system.service.IRoleMenuService; |
| | | import org.springblade.system.service.IRoleScopeService; |
| | | import org.springblade.system.service.ITopMenuSettingService; |
| | | import org.springblade.system.vo.MenuVO; |
| | | import org.springblade.system.wrapper.MenuWrapper; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springblade.common.constant.CommonConstant.API_SCOPE_CATEGORY; |
| | | import static org.springblade.common.constant.CommonConstant.DATA_SCOPE_CATEGORY; |
| | | import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService { |
| | | |
| | | private final IRoleMenuService roleMenuService; |
| | | private final IRoleScopeService roleScopeService; |
| | | private final ITopMenuSettingService topMenuSettingService; |
| | | private final static String PARENT_ID = "parentId"; |
| | | private final static Integer MENU_CATEGORY = 1; |
| | | |
| | | @Override |
| | | public List<MenuVO> lazyList(Long parentId, Map<String, Object> param) { |
| | | if (Func.isEmpty(Func.toStr(param.get(PARENT_ID)))) { |
| | | parentId = null; |
| | | } |
| | | return baseMapper.lazyList(parentId, param); |
| | | } |
| | | |
| | | @Override |
| | | public List<MenuVO> lazyMenuList(Long parentId, Map<String, Object> param) { |
| | | if (Func.isEmpty(Func.toStr(param.get(PARENT_ID)))) { |
| | | parentId = null; |
| | | } |
| | | return baseMapper.lazyMenuList(parentId, param); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<MenuVO> routes(String roleId, Long topMenuId) { |
| | | if (StringUtil.isBlank(roleId)) { |
| | | return null; |
| | | } |
| | | List<Menu> allMenus = baseMapper.allMenu(); |
| | | List<Menu> roleMenus; |
| | | // 超级管理员并且不是顶部菜单请求则返回全部菜单 |
| | | if (AuthUtil.isAdministrator() && Func.isEmpty(topMenuId)) { |
| | | roleMenus = allMenus; |
| | | } |
| | | // 非超级管理员并且不是顶部菜单请求则返回对应角色权限菜单 |
| | | else if (!AuthUtil.isAdministrator() && Func.isEmpty(topMenuId)) { |
| | | roleMenus = tenantPackageMenu(baseMapper.roleMenuByRoleId(Func.toLongList(roleId))); |
| | | } |
| | | // 顶部菜单请求返回对应角色权限菜单 |
| | | else { |
| | | // 角色配置对应菜单 |
| | | List<Menu> roleIdMenus = baseMapper.roleMenuByRoleId(Func.toLongList(roleId)); |
| | | // 反向递归角色菜单所有父级 |
| | | List<Menu> routes = new LinkedList<>(roleIdMenus); |
| | | roleIdMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu)); |
| | | // 顶部配置对应菜单 |
| | | List<Menu> topIdMenus = baseMapper.roleMenuByTopMenuId(topMenuId); |
| | | // 筛选匹配角色对应的权限菜单 |
| | | roleMenus = topIdMenus.stream().filter(x -> |
| | | routes.stream().anyMatch(route -> route.getId().longValue() == x.getId().longValue()) |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | return buildRoutes(allMenus, roleMenus); |
| | | } |
| | | |
| | | private List<MenuVO> buildRoutes(List<Menu> allMenus, List<Menu> roleMenus) { |
| | | List<Menu> routes = new LinkedList<>(roleMenus); |
| | | roleMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu)); |
| | | routes.sort(Comparator.comparing(Menu::getSort)); |
| | | MenuWrapper menuWrapper = new MenuWrapper(); |
| | | List<Menu> collect = routes.stream().filter(x -> Func.equals(x.getCategory(), 1)).collect(Collectors.toList()); |
| | | return menuWrapper.listNodeVO(collect); |
| | | } |
| | | |
| | | private void recursion(List<Menu> allMenus, List<Menu> routes, Menu roleMenu) { |
| | | Optional<Menu> menu = allMenus.stream().filter(x -> Func.equals(x.getId(), roleMenu.getParentId())).findFirst(); |
| | | if (menu.isPresent() && !routes.contains(menu.get())) { |
| | | routes.add(menu.get()); |
| | | recursion(allMenus, routes, menu.get()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<MenuVO> buttons(String roleId) { |
| | | List<Menu> buttons = (AuthUtil.isAdministrator()) ? baseMapper.allButtons() : baseMapper.buttons(Func.toLongList(roleId)); |
| | | MenuWrapper menuWrapper = new MenuWrapper(); |
| | | return menuWrapper.listNodeVO(buttons); |
| | | } |
| | | |
| | | @Override |
| | | public List<TreeNode> tree() { |
| | | return ForestNodeMerger.merge(baseMapper.tree()); |
| | | } |
| | | |
| | | @Override |
| | | public List<TreeNode> grantTree(BladeUser user) { |
| | | List<TreeNode> menuTree = user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTree() : baseMapper.grantTreeByRole(Func.toLongList(user.getRoleId())); |
| | | return ForestNodeMerger.merge(tenantPackageTree(menuTree, user.getTenantId())); |
| | | } |
| | | |
| | | @Override |
| | | public List<TreeNode> grantTopTree(BladeUser user) { |
| | | List<TreeNode> menuTree = user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTopTree() : baseMapper.grantTopTreeByRole(Func.toLongList(user.getRoleId())); |
| | | return ForestNodeMerger.merge(tenantPackageTree(menuTree, user.getTenantId())); |
| | | } |
| | | |
| | | /** |
| | | * 租户菜单权限自定义筛选 |
| | | */ |
| | | private List<TreeNode> tenantPackageTree(List<TreeNode> menuTree, String tenantId) { |
| | | TenantPackage tenantPackage = SysCache.getTenantPackage(tenantId); |
| | | if (!AuthUtil.isAdministrator() && Func.isNotEmpty(tenantPackage) && tenantPackage.getId() > 0L) { |
| | | List<Long> menuIds = Func.toLongList(tenantPackage.getMenuId()); |
| | | // 筛选出两者菜单交集集合 |
| | | List<TreeNode> collect = menuTree.stream().filter(x -> menuIds.contains(x.getId())).collect(Collectors.toList()); |
| | | // 创建递归基础集合 |
| | | List<TreeNode> packageTree = new LinkedList<>(collect); |
| | | // 递归筛选出菜单集合所有父级 |
| | | collect.forEach(treeNode -> recursionParent(menuTree, packageTree, treeNode)); |
| | | // 递归筛选出菜单集合所有子级 |
| | | collect.forEach(treeNode -> recursionChild(menuTree, packageTree, treeNode)); |
| | | // 合并在一起返回最终集合 |
| | | return packageTree; |
| | | } |
| | | return menuTree; |
| | | } |
| | | |
| | | /** |
| | | * 父节点递归 |
| | | */ |
| | | public void recursionParent(List<TreeNode> menuTree, List<TreeNode> packageTree, TreeNode treeNode) { |
| | | Optional<TreeNode> node = menuTree.stream().filter(x -> Func.equals(x.getId(), treeNode.getParentId())).findFirst(); |
| | | if (node.isPresent() && !packageTree.contains(node.get())) { |
| | | packageTree.add(node.get()); |
| | | recursionParent(menuTree, packageTree, node.get()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 子节点递归 |
| | | */ |
| | | public void recursionChild(List<TreeNode> menuTree, List<TreeNode> packageTree, TreeNode treeNode) { |
| | | List<TreeNode> nodes = menuTree.stream().filter(x -> Func.equals(x.getParentId(), treeNode.getId())).collect(Collectors.toList()); |
| | | nodes.forEach(node -> { |
| | | if (!packageTree.contains(node)) { |
| | | packageTree.add(node); |
| | | recursionChild(menuTree, packageTree, node); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 租户菜单权限自定义筛选 |
| | | */ |
| | | private List<Menu> tenantPackageMenu(List<Menu> menu) { |
| | | TenantPackage tenantPackage = SysCache.getTenantPackage(AuthUtil.getTenantId()); |
| | | if (Func.isNotEmpty(tenantPackage) && tenantPackage.getId() > 0L) { |
| | | List<Long> menuIds = Func.toLongList(tenantPackage.getMenuId()); |
| | | menu = menu.stream().filter(x -> menuIds.contains(x.getId())).collect(Collectors.toList()); |
| | | } |
| | | return menu; |
| | | } |
| | | |
| | | @Override |
| | | public List<TreeNode> grantDataScopeTree(BladeUser user) { |
| | | return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantDataScopeTree() : baseMapper.grantDataScopeTreeByRole(Func.toLongList(user.getRoleId()))); |
| | | } |
| | | |
| | | @Override |
| | | public List<TreeNode> grantApiScopeTree(BladeUser user) { |
| | | return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantApiScopeTree() : baseMapper.grantApiScopeTreeByRole(Func.toLongList(user.getRoleId()))); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> roleTreeKeys(String roleIds) { |
| | | List<RoleMenu> roleMenus = roleMenuService.list(Wrappers.<RoleMenu>query().lambda().in(RoleMenu::getRoleId, Func.toLongList(roleIds))); |
| | | return roleMenus.stream().map(roleMenu -> Func.toStr(roleMenu.getMenuId())).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> topTreeKeys(String topMenuIds) { |
| | | List<TopMenuSetting> settings = topMenuSettingService.list(Wrappers.<TopMenuSetting>query().lambda().in(TopMenuSetting::getTopMenuId, Func.toLongList(topMenuIds))); |
| | | return settings.stream().map(setting -> Func.toStr(setting.getMenuId())).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> dataScopeTreeKeys(String roleIds) { |
| | | List<RoleScope> roleScopes = roleScopeService.list(Wrappers.<RoleScope>query().lambda().eq(RoleScope::getScopeCategory, DATA_SCOPE_CATEGORY).in(RoleScope::getRoleId, Func.toLongList(roleIds))); |
| | | return roleScopes.stream().map(roleScope -> Func.toStr(roleScope.getScopeId())).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> apiScopeTreeKeys(String roleIds) { |
| | | List<RoleScope> roleScopes = roleScopeService.list(Wrappers.<RoleScope>query().lambda().eq(RoleScope::getScopeCategory, API_SCOPE_CATEGORY).in(RoleScope::getRoleId, Func.toLongList(roleIds))); |
| | | return roleScopes.stream().map(roleScope -> Func.toStr(roleScope.getScopeId())).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | @Cacheable(cacheNames = MENU_CACHE, key = "'auth:routes:' + #user.roleId") |
| | | public List<Kv> authRoutes(BladeUser user) { |
| | | List<MenuDTO> routes = baseMapper.authRoutes(Func.toLongList(user.getRoleId())); |
| | | List<Kv> list = new ArrayList<>(); |
| | | routes.forEach(route -> list.add(Kv.create().set(route.getPath(), Kv.create().set("authority", Func.toStrArray(route.getAlias()))))); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeMenu(String ids) { |
| | | Long cnt = baseMapper.selectCount(Wrappers.<Menu>query().lambda().in(Menu::getParentId, Func.toLongList(ids))); |
| | | if (cnt > 0L) { |
| | | // throw new ServiceException("请先删除子节点!"); |
| | | } |
| | | return removeByIds(Func.toLongList(ids)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean submit(Menu menu) { |
| | | LambdaQueryWrapper<Menu> menuQueryWrapper = Wrappers.lambdaQuery(); |
| | | if (menu.getId() == null) { |
| | | menuQueryWrapper.eq(Menu::getCode, menu.getCode()).or( |
| | | wrapper -> wrapper.eq(Menu::getName, menu.getName()).eq(Menu::getCategory, MENU_CATEGORY) |
| | | ); |
| | | } else { |
| | | menuQueryWrapper.ne(Menu::getId, menu.getId()).and( |
| | | wrapper -> wrapper.eq(Menu::getCode, menu.getCode()).or( |
| | | o -> o.eq(Menu::getName, menu.getName()).eq(Menu::getCategory, MENU_CATEGORY) |
| | | ) |
| | | ); |
| | | } |
| | | Long cnt = baseMapper.selectCount(menuQueryWrapper); |
| | | if (cnt > 0L) { |
| | | // throw new ServiceException("菜单名或编号已存在!"); |
| | | } |
| | | if (menu.getParentId() == null && menu.getId() == null) { |
| | | menu.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | } |
| | | if (menu.getParentId() != null && menu.getId() == null) { |
| | | Menu parentMenu = baseMapper.selectById(menu.getParentId()); |
| | | if (parentMenu != null && parentMenu.getCategory() != 1) { |
| | | // throw new ServiceException("父节点只可选择菜单类型!"); |
| | | } |
| | | } |
| | | menu.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | return saveOrUpdate(menu); |
| | | } |
| | | |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.system.entity.Param; |
| | | import org.springblade.system.mapper.ParamMapper; |
| | | import org.springblade.system.service.IParamService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class ParamServiceImpl extends BaseServiceImpl<ParamMapper, Param> implements IParamService { |
| | | |
| | | @Override |
| | | public String getValue(String paramKey) { |
| | | Param param = this.getOne(Wrappers.<Param>query().lambda().eq(Param::getParamKey, paramKey)); |
| | | return param.getParamValue(); |
| | | } |
| | | |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.system.entity.Post; |
| | | import org.springblade.system.mapper.PostMapper; |
| | | import org.springblade.system.service.IPostService; |
| | | import org.springblade.system.vo.PostVO; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 岗位表 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class PostServiceImpl extends BaseServiceImpl<PostMapper, Post> implements IPostService { |
| | | |
| | | @Override |
| | | public IPage<PostVO> selectPostPage(IPage<PostVO> page, PostVO post) { |
| | | return page.setRecords(baseMapper.selectPostPage(page, post)); |
| | | } |
| | | |
| | | @Override |
| | | public String getPostIds(String tenantId, String postNames) { |
| | | List<Post> postList = baseMapper.selectList(Wrappers.<Post>query().lambda().eq(Post::getTenantId, tenantId).in(Post::getPostName, Func.toStrList(postNames))); |
| | | if (postList != null && postList.size() > 0) { |
| | | return postList.stream().map(post -> Func.toStr(post.getId())).distinct().collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String getPostIdsByFuzzy(String tenantId, String postNames) { |
| | | LambdaQueryWrapper<Post> queryWrapper = Wrappers.<Post>query().lambda().eq(Post::getTenantId, tenantId); |
| | | queryWrapper.and(wrapper -> { |
| | | List<String> names = Func.toStrList(postNames); |
| | | names.forEach(name -> wrapper.like(Post::getPostName, name).or()); |
| | | }); |
| | | List<Post> postList = baseMapper.selectList(queryWrapper); |
| | | if (postList != null && postList.size() > 0) { |
| | | return postList.stream().map(post -> Func.toStr(post.getId())).distinct().collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getPostNames(String postIds) { |
| | | return baseMapper.getPostNames(Func.toLongArray(postIds)); |
| | | } |
| | | |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | //import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.system.entity.Region; |
| | | import org.springblade.system.excel.RegionExcel; |
| | | import org.springblade.system.mapper.RegionMapper; |
| | | import org.springblade.system.service.IRegionService; |
| | | import org.springblade.system.vo.RegionVO; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.system.cache.RegionCache.*; |
| | | |
| | | |
| | | /** |
| | | * 行政区划表 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements IRegionService { |
| | | |
| | | @Override |
| | | public boolean submit(Region region) { |
| | | Long cnt = baseMapper.selectCount(Wrappers.<Region>query().lambda().eq(Region::getCode, region.getCode())); |
| | | if (cnt > 0L) { |
| | | return this.updateById(region); |
| | | } |
| | | // 设置祖区划编号 |
| | | Region parent = getByCode(region.getParentCode()); |
| | | if (Func.isNotEmpty(parent) || Func.isNotEmpty(parent.getCode())) { |
| | | String ancestors = parent.getAncestors() + StringPool.COMMA + parent.getCode(); |
| | | region.setAncestors(ancestors); |
| | | } |
| | | // 设置省、市、区、镇、村 |
| | | Integer level = region.getRegionLevel(); |
| | | String code = region.getCode(); |
| | | String name = region.getName(); |
| | | if (level == PROVINCE_LEVEL) { |
| | | region.setProvinceCode(code); |
| | | region.setProvinceName(name); |
| | | } else if (level == CITY_LEVEL) { |
| | | region.setCityCode(code); |
| | | region.setCityName(name); |
| | | } else if (level == DISTRICT_LEVEL) { |
| | | region.setDistrictCode(code); |
| | | region.setDistrictName(name); |
| | | } else if (level == TOWN_LEVEL) { |
| | | region.setTownCode(code); |
| | | region.setTownName(name); |
| | | } else if (level == VILLAGE_LEVEL) { |
| | | region.setVillageCode(code); |
| | | region.setVillageName(name); |
| | | } |
| | | return this.save(region); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeRegion(String id) { |
| | | Long cnt = baseMapper.selectCount(Wrappers.<Region>query().lambda().eq(Region::getParentCode, id)); |
| | | if (cnt > 0L) { |
| | | // throw new ServiceException("请先删除子节点!"); |
| | | } |
| | | return removeById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<RegionVO> lazyList(String parentCode, Map<String, Object> param) { |
| | | return baseMapper.lazyList(parentCode, param); |
| | | } |
| | | |
| | | @Override |
| | | public List<RegionVO> lazyTree(String parentCode, Map<String, Object> param) { |
| | | return baseMapper.lazyTree(parentCode, param); |
| | | } |
| | | |
| | | @Override |
| | | public void importRegion(List<RegionExcel> data, Boolean isCovered) { |
| | | List<Region> list = new ArrayList<>(); |
| | | data.forEach(regionExcel -> { |
| | | Region region = BeanUtil.copy(regionExcel, Region.class); |
| | | list.add(region); |
| | | }); |
| | | if (isCovered) { |
| | | this.saveOrUpdateBatch(list); |
| | | } else { |
| | | this.saveBatch(list); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<RegionExcel> exportRegion(Wrapper<Region> queryWrapper) { |
| | | return baseMapper.exportRegion(queryWrapper); |
| | | } |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/impl/RoleMenuServiceImpl.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service.impl; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.system.entity.RoleMenu; |
| | | import org.springblade.system.mapper.RoleMenuMapper; |
| | | import org.springblade.system.service.IRoleMenuService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Service |
| | | public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements IRoleMenuService { |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/impl/RoleScopeServiceImpl.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service.impl; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.system.entity.RoleScope; |
| | | import org.springblade.system.mapper.RoleScopeMapper; |
| | | import org.springblade.system.service.IRoleScopeService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Service |
| | | public class RoleScopeServiceImpl extends ServiceImpl<RoleScopeMapper, RoleScope> implements IRoleScopeService { |
| | | |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | //import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.CollectionUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.system.entity.Role; |
| | | import org.springblade.system.entity.RoleMenu; |
| | | import org.springblade.system.entity.RoleScope; |
| | | import org.springblade.system.mapper.RoleMapper; |
| | | import org.springblade.system.service.IRoleMenuService; |
| | | import org.springblade.system.service.IRoleScopeService; |
| | | import org.springblade.system.service.IRoleService; |
| | | import org.springblade.system.vo.RoleVO; |
| | | import org.springblade.system.wrapper.RoleWrapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springblade.common.constant.CommonConstant.API_SCOPE_CATEGORY; |
| | | import static org.springblade.common.constant.CommonConstant.DATA_SCOPE_CATEGORY; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @Validated |
| | | @AllArgsConstructor |
| | | public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService { |
| | | |
| | | private final IRoleMenuService roleMenuService; |
| | | private final IRoleScopeService roleScopeService; |
| | | |
| | | @Override |
| | | public IPage<RoleVO> selectRolePage(IPage<RoleVO> page, RoleVO role) { |
| | | return page.setRecords(baseMapper.selectRolePage(page, role)); |
| | | } |
| | | |
| | | @Override |
| | | public List<RoleVO> tree(String tenantId) { |
| | | String userRole = AuthUtil.getUserRole(); |
| | | String excludeRole = null; |
| | | if (!CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMIN) && !CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMINISTRATOR)) { |
| | | excludeRole = RoleConstant.ADMINISTRATOR; |
| | | } |
| | | return ForestNodeMerger.merge(baseMapper.tree(tenantId, excludeRole)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds) { |
| | | return grantRoleMenu(roleIds, menuIds) && grantDataScope(roleIds, dataScopeIds) && grantApiScope(roleIds, apiScopeIds); |
| | | } |
| | | |
| | | private boolean grantRoleMenu(List<Long> roleIds, List<Long> menuIds) { |
| | | // 防止越权配置超管角色 |
| | | Long administratorCount = baseMapper.selectCount(Wrappers.<Role>query().lambda().eq(Role::getRoleAlias, RoleConstant.ADMINISTRATOR).in(Role::getId, roleIds)); |
| | | if (!AuthUtil.isAdministrator() && administratorCount > 0L) { |
| | | // throw new ServiceException("无权配置超管角色!"); |
| | | } |
| | | // 防止越权配置管理员角色 |
| | | Long adminCount = baseMapper.selectCount(Wrappers.<Role>query().lambda().eq(Role::getRoleAlias, RoleConstant.ADMIN).in(Role::getId, roleIds)); |
| | | if (!AuthUtil.isAdmin() && adminCount > 0L) { |
| | | // throw new ServiceException("无权配置管理员角色!"); |
| | | } |
| | | // 删除角色配置的菜单集合 |
| | | roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().in(RoleMenu::getRoleId, roleIds)); |
| | | // 组装配置 |
| | | List<RoleMenu> roleMenus = new ArrayList<>(); |
| | | roleIds.forEach(roleId -> menuIds.forEach(menuId -> { |
| | | RoleMenu roleMenu = new RoleMenu(); |
| | | roleMenu.setRoleId(roleId); |
| | | roleMenu.setMenuId(menuId); |
| | | roleMenus.add(roleMenu); |
| | | })); |
| | | // 新增配置 |
| | | roleMenuService.saveBatch(roleMenus); |
| | | // 递归设置下属角色菜单集合 |
| | | recursionRoleMenu(roleIds, menuIds); |
| | | return true; |
| | | } |
| | | |
| | | private void recursionRoleMenu(List<Long> roleIds, List<Long> menuIds) { |
| | | roleIds.forEach(roleId -> baseMapper.selectList(Wrappers.<Role>query().lambda().eq(Role::getParentId, roleId)).forEach(role -> { |
| | | List<RoleMenu> roleMenuList = roleMenuService.list(Wrappers.<RoleMenu>query().lambda().eq(RoleMenu::getRoleId, role.getId())); |
| | | // 子节点过滤出父节点删除的菜单集合 |
| | | List<Long> collectRoleMenuIds = roleMenuList.stream().map(RoleMenu::getMenuId).filter(menuId -> !menuIds.contains(menuId)).collect(Collectors.toList()); |
| | | if (collectRoleMenuIds.size() > 0) { |
| | | // 删除子节点权限外的菜单集合 |
| | | roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().eq(RoleMenu::getRoleId, role.getId()).in(RoleMenu::getMenuId, collectRoleMenuIds)); |
| | | // 递归设置下属角色菜单集合 |
| | | recursionRoleMenu(Collections.singletonList(role.getId()), menuIds); |
| | | } |
| | | })); |
| | | } |
| | | |
| | | private boolean grantDataScope(List<Long> roleIds, List<Long> dataScopeIds) { |
| | | // 删除角色配置的数据权限集合 |
| | | roleScopeService.remove(Wrappers.<RoleScope>update().lambda().eq(RoleScope::getScopeCategory, DATA_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds)); |
| | | // 组装配置 |
| | | List<RoleScope> roleDataScopes = new ArrayList<>(); |
| | | roleIds.forEach(roleId -> dataScopeIds.forEach(scopeId -> { |
| | | RoleScope roleScope = new RoleScope(); |
| | | roleScope.setScopeCategory(DATA_SCOPE_CATEGORY); |
| | | roleScope.setRoleId(roleId); |
| | | roleScope.setScopeId(scopeId); |
| | | roleDataScopes.add(roleScope); |
| | | })); |
| | | // 新增配置 |
| | | roleScopeService.saveBatch(roleDataScopes); |
| | | return true; |
| | | } |
| | | |
| | | private boolean grantApiScope(List<Long> roleIds, List<Long> apiScopeIds) { |
| | | // 删除角色配置的接口权限集合 |
| | | roleScopeService.remove(Wrappers.<RoleScope>update().lambda().eq(RoleScope::getScopeCategory, API_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds)); |
| | | // 组装配置 |
| | | List<RoleScope> roleApiScopes = new ArrayList<>(); |
| | | roleIds.forEach(roleId -> apiScopeIds.forEach(scopeId -> { |
| | | RoleScope roleScope = new RoleScope(); |
| | | roleScope.setScopeCategory(API_SCOPE_CATEGORY); |
| | | roleScope.setScopeId(scopeId); |
| | | roleScope.setRoleId(roleId); |
| | | roleApiScopes.add(roleScope); |
| | | })); |
| | | // 新增配置 |
| | | roleScopeService.saveBatch(roleApiScopes); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public String getRoleIds(String tenantId, String roleNames) { |
| | | List<Role> roleList = baseMapper.selectList(Wrappers.<Role>query().lambda().eq(Role::getTenantId, tenantId).in(Role::getRoleName, Func.toStrList(roleNames))); |
| | | if (roleList != null && roleList.size() > 0) { |
| | | return roleList.stream().map(role -> Func.toStr(role.getId())).distinct().collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getRoleNames(String roleIds) { |
| | | return baseMapper.getRoleNames(Func.toLongArray(roleIds)); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getRoleAliases(String roleIds) { |
| | | return baseMapper.getRoleAliases(Func.toLongArray(roleIds)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean submit(Role role) { |
| | | if (!AuthUtil.isAdministrator()) { |
| | | if (Func.toStr(role.getRoleAlias()).equals(RoleConstant.ADMINISTRATOR)) { |
| | | // throw new ServiceException("无权限创建超管角色!"); |
| | | } |
| | | } |
| | | if (Func.isEmpty(role.getParentId())) { |
| | | role.setTenantId(AuthUtil.getTenantId()); |
| | | role.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | } |
| | | if (role.getParentId() > 0) { |
| | | Role parent = getById(role.getParentId()); |
| | | if (Func.toLong(role.getParentId()) == Func.toLong(role.getId())) { |
| | | // throw new ServiceException("父节点不可选择自身!"); |
| | | } |
| | | role.setTenantId(parent.getTenantId()); |
| | | } |
| | | role.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | return saveOrUpdate(role); |
| | | } |
| | | |
| | | @Override |
| | | public List<RoleVO> search(String roleName, Long parentId) { |
| | | String tenantId = AuthUtil.getTenantId(); |
| | | LambdaQueryWrapper<Role> queryWrapper = Wrappers.<Role>query().lambda(); |
| | | if (Func.isNotEmpty(roleName)) { |
| | | queryWrapper.like(Role::getRoleName, roleName); |
| | | } |
| | | if (Func.isNotEmpty(parentId) && parentId > 0L) { |
| | | queryWrapper.eq(Role::getParentId, parentId); |
| | | } |
| | | if (Func.isNotEmpty(tenantId)) { |
| | | queryWrapper.eq(Role::getTenantId, tenantId); |
| | | } |
| | | List<Role> roleList = baseMapper.selectList(queryWrapper); |
| | | return RoleWrapper.build().listNodeVO(roleList); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeRole(String ids) { |
| | | Long cnt = baseMapper.selectCount(Wrappers.<Role>query().lambda().in(Role::getParentId, Func.toLongList(ids))); |
| | | if (cnt > 0L) { |
| | | // throw new ServiceException("请先删除子节点!"); |
| | | } |
| | | return removeByIds(Func.toLongList(ids)); |
| | | } |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/impl/TenantPackageServiceImpl.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service.impl; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.system.entity.TenantPackage; |
| | | import org.springblade.system.mapper.TenantPackageMapper; |
| | | import org.springblade.system.service.ITenantPackageService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 租户产品表 服务实现类 |
| | | * |
| | | * @author Chill |
| | | * @author BladeX |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Service |
| | | public class TenantPackageServiceImpl extends BaseServiceImpl<TenantPackageMapper, TenantPackage> implements ITenantPackageService { |
| | | |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | //import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.tenant.TenantId; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.jackson.JsonUtil; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.DesUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.system.cache.ParamCache; |
| | | import org.springblade.system.entity.*; |
| | | import org.springblade.system.mapper.TenantMapper; |
| | | import org.springblade.system.service.*; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.enums.UserEnum; |
| | | import org.springblade.system.user.feign.IUserClient; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springblade.common.constant.TenantConstant.*; |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> implements ITenantService { |
| | | |
| | | private final TenantId tenantId; |
| | | private final IRoleService roleService; |
| | | private final IMenuService menuService; |
| | | private final IDeptService deptService; |
| | | private final IPostService postService; |
| | | private final IRoleMenuService roleMenuService; |
| | | private final IDictBizService dictBizService; |
| | | private final IUserClient userClient; |
| | | |
| | | @Override |
| | | public IPage<Tenant> selectTenantPage(IPage<Tenant> page, Tenant tenant) { |
| | | return page.setRecords(baseMapper.selectTenantPage(page, tenant)); |
| | | } |
| | | |
| | | @Override |
| | | public Tenant getByTenantId(String tenantId) { |
| | | return getOne(Wrappers.<Tenant>query().lambda().eq(Tenant::getTenantId, tenantId)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean submitTenant(Tenant tenant) { |
| | | if (Func.isEmpty(tenant.getId())) { |
| | | List<Tenant> tenants = baseMapper.selectList(Wrappers.<Tenant>query().lambda().eq(Tenant::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | List<String> codes = tenants.stream().map(Tenant::getTenantId).collect(Collectors.toList()); |
| | | String tenantId = getTenantId(codes); |
| | | tenant.setTenantId(tenantId); |
| | | // 获取参数配置的账号额度 |
| | | int accountNumber = Func.toInt(ParamCache.getValue(ACCOUNT_NUMBER_KEY), DEFAULT_ACCOUNT_NUMBER); |
| | | tenant.setAccountNumber(accountNumber); |
| | | // 新建租户对应的默认角色 |
| | | Role role = new Role(); |
| | | role.setTenantId(tenantId); |
| | | role.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | role.setRoleName("管理员"); |
| | | role.setRoleAlias("admin"); |
| | | role.setSort(2); |
| | | role.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | roleService.save(role); |
| | | // 新建租户对应的角色菜单权限 |
| | | LinkedList<Menu> userMenus = new LinkedList<>(); |
| | | // 获取参数配置的默认菜单集合,逗号隔开 |
| | | List<String> menuCodes = Func.toStrList(ParamCache.getValue(ACCOUNT_MENU_CODE_KEY)); |
| | | List<Menu> menus = getMenus((menuCodes.size() > 0 ? menuCodes : MENU_CODES), userMenus); |
| | | List<RoleMenu> roleMenus = new ArrayList<>(); |
| | | menus.forEach(menu -> { |
| | | RoleMenu roleMenu = new RoleMenu(); |
| | | roleMenu.setMenuId(menu.getId()); |
| | | roleMenu.setRoleId(role.getId()); |
| | | roleMenus.add(roleMenu); |
| | | }); |
| | | roleMenuService.saveBatch(roleMenus); |
| | | // 新建租户对应的默认部门 |
| | | Dept dept = new Dept(); |
| | | dept.setTenantId(tenantId); |
| | | dept.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID)); |
| | | dept.setDeptName(tenant.getTenantName()); |
| | | dept.setFullName(tenant.getTenantName()); |
| | | dept.setDeptCategory(1); |
| | | dept.setSort(2); |
| | | dept.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | deptService.save(dept); |
| | | // 新建租户对应的默认岗位 |
| | | Post post = new Post(); |
| | | post.setTenantId(tenantId); |
| | | post.setCategory(1); |
| | | post.setPostCode("ceo"); |
| | | post.setPostName("首席执行官"); |
| | | post.setSort(1); |
| | | postService.save(post); |
| | | // 新建租户对应的默认业务字典 |
| | | LinkedList<DictBiz> dictBizs = new LinkedList<>(); |
| | | List<DictBiz> dictBizList = getDictBizs(tenantId, dictBizs); |
| | | dictBizService.saveBatch(dictBizList); |
| | | // 新建租户对应的默认管理用户 |
| | | User user = new User(); |
| | | user.setTenantId(tenantId); |
| | | user.setName("admin"); |
| | | user.setRealName("admin"); |
| | | user.setAccount("admin"); |
| | | // 获取参数配置的密码 |
| | | String password = Func.toStr(ParamCache.getValue(PASSWORD_KEY), DEFAULT_PASSWORD); |
| | | user.setPassword(password); |
| | | user.setRoleId(String.valueOf(role.getId())); |
| | | user.setDeptId(String.valueOf(dept.getId())); |
| | | user.setPostId(String.valueOf(post.getId())); |
| | | user.setBirthday(new Date()); |
| | | user.setSex(1); |
| | | user.setUserType(UserEnum.WEB.getCategory()); |
| | | user.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | boolean temp = super.saveOrUpdate(tenant); |
| | | R<Boolean> result = userClient.saveUser(user); |
| | | if (!result.isSuccess()) { |
| | | // throw new ServiceException(result.getMsg()); |
| | | } |
| | | return temp; |
| | | } else { |
| | | CacheUtil.clear(SYS_CACHE, tenant.getTenantId()); |
| | | return super.saveOrUpdate(tenant); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean removeTenant(List<Long> ids) { |
| | | List<String> tenantIds = this.list(Wrappers.<Tenant>query().lambda().in(Tenant::getId, ids)) |
| | | .stream().map(tenant -> Func.toStr(tenant.getTenantId())).distinct().collect(Collectors.toList()); |
| | | CacheUtil.clear(SYS_CACHE, tenantIds); |
| | | if (tenantIds.contains(BladeConstant.ADMIN_TENANT_ID)) { |
| | | // throw new ServiceException("不可删除管理租户!"); |
| | | } |
| | | boolean tenantTemp = this.deleteLogic(ids); |
| | | R<Boolean> result = userClient.removeUser(StringUtil.join(tenantIds)); |
| | | if (!result.isSuccess()) { |
| | | // throw new ServiceException(result.getMsg()); |
| | | } |
| | | return tenantTemp; |
| | | } |
| | | |
| | | @Override |
| | | public boolean setting(Integer accountNumber, Date expireTime, String ids) { |
| | | List<String> tenantIds = this.list(Wrappers.<Tenant>query().lambda().in(Tenant::getId, ids)) |
| | | .stream().map(tenant -> Func.toStr(tenant.getTenantId())).distinct().collect(Collectors.toList()); |
| | | CacheUtil.clear(SYS_CACHE, tenantIds); |
| | | Func.toLongList(ids).forEach(id -> { |
| | | Kv kv = Kv.create().set("accountNumber", accountNumber).set("expireTime", expireTime).set("id", id); |
| | | String licenseKey = DesUtil.encryptToHex(JsonUtil.toJson(kv), DES_KEY); |
| | | update( |
| | | Wrappers.<Tenant>update().lambda() |
| | | .set(Tenant::getAccountNumber, accountNumber) |
| | | .set(Tenant::getExpireTime, expireTime) |
| | | .set(Tenant::getLicenseKey, licenseKey) |
| | | .eq(Tenant::getId, id) |
| | | ); |
| | | }); |
| | | return true; |
| | | } |
| | | |
| | | private String getTenantId(List<String> codes) { |
| | | String code = tenantId.generate(); |
| | | if (codes.contains(code)) { |
| | | return getTenantId(codes); |
| | | } |
| | | return code; |
| | | } |
| | | |
| | | private List<Menu> getMenus(List<String> codes, LinkedList<Menu> menus) { |
| | | codes.forEach(code -> { |
| | | Menu menu = menuService.getOne(Wrappers.<Menu>query().lambda().eq(Menu::getCode, code).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | if (menu != null) { |
| | | menus.add(menu); |
| | | recursionMenu(menu.getId(), menus); |
| | | } |
| | | }); |
| | | return menus; |
| | | } |
| | | |
| | | private void recursionMenu(Long parentId, LinkedList<Menu> menus) { |
| | | List<Menu> menuList = menuService.list(Wrappers.<Menu>query().lambda().eq(Menu::getParentId, parentId).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | menus.addAll(menuList); |
| | | menuList.forEach(menu -> recursionMenu(menu.getId(), menus)); |
| | | } |
| | | |
| | | private List<DictBiz> getDictBizs(String tenantId, LinkedList<DictBiz> dictBizs) { |
| | | List<DictBiz> dictBizList = dictBizService.list(Wrappers.<DictBiz>query().lambda().eq(DictBiz::getParentId, BladeConstant.TOP_PARENT_ID).eq(DictBiz::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | dictBizList.forEach(dictBiz -> { |
| | | Long oldParentId = dictBiz.getId(); |
| | | Long newParentId = IdWorker.getId(); |
| | | dictBiz.setId(newParentId); |
| | | dictBiz.setTenantId(tenantId); |
| | | dictBizs.add(dictBiz); |
| | | recursionDictBiz(tenantId, oldParentId, newParentId, dictBizs); |
| | | }); |
| | | return dictBizs; |
| | | } |
| | | |
| | | private void recursionDictBiz(String tenantId, Long oldParentId, Long newParentId, LinkedList<DictBiz> dictBizs) { |
| | | List<DictBiz> dictBizList = dictBizService.list(Wrappers.<DictBiz>query().lambda().eq(DictBiz::getParentId, oldParentId).eq(DictBiz::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | dictBizList.forEach(dictBiz -> { |
| | | Long oldSubParentId = dictBiz.getId(); |
| | | Long newSubParentId = IdWorker.getId(); |
| | | dictBiz.setId(newSubParentId); |
| | | dictBiz.setTenantId(tenantId); |
| | | dictBiz.setParentId(newParentId); |
| | | dictBizs.add(dictBiz); |
| | | recursionDictBiz(tenantId, oldSubParentId, newSubParentId, dictBizs); |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.system.entity.TopMenu; |
| | | import org.springblade.system.entity.TopMenuSetting; |
| | | import org.springblade.system.mapper.TopMenuMapper; |
| | | import org.springblade.system.service.ITopMenuService; |
| | | import org.springblade.system.service.ITopMenuSettingService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 顶部菜单表 服务实现类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class TopMenuServiceImpl extends BaseServiceImpl<TopMenuMapper, TopMenu> implements ITopMenuService { |
| | | |
| | | private final ITopMenuSettingService topMenuSettingService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean grant(@NotEmpty List<Long> topMenuIds, @NotEmpty List<Long> menuIds) { |
| | | // 删除顶部菜单配置的菜单集合 |
| | | topMenuSettingService.remove(Wrappers.<TopMenuSetting>update().lambda().in(TopMenuSetting::getTopMenuId, topMenuIds)); |
| | | // 组装配置 |
| | | List<TopMenuSetting> menuSettings = new ArrayList<>(); |
| | | topMenuIds.forEach(topMenuId -> menuIds.forEach(menuId -> { |
| | | TopMenuSetting menuSetting = new TopMenuSetting(); |
| | | menuSetting.setTopMenuId(topMenuId); |
| | | menuSetting.setMenuId(menuId); |
| | | menuSettings.add(menuSetting); |
| | | })); |
| | | // 新增配置 |
| | | topMenuSettingService.saveBatch(menuSettings); |
| | | return true; |
| | | } |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/service/impl/TopMenuSettingServiceImpl.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.service.impl; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.system.entity.TopMenuSetting; |
| | | import org.springblade.system.mapper.TopMenuSettingMapper; |
| | | import org.springblade.system.service.ITopMenuSettingService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Service |
| | | public class TopMenuSettingServiceImpl extends ServiceImpl<TopMenuSettingMapper, TopMenuSetting> implements ITopMenuSettingService { |
| | | |
| | | } |
| 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.system.user.cache; |
| | | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | 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.feign.IUserClient; |
| | | 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 IUserService userClient; |
| | | |
| | | private static IUserService getUserClient() { |
| | | if (userClient == null) { |
| | | userClient = SpringUtil.getBean(IUserService.class); |
| | | } |
| | | return userClient; |
| | | } |
| | | |
| | | /** |
| | | * 根据任务用户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, () -> { |
| | | User result = getUserClient().getById(userId); |
| | | return result; |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户 |
| | | * |
| | | * @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, () -> { |
| | | User result = getUserClient().userByAccount(tenantId, account); |
| | | return result; |
| | | }); |
| | | } |
| | | |
| | | } |
| 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.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class User extends TenantEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户编号 |
| | | */ |
| | | private String code; |
| | | /** |
| | | * 用户平台 |
| | | */ |
| | | private Integer userType; |
| | | /** |
| | | * 账号 |
| | | */ |
| | | private String account; |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | /** |
| | | * 昵称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 真名 |
| | | */ |
| | | private String realName; |
| | | /** |
| | | * 头像 |
| | | */ |
| | | private String avatar; |
| | | /** |
| | | * 邮箱 |
| | | */ |
| | | private String email; |
| | | /** |
| | | * 手机 |
| | | */ |
| | | private String phone; |
| | | /** |
| | | * 生日 |
| | | */ |
| | | private Date birthday; |
| | | /** |
| | | * 性别 |
| | | */ |
| | | private Integer sex; |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private String roleId; |
| | | /** |
| | | * 部门id |
| | | */ |
| | | private String deptId; |
| | | /** |
| | | * 岗位id |
| | | */ |
| | | private String postId; |
| | | |
| | | |
| | | } |
| 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.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user_app") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "UserApp对象", description = "UserApp对象") |
| | | public class UserApp extends Model<UserApp> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户拓展信息 |
| | | */ |
| | | @ApiModelProperty(value = "用户拓展信息") |
| | | private String userExt; |
| | | |
| | | } |
| 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.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user_dept") |
| | | @ApiModel(value = "UserDept对象", description = "UserDept对象") |
| | | public class UserDept implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "部门ID") |
| | | private Long deptId; |
| | | |
| | | } |
| 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.system.user.entity; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springblade.core.tool.support.Kv; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @ApiModel(description = "用户信息") |
| | | public class UserInfo implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 第三方授权id |
| | | */ |
| | | @ApiModelProperty(value = "第三方授权id") |
| | | private String oauthId; |
| | | |
| | | /** |
| | | * 用户基础信息 |
| | | */ |
| | | @ApiModelProperty(value = "用户") |
| | | private User user; |
| | | |
| | | /** |
| | | * 拓展信息 |
| | | */ |
| | | @ApiModelProperty(value = "拓展信息") |
| | | private Kv detail; |
| | | |
| | | /** |
| | | * 权限标识集合 |
| | | */ |
| | | @ApiModelProperty(value = "权限集合") |
| | | private List<String> permissions; |
| | | |
| | | /** |
| | | * 角色集合 |
| | | */ |
| | | @ApiModelProperty(value = "角色集合") |
| | | private List<String> roles; |
| | | |
| | | } |
| 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.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user_oauth") |
| | | public class UserOauth implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 第三方系统用户ID |
| | | */ |
| | | private String uuid; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "用户主键") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | private String username; |
| | | /** |
| | | * 用户昵称 |
| | | */ |
| | | private String nickname; |
| | | /** |
| | | * 用户头像 |
| | | */ |
| | | private String avatar; |
| | | /** |
| | | * 用户网址 |
| | | */ |
| | | private String blog; |
| | | /** |
| | | * 所在公司 |
| | | */ |
| | | private String company; |
| | | /** |
| | | * 位置 |
| | | */ |
| | | private String location; |
| | | /** |
| | | * 用户邮箱 |
| | | */ |
| | | private String email; |
| | | /** |
| | | * 用户备注(各平台中的用户个人介绍) |
| | | */ |
| | | private String remark; |
| | | /** |
| | | * 性别 |
| | | */ |
| | | private String gender; |
| | | /** |
| | | * 用户来源 |
| | | */ |
| | | private String source; |
| | | |
| | | |
| | | } |
| 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.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user_other") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "UserOther对象", description = "UserOther对象") |
| | | public class UserOther extends Model<UserOther> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户拓展信息 |
| | | */ |
| | | @ApiModelProperty(value = "用户拓展信息") |
| | | private String userExt; |
| | | |
| | | } |
| 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.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user_web") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "UserWeb对象", description = "UserWeb对象") |
| | | public class UserWeb extends Model<UserWeb> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户拓展信息 |
| | | */ |
| | | @ApiModelProperty(value = "用户拓展信息") |
| | | private String userExt; |
| | | |
| | | } |
| 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.system.user.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 用户类型枚举 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum UserEnum { |
| | | |
| | | /** |
| | | * web |
| | | */ |
| | | WEB("web", 1), |
| | | |
| | | /** |
| | | * app |
| | | */ |
| | | APP("app", 2), |
| | | |
| | | /** |
| | | * other |
| | | */ |
| | | OTHER("other", 3), |
| | | ; |
| | | |
| | | final String name; |
| | | final int category; |
| | | |
| | | /** |
| | | * 匹配枚举值 |
| | | * |
| | | * @param name 名称 |
| | | * @return BladeUserEnum |
| | | */ |
| | | public static UserEnum of(String name) { |
| | | if (name == null) { |
| | | return null; |
| | | } |
| | | UserEnum[] values = UserEnum.values(); |
| | | for (UserEnum smsEnum : values) { |
| | | if (smsEnum.name.equals(name)) { |
| | | return smsEnum; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| 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.system.user.excel; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnore; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * UserExcel |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @ColumnWidth(25) |
| | | @HeadRowHeight(20) |
| | | @ContentRowHeight(18) |
| | | public class UserExcel implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("租户编号") |
| | | private String tenantId; |
| | | |
| | | @ExcelIgnore |
| | | @ExcelProperty("用户平台") |
| | | private String userType; |
| | | |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("用户平台名称") |
| | | private String userTypeName; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("账户") |
| | | private String account; |
| | | |
| | | @ColumnWidth(10) |
| | | @ExcelProperty("昵称") |
| | | private String name; |
| | | |
| | | @ColumnWidth(10) |
| | | @ExcelProperty("姓名") |
| | | private String realName; |
| | | |
| | | @ExcelProperty("邮箱") |
| | | private String email; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("手机") |
| | | private String phone; |
| | | |
| | | @ExcelIgnore |
| | | @ExcelProperty("角色ID") |
| | | private String roleId; |
| | | |
| | | @ExcelIgnore |
| | | @ExcelProperty("部门ID") |
| | | private String deptId; |
| | | |
| | | @ExcelIgnore |
| | | @ExcelProperty("岗位ID") |
| | | private String postId; |
| | | |
| | | @ExcelProperty("角色名称") |
| | | private String roleName; |
| | | |
| | | @ExcelProperty("部门名称") |
| | | private String deptName; |
| | | |
| | | @ExcelProperty("岗位名称") |
| | | private String postName; |
| | | |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("生日") |
| | | private Date birthday; |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/user/excel/UserImporter.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.user.excel; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.core.excel.support.ExcelImporter; |
| | | import org.springblade.system.user.service.IUserService; |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 用户数据导入类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | @RequiredArgsConstructor |
| | | public class UserImporter implements ExcelImporter<UserExcel> { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | private final IUserService service; |
| | | private final Boolean isCovered; |
| | | |
| | | @Override |
| | | public void save(List<UserExcel> data) { |
| | | service.importUser(data, isCovered); |
| | | } |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/user/mapper/UserAppMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.user.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.user.entity.UserApp; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | public interface UserAppMapper extends BaseMapper<UserApp> { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.user.mapper.UserAppMapper"> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/user/mapper/UserDeptMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.user.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.user.entity.UserDept; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | public interface UserDeptMapper extends BaseMapper<UserDept> { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.user.mapper.UserDeptMapper"> |
| | | |
| | | </mapper> |
| 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.system.user.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.excel.UserExcel; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface UserMapper extends BaseMapper<User> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param user |
| | | * @param deptIdList |
| | | * @param tenantId |
| | | * @return |
| | | */ |
| | | List<User> selectUserPage(IPage<User> page, @Param("user") User user, @Param("deptIdList") List<Long> deptIdList, @Param("tenantId") String tenantId); |
| | | |
| | | /** |
| | | * 获取用户 |
| | | * |
| | | * @param tenantId |
| | | * @param account |
| | | * @return |
| | | */ |
| | | User getUser(String tenantId, String account); |
| | | |
| | | /** |
| | | * 获取导出用户数据 |
| | | * |
| | | * @param queryWrapper |
| | | * @return |
| | | */ |
| | | List<UserExcel> exportUser(@Param("ew") Wrapper<User> queryWrapper); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.user.mapper.UserMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="userResultMap" type="org.springblade.system.user.entity.User"> |
| | | <result column="id" property="id"/> |
| | | <result column="tenant_id" property="tenantId"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="code" property="code"/> |
| | | <result column="user_type" property="userType"/> |
| | | <result column="account" property="account"/> |
| | | <result column="password" property="password"/> |
| | | <result column="name" property="name"/> |
| | | <result column="real_name" property="realName"/> |
| | | <result column="email" property="email"/> |
| | | <result column="phone" property="phone"/> |
| | | <result column="birthday" property="birthday"/> |
| | | <result column="sex" property="sex"/> |
| | | <result column="role_id" property="roleId"/> |
| | | <result column="dept_id" property="deptId"/> |
| | | <result column="post_id" property="postId"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectUserPage" resultMap="userResultMap"> |
| | | select * from blade_user where is_deleted = 0 |
| | | <if test="tenantId!=null and tenantId != ''"> |
| | | and tenant_id = #{tenantId} |
| | | </if> |
| | | <if test="user.tenantId!=null and user.tenantId != ''"> |
| | | and tenant_id = #{user.tenantId} |
| | | </if> |
| | | <if test="user.account!=null and user.account != ''"> |
| | | and account = #{user.account} |
| | | </if> |
| | | <if test="user.realName!=null and user.realName != ''"> |
| | | and real_name = #{user.realName} |
| | | </if> |
| | | <if test="user.userType!=null and user.userType != ''"> |
| | | and user_type = #{user.userType} |
| | | </if> |
| | | <if test="deptIdList!=null and deptIdList.size>0"> |
| | | and id in ( |
| | | SELECT |
| | | user_id |
| | | FROM |
| | | blade_user_dept |
| | | WHERE |
| | | dept_id IN |
| | | <foreach collection="deptIdList" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | ORDER BY id |
| | | </select> |
| | | |
| | | <select id="getUser" resultMap="userResultMap"> |
| | | SELECT |
| | | * |
| | | FROM |
| | | blade_user |
| | | WHERE |
| | | tenant_id = #{param1} and account = #{param2} and is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="exportUser" resultType="org.springblade.system.user.excel.UserExcel"> |
| | | SELECT id, tenant_id, user_type, account, name, real_name, email, phone, birthday, role_id, dept_id, post_id FROM blade_user ${ew.customSqlSegment} |
| | | </select> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/user/mapper/UserOauthMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.user.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.user.entity.UserOauth; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface UserOauthMapper extends BaseMapper<UserOauth> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.user.mapper.UserOauthMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="userResultMap" type="org.springblade.system.user.entity.UserOauth"> |
| | | <result column="id" property="id"/> |
| | | <result column="tenant_id" property="tenantId"/> |
| | | <result column="user_id" property="userId"/> |
| | | <result column="username" property="username"/> |
| | | <result column="nickname" property="nickname"/> |
| | | <result column="avatar" property="avatar"/> |
| | | <result column="blog" property="blog"/> |
| | | <result column="company" property="company"/> |
| | | <result column="location" property="location"/> |
| | | <result column="email" property="email"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="gender" property="gender"/> |
| | | <result column="source" property="source"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/user/mapper/UserOtherMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.user.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.user.entity.UserOther; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | public interface UserOtherMapper extends BaseMapper<UserOther> { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.user.mapper.UserOtherMapper"> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/user/mapper/UserWebMapper.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.user.mapper; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.user.entity.UserWeb; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | public interface UserWebMapper extends BaseMapper<UserWeb> { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.system.user.mapper.UserWebMapper"> |
| | | |
| | | </mapper> |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/user/service/IUserDeptService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.user.service; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.system.user.entity.UserDept; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface IUserDeptService extends IService<UserDept> { |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/user/service/IUserOauthService.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.user.service; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.system.user.entity.UserOauth; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | public interface IUserOauthService extends IService<UserOauth> { |
| | | |
| | | } |
| 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.system.user.service; |
| | | |
| | | |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.system.user.entity.User; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户查询服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IUserSearchService extends BaseService<User> { |
| | | |
| | | /** |
| | | * 根据用户ID查询用户列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 用户列表 |
| | | */ |
| | | List<User> listByUser(List<Long> userId); |
| | | |
| | | /** |
| | | * 根据部门ID查询用户列表 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 用户列表 |
| | | */ |
| | | List<User> listByDept(List<Long> deptId); |
| | | |
| | | /** |
| | | * 根据岗位ID查询用户列表 |
| | | * |
| | | * @param postId 岗位ID |
| | | * @return 用户列表 |
| | | */ |
| | | List<User> listByPost(List<Long> postId); |
| | | |
| | | /** |
| | | * 根据角色ID查询用户列表 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 用户列表 |
| | | */ |
| | | List<User> listByRole(List<Long> roleId); |
| | | |
| | | } |
| 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.system.user.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.entity.UserInfo; |
| | | import org.springblade.system.user.entity.UserOauth; |
| | | import org.springblade.system.user.enums.UserEnum; |
| | | import org.springblade.system.user.excel.UserExcel; |
| | | import org.springblade.system.user.vo.UserVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IUserService extends BaseService<User> { |
| | | |
| | | /** |
| | | * 新增用户 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | boolean submit(User user); |
| | | |
| | | /** |
| | | * 修改用户 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | boolean updateUser(User user); |
| | | |
| | | /** |
| | | * 修改用户基本信息 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | boolean updateUserInfo(User user); |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param user |
| | | * @param deptId |
| | | * @param tenantId |
| | | * @return |
| | | */ |
| | | IPage<User> selectUserPage(IPage<User> page, User user, Long deptId, String tenantId); |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param user |
| | | * @param query |
| | | * @return |
| | | */ |
| | | IPage<UserVO> selectUserSearch(UserVO user, Query query); |
| | | |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | UserInfo userInfo(Long userId); |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @param tenantId |
| | | * @param account |
| | | * @return |
| | | */ |
| | | UserInfo userInfo(String tenantId, String account); |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @param tenantId |
| | | * @param account |
| | | * @param userEnum |
| | | * @return |
| | | */ |
| | | UserInfo userInfo(String tenantId, String account, UserEnum userEnum); |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @param userOauth |
| | | * @return |
| | | */ |
| | | UserInfo userInfo(UserOauth userOauth); |
| | | |
| | | /** |
| | | * 根据账号获取用户 |
| | | * |
| | | * @param tenantId |
| | | * @param account |
| | | * @return |
| | | */ |
| | | User userByAccount(String tenantId, String account); |
| | | |
| | | /** |
| | | * 给用户设置角色 |
| | | * |
| | | * @param userIds |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | boolean grant(String userIds, String roleIds); |
| | | |
| | | /** |
| | | * 初始化密码 |
| | | * |
| | | * @param userIds |
| | | * @return |
| | | */ |
| | | boolean resetPassword(String userIds); |
| | | |
| | | /** |
| | | * 修改密码 |
| | | * |
| | | * @param userId |
| | | * @param oldPassword |
| | | * @param newPassword |
| | | * @param newPassword1 |
| | | * @return |
| | | */ |
| | | boolean updatePassword(Long userId, String oldPassword, String newPassword, String newPassword1); |
| | | |
| | | /** |
| | | * 删除用户 |
| | | * |
| | | * @param userIds |
| | | * @return |
| | | */ |
| | | boolean removeUser(String userIds); |
| | | |
| | | /** |
| | | * 导入用户数据 |
| | | * |
| | | * @param data |
| | | * @param isCovered |
| | | * @return |
| | | */ |
| | | void importUser(List<UserExcel> data, Boolean isCovered); |
| | | |
| | | /** |
| | | * 导出用户数据 |
| | | * |
| | | * @param queryWrapper |
| | | * @return |
| | | */ |
| | | List<UserExcel> exportUser(Wrapper<User> queryWrapper); |
| | | |
| | | /** |
| | | * 注册用户 |
| | | * |
| | | * @param user |
| | | * @param oauthId |
| | | * @return |
| | | */ |
| | | boolean registerGuest(User user, Long oauthId); |
| | | |
| | | /** |
| | | * 配置用户平台 |
| | | * |
| | | * @param userId |
| | | * @param userType |
| | | * @param userExt |
| | | * @return |
| | | */ |
| | | boolean updatePlatform(Long userId, Integer userType, String userExt); |
| | | |
| | | /** |
| | | * 用户详细信息 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | UserVO platformDetail(User user); |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/user/service/impl/UserDeptServiceImpl.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.user.service.impl; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.system.user.entity.UserDept; |
| | | import org.springblade.system.user.mapper.UserDeptMapper; |
| | | import org.springblade.system.user.service.IUserDeptService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Service |
| | | public class UserDeptServiceImpl extends ServiceImpl<UserDeptMapper, UserDept> implements IUserDeptService { |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/user/service/impl/UserOauthServiceImpl.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.user.service.impl; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.system.user.entity.UserOauth; |
| | | import org.springblade.system.user.mapper.UserOauthMapper; |
| | | import org.springblade.system.user.service.IUserOauthService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class UserOauthServiceImpl extends ServiceImpl<UserOauthMapper, UserOauth> implements IUserOauthService { |
| | | |
| | | } |
| 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.system.user.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.mapper.UserMapper; |
| | | import org.springblade.system.user.service.IUserSearchService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户查询服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class UserSearchServiceImpl extends BaseServiceImpl<UserMapper, User> implements IUserSearchService { |
| | | |
| | | @Override |
| | | public List<User> listByUser(List<Long> userId) { |
| | | return this.list(Wrappers.<User>lambdaQuery().in(User::getId, userId)); |
| | | } |
| | | |
| | | @Override |
| | | public List<User> listByDept(List<Long> deptId) { |
| | | LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery(); |
| | | deptId.forEach(id -> queryWrapper.like(User::getDeptId, id).or()); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<User> listByPost(List<Long> postId) { |
| | | LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery(); |
| | | postId.forEach(id -> queryWrapper.like(User::getPostId, id).or()); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<User> listByRole(List<Long> roleId) { |
| | | LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery(); |
| | | roleId.forEach(id -> queryWrapper.like(User::getRoleId, id).or()); |
| | | return this.list(queryWrapper); |
| | | } |
| | | } |
| 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.system.user.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.common.constant.TenantConstant; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tenant.BladeTenantProperties; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | 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; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.feign.ISysClient; |
| | | import org.springblade.system.service.IRoleService; |
| | | import org.springblade.system.service.ITenantService; |
| | | import org.springblade.system.user.cache.UserCache; |
| | | import org.springblade.system.user.entity.*; |
| | | import org.springblade.system.user.enums.UserEnum; |
| | | import org.springblade.system.user.excel.UserExcel; |
| | | import org.springblade.system.user.mapper.UserMapper; |
| | | import org.springblade.system.user.service.IUserDeptService; |
| | | import org.springblade.system.user.service.IUserOauthService; |
| | | import org.springblade.system.user.service.IUserService; |
| | | import org.springblade.system.user.vo.UserVO; |
| | | import org.springblade.system.user.wrapper.UserWrapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import static org.springblade.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implements IUserService { |
| | | private static final String GUEST_NAME = "guest"; |
| | | |
| | | private final IUserDeptService userDeptService; |
| | | private final IUserOauthService userOauthService; |
| | | private final IRoleService sysClient; |
| | | private final BladeTenantProperties tenantProperties; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean submit(User user) { |
| | | if (StringUtil.isBlank(user.getTenantId())) { |
| | | user.setTenantId(BladeConstant.ADMIN_TENANT_ID); |
| | | } |
| | | String tenantId = user.getTenantId(); |
| | | Tenant tenant = SysCache.getTenant(tenantId); |
| | | if (Func.isNotEmpty(tenant)) { |
| | | Integer accountNumber = tenant.getAccountNumber(); |
| | | if (tenantProperties.getLicense()) { |
| | | String licenseKey = tenant.getLicenseKey(); |
| | | String decrypt = DesUtil.decryptFormHex(licenseKey, TenantConstant.DES_KEY); |
| | | accountNumber = JsonUtil.parse(decrypt, Tenant.class).getAccountNumber(); |
| | | } |
| | | Long tenantCount = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId)); |
| | | if (accountNumber != null && accountNumber > 0 && accountNumber <= tenantCount) { |
| | | // throw new ServiceException("当前租户已到最大账号额度!"); |
| | | } |
| | | } |
| | | if (Func.isNotEmpty(user.getPassword())) { |
| | | user.setPassword(DigestUtil.encrypt(user.getPassword())); |
| | | } |
| | | Long userCount = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, user.getAccount())); |
| | | if (userCount > 0L && Func.isEmpty(user.getId())) { |
| | | // throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | return save(user) && submitUserDept(user); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateUser(User user) { |
| | | String tenantId = user.getTenantId(); |
| | | Long userCount = baseMapper.selectCount( |
| | | Wrappers.<User>query().lambda() |
| | | .eq(User::getTenantId, tenantId) |
| | | .eq(User::getAccount, user.getAccount()) |
| | | .notIn(User::getId, user.getId()) |
| | | ); |
| | | if (userCount > 0L) { |
| | | // throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | return updateUserInfo(user) && submitUserDept(user); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateUserInfo(User user) { |
| | | user.setPassword(null); |
| | | return updateById(user); |
| | | } |
| | | |
| | | private boolean submitUserDept(User user) { |
| | | List<Long> deptIdList = Func.toLongList(user.getDeptId()); |
| | | List<UserDept> userDeptList = new ArrayList<>(); |
| | | deptIdList.forEach(deptId -> { |
| | | UserDept userDept = new UserDept(); |
| | | userDept.setUserId(user.getId()); |
| | | userDept.setDeptId(deptId); |
| | | userDeptList.add(userDept); |
| | | }); |
| | | userDeptService.remove(Wrappers.<UserDept>update().lambda().eq(UserDept::getUserId, user.getId())); |
| | | return userDeptService.saveBatch(userDeptList); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<User> selectUserPage(IPage<User> page, User user, Long deptId, String tenantId) { |
| | | List<Long> deptIdList = SysCache.getDeptChildIds(deptId); |
| | | return page.setRecords(baseMapper.selectUserPage(page, user, deptIdList, tenantId)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<UserVO> selectUserSearch(UserVO user, Query query) { |
| | | LambdaQueryWrapper<User> queryWrapper = Wrappers.<User>query().lambda(); |
| | | String tenantId = AuthUtil.getTenantId(); |
| | | if (StringUtil.isNotBlank(tenantId)) { |
| | | queryWrapper.eq(User::getTenantId, tenantId); |
| | | } |
| | | if (StringUtil.isNotBlank(user.getName())) { |
| | | queryWrapper.like(User::getName, user.getName()); |
| | | } |
| | | if (StringUtil.isNotBlank(user.getDeptName())) { |
| | | String deptIds = SysCache.getDeptIdsByFuzzy(AuthUtil.getTenantId(), user.getDeptName()); |
| | | if (StringUtil.isNotBlank(deptIds)) { |
| | | queryWrapper.and(wrapper -> { |
| | | List<String> ids = Func.toStrList(deptIds); |
| | | ids.forEach(id -> wrapper.like(User::getDeptId, id).or()); |
| | | }); |
| | | } |
| | | } |
| | | if (StringUtil.isNotBlank(user.getPostName())) { |
| | | String postIds = SysCache.getPostIdsByFuzzy(AuthUtil.getTenantId(), user.getPostName()); |
| | | if (StringUtil.isNotBlank(postIds)) { |
| | | queryWrapper.and(wrapper -> { |
| | | List<String> ids = Func.toStrList(postIds); |
| | | ids.forEach(id -> wrapper.like(User::getPostId, id).or()); |
| | | }); |
| | | } |
| | | } |
| | | IPage<User> pages = this.page(Condition.getPage(query), queryWrapper); |
| | | return UserWrapper.build().pageVO(pages); |
| | | } |
| | | |
| | | @Override |
| | | public User userByAccount(String tenantId, String account) { |
| | | return baseMapper.selectOne(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, account).eq(User::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | } |
| | | |
| | | @Override |
| | | public UserInfo userInfo(Long userId) { |
| | | User user = baseMapper.selectById(userId); |
| | | return buildUserInfo(user); |
| | | } |
| | | |
| | | @Override |
| | | public UserInfo userInfo(String tenantId, String account) { |
| | | User user = baseMapper.getUser(tenantId, account); |
| | | return buildUserInfo(user); |
| | | } |
| | | |
| | | @Override |
| | | public UserInfo userInfo(String tenantId, String account, UserEnum userEnum) { |
| | | User user = baseMapper.getUser(tenantId, account); |
| | | return buildUserInfo(user, userEnum); |
| | | } |
| | | |
| | | private UserInfo buildUserInfo(User user) { |
| | | return buildUserInfo(user, UserEnum.WEB); |
| | | } |
| | | |
| | | private UserInfo buildUserInfo(User user, UserEnum userEnum) { |
| | | if (ObjectUtil.isEmpty(user)) { |
| | | return null; |
| | | } |
| | | UserInfo userInfo = new UserInfo(); |
| | | userInfo.setUser(user); |
| | | if (Func.isNotEmpty(user)) { |
| | | List<String> result = sysClient.getRoleAliases(user.getRoleId()); |
| | | if (result.size()>0) { |
| | | List<String> roleAlias = result; |
| | | userInfo.setRoles(roleAlias); |
| | | } |
| | | } |
| | | // 根据每个用户平台,建立对应的detail表,通过查询将结果集写入到detail字段 |
| | | Kv detail = Kv.create().set("type", userEnum.getName()); |
| | | if (userEnum == UserEnum.WEB) { |
| | | UserWeb userWeb = new UserWeb(); |
| | | UserWeb query = userWeb.selectOne(Wrappers.<UserWeb>lambdaQuery().eq(UserWeb::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | detail.set("ext", query.getUserExt()); |
| | | } |
| | | } else if (userEnum == UserEnum.APP) { |
| | | UserApp userApp = new UserApp(); |
| | | UserApp query = userApp.selectOne(Wrappers.<UserApp>lambdaQuery().eq(UserApp::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | detail.set("ext", query.getUserExt()); |
| | | } |
| | | } else { |
| | | UserOther userOther = new UserOther(); |
| | | UserOther query = userOther.selectOne(Wrappers.<UserOther>lambdaQuery().eq(UserOther::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | detail.set("ext", query.getUserExt()); |
| | | } |
| | | } |
| | | userInfo.setDetail(detail); |
| | | return userInfo; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public UserInfo userInfo(UserOauth userOauth) { |
| | | UserOauth uo = userOauthService.getOne(Wrappers.<UserOauth>query().lambda().eq(UserOauth::getUuid, userOauth.getUuid()).eq(UserOauth::getSource, userOauth.getSource())); |
| | | UserInfo userInfo; |
| | | if (Func.isNotEmpty(uo) && Func.isNotEmpty(uo.getUserId())) { |
| | | userInfo = this.userInfo(uo.getUserId()); |
| | | userInfo.setOauthId(Func.toStr(uo.getId())); |
| | | } else { |
| | | userInfo = new UserInfo(); |
| | | if (Func.isEmpty(uo)) { |
| | | userOauthService.save(userOauth); |
| | | userInfo.setOauthId(Func.toStr(userOauth.getId())); |
| | | } else { |
| | | userInfo.setOauthId(Func.toStr(uo.getId())); |
| | | } |
| | | User user = new User(); |
| | | user.setAccount(userOauth.getUsername()); |
| | | user.setTenantId(userOauth.getTenantId()); |
| | | userInfo.setUser(user); |
| | | userInfo.setRoles(Collections.singletonList(GUEST_NAME)); |
| | | } |
| | | return userInfo; |
| | | } |
| | | |
| | | @Override |
| | | public boolean grant(String userIds, String roleIds) { |
| | | User user = new User(); |
| | | user.setRoleId(roleIds); |
| | | return this.update(user, Wrappers.<User>update().lambda().in(User::getId, Func.toLongList(userIds))); |
| | | } |
| | | |
| | | @Override |
| | | public boolean resetPassword(String userIds) { |
| | | User user = new User(); |
| | | user.setPassword(DigestUtil.encrypt(CommonConstant.DEFAULT_PASSWORD)); |
| | | user.setUpdateTime(DateUtil.now()); |
| | | return this.update(user, Wrappers.<User>update().lambda().in(User::getId, Func.toLongList(userIds))); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updatePassword(Long userId, String oldPassword, String newPassword, String newPassword1) { |
| | | User user = getById(userId); |
| | | if (!newPassword.equals(newPassword1)) { |
| | | // throw new ServiceException("请输入正确的确认密码!"); |
| | | } |
| | | if (!user.getPassword().equals(DigestUtil.hex(oldPassword))) { |
| | | // throw new ServiceException("原密码不正确!"); |
| | | } |
| | | return this.update(Wrappers.<User>update().lambda().set(User::getPassword, DigestUtil.hex(newPassword)).eq(User::getId, userId)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeUser(String userIds) { |
| | | if (Func.contains(Func.toLongArray(userIds), AuthUtil.getUserId())) { |
| | | // throw new ServiceException("不能删除本账号!"); |
| | | } |
| | | return deleteLogic(Func.toLongList(userIds)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importUser(List<UserExcel> data, Boolean isCovered) { |
| | | data.forEach(userExcel -> { |
| | | User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class)); |
| | | // 设置用户平台 |
| | | user.setUserType(Func.toInt(DictCache.getKey(DictEnum.USER_TYPE, userExcel.getUserTypeName()), 1)); |
| | | // 设置部门ID |
| | | user.setDeptId(Func.toStrWithEmpty(SysCache.getDeptIds(userExcel.getTenantId(), userExcel.getDeptName()), StringPool.EMPTY)); |
| | | // 设置岗位ID |
| | | user.setPostId(Func.toStrWithEmpty(SysCache.getPostIds(userExcel.getTenantId(), userExcel.getPostName()), StringPool.EMPTY)); |
| | | // 设置角色ID |
| | | user.setRoleId(Func.toStrWithEmpty(SysCache.getRoleIds(userExcel.getTenantId(), userExcel.getRoleName()), StringPool.EMPTY)); |
| | | // 设置租户ID |
| | | if (!AuthUtil.isAdministrator() || StringUtil.isBlank(user.getTenantId())) { |
| | | user.setTenantId(AuthUtil.getTenantId()); |
| | | } |
| | | // 覆盖数据 |
| | | if (isCovered) { |
| | | // 查询用户是否存在 |
| | | User oldUser = UserCache.getUser(userExcel.getTenantId(), userExcel.getAccount()); |
| | | if (oldUser != null && oldUser.getId() != null) { |
| | | user.setId(oldUser.getId()); |
| | | this.updateUser(user); |
| | | return; |
| | | } |
| | | } |
| | | // 获取默认密码配置 |
| | | String initPassword = ParamCache.getValue(DEFAULT_PARAM_PASSWORD); |
| | | user.setPassword(initPassword); |
| | | this.submit(user); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | 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.setRoleName(StringUtil.join(SysCache.getRoleNames(user.getRoleId()))); |
| | | user.setDeptName(StringUtil.join(SysCache.getDeptNames(user.getDeptId()))); |
| | | user.setPostName(StringUtil.join(SysCache.getPostNames(user.getPostId()))); |
| | | }); |
| | | return userList; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean registerGuest(User user, Long oauthId) { |
| | | Tenant tenant = SysCache.getTenant(user.getTenantId()); |
| | | if (tenant == null || tenant.getId() == null) { |
| | | // throw new ServiceException("租户信息错误!"); |
| | | } |
| | | UserOauth userOauth = userOauthService.getById(oauthId); |
| | | if (userOauth == null || userOauth.getId() == null) { |
| | | // throw new ServiceException("第三方登陆信息错误!"); |
| | | } |
| | | user.setRealName(user.getName()); |
| | | user.setAvatar(userOauth.getAvatar()); |
| | | user.setRoleId(StringPool.MINUS_ONE); |
| | | user.setDeptId(StringPool.MINUS_ONE); |
| | | user.setPostId(StringPool.MINUS_ONE); |
| | | boolean userTemp = this.submit(user); |
| | | userOauth.setUserId(user.getId()); |
| | | userOauth.setTenantId(user.getTenantId()); |
| | | boolean oauthTemp = userOauthService.updateById(userOauth); |
| | | return (userTemp && oauthTemp); |
| | | } |
| | | @Override |
| | | public boolean updatePlatform(Long userId, Integer userType, String userExt) { |
| | | if (userType.equals(UserEnum.WEB.getCategory())) { |
| | | UserWeb userWeb = new UserWeb(); |
| | | UserWeb query = userWeb.selectOne(Wrappers.<UserWeb>lambdaQuery().eq(UserWeb::getUserId, userId)); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userWeb.setId(query.getId()); |
| | | } |
| | | userWeb.setUserId(userId); |
| | | userWeb.setUserExt(userExt); |
| | | return userWeb.insertOrUpdate(); |
| | | } else if (userType.equals(UserEnum.APP.getCategory())) { |
| | | UserApp userApp = new UserApp(); |
| | | UserApp query = userApp.selectOne(Wrappers.<UserApp>lambdaQuery().eq(UserApp::getUserId, userId)); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userApp.setId(query.getId()); |
| | | } |
| | | userApp.setUserId(userId); |
| | | userApp.setUserExt(userExt); |
| | | return userApp.insertOrUpdate(); |
| | | } else { |
| | | UserOther userOther = new UserOther(); |
| | | UserOther query = userOther.selectOne(Wrappers.<UserOther>lambdaQuery().eq(UserOther::getUserId, userId)); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userOther.setId(query.getId()); |
| | | } |
| | | userOther.setUserId(userId); |
| | | userOther.setUserExt(userExt); |
| | | return userOther.insertOrUpdate(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public UserVO platformDetail(User user) { |
| | | User detail = baseMapper.selectOne(Condition.getQueryWrapper(user)); |
| | | UserVO userVO = UserWrapper.build().entityVO(detail); |
| | | if (userVO.getUserType().equals(UserEnum.WEB.getCategory())) { |
| | | UserWeb userWeb = new UserWeb(); |
| | | UserWeb query = userWeb.selectOne(Wrappers.<UserWeb>lambdaQuery().eq(UserWeb::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userVO.setUserExt(query.getUserExt()); |
| | | } |
| | | } else if (userVO.getUserType().equals(UserEnum.APP.getCategory())) { |
| | | UserApp userApp = new UserApp(); |
| | | UserApp query = userApp.selectOne(Wrappers.<UserApp>lambdaQuery().eq(UserApp::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userVO.setUserExt(query.getUserExt()); |
| | | } |
| | | } else { |
| | | UserOther userOther = new UserOther(); |
| | | UserOther query = userOther.selectOne(Wrappers.<UserOther>lambdaQuery().eq(UserOther::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userVO.setUserExt(query.getUserExt()); |
| | | } |
| | | } |
| | | return userVO; |
| | | } |
| | | |
| | | } |
| 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.system.user.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.system.user.entity.User; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "UserVO对象", description = "UserVO对象") |
| | | public class UserVO extends User { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | @JsonIgnore |
| | | private String password; |
| | | |
| | | /** |
| | | * 租户名 |
| | | */ |
| | | private String tenantName; |
| | | |
| | | /** |
| | | * 用户平台名 |
| | | */ |
| | | private String userTypeName; |
| | | |
| | | /** |
| | | * 角色名 |
| | | */ |
| | | private String roleName; |
| | | |
| | | /** |
| | | * 部门名 |
| | | */ |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 岗位名 |
| | | */ |
| | | private String postName; |
| | | |
| | | /** |
| | | * 性别 |
| | | */ |
| | | private String sexName; |
| | | |
| | | /** |
| | | * 拓展信息 |
| | | */ |
| | | private String userExt; |
| | | } |
| 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.system.user.wrapper; |
| | | |
| | | 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.system.cache.SysCache; |
| | | import org.springblade.system.entity.Tenant; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.vo.UserVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class UserWrapper extends BaseEntityWrapper<User, UserVO> { |
| | | |
| | | public static UserWrapper build() { |
| | | return new UserWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public UserVO entityVO(User user) { |
| | | UserVO userVO = Objects.requireNonNull(BeanUtil.copy(user, UserVO.class)); |
| | | Tenant tenant = SysCache.getTenant(user.getTenantId()); |
| | | List<String> roleName = SysCache.getRoleNames(user.getRoleId()); |
| | | List<String> deptName = SysCache.getDeptNames(user.getDeptId()); |
| | | List<String> postName = SysCache.getPostNames(user.getPostId()); |
| | | userVO.setTenantName(tenant.getTenantName()); |
| | | 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())); |
| | | return userVO; |
| | | } |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/vo/ApiScopeVO.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.vo; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.system.entity.ApiScope; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "ApiScopeVO对象", description = "ApiScopeVO对象") |
| | | public class ApiScopeVO extends ApiScope { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | |
| | | /** |
| | | * 规则类型名 |
| | | */ |
| | | private String scopeTypeName; |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/vo/CheckedTreeVO.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * CheckedTreeVO |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | @Data |
| | | public class CheckedTreeVO { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | private List<String> menu; |
| | | |
| | | private List<String> dataScope; |
| | | |
| | | private List<String> apiScope; |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/vo/DataScopeVO.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.vo; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.system.entity.DataScope; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "DataScopeVO对象", description = "DataScopeVO对象") |
| | | public class DataScopeVO extends DataScope { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | |
| | | /** |
| | | * 规则类型名 |
| | | */ |
| | | private String scopeTypeName; |
| | | } |
| 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.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import org.springblade.system.entity.Dept; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "DeptVO对象", description = "DeptVO对象") |
| | | public class DeptVO extends Dept implements INode<DeptVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<DeptVO> children; |
| | | |
| | | /** |
| | | * 是否有子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private Boolean hasChildren; |
| | | |
| | | @Override |
| | | public List<DeptVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | |
| | | /** |
| | | * 上级机构 |
| | | */ |
| | | private String parentName; |
| | | |
| | | /** |
| | | * 机构类型名称 |
| | | */ |
| | | private String deptCategoryName; |
| | | |
| | | } |
| 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.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import org.springblade.system.entity.DictBiz; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "DictBizVO对象", description = "DictBizVO对象") |
| | | public class DictBizVO extends DictBiz implements INode<DictBizVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<DictBizVO> children; |
| | | |
| | | @Override |
| | | public List<DictBizVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | |
| | | /** |
| | | * 上级字典 |
| | | */ |
| | | private String parentName; |
| | | } |
| 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.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import org.springblade.system.entity.Dict; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "DictVO对象", description = "DictVO对象") |
| | | public class DictVO extends Dict implements INode<DictVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<DictVO> children; |
| | | |
| | | @Override |
| | | public List<DictVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | |
| | | /** |
| | | * 上级字典 |
| | | */ |
| | | private String parentName; |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/vo/GrantTreeVO.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.vo; |
| | | |
| | | import lombok.Data; |
| | | import org.springblade.core.tool.node.TreeNode; |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * GrantTreeVO |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | @Data |
| | | public class GrantTreeVO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | private List<TreeNode> menu; |
| | | |
| | | private List<TreeNode> dataScope; |
| | | |
| | | private List<TreeNode> apiScope; |
| | | |
| | | } |
| 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.system.vo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * GrantVO |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | public class GrantVO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "roleIds集合") |
| | | private List<Long> roleIds; |
| | | |
| | | @ApiModelProperty(value = "menuIds集合") |
| | | private List<Long> menuIds; |
| | | |
| | | @ApiModelProperty(value = "topMenuIds集合") |
| | | private List<Long> topMenuIds; |
| | | |
| | | @ApiModelProperty(value = "dataScopeIds集合") |
| | | private List<Long> dataScopeIds; |
| | | |
| | | @ApiModelProperty(value = "apiScopeIds集合") |
| | | private List<Long> apiScopeIds; |
| | | |
| | | } |
| 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.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import org.springblade.system.entity.Menu; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "MenuVO对象", description = "MenuVO对象") |
| | | public class MenuVO extends Menu implements INode<MenuVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<MenuVO> children; |
| | | |
| | | /** |
| | | * 是否有子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private Boolean hasChildren; |
| | | |
| | | @Override |
| | | public List<MenuVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | |
| | | /** |
| | | * 上级菜单 |
| | | */ |
| | | private String parentName; |
| | | |
| | | /** |
| | | * 菜单类型 |
| | | */ |
| | | private String categoryName; |
| | | |
| | | /** |
| | | * 按钮功能 |
| | | */ |
| | | private String actionName; |
| | | |
| | | /** |
| | | * 是否新窗口打开 |
| | | */ |
| | | private String isOpenName; |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/vo/ParamVO.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.vo; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.system.entity.Param; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "ParamVO对象", description = "ParamVO对象") |
| | | public class ParamVO extends Param { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/vo/PostVO.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.vo; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.system.entity.Post; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 岗位表视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "PostVO对象", description = "岗位表") |
| | | public class PostVO extends Post { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | /** |
| | | * 岗位分类名 |
| | | */ |
| | | private String categoryName; |
| | | |
| | | } |
| 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.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.system.entity.Region; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 行政区划表视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "RegionVO对象", description = "行政区划表") |
| | | public class RegionVO extends Region implements INode<RegionVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 父节点名称 |
| | | */ |
| | | private String parentName; |
| | | |
| | | /** |
| | | * 是否有子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private Boolean hasChildren; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<RegionVO> children; |
| | | |
| | | @Override |
| | | public Long getId() { |
| | | return Func.toLong(this.getCode()); |
| | | } |
| | | |
| | | @Override |
| | | public Long getParentId() { |
| | | return Func.toLong(this.getParentCode()); |
| | | } |
| | | |
| | | @Override |
| | | public List<RegionVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | } |
copy from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
copy to blade-auth/src/main/java/org/springblade/system/vo/RoleMenuVO.java
| File was copied from blade-auth/src/main/java/org/springblade/auth/AuthApplication.java |
| | |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.auth; |
| | | package org.springblade.system.vo; |
| | | |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.system.entity.RoleMenu; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "RoleMenuVO对象", description = "RoleMenuVO对象") |
| | | public class RoleMenuVO extends RoleMenu { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| 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.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import org.springblade.system.entity.Role; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "RoleVO对象", description = "RoleVO对象") |
| | | public class RoleVO extends Role implements INode<RoleVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<RoleVO> children; |
| | | |
| | | @Override |
| | | public List<RoleVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | |
| | | /** |
| | | * 上级角色 |
| | | */ |
| | | private String parentName; |
| | | } |
| 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.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.system.entity.ApiScope; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.vo.ApiScopeVO; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class ApiScopeWrapper extends BaseEntityWrapper<ApiScope, ApiScopeVO> { |
| | | |
| | | public static ApiScopeWrapper build() { |
| | | return new ApiScopeWrapper(); |
| | | } |
| | | |
| | | @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()); |
| | | apiScopeVO.setScopeTypeName(scopeTypeName); |
| | | return apiScopeVO; |
| | | } |
| | | |
| | | } |
| 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.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.system.entity.DataScope; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.vo.DataScopeVO; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DataScopeWrapper extends BaseEntityWrapper<DataScope, DataScopeVO> { |
| | | |
| | | public static DataScopeWrapper build() { |
| | | return new DataScopeWrapper(); |
| | | } |
| | | |
| | | @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()); |
| | | dataScopeVO.setScopeTypeName(scopeTypeName); |
| | | return dataScopeVO; |
| | | } |
| | | |
| | | } |
| 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.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | 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.system.cache.SysCache; |
| | | import org.springblade.system.entity.Dept; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.vo.DeptVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DeptWrapper extends BaseEntityWrapper<Dept, DeptVO> { |
| | | |
| | | public static DeptWrapper build() { |
| | | return new DeptWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public DeptVO entityVO(Dept dept) { |
| | | DeptVO deptVO = Objects.requireNonNull(BeanUtil.copy(dept, DeptVO.class)); |
| | | if (Func.equals(dept.getParentId(), BladeConstant.TOP_PARENT_ID)) { |
| | | deptVO.setParentName(BladeConstant.TOP_PARENT_NAME); |
| | | } else { |
| | | Dept parent = SysCache.getDept(dept.getParentId()); |
| | | deptVO.setParentName(parent.getDeptName()); |
| | | } |
| | | String category = DictCache.getValue(DictEnum.ORG_CATEGORY, 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()); |
| | | Objects.requireNonNull(deptVO).setDeptCategoryName(category); |
| | | return deptVO; |
| | | }).collect(Collectors.toList()); |
| | | return ForestNodeMerger.merge(collect); |
| | | } |
| | | |
| | | public List<DeptVO> listNodeLazyVO(List<DeptVO> list) { |
| | | List<DeptVO> collect = list.stream().peek(dept -> { |
| | | String category = DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()); |
| | | Objects.requireNonNull(dept).setDeptCategoryName(category); |
| | | }).collect(Collectors.toList()); |
| | | return ForestNodeMerger.merge(collect); |
| | | } |
| | | |
| | | } |
| 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.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | 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.system.entity.DictBiz; |
| | | import org.springblade.system.vo.DictBizVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DictBizWrapper extends BaseEntityWrapper<DictBiz, DictBizVO> { |
| | | |
| | | public static DictBizWrapper build() { |
| | | return new DictBizWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public DictBizVO entityVO(DictBiz dict) { |
| | | DictBizVO dictVO = Objects.requireNonNull(BeanUtil.copy(dict, DictBizVO.class)); |
| | | if (Func.equals(dict.getParentId(), BladeConstant.TOP_PARENT_ID)) { |
| | | dictVO.setParentName(BladeConstant.TOP_PARENT_NAME); |
| | | } else { |
| | | DictBiz parent = DictBizCache.getById(dict.getParentId()); |
| | | dictVO.setParentName(parent.getDictValue()); |
| | | } |
| | | return dictVO; |
| | | } |
| | | |
| | | public List<DictBizVO> listNodeVO(List<DictBiz> list) { |
| | | List<DictBizVO> collect = list.stream().map(dict -> BeanUtil.copy(dict, DictBizVO.class)).collect(Collectors.toList()); |
| | | return ForestNodeMerger.merge(collect); |
| | | } |
| | | |
| | | } |
| 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.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | 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.system.entity.Dict; |
| | | import org.springblade.system.vo.DictVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DictWrapper extends BaseEntityWrapper<Dict, DictVO> { |
| | | |
| | | public static DictWrapper build() { |
| | | return new DictWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public DictVO entityVO(Dict dict) { |
| | | DictVO dictVO = Objects.requireNonNull(BeanUtil.copy(dict, DictVO.class)); |
| | | if (Func.equals(dict.getParentId(), BladeConstant.TOP_PARENT_ID)) { |
| | | dictVO.setParentName(BladeConstant.TOP_PARENT_NAME); |
| | | } else { |
| | | Dict parent = DictCache.getById(dict.getParentId()); |
| | | dictVO.setParentName(parent.getDictValue()); |
| | | } |
| | | return dictVO; |
| | | } |
| | | |
| | | public List<DictVO> listNodeVO(List<Dict> list) { |
| | | List<DictVO> collect = list.stream().map(dict -> BeanUtil.copy(dict, DictVO.class)).collect(Collectors.toList()); |
| | | return ForestNodeMerger.merge(collect); |
| | | } |
| | | |
| | | } |
| 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.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | 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.system.cache.SysCache; |
| | | import org.springblade.system.entity.Menu; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.vo.MenuVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class MenuWrapper extends BaseEntityWrapper<Menu, MenuVO> { |
| | | |
| | | public static MenuWrapper build() { |
| | | return new MenuWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public MenuVO entityVO(Menu menu) { |
| | | MenuVO menuVO = Objects.requireNonNull(BeanUtil.copy(menu, MenuVO.class)); |
| | | if (Func.equals(menu.getParentId(), BladeConstant.TOP_PARENT_ID)) { |
| | | menuVO.setParentName(BladeConstant.TOP_PARENT_NAME); |
| | | } else { |
| | | 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())); |
| | | menuVO.setCategoryName(category); |
| | | menuVO.setActionName(action); |
| | | menuVO.setIsOpenName(open); |
| | | return menuVO; |
| | | } |
| | | |
| | | public List<MenuVO> listNodeVO(List<Menu> list) { |
| | | List<MenuVO> collect = list.stream().map(menu -> BeanUtil.copy(menu, MenuVO.class)).collect(Collectors.toList()); |
| | | return ForestNodeMerger.merge(collect); |
| | | } |
| | | |
| | | public List<MenuVO> listNodeLazyVO(List<MenuVO> list) { |
| | | return ForestNodeMerger.merge(list); |
| | | } |
| | | |
| | | } |
| 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.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.system.entity.Post; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.vo.PostVO; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 岗位表包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class PostWrapper extends BaseEntityWrapper<Post, PostVO> { |
| | | |
| | | public static PostWrapper build() { |
| | | return new PostWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public PostVO entityVO(Post post) { |
| | | PostVO postVO = Objects.requireNonNull(BeanUtil.copy(post, PostVO.class)); |
| | | String categoryName = DictCache.getValue(DictEnum.POST_CATEGORY, post.getCategory()); |
| | | postVO.setCategoryName(categoryName); |
| | | return postVO; |
| | | } |
| | | |
| | | } |
| 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.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.system.cache.RegionCache; |
| | | import org.springblade.system.entity.Region; |
| | | import org.springblade.system.vo.RegionVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class RegionWrapper extends BaseEntityWrapper<Region, RegionVO> { |
| | | |
| | | public static RegionWrapper build() { |
| | | return new RegionWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public RegionVO entityVO(Region region) { |
| | | RegionVO regionVO = Objects.requireNonNull(BeanUtil.copy(region, RegionVO.class)); |
| | | Region parentRegion = RegionCache.getByCode(region.getParentCode()); |
| | | regionVO.setParentName(parentRegion.getName()); |
| | | return regionVO; |
| | | } |
| | | |
| | | public List<RegionVO> listNodeLazyVO(List<RegionVO> list) { |
| | | return ForestNodeMerger.merge(list); |
| | | } |
| | | |
| | | } |
| 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.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | 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.SysCache; |
| | | import org.springblade.system.entity.Role; |
| | | import org.springblade.system.vo.RoleVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class RoleWrapper extends BaseEntityWrapper<Role, RoleVO> { |
| | | |
| | | public static RoleWrapper build() { |
| | | return new RoleWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public RoleVO entityVO(Role role) { |
| | | RoleVO roleVO = Objects.requireNonNull(BeanUtil.copy(role, RoleVO.class)); |
| | | if (Func.equals(role.getParentId(), BladeConstant.TOP_PARENT_ID)) { |
| | | roleVO.setParentName(BladeConstant.TOP_PARENT_NAME); |
| | | } else { |
| | | Role parent = SysCache.getRole(role.getParentId()); |
| | | roleVO.setParentName(parent.getRoleName()); |
| | | } |
| | | return roleVO; |
| | | } |
| | | |
| | | |
| | | public List<RoleVO> listNodeVO(List<Role> list) { |
| | | List<RoleVO> collect = list.stream().map(this::entityVO).collect(Collectors.toList()); |
| | | return ForestNodeMerger.merge(collect); |
| | | } |
| | | |
| | | } |