├── .classpath ├── .gitattributes ├── .gitignore ├── .project ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.jdt.apt.core.prefs ├── org.eclipse.jdt.core.prefs ├── org.eclipse.wst.common.component ├── org.eclipse.wst.common.project.facet.core.xml └── org.eclipse.wst.validation.prefs ├── LICENSE ├── README.md ├── bip.sql ├── pom.xml └── src └── main ├── java └── com │ └── beamofsoul │ └── bip │ ├── ApplicationEntry.java │ ├── controller │ ├── ActionMonitorController.java │ ├── BaseAbstractController.java │ ├── DepartmentController.java │ ├── DevelopmentController.java │ ├── ExceptionController.java │ ├── HomeController.java │ ├── LoginController.java │ ├── OrganizationController.java │ ├── PermissionController.java │ ├── RoleController.java │ ├── SensitiveWordController.java │ └── UserController.java │ ├── entity │ ├── ActionMonitor.java │ ├── BaseAbstractEntity.java │ ├── BaseAbstractRelationalEntity.java │ ├── Department.java │ ├── DetailControl.java │ ├── Login.java │ ├── Organization.java │ ├── Permission.java │ ├── Role.java │ ├── RolePermission.java │ ├── SensitiveWord.java │ ├── User.java │ ├── UserRole.java │ ├── UserRoleCombineRole.java │ ├── dto │ │ ├── RolePermissionDTO.java │ │ ├── RolePermissionMappingDTO.java │ │ ├── UserExtension.java │ │ └── UserRoleDTO.java │ └── query │ │ ├── QActionMonitor.java │ │ ├── QBaseAbstractEntity.java │ │ ├── QBaseAbstractRelationalEntity.java │ │ ├── QDepartment.java │ │ ├── QDetailControl.java │ │ ├── QLogin.java │ │ ├── QOrganization.java │ │ ├── QPermission.java │ │ ├── QRole.java │ │ ├── QRolePermission.java │ │ ├── QSensitiveWord.java │ │ ├── QUser.java │ │ ├── QUserRole.java │ │ └── QUserRoleCombineRole.java │ ├── management │ ├── cache │ │ ├── CacheEvictBasedCollection.java │ │ ├── CacheEvictBasedCollectionAspect.java │ │ ├── CacheableBasedPageableCollection.java │ │ ├── CacheableBasedPageableCollectionAspect.java │ │ └── GlobalSharedEhCacheConfiguration.java │ ├── cluster │ │ ├── CustomHttpSessionApplicationInitializer.java │ │ └── HttpSessionConfiguration.java │ ├── control │ │ ├── CustomHttpServletRequestWrapper.java │ │ ├── CustomJSONFilter.java │ │ ├── CustomJSONReturnHandler.java │ │ ├── CustomJSONReturnSupportFactoryBean.java │ │ ├── CustomJSONSerializer.java │ │ ├── JSON.java │ │ ├── JSONS.java │ │ ├── Monitoring.java │ │ ├── MonitoringAspect.java │ │ ├── Sensitive.java │ │ ├── SensitiveAspect.java │ │ └── SensitiveWordFilter.java │ ├── mail │ │ ├── ForgotPasswordMail.java │ │ ├── Mail.java │ │ └── UnreplyableMail.java │ ├── mvc │ │ ├── Attribute.java │ │ ├── ConditionAttribute.java │ │ ├── ConditionMethodArgumentResolver.java │ │ ├── CurrentUser.java │ │ ├── CurrentUserId.java │ │ ├── CurrentUserIdMethodArgumentResolver.java │ │ ├── CurrentUserMethodArgumentResolver.java │ │ ├── CustomWebMvcConfigurerAdapter.java │ │ ├── HttpServletRequestWrapperFilter.java │ │ ├── IdAttribute.java │ │ ├── IdMethodArgumentResolver.java │ │ ├── PageableAttribute.java │ │ ├── PageableMethodArgumentResolver.java │ │ └── SettingAttributeMethodArgumentResolver.java │ ├── repository │ │ ├── BaseMultielementRepository.java │ │ ├── BaseMultielementRepositoryFactory.java │ │ ├── BaseMultielementRepositoryImpl.java │ │ ├── BaseMultielementRepositoryProvider.java │ │ ├── CustomRepositoryConfiguration.java │ │ ├── CustomRepositoryFactory.java │ │ ├── CustomRepositoryFactoryBean.java │ │ └── JpaRepositoryConfiguration.java │ ├── runner │ │ └── CustomDataFillingStartupRunner.java │ ├── schedule │ │ └── CustomJobs.java │ ├── security │ │ ├── Authorize.java │ │ ├── AuthorizeAspect.java │ │ ├── CustomAuthenticationProvider.java │ │ ├── CustomAuthenticationSuccessHandler.java │ │ ├── CustomPermissionEvaluator.java │ │ ├── CustomRememberMeServices.java │ │ ├── CustomSecurityConfigurationProperties.java │ │ ├── CustomUserDetailsService.java │ │ └── CustomWebSecurityConfig.java │ ├── util │ │ ├── AnnotationRepositoryNameMapping.java │ │ ├── AnnotationServiceNameMapping.java │ │ ├── BooleanExpressionUtils.java │ │ ├── CacheUtils.java │ │ ├── Callback.java │ │ ├── ClientInformationUtils.java │ │ ├── ClientMacAddressHandler.java │ │ ├── CodeGenerator.java │ │ ├── CollectionUtils.java │ │ ├── CommonConvertUtils.java │ │ ├── CommonUtils.java │ │ ├── ConfigurationReader.java │ │ ├── Constants.java │ │ ├── CurrentThreadDataManager.java │ │ ├── DatabaseTableEntityMapping.java │ │ ├── DatabaseUtils.java │ │ ├── HttpServletRequestUtils.java │ │ ├── ImageUtils.java │ │ ├── JSONUtils.java │ │ ├── MailUtils.java │ │ ├── PageImpl.java │ │ ├── PageUtils.java │ │ ├── QRCodeUtils.java │ │ ├── QueryDSLUtils.java │ │ ├── RC4.java │ │ ├── RolePermissionsMapping.java │ │ ├── SensitiveWordsMapping.java │ │ ├── SerializationUtils.java │ │ ├── SpringUtils.java │ │ └── UserUtils.java │ └── websocket │ │ ├── CustomSystemLogWebSocketHandler.java │ │ └── CustomWebSocketConfiguration.java │ ├── repository │ ├── ActionMonitorRepository.java │ ├── DepartmentRepository.java │ ├── DetailControlRepository.java │ ├── LoginRepository.java │ ├── MessageRepositoryCustom.java │ ├── OrganizationRepository.java │ ├── OrganizationRepositoryCustom.java │ ├── PermissionRepository.java │ ├── RolePermissionRepository.java │ ├── RolePermissionRepositoryCustom.java │ ├── RoleRepository.java │ ├── SensitiveWordRepository.java │ ├── UserRepository.java │ ├── UserRoleRepository.java │ ├── UserRoleRepositoryCustom.java │ └── impl │ │ ├── OrganizationRepositoryImpl.java │ │ ├── RolePermissionRepositoryImpl.java │ │ └── UserRoleRepositoryImpl.java │ └── service │ ├── ActionMonitorService.java │ ├── BaseServiceInterface.java │ ├── DepartmentService.java │ ├── DetailControlService.java │ ├── LoginService.java │ ├── OrganizationService.java │ ├── PermissionService.java │ ├── RolePermissionService.java │ ├── RoleService.java │ ├── SensitiveWordService.java │ ├── UserRoleService.java │ ├── UserService.java │ └── impl │ ├── ActionMonitorServiceImpl.java │ ├── BaseAbstractServiceImpl.java │ ├── DepartmentServiceImpl.java │ ├── DetailControlServiceImpl.java │ ├── LoginServiceImpl.java │ ├── OrganizationServiceImpl.java │ ├── PermissionServiceImpl.java │ ├── RolePermissionServiceImpl.java │ ├── RoleServiceImpl.java │ ├── SensitiveWordServiceImpl.java │ ├── UserRoleServiceImpl.java │ └── UserServiceImpl.java └── resources ├── application.yml ├── banner.txt ├── ehcache.xml ├── logback.xml ├── static ├── HOTKEYS │ └── js │ │ └── hotkeys.min.js ├── WEBSOCKET │ └── js │ │ ├── sockjs-1.1.2.min.js │ │ └── stomp.js ├── css │ ├── business │ │ ├── admin-index-iview.css │ │ ├── admin-index.css │ │ ├── backend-biz.css │ │ └── user-biz.css │ └── web │ │ └── index.css ├── image │ ├── SpringSecurityExecutionFlowDiagram.jpg │ ├── default_avatar.png │ ├── logo_qrcode.png │ ├── temp │ │ ├── timg (1).jpg │ │ ├── timg (2).jpg │ │ └── timg.jpg │ └── user2-160x160.jpg ├── iview │ ├── fonts │ │ ├── ionicons.eot │ │ ├── ionicons.svg │ │ ├── ionicons.ttf │ │ └── ionicons.woff │ ├── iview-custom.css │ ├── iview.css │ ├── iview.js │ ├── iview.min.js │ ├── jquery.min.js │ ├── vue.js │ └── vue.min.js └── js │ ├── business │ ├── action-monitor-biz.js │ ├── admin-index-biz.js │ ├── backend-biz.js │ ├── department-biz.js │ ├── development-biz.js │ ├── login-biz.js │ ├── organization-biz.js │ ├── permission-biz.js │ ├── role-biz.js │ ├── role-user-biz.js │ ├── sensitive-word-biz.js │ └── user-biz.js │ ├── system │ └── global-ajax-exception-handler.js │ └── utils │ ├── ajax-utils.js │ ├── common-utils.js │ ├── form-utils.js │ ├── format-utils.js │ ├── hotkey-utils.js │ ├── iview-utils.js │ ├── table-utils.js │ └── tree-utils.js └── templates ├── action_monitor └── admin_action_monitor_list.html ├── admin_index.html ├── department └── admin_department_list.html ├── development └── admin_development_main.html ├── error.html ├── fragment ├── admin_breadcrumb.html ├── admin_content.html ├── admin_content_delete_modal.html ├── admin_content_query_form.html ├── admin_content_scripts.html ├── admin_content_table.html ├── admin_footer.html ├── admin_header.html ├── admin_sidebar.html └── header.html ├── index.html ├── login.html ├── login └── admin_login_list.html ├── organization └── admin_organization_list.html ├── permission └── admin_permission_list.html ├── role └── admin_role_list.html ├── role_user └── admin_role_user_list.html ├── sensitive_word └── admin_sensitive_word_list.html ├── system_log └── admin_system_log_list.html └── user └── admin_user_list.html /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BusinessInfrastructurePlatformGroupVersion 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | org.springframework.ide.eclipse.core.springbuilder 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.ide.eclipse.core.springnature 36 | org.eclipse.jem.workbench.JavaEMFNature 37 | org.eclipse.wst.common.modulecore.ModuleCoreNature 38 | org.eclipse.jdt.core.javanature 39 | org.eclipse.m2e.core.maven2Nature 40 | org.eclipse.wst.common.project.facet.core.nature 41 | org.eclipse.wst.jsdt.core.jsNature 42 | 43 | 44 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=true 3 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.processAnnotations=enabled 9 | org.eclipse.jdt.core.compiler.source=1.8 10 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BusinessInfrastructurePlatformGroupVersion 2 | 3 |

Run

4 | clean org.springframework.boot:spring-boot-maven-plugin:run -q -e 5 | 6 |

License

7 | BusinessInfrastructurePlatformGroupVersion is Open Source software released under the Apache 2.0 license 8 |

Copyright (c) 2017-present Mingshu Jian

9 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/ApplicationEntry.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.boot.web.servlet.ServletComponentScan; 7 | import org.springframework.boot.web.support.SpringBootServletInitializer; 8 | import org.springframework.cache.annotation.EnableCaching; 9 | import org.springframework.scheduling.annotation.EnableAsync; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | import org.springframework.transaction.annotation.EnableTransactionManagement; 12 | 13 | @SpringBootApplication 14 | @EnableTransactionManagement 15 | @ServletComponentScan 16 | @EnableCaching 17 | @EnableScheduling 18 | @EnableAsync //for websocket 19 | public class ApplicationEntry extends SpringBootServletInitializer { 20 | 21 | @Override 22 | protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { 23 | return builder.sources(ApplicationEntry.class); 24 | } 25 | 26 | public static void main(String[] args) { 27 | SpringApplication.run(ApplicationEntry.class, args); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/controller/ActionMonitorController.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.controller; 2 | 3 | import static com.beamofsoul.bip.management.util.JSONUtils.formatAndParseObject; 4 | import static com.beamofsoul.bip.management.util.JSONUtils.newInstance; 5 | 6 | import java.util.Map; 7 | 8 | import javax.annotation.Resource; 9 | 10 | import org.springframework.data.domain.Pageable; 11 | import org.springframework.security.access.prepost.PreAuthorize; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RequestMethod; 16 | import org.springframework.web.bind.annotation.ResponseBody; 17 | 18 | import com.alibaba.fastjson.JSONObject; 19 | import com.beamofsoul.bip.management.util.PageUtils; 20 | import com.beamofsoul.bip.service.ActionMonitorService; 21 | 22 | @Controller 23 | @RequestMapping("/admin/actionMonitor") 24 | public class ActionMonitorController extends BaseAbstractController { 25 | 26 | @Resource 27 | private ActionMonitorService actionMonitorService; 28 | 29 | @PreAuthorize("authenticated and hasPermission('actionMonitor','actionMonitor:list')") 30 | @RequestMapping(value = "/adminList") 31 | public String adminList() { 32 | return "/action_monitor/admin_action_monitor_list"; 33 | } 34 | 35 | @PreAuthorize("authenticated and hasPermission('actionMonitor','actionMonitor:list')") 36 | @RequestMapping(value = "actionMonitorsByPage", method = RequestMethod.POST, produces = PRODUCES_APPLICATION_JSON) 37 | @ResponseBody 38 | public JSONObject getPageableActionMonitors(@RequestBody Map map) { 39 | Object condition = map.get("condition"); 40 | Pageable pageable = PageUtils.parsePageable(map); 41 | return newInstance(actionMonitorService.findAll(pageable, 42 | condition == null ? null : 43 | actionMonitorService.onSearch(formatAndParseObject(condition.toString())))); 44 | } 45 | 46 | @RequestMapping(value = "single", method = RequestMethod.POST, produces = PRODUCES_APPLICATION_JSON) 47 | @ResponseBody 48 | public JSONObject getSingleJSONObject(@RequestBody Map map) { 49 | return newInstance("obj",actionMonitorService.findById(Long.valueOf(map.get("id").toString()))); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/controller/BaseAbstractController.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.controller; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpSession; 5 | 6 | import org.slf4j.Logger; 7 | import org.springframework.web.bind.annotation.ModelAttribute; 8 | 9 | import lombok.extern.slf4j.Slf4j; 10 | 11 | /** 12 | * Nothing here but blank... 13 | * Waiting for adding code lines in future... 14 | * @author MingshuJian 15 | */ 16 | @Slf4j 17 | public abstract class BaseAbstractController { 18 | 19 | static final String PRODUCES_APPLICATION_JSON = "application/json"; 20 | static Logger logger = log; 21 | 22 | @ModelAttribute 23 | void preAction(HttpSession session, HttpServletRequest request) { 24 | try { 25 | // if (!containsKey(CLIENT_IP_ADDRESS)) { 26 | // String ipAddress = getIpAddress(request); 27 | // String macAddress = getMacAddress(ipAddress); 28 | // setData(CLIENT_IP_ADDRESS, ipAddress); 29 | // setData(CLIENT_MAC_ADDRESS, macAddress); 30 | // } 31 | // if (!containsKey(CURRENT_USER)) { 32 | // if (isExist(session)) { 33 | // setData(CURRENT_USER, getLongUserId(session)); 34 | // } 35 | // } 36 | } catch (Exception e) { 37 | log.debug("获取客户端IP地址与MAC地址失败", e); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/controller/DevelopmentController.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.controller; 2 | 3 | import static com.beamofsoul.bip.management.util.JSONUtils.newInstance; 4 | 5 | import java.io.BufferedWriter; 6 | import java.nio.charset.StandardCharsets; 7 | import java.nio.file.Files; 8 | import java.nio.file.Paths; 9 | import java.util.Map; 10 | 11 | import org.mdkt.compiler.InMemoryJavaCompiler; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RequestMethod; 16 | import org.springframework.web.bind.annotation.ResponseBody; 17 | 18 | import com.alibaba.fastjson.JSONObject; 19 | 20 | @Controller 21 | @RequestMapping("/admin/development") 22 | public class DevelopmentController extends BaseAbstractController { 23 | 24 | @RequestMapping(value = "/adminList") 25 | public String adminList() { 26 | return "/development/admin_development_main"; 27 | } 28 | 29 | @RequestMapping(value = "/buildEntity", method = RequestMethod.POST) 30 | @ResponseBody 31 | public JSONObject buildEntity(@RequestBody Map map) { 32 | String entityName = map.get("entityName").toString(); 33 | StringBuffer entityContent = getEntityContent(); 34 | Object instance = null; 35 | try { 36 | try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(getFullSourcePath(entityName)), StandardCharsets.UTF_8)) { 37 | writer.write(entityContent.toString()); 38 | } 39 | Class clazz = InMemoryJavaCompiler.compile("com.beamofsoul.bip.entity." + entityName, entityContent.toString()); 40 | instance = clazz.newInstance(); 41 | } catch (Exception e) { 42 | e.printStackTrace(); 43 | } 44 | 45 | return newInstance("instance", instance.toString()); 46 | } 47 | 48 | private String getFullSourcePath(String entityName) { 49 | return System.getProperty("user.dir") + "/src/main/java/com/beamofsoul/bip/entity/" + entityName + ".java"; 50 | } 51 | 52 | private StringBuffer getEntityContent() { 53 | StringBuffer entityContent = new StringBuffer(); 54 | entityContent.append("package com.beamofsoul.bip.entity;\r\n\r\n"); 55 | entityContent.append("public class TestEntity {\r\n\r\n"); 56 | entityContent.append(" @Override\r\n"); 57 | entityContent.append(" public String toString() {\r\n"); 58 | entityContent.append(" return \"This is the result of toString method from TestEntity instance...\";\r\n"); 59 | entityContent.append(" }\r\n"); 60 | entityContent.append("}"); 61 | return entityContent; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/controller/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.controller; 2 | 3 | import java.util.Map; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | import javax.servlet.http.HttpSession; 8 | 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.servlet.ModelAndView; 13 | 14 | import com.beamofsoul.bip.management.util.Constants; 15 | 16 | @Controller 17 | public class HomeController { 18 | 19 | @RequestMapping(value = { "/", "/index" }, method = RequestMethod.GET) 20 | public String index(HttpServletRequest request, HttpServletResponse response, Map map) { 21 | return "index"; 22 | } 23 | 24 | @RequestMapping(value = "/admin/adminIndex", method = RequestMethod.GET) 25 | public ModelAndView adminIndex(HttpServletRequest request, HttpServletResponse response, HttpSession session) { 26 | return new ModelAndView("admin_index"); 27 | } 28 | 29 | @RequestMapping(value = "/admin/adminIndexContent", method = RequestMethod.GET) 30 | public ModelAndView adminIndexContent() { 31 | return new ModelAndView("/fragment/admin_content"); 32 | } 33 | 34 | @RequestMapping(value = "/login", method = RequestMethod.GET) 35 | public String login(HttpSession session, Map map) { 36 | if (session.getAttribute(Constants.CURRENT_USER) != null) 37 | return "redirect:/index"; 38 | return "login"; 39 | } 40 | 41 | @RequestMapping(value = "/logout", method = RequestMethod.GET) 42 | public String logout(HttpSession session, Map map) { 43 | session.invalidate(); 44 | return "login"; 45 | } 46 | 47 | @RequestMapping(value = "/expired", method = RequestMethod.GET) 48 | public String expired(Map map) { 49 | map.put("expired", "该账号已经在其他地方重新登录"); 50 | return "login"; 51 | } 52 | 53 | @RequestMapping(value = "/anonymous", method = RequestMethod.GET) 54 | public String anonymousLogin() { 55 | return "admin_index"; 56 | } 57 | 58 | // @RequestMapping(value = "/admin/systemLog") 59 | // public String systemLog() { 60 | // return "/system_log/admin_system_log_list"; 61 | // } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.controller; 2 | 3 | import static com.beamofsoul.bip.management.util.JSONUtils.formatAndParseObject; 4 | import static com.beamofsoul.bip.management.util.JSONUtils.newInstance; 5 | 6 | import java.util.Map; 7 | 8 | import javax.annotation.Resource; 9 | 10 | import org.springframework.data.domain.Pageable; 11 | import org.springframework.security.access.prepost.PreAuthorize; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RequestMethod; 16 | import org.springframework.web.bind.annotation.ResponseBody; 17 | 18 | import com.alibaba.fastjson.JSONObject; 19 | import com.beamofsoul.bip.management.util.PageUtils; 20 | import com.beamofsoul.bip.service.LoginService; 21 | 22 | @Controller 23 | @RequestMapping("/admin/login") 24 | public class LoginController extends BaseAbstractController { 25 | 26 | @Resource 27 | private LoginService loginService; 28 | 29 | @PreAuthorize("authenticated and hasPermission('login','login:list')") 30 | @RequestMapping(value = "/adminList") 31 | public String adminList() { 32 | return "/login/admin_login_list"; 33 | } 34 | 35 | @PreAuthorize("authenticated and hasPermission('login','login:list')") 36 | @RequestMapping(value = "loginsByPage", method = RequestMethod.POST, produces = PRODUCES_APPLICATION_JSON) 37 | @ResponseBody 38 | public JSONObject getPageableLogins(@RequestBody Map map) { 39 | Object condition = map.get("condition"); 40 | Pageable pageable = PageUtils.parsePageable(map); 41 | return newInstance(loginService.findAll(pageable, 42 | condition == null ? null : 43 | loginService.onSearch(formatAndParseObject(condition.toString())))); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/ActionMonitor.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import java.util.HashMap; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.JoinColumn; 11 | import javax.persistence.ManyToOne; 12 | import javax.persistence.Table; 13 | 14 | import lombok.AccessLevel; 15 | import lombok.AllArgsConstructor; 16 | import lombok.Builder; 17 | import lombok.Data; 18 | import lombok.EqualsAndHashCode; 19 | import lombok.Getter; 20 | import lombok.NoArgsConstructor; 21 | import lombok.RequiredArgsConstructor; 22 | 23 | /** 24 | * 行为监控 25 | */ 26 | @Data 27 | @EqualsAndHashCode(callSuper = false) 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | @Builder 31 | 32 | @Entity 33 | @Table(name = "T_ACTION_MONITOR") 34 | public class ActionMonitor extends BaseAbstractEntity { 35 | 36 | private static final long serialVersionUID = 7936770852487042470L; 37 | /** 38 | * id 39 | */ 40 | @Id 41 | @GeneratedValue(strategy = GenerationType.AUTO) 42 | @Column(name = "id") 43 | private Long id; 44 | /** 45 | * 操作行为用户 46 | */ 47 | @ManyToOne 48 | @JoinColumn(name = "user_id") 49 | private User user; 50 | /** 51 | * 针对目标 52 | */ 53 | @Column(name = "target") 54 | private String target; 55 | /** 56 | * 特定操作 57 | */ 58 | @Column(name = "specific_action") 59 | private String specificAction; 60 | /** 61 | * 对目标的影响 62 | */ 63 | @Column(name = "effect") 64 | private String effect; 65 | /** 66 | * 客户端ip地址 67 | */ 68 | @Column(name = "id_address") 69 | private String ipAddress; 70 | /** 71 | * 客户端mac地址 72 | */ 73 | @Column(name = "mac_address") 74 | private String macAddress; 75 | /** 76 | * 可能对系统造成的危害的危险等级 77 | */ 78 | @Column(name = "hazard_level") 79 | private Integer hazardLevel; //0: 毁灭性的, 1: 极恶性的, 2: 恶性的, 3: 良性的, 4: 可忽略的 80 | 81 | @RequiredArgsConstructor(access=AccessLevel.PROTECTED) 82 | public static enum HazardLevel { 83 | CATASTROPHIC(0),EXTREMELY_VIRULENT(1),VIRULENT(2),BENIGN(3),INSIGNIFICANT(4); 84 | @Getter private final Integer value; 85 | private static HashMap codeValueMap = new HashMap<>(5); 86 | static { 87 | for (HazardLevel hazardLevel : HazardLevel.values()) { 88 | codeValueMap.put(hazardLevel.value, hazardLevel); 89 | } 90 | } 91 | 92 | public static HazardLevel getInstance(Integer code) { 93 | return codeValueMap.get(code); 94 | } 95 | } 96 | } -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/BaseAbstractEntity.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import java.io.Serializable; 4 | import java.io.StringWriter; 5 | import java.util.Date; 6 | 7 | import javax.persistence.Column; 8 | import javax.persistence.MappedSuperclass; 9 | import javax.xml.bind.JAXBContext; 10 | import javax.xml.bind.Marshaller; 11 | 12 | import org.springframework.format.annotation.DateTimeFormat; 13 | 14 | import com.alibaba.fastjson.JSONObject; 15 | import com.alibaba.fastjson.serializer.SerializerFeature; 16 | 17 | import lombok.AllArgsConstructor; 18 | import lombok.Data; 19 | 20 | /** 21 | * 基本 22 | */ 23 | @Data 24 | @AllArgsConstructor 25 | @MappedSuperclass 26 | public abstract class BaseAbstractEntity implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * 创建日期 32 | */ 33 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 34 | @Column(name = "CREATE_DATE", updatable = false) 35 | protected Date createDate; 36 | 37 | /** 38 | * 修改日期 39 | */ 40 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 41 | @Column(name = "MODIFY_DATE") 42 | protected Date modifyDate; 43 | 44 | public BaseAbstractEntity() { 45 | this.createDate = this.modifyDate = new Date(); 46 | } 47 | 48 | public String toString() { 49 | return JSONObject.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect); 50 | } 51 | 52 | public String toXML() { 53 | String xmlString = null; 54 | try { 55 | StringWriter writer = new StringWriter(); 56 | JAXBContext context = JAXBContext.newInstance(getClass()); 57 | Marshaller marshaller = context.createMarshaller(); 58 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); 59 | 60 | marshaller.marshal(this, writer); 61 | xmlString = writer.toString(); 62 | } catch (Exception e) { 63 | e.printStackTrace(); 64 | } 65 | return xmlString; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/BaseAbstractRelationalEntity.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import javax.persistence.MappedSuperclass; 4 | import javax.persistence.Transient; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Getter; 8 | 9 | @Getter 10 | @AllArgsConstructor 11 | @MappedSuperclass 12 | public class BaseAbstractRelationalEntity extends BaseAbstractEntity { 13 | 14 | private static final long serialVersionUID = 3939416931646679237L; 15 | 16 | /** 17 | * 子节点的数量 18 | */ 19 | @Transient 20 | private Long countOfChildren; 21 | /** 22 | * 是否为父节点 23 | */ 24 | @Transient 25 | private Boolean isParent; 26 | 27 | public BaseAbstractRelationalEntity() { 28 | super(); 29 | } 30 | 31 | public BaseAbstractRelationalEntity(Long countOfChildren) { 32 | super(); 33 | setter(countOfChildren); 34 | } 35 | 36 | public void setCountOfChildren(Long countOfChildren) { 37 | setter(countOfChildren); 38 | } 39 | 40 | private void setter(Long countOfChildren) { 41 | if (countOfChildren == null) countOfChildren = 0L; 42 | this.countOfChildren = countOfChildren; 43 | this.isParent = countOfChildren > 0; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/Department.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.JoinColumn; 9 | import javax.persistence.ManyToOne; 10 | import javax.persistence.Table; 11 | 12 | import lombok.AllArgsConstructor; 13 | import lombok.EqualsAndHashCode; 14 | import lombok.Getter; 15 | import lombok.NoArgsConstructor; 16 | import lombok.Setter; 17 | 18 | /** 19 | * @ClassName Department 20 | * @Description 部门表实体类 21 | * @author MingshuJian 22 | * @Date 2017年5月19日 上午09:53:00 23 | * @version 1.0.0 24 | */ 25 | @Setter 26 | @Getter 27 | @NoArgsConstructor 28 | @AllArgsConstructor 29 | @EqualsAndHashCode(callSuper=false) 30 | 31 | @Entity 32 | @Table(name = "T_DEPARTMENT") 33 | public class Department extends BaseAbstractRelationalEntity { 34 | 35 | private static final long serialVersionUID = 7325041962975446069L; 36 | 37 | @Id 38 | @GeneratedValue(strategy = GenerationType.AUTO) 39 | @Column 40 | protected Long id; 41 | /** 42 | * 部门编码 43 | */ 44 | @Column 45 | private String code; 46 | /** 47 | * 部门名称 48 | */ 49 | @Column 50 | private String name; 51 | /** 52 | * 部门描述 53 | */ 54 | @Column 55 | private String descirption; 56 | /** 57 | * 排序 58 | */ 59 | @Column 60 | private Integer sort; 61 | /** 62 | * 上级部门 63 | */ 64 | @ManyToOne 65 | @JoinColumn(name = "PARENT_ID", nullable = true) 66 | private Department parent; 67 | /** 68 | * 所属结构 69 | */ 70 | @ManyToOne 71 | @JoinColumn(name = "ORGANIZATION_ID", nullable = true) 72 | private Organization organization; 73 | /** 74 | * 是否可用 75 | */ 76 | @Column 77 | private Boolean available; 78 | 79 | @Override 80 | public String toString() { 81 | return "Department [id=" + id + ", code=" + code + ", name=" + name + ", descirption=" + descirption + ", sort=" 82 | + sort + ", parent=" + parent + ", available=" + available + "]"; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/DetailControl.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | 10 | import lombok.AllArgsConstructor; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | import lombok.NoArgsConstructor; 14 | 15 | /** 16 | * 详细控制 17 | */ 18 | @Data 19 | @EqualsAndHashCode(callSuper = false) 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | 23 | @Entity 24 | @Table(name = "T_DETAIL_CONTROL") 25 | public class DetailControl extends BaseAbstractEntity { 26 | 27 | private static final long serialVersionUID = -6722830563824341150L; 28 | 29 | /** 30 | * id 31 | */ 32 | @Id 33 | @GeneratedValue(strategy = GenerationType.AUTO) 34 | @Column(name = "id") 35 | protected Long id; 36 | /** 37 | * 角色ID 38 | */ 39 | @Column(name = "role_id") 40 | private Long roleId; 41 | /** 42 | * 实体类 43 | */ 44 | @Column(name = "entity_class") 45 | private String entityClass; 46 | /** 47 | * 不可用列 48 | */ 49 | @Column(name = "unavailable_columns") 50 | private String unavailableColumns; 51 | /** 52 | * 过滤规则 53 | */ 54 | @Column(name = "filter_rules") 55 | private String filterRules; 56 | /** 57 | * 优先 priority的值越小,优先级越高 58 | */ 59 | @Column(name = "priority") 60 | private Integer priority; 61 | /** 62 | * 启用 63 | */ 64 | @Column(name = "enabled") 65 | private Boolean enabled; 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/Login.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.JoinColumn; 9 | import javax.persistence.ManyToOne; 10 | import javax.persistence.Table; 11 | 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.EqualsAndHashCode; 15 | import lombok.NoArgsConstructor; 16 | 17 | /** 18 | * @ClassName Login 19 | * @Description 系统登录记录表实体类 20 | * @author MingshuJian 21 | * @Date 2017年5月31日 上午10:27:23 22 | * @version 1.0.0 23 | */ 24 | @NoArgsConstructor 25 | @AllArgsConstructor 26 | @EqualsAndHashCode(callSuper=false) 27 | @Data 28 | 29 | @Entity 30 | @Table(name = "T_LOGIN") 31 | public class Login extends BaseAbstractEntity { 32 | 33 | private static final long serialVersionUID = 1336473767251163468L; 34 | 35 | /** 36 | * id 37 | */ 38 | @Id 39 | @GeneratedValue(strategy = GenerationType.AUTO) 40 | @Column(name = "id") 41 | protected Long id; 42 | /** 43 | * 登录用户 44 | */ 45 | @ManyToOne 46 | @JoinColumn(name = "user_id") 47 | private User user; 48 | /** 49 | * IP地址 50 | */ 51 | @Column(name = "ip_address") 52 | private String ipAddress; 53 | /** 54 | * 所用设备品牌 55 | */ 56 | @Column(name = "brand") 57 | private String brand; 58 | /** 59 | * 所用设备型号 60 | */ 61 | @Column(name = "model") 62 | private String model; 63 | /** 64 | * 所用设备屏幕尺寸 65 | */ 66 | @Column(name = "screen_size") 67 | private String screenSize; 68 | /** 69 | * 所用设备操作系统 70 | */ 71 | @Column(name = "operating_system") 72 | private String operatingSystem; 73 | /** 74 | * 访问的浏览器 75 | */ 76 | @Column(name = "browser") 77 | private String browser; 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/Organization.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import java.util.HashMap; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.JoinColumn; 11 | import javax.persistence.ManyToOne; 12 | import javax.persistence.Table; 13 | 14 | import lombok.AccessLevel; 15 | import lombok.AllArgsConstructor; 16 | import lombok.EqualsAndHashCode; 17 | import lombok.Getter; 18 | import lombok.NoArgsConstructor; 19 | import lombok.RequiredArgsConstructor; 20 | import lombok.Setter; 21 | 22 | /** 23 | * @ClassName Organization 24 | * @Description 系统组织机构信息表实体类 25 | * @author MingshuJian 26 | * @Date 2017年1月21日 上午9:21:27 27 | * @version 1.0.0 28 | */ 29 | @Setter 30 | @Getter 31 | @NoArgsConstructor 32 | @AllArgsConstructor 33 | @EqualsAndHashCode(callSuper=false) 34 | 35 | @Entity 36 | @Table(name = "T_ORGANIZATION") 37 | public class Organization extends BaseAbstractRelationalEntity { 38 | 39 | private static final long serialVersionUID = -3698064755378429720L; 40 | 41 | @Id 42 | @GeneratedValue(strategy = GenerationType.AUTO) 43 | @Column(name = "id") 44 | protected Long id; 45 | /** 46 | * 组织机构名称 47 | */ 48 | @Column(name = "name") 49 | private String name; 50 | /** 51 | * 组织机构描述 52 | */ 53 | @Column(name = "descirption") 54 | private String descirption; 55 | /** 56 | * 排序 57 | */ 58 | @Column(name = "sort") 59 | private Integer sort; 60 | /** 61 | * 上级组织机构 62 | */ 63 | // @Column(name = "parentId") 64 | // private Long parentId; 65 | 66 | @ManyToOne 67 | @JoinColumn(name = "PARENT_ID", nullable = true) 68 | private Organization parent; 69 | 70 | 71 | // @ManyToOne(cascade = CascadeType.ALL) 72 | // @JoinColumn(name = "PARENT_ID") 73 | // private Organization parent; 74 | /** 75 | * 是否可用 76 | */ 77 | // @Column 78 | // private Boolean available; 79 | @Column(name = "available") 80 | private Boolean available = Boolean.FALSE; 81 | 82 | @Override 83 | public String toString() { 84 | return "Organization [id=" + id + ", name=" + name + ", descirption=" + descirption + ", sort=" + sort 85 | + ", parent=" + parent + ", available=" + available + "]"; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/Role.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import javax.persistence.CascadeType; 7 | import javax.persistence.Column; 8 | import javax.persistence.Entity; 9 | import javax.persistence.FetchType; 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.GenerationType; 12 | import javax.persistence.Id; 13 | import javax.persistence.JoinColumn; 14 | import javax.persistence.JoinTable; 15 | import javax.persistence.ManyToMany; 16 | import javax.persistence.Table; 17 | 18 | import lombok.Getter; 19 | import lombok.NoArgsConstructor; 20 | import lombok.Setter; 21 | 22 | /** 23 | * @ClassName Role 24 | * @Description 系统角色表实体类 25 | * @author MingshuJian 26 | * @Date 2017年2月7日 上午10:42:23 27 | * @version 1.0.0 28 | */ 29 | @Setter 30 | @Getter 31 | @NoArgsConstructor 32 | 33 | @Entity 34 | @Table(name = "T_ROLE") 35 | public class Role extends BaseAbstractEntity { 36 | 37 | private static final long serialVersionUID = -3376152299137758615L; 38 | private static final int MAX_PRIORITY = 99; 39 | 40 | @Id 41 | @GeneratedValue(strategy = GenerationType.AUTO) 42 | @Column(name = "id") 43 | private Long id; 44 | 45 | @Column(name = "name") 46 | private String name; 47 | 48 | @Column(name = "priority") 49 | private int priority; //优先级数值越低,代表优先级越大,角色normal的优先级为99 50 | 51 | @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE }, fetch = FetchType.LAZY) 52 | @JoinTable(name = "T_ROLE_PERMISSION", joinColumns = { @JoinColumn(name = "role_id") }, inverseJoinColumns = { 53 | @JoinColumn(name = "permission_id") }) 54 | private Set permissions = new HashSet(0); 55 | 56 | public Role(Long id) { 57 | this.id = id; 58 | } 59 | 60 | public Role(Long id, String name) { 61 | super(); 62 | this.id = id; 63 | this.name = name; 64 | this.priority = MAX_PRIORITY; 65 | } 66 | 67 | public Role(Long id, String name, int priority) { 68 | super(); 69 | this.id = id; 70 | this.name = name; 71 | this.priority = priority; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return "Role [id=" + id + ", name=" + name + ", priority=" + priority + "]"; 77 | } 78 | } -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/RolePermission.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.FetchType; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.JoinColumn; 10 | import javax.persistence.ManyToOne; 11 | import javax.persistence.Table; 12 | 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.EqualsAndHashCode; 16 | import lombok.NoArgsConstructor; 17 | 18 | /** 19 | * 角色权限 20 | */ 21 | @Data 22 | @EqualsAndHashCode(callSuper = false) 23 | @NoArgsConstructor 24 | @AllArgsConstructor 25 | 26 | @Entity 27 | @Table(name = "T_ROLE_PERMISSION") 28 | public class RolePermission extends BaseAbstractEntity { 29 | 30 | private static final long serialVersionUID = 4579842972075517496L; 31 | 32 | /** 33 | * id 34 | */ 35 | @Id 36 | @GeneratedValue(strategy = GenerationType.AUTO) 37 | @Column(name = "id") 38 | protected Long id; 39 | /** 40 | * 角色 41 | */ 42 | @ManyToOne(fetch = FetchType.LAZY) 43 | @JoinColumn(name = "ROLE_ID") 44 | private Role role; 45 | /** 46 | * 权限 47 | */ 48 | @ManyToOne(fetch = FetchType.LAZY) 49 | @JoinColumn(name = "PERMISSION_ID") 50 | private Permission permission; 51 | 52 | public RolePermission(Role role, Permission permission) { 53 | this.role = role; 54 | this.permission = permission; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/SensitiveWord.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | 10 | import lombok.AllArgsConstructor; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | import lombok.NoArgsConstructor; 14 | 15 | /** 16 | * @ClassName SensitiveWord 17 | * @Description 系统敏感词表实体类 18 | * @author MingshuJian 19 | * @Date 2017年5月31日 上午10:27:23 20 | * @version 1.0.0 21 | */ 22 | @NoArgsConstructor 23 | @AllArgsConstructor 24 | @EqualsAndHashCode(callSuper=false) 25 | @Data 26 | 27 | @Entity 28 | @Table(name = "T_SENSITIVE_WORD") 29 | public class SensitiveWord extends BaseAbstractEntity { 30 | 31 | private static final long serialVersionUID = 5424728581820646841L; 32 | 33 | /** 34 | * id 35 | */ 36 | @Id 37 | @GeneratedValue(strategy = GenerationType.AUTO) 38 | @Column(name = "id") 39 | protected Long id; 40 | /** 41 | * 敏感词 42 | */ 43 | @Column(name = "word") 44 | private String word; //多个词用#间隔 45 | /** 46 | * 替换词 47 | */ 48 | @Column(name = "replacement") 49 | private String replacement; 50 | /** 51 | * 是否正则表达式 52 | */ 53 | @Column(name = "regular") 54 | private Boolean regular; 55 | /** 56 | * 可用状态 57 | */ 58 | @Column(name = "available") 59 | private Boolean available; 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.FetchType; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.JoinColumn; 10 | import javax.persistence.ManyToOne; 11 | import javax.persistence.Table; 12 | 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.EqualsAndHashCode; 16 | import lombok.NoArgsConstructor; 17 | 18 | /** 19 | * 用户角色 20 | */ 21 | @Data 22 | @EqualsAndHashCode(callSuper = false) 23 | @NoArgsConstructor 24 | @AllArgsConstructor 25 | 26 | @Entity 27 | @Table(name = "T_USER_ROLE") 28 | public class UserRole extends BaseAbstractEntity { 29 | 30 | private static final long serialVersionUID = 5958425793207457337L; 31 | 32 | /** 33 | * id 34 | */ 35 | @Id 36 | @GeneratedValue(strategy = GenerationType.AUTO) 37 | @Column(name = "id") 38 | protected Long id; 39 | /** 40 | * 用户 41 | */ 42 | @ManyToOne(fetch = FetchType.LAZY) 43 | @JoinColumn(name = "USER_ID") 44 | private User user; 45 | /** 46 | * 角色 47 | */ 48 | @ManyToOne(fetch = FetchType.LAZY) 49 | @JoinColumn(name = "ROLE_ID") 50 | private Role role; 51 | 52 | public UserRole(User user, Role role) { 53 | this.user = user; 54 | this.role = role; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/UserRoleCombineRole.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | 10 | import lombok.AllArgsConstructor; 11 | import lombok.Data; 12 | import lombok.NoArgsConstructor; 13 | 14 | @Data 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | 18 | @Entity 19 | @Table(name="V_User_Role_Combine_Role") 20 | public class UserRoleCombineRole implements Serializable { 21 | 22 | private static final long serialVersionUID = 6512226179888555302L; 23 | 24 | @Id 25 | @Column(name="id", insertable=false, updatable=false) 26 | private String id; 27 | 28 | @Column(name="user_id", insertable=false, updatable=false) 29 | private Long userId; 30 | 31 | @Column(name="username", insertable=false, updatable=false) 32 | private String username; 33 | 34 | @Column(name="nickname", insertable=false, updatable=false) 35 | private String nickname; 36 | 37 | @Column(name="role_id", insertable=false, updatable=false) 38 | private String roleId; 39 | 40 | @Column(name="role_name", insertable=false, updatable=false) 41 | private String roleName; 42 | } -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/dto/RolePermissionDTO.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.dto; 2 | 3 | import com.beamofsoul.bip.entity.Permission; 4 | import com.beamofsoul.bip.entity.Role; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Data 11 | @NoArgsConstructor(force=true) 12 | @AllArgsConstructor 13 | public class RolePermissionDTO { 14 | 15 | private Long roleId; 16 | private String roleName; 17 | private Long permissionId; 18 | private String permissionName; 19 | private String permissionAction; 20 | private String permissionUrl; 21 | private String permissionResourceType; 22 | private Long permissionParentId; 23 | private String permissionGroup; 24 | private Long permissionSort; 25 | private Boolean permissionAvailable; 26 | 27 | public RolePermissionDTO(Long roleId, String roleName, 28 | Long permissionId, String permissionName, 29 | Boolean permissionAvailable, Long permissionParentId, 30 | String permissionResourceType, String permissionUrl, 31 | String permissionAction, Long permissionSort) { 32 | super(); 33 | this.roleId = roleId; 34 | this.roleName = roleName; 35 | this.permissionId = permissionId; 36 | this.permissionName = permissionName; 37 | this.permissionAvailable = permissionAvailable; 38 | this.permissionParentId = permissionParentId; 39 | this.permissionResourceType = permissionResourceType; 40 | this.permissionUrl = permissionUrl; 41 | this.permissionAction = permissionAction; 42 | this.permissionSort = permissionSort; 43 | } 44 | 45 | public Role convertToRole() { 46 | return new Role(roleId, roleName); 47 | } 48 | 49 | public Permission convertToPermission() { 50 | return new Permission(permissionId, permissionName, permissionAction, 51 | permissionUrl, permissionResourceType, permissionParentId, 52 | permissionGroup, permissionSort, permissionAvailable); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/dto/RolePermissionMappingDTO.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.dto; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | /** 11 | * @ClassName RolePermissionMappingDTO 12 | * @Description 角色权限实体类映射关系数据传输对象 13 | * @author MingshuJian 14 | * @Date 2017年2月21日 下午2:15:30 15 | * @version 1.0.0 16 | */ 17 | @Data 18 | @NoArgsConstructor 19 | @AllArgsConstructor 20 | public class RolePermissionMappingDTO { 21 | 22 | private Long roleId; 23 | private Set permissionIds; 24 | 25 | public Set getPermissionIds() { 26 | return permissionIds == null ? new HashSet(0) : permissionIds; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/dto/UserExtension.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.dto; 2 | 3 | import java.util.Collection; 4 | 5 | import org.springframework.security.core.GrantedAuthority; 6 | import org.springframework.security.core.userdetails.User; 7 | 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | 11 | @Setter 12 | @Getter 13 | public class UserExtension extends User { 14 | 15 | private static final long serialVersionUID = -8269621072024835804L; 16 | 17 | private Long userId; 18 | private String nickname; 19 | 20 | public UserExtension(Long userId, String username, String password, String nickname, boolean enabled, boolean accountNonExpired, 21 | boolean credentialsNonExpired, boolean accountNonLocked, 22 | Collection authorities) { 23 | super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities); 24 | this.userId = userId; 25 | this.nickname = nickname; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/dto/UserRoleDTO.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor(force=true) 9 | @AllArgsConstructor 10 | public class UserRoleDTO { 11 | 12 | private Long userRoleId; 13 | private long userId; 14 | private String username; 15 | private String nickname; 16 | private Long roleId; 17 | private String roleName; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QActionMonitor.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.ActionMonitor; 11 | import com.querydsl.core.types.Path; 12 | 13 | 14 | /** 15 | * QActionMonitor is a Querydsl query type for ActionMonitor 16 | */ 17 | @Generated("com.querydsl.codegen.EntitySerializer") 18 | public class QActionMonitor extends EntityPathBase { 19 | 20 | private static final long serialVersionUID = 1626582214L; 21 | 22 | private static final PathInits INITS = PathInits.DIRECT2; 23 | 24 | public static final QActionMonitor actionMonitor = new QActionMonitor("actionMonitor"); 25 | 26 | public final QBaseAbstractEntity _super = new QBaseAbstractEntity(this); 27 | 28 | //inherited 29 | public final DateTimePath createDate = _super.createDate; 30 | 31 | public final StringPath effect = createString("effect"); 32 | 33 | public final NumberPath hazardLevel = createNumber("hazardLevel", Integer.class); 34 | 35 | public final NumberPath id = createNumber("id", Long.class); 36 | 37 | public final StringPath ipAddress = createString("ipAddress"); 38 | 39 | public final StringPath macAddress = createString("macAddress"); 40 | 41 | //inherited 42 | public final DateTimePath modifyDate = _super.modifyDate; 43 | 44 | public final StringPath specificAction = createString("specificAction"); 45 | 46 | public final StringPath target = createString("target"); 47 | 48 | public final QUser user; 49 | 50 | public QActionMonitor(String variable) { 51 | this(ActionMonitor.class, forVariable(variable), INITS); 52 | } 53 | 54 | public QActionMonitor(Path path) { 55 | this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); 56 | } 57 | 58 | public QActionMonitor(PathMetadata metadata) { 59 | this(metadata, PathInits.getFor(metadata, INITS)); 60 | } 61 | 62 | public QActionMonitor(PathMetadata metadata, PathInits inits) { 63 | this(ActionMonitor.class, metadata, inits); 64 | } 65 | 66 | public QActionMonitor(Class type, PathMetadata metadata, PathInits inits) { 67 | super(type, metadata, inits); 68 | this.user = inits.isInitialized("user") ? new QUser(forProperty("user")) : null; 69 | } 70 | 71 | } 72 | 73 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QBaseAbstractEntity.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.BaseAbstractEntity; 11 | import com.querydsl.core.types.Path; 12 | 13 | 14 | /** 15 | * QBaseAbstractEntity is a Querydsl query type for BaseAbstractEntity 16 | */ 17 | @Generated("com.querydsl.codegen.SupertypeSerializer") 18 | public class QBaseAbstractEntity extends EntityPathBase { 19 | 20 | private static final long serialVersionUID = 47434458L; 21 | 22 | public static final QBaseAbstractEntity baseAbstractEntity = new QBaseAbstractEntity("baseAbstractEntity"); 23 | 24 | public final DateTimePath createDate = createDateTime("createDate", java.util.Date.class); 25 | 26 | public final DateTimePath modifyDate = createDateTime("modifyDate", java.util.Date.class); 27 | 28 | public QBaseAbstractEntity(String variable) { 29 | super(BaseAbstractEntity.class, forVariable(variable)); 30 | } 31 | 32 | public QBaseAbstractEntity(Path path) { 33 | super(path.getType(), path.getMetadata()); 34 | } 35 | 36 | public QBaseAbstractEntity(PathMetadata metadata) { 37 | super(BaseAbstractEntity.class, metadata); 38 | } 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QBaseAbstractRelationalEntity.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.BaseAbstractRelationalEntity; 11 | import com.querydsl.core.types.Path; 12 | 13 | 14 | /** 15 | * QBaseAbstractRelationalEntity is a Querydsl query type for BaseAbstractRelationalEntity 16 | */ 17 | @Generated("com.querydsl.codegen.SupertypeSerializer") 18 | public class QBaseAbstractRelationalEntity extends EntityPathBase { 19 | 20 | private static final long serialVersionUID = -1933339813L; 21 | 22 | public static final QBaseAbstractRelationalEntity baseAbstractRelationalEntity = new QBaseAbstractRelationalEntity("baseAbstractRelationalEntity"); 23 | 24 | public final QBaseAbstractEntity _super = new QBaseAbstractEntity(this); 25 | 26 | //inherited 27 | public final DateTimePath createDate = _super.createDate; 28 | 29 | //inherited 30 | public final DateTimePath modifyDate = _super.modifyDate; 31 | 32 | public QBaseAbstractRelationalEntity(String variable) { 33 | super(BaseAbstractRelationalEntity.class, forVariable(variable)); 34 | } 35 | 36 | public QBaseAbstractRelationalEntity(Path path) { 37 | super(path.getType(), path.getMetadata()); 38 | } 39 | 40 | public QBaseAbstractRelationalEntity(PathMetadata metadata) { 41 | super(BaseAbstractRelationalEntity.class, metadata); 42 | } 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QDetailControl.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.DetailControl; 11 | import com.querydsl.core.types.Path; 12 | 13 | 14 | /** 15 | * QDetailControl is a Querydsl query type for DetailControl 16 | */ 17 | @Generated("com.querydsl.codegen.EntitySerializer") 18 | public class QDetailControl extends EntityPathBase { 19 | 20 | private static final long serialVersionUID = -1969542584L; 21 | 22 | public static final QDetailControl detailControl = new QDetailControl("detailControl"); 23 | 24 | public final QBaseAbstractEntity _super = new QBaseAbstractEntity(this); 25 | 26 | //inherited 27 | public final DateTimePath createDate = _super.createDate; 28 | 29 | public final BooleanPath enabled = createBoolean("enabled"); 30 | 31 | public final StringPath entityClass = createString("entityClass"); 32 | 33 | public final StringPath filterRules = createString("filterRules"); 34 | 35 | public final NumberPath id = createNumber("id", Long.class); 36 | 37 | //inherited 38 | public final DateTimePath modifyDate = _super.modifyDate; 39 | 40 | public final NumberPath priority = createNumber("priority", Integer.class); 41 | 42 | public final NumberPath roleId = createNumber("roleId", Long.class); 43 | 44 | public final StringPath unavailableColumns = createString("unavailableColumns"); 45 | 46 | public QDetailControl(String variable) { 47 | super(DetailControl.class, forVariable(variable)); 48 | } 49 | 50 | public QDetailControl(Path path) { 51 | super(path.getType(), path.getMetadata()); 52 | } 53 | 54 | public QDetailControl(PathMetadata metadata) { 55 | super(DetailControl.class, metadata); 56 | } 57 | 58 | } 59 | 60 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QLogin.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.Login; 11 | import com.querydsl.core.types.Path; 12 | import com.querydsl.core.types.dsl.PathInits; 13 | 14 | 15 | /** 16 | * QLogin is a Querydsl query type for Login 17 | */ 18 | @Generated("com.querydsl.codegen.EntitySerializer") 19 | public class QLogin extends EntityPathBase { 20 | 21 | private static final long serialVersionUID = 1604956139L; 22 | 23 | private static final PathInits INITS = PathInits.DIRECT2; 24 | 25 | public static final QLogin login = new QLogin("login"); 26 | 27 | public final QBaseAbstractEntity _super = new QBaseAbstractEntity(this); 28 | 29 | public final StringPath brand = createString("brand"); 30 | 31 | public final StringPath browser = createString("browser"); 32 | 33 | //inherited 34 | public final DateTimePath createDate = _super.createDate; 35 | 36 | public final NumberPath id = createNumber("id", Long.class); 37 | 38 | public final StringPath ipAddress = createString("ipAddress"); 39 | 40 | public final StringPath model = createString("model"); 41 | 42 | //inherited 43 | public final DateTimePath modifyDate = _super.modifyDate; 44 | 45 | public final StringPath operatingSystem = createString("operatingSystem"); 46 | 47 | public final StringPath screenSize = createString("screenSize"); 48 | 49 | public final QUser user; 50 | 51 | public QLogin(String variable) { 52 | this(Login.class, forVariable(variable), INITS); 53 | } 54 | 55 | public QLogin(Path path) { 56 | this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); 57 | } 58 | 59 | public QLogin(PathMetadata metadata) { 60 | this(metadata, PathInits.getFor(metadata, INITS)); 61 | } 62 | 63 | public QLogin(PathMetadata metadata, PathInits inits) { 64 | this(Login.class, metadata, inits); 65 | } 66 | 67 | public QLogin(Class type, PathMetadata metadata, PathInits inits) { 68 | super(type, metadata, inits); 69 | this.user = inits.isInitialized("user") ? new QUser(forProperty("user")) : null; 70 | } 71 | 72 | } 73 | 74 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QPermission.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.Permission; 11 | import com.querydsl.core.types.Path; 12 | 13 | 14 | /** 15 | * QPermission is a Querydsl query type for Permission 16 | */ 17 | @Generated("com.querydsl.codegen.EntitySerializer") 18 | public class QPermission extends EntityPathBase { 19 | 20 | private static final long serialVersionUID = -1166662445L; 21 | 22 | public static final QPermission permission = new QPermission("permission"); 23 | 24 | public final QBaseAbstractEntity _super = new QBaseAbstractEntity(this); 25 | 26 | public final StringPath action = createString("action"); 27 | 28 | public final BooleanPath available = createBoolean("available"); 29 | 30 | //inherited 31 | public final DateTimePath createDate = _super.createDate; 32 | 33 | public final StringPath group = createString("group"); 34 | 35 | public final NumberPath id = createNumber("id", Long.class); 36 | 37 | //inherited 38 | public final DateTimePath modifyDate = _super.modifyDate; 39 | 40 | public final StringPath name = createString("name"); 41 | 42 | public final NumberPath parentId = createNumber("parentId", Long.class); 43 | 44 | public final StringPath resourceType = createString("resourceType"); 45 | 46 | public final NumberPath sort = createNumber("sort", Long.class); 47 | 48 | public final StringPath url = createString("url"); 49 | 50 | public QPermission(String variable) { 51 | super(Permission.class, forVariable(variable)); 52 | } 53 | 54 | public QPermission(Path path) { 55 | super(path.getType(), path.getMetadata()); 56 | } 57 | 58 | public QPermission(PathMetadata metadata) { 59 | super(Permission.class, metadata); 60 | } 61 | 62 | } 63 | 64 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QRole.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.Permission; 11 | import com.beamofsoul.bip.entity.Role; 12 | import com.querydsl.core.types.Path; 13 | 14 | 15 | /** 16 | * QRole is a Querydsl query type for Role 17 | */ 18 | @Generated("com.querydsl.codegen.EntitySerializer") 19 | public class QRole extends EntityPathBase { 20 | 21 | private static final long serialVersionUID = -1192594822L; 22 | 23 | public static final QRole role = new QRole("role"); 24 | 25 | public final QBaseAbstractEntity _super = new QBaseAbstractEntity(this); 26 | 27 | //inherited 28 | public final DateTimePath createDate = _super.createDate; 29 | 30 | public final NumberPath id = createNumber("id", Long.class); 31 | 32 | //inherited 33 | public final DateTimePath modifyDate = _super.modifyDate; 34 | 35 | public final StringPath name = createString("name"); 36 | 37 | public final SetPath permissions = this.createSet("permissions", Permission.class, QPermission.class, PathInits.DIRECT2); 38 | 39 | public final NumberPath priority = createNumber("priority", Integer.class); 40 | 41 | public QRole(String variable) { 42 | super(Role.class, forVariable(variable)); 43 | } 44 | 45 | public QRole(Path path) { 46 | super(path.getType(), path.getMetadata()); 47 | } 48 | 49 | public QRole(PathMetadata metadata) { 50 | super(Role.class, metadata); 51 | } 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QRolePermission.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.RolePermission; 11 | import com.querydsl.core.types.Path; 12 | 13 | 14 | /** 15 | * QRolePermission is a Querydsl query type for RolePermission 16 | */ 17 | @Generated("com.querydsl.codegen.EntitySerializer") 18 | public class QRolePermission extends EntityPathBase { 19 | 20 | private static final long serialVersionUID = 1090044905L; 21 | 22 | private static final PathInits INITS = PathInits.DIRECT2; 23 | 24 | public static final QRolePermission rolePermission = new QRolePermission("rolePermission"); 25 | 26 | public final QBaseAbstractEntity _super = new QBaseAbstractEntity(this); 27 | 28 | //inherited 29 | public final DateTimePath createDate = _super.createDate; 30 | 31 | public final NumberPath id = createNumber("id", Long.class); 32 | 33 | //inherited 34 | public final DateTimePath modifyDate = _super.modifyDate; 35 | 36 | public final QPermission permission; 37 | 38 | public final QRole role; 39 | 40 | public QRolePermission(String variable) { 41 | this(RolePermission.class, forVariable(variable), INITS); 42 | } 43 | 44 | public QRolePermission(Path path) { 45 | this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); 46 | } 47 | 48 | public QRolePermission(PathMetadata metadata) { 49 | this(metadata, PathInits.getFor(metadata, INITS)); 50 | } 51 | 52 | public QRolePermission(PathMetadata metadata, PathInits inits) { 53 | this(RolePermission.class, metadata, inits); 54 | } 55 | 56 | public QRolePermission(Class type, PathMetadata metadata, PathInits inits) { 57 | super(type, metadata, inits); 58 | this.permission = inits.isInitialized("permission") ? new QPermission(forProperty("permission")) : null; 59 | this.role = inits.isInitialized("role") ? new QRole(forProperty("role")) : null; 60 | } 61 | 62 | } 63 | 64 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QSensitiveWord.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.SensitiveWord; 11 | import com.querydsl.core.types.Path; 12 | 13 | 14 | /** 15 | * QSensitiveWord is a Querydsl query type for SensitiveWord 16 | */ 17 | @Generated("com.querydsl.codegen.EntitySerializer") 18 | public class QSensitiveWord extends EntityPathBase { 19 | 20 | private static final long serialVersionUID = 223702338L; 21 | 22 | public static final QSensitiveWord sensitiveWord = new QSensitiveWord("sensitiveWord"); 23 | 24 | public final QBaseAbstractEntity _super = new QBaseAbstractEntity(this); 25 | 26 | public final BooleanPath available = createBoolean("available"); 27 | 28 | //inherited 29 | public final DateTimePath createDate = _super.createDate; 30 | 31 | public final NumberPath id = createNumber("id", Long.class); 32 | 33 | //inherited 34 | public final DateTimePath modifyDate = _super.modifyDate; 35 | 36 | public final BooleanPath regular = createBoolean("regular"); 37 | 38 | public final StringPath replacement = createString("replacement"); 39 | 40 | public final StringPath word = createString("word"); 41 | 42 | public QSensitiveWord(String variable) { 43 | super(SensitiveWord.class, forVariable(variable)); 44 | } 45 | 46 | public QSensitiveWord(Path path) { 47 | super(path.getType(), path.getMetadata()); 48 | } 49 | 50 | public QSensitiveWord(PathMetadata metadata) { 51 | super(SensitiveWord.class, metadata); 52 | } 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QUser.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.Role; 11 | import com.beamofsoul.bip.entity.User; 12 | import com.querydsl.core.types.Path; 13 | 14 | 15 | /** 16 | * QUser is a Querydsl query type for User 17 | */ 18 | @Generated("com.querydsl.codegen.EntitySerializer") 19 | public class QUser extends EntityPathBase { 20 | 21 | private static final long serialVersionUID = -86502647L; 22 | 23 | public static final QUser user = new QUser("user"); 24 | 25 | public final QBaseAbstractEntity _super = new QBaseAbstractEntity(this); 26 | 27 | //inherited 28 | public final DateTimePath createDate = _super.createDate; 29 | 30 | public final StringPath email = createString("email"); 31 | 32 | public final NumberPath id = createNumber("id", Long.class); 33 | 34 | //inherited 35 | public final DateTimePath modifyDate = _super.modifyDate; 36 | 37 | public final StringPath nickname = createString("nickname"); 38 | 39 | public final StringPath password = createString("password"); 40 | 41 | public final StringPath phone = createString("phone"); 42 | 43 | public final StringPath photo = createString("photo"); 44 | 45 | public final SetPath roles = this.createSet("roles", Role.class, QRole.class, PathInits.DIRECT2); 46 | 47 | public final NumberPath status = createNumber("status", Integer.class); 48 | 49 | public final StringPath username = createString("username"); 50 | 51 | public QUser(String variable) { 52 | super(User.class, forVariable(variable)); 53 | } 54 | 55 | public QUser(Path path) { 56 | super(path.getType(), path.getMetadata()); 57 | } 58 | 59 | public QUser(PathMetadata metadata) { 60 | super(User.class, metadata); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QUserRole.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.UserRole; 11 | import com.querydsl.core.types.Path; 12 | 13 | 14 | /** 15 | * QUserRole is a Querydsl query type for UserRole 16 | */ 17 | @Generated("com.querydsl.codegen.EntitySerializer") 18 | public class QUserRole extends EntityPathBase { 19 | 20 | private static final long serialVersionUID = -616801505L; 21 | 22 | private static final PathInits INITS = PathInits.DIRECT2; 23 | 24 | public static final QUserRole userRole = new QUserRole("userRole"); 25 | 26 | public final QBaseAbstractEntity _super = new QBaseAbstractEntity(this); 27 | 28 | //inherited 29 | public final DateTimePath createDate = _super.createDate; 30 | 31 | public final NumberPath id = createNumber("id", Long.class); 32 | 33 | //inherited 34 | public final DateTimePath modifyDate = _super.modifyDate; 35 | 36 | public final QRole role; 37 | 38 | public final QUser user; 39 | 40 | public QUserRole(String variable) { 41 | this(UserRole.class, forVariable(variable), INITS); 42 | } 43 | 44 | public QUserRole(Path path) { 45 | this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); 46 | } 47 | 48 | public QUserRole(PathMetadata metadata) { 49 | this(metadata, PathInits.getFor(metadata, INITS)); 50 | } 51 | 52 | public QUserRole(PathMetadata metadata, PathInits inits) { 53 | this(UserRole.class, metadata, inits); 54 | } 55 | 56 | public QUserRole(Class type, PathMetadata metadata, PathInits inits) { 57 | super(type, metadata, inits); 58 | this.role = inits.isInitialized("role") ? new QRole(forProperty("role")) : null; 59 | this.user = inits.isInitialized("user") ? new QUser(forProperty("user")) : null; 60 | } 61 | 62 | } 63 | 64 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/entity/query/QUserRoleCombineRole.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.entity.query; 2 | 3 | import static com.querydsl.core.types.PathMetadataFactory.*; 4 | 5 | import com.querydsl.core.types.dsl.*; 6 | 7 | import com.querydsl.core.types.PathMetadata; 8 | import javax.annotation.Generated; 9 | 10 | import com.beamofsoul.bip.entity.UserRoleCombineRole; 11 | import com.querydsl.core.types.Path; 12 | 13 | 14 | /** 15 | * QUserRoleCombineRole is a Querydsl query type for UserRoleCombineRole 16 | */ 17 | @Generated("com.querydsl.codegen.EntitySerializer") 18 | public class QUserRoleCombineRole extends EntityPathBase { 19 | 20 | private static final long serialVersionUID = -505201104L; 21 | 22 | public static final QUserRoleCombineRole userRoleCombineRole = new QUserRoleCombineRole("userRoleCombineRole"); 23 | 24 | public final StringPath id = createString("id"); 25 | 26 | public final StringPath nickname = createString("nickname"); 27 | 28 | public final StringPath roleId = createString("roleId"); 29 | 30 | public final StringPath roleName = createString("roleName"); 31 | 32 | public final NumberPath userId = createNumber("userId", Long.class); 33 | 34 | public final StringPath username = createString("username"); 35 | 36 | public QUserRoleCombineRole(String variable) { 37 | super(UserRoleCombineRole.class, forVariable(variable)); 38 | } 39 | 40 | public QUserRoleCombineRole(Path path) { 41 | super(path.getType(), path.getMetadata()); 42 | } 43 | 44 | public QUserRoleCombineRole(PathMetadata metadata) { 45 | super(UserRoleCombineRole.class, metadata); 46 | } 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/cache/CacheEvictBasedCollection.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.cache; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.core.Ordered; 10 | import org.springframework.core.annotation.Order; 11 | 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Target(ElementType.METHOD) 14 | @Documented 15 | @Order(Ordered.HIGHEST_PRECEDENCE) 16 | public @interface CacheEvictBasedCollection { 17 | 18 | String[] value() default ""; 19 | String key(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/cache/CacheableBasedPageableCollection.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.cache; 2 | 3 | import java.io.Serializable; 4 | import java.lang.annotation.Documented; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | import org.springframework.core.Ordered; 11 | import org.springframework.core.annotation.Order; 12 | 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target(ElementType.METHOD) 15 | @Documented 16 | @Order(Ordered.HIGHEST_PRECEDENCE) 17 | public @interface CacheableBasedPageableCollection { 18 | 19 | String[] value() default ""; 20 | Class entity(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/cache/GlobalSharedEhCacheConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.cache; 2 | 3 | import org.springframework.cache.ehcache.EhCacheCacheManager; 4 | import org.springframework.cache.ehcache.EhCacheManagerFactoryBean; 5 | import org.springframework.context.annotation.Bean; 6 | 7 | /** 8 | * 全局共享缓存配置类 9 | *

使用EhCache实现

10 | * @author MingshuJian 11 | */ 12 | public abstract class GlobalSharedEhCacheConfiguration { 13 | 14 | @Bean("ehcache") 15 | public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() { 16 | EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean(); 17 | ehCacheManagerFactoryBean.setShared(true); 18 | return ehCacheManagerFactoryBean; 19 | } 20 | 21 | /** 22 | * Spring使用的Cache 23 | */ 24 | @Bean(name = "cacheManager") 25 | public EhCacheCacheManager ehCacheCacheManager(){ 26 | EhCacheCacheManager ehCacheCacheManager = new EhCacheCacheManager(); 27 | ehCacheCacheManager.setCacheManager(ehCacheManagerFactoryBean().getObject()); 28 | return ehCacheCacheManager; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/cluster/CustomHttpSessionApplicationInitializer.java: -------------------------------------------------------------------------------- 1 | //package com.beamofsoul.bip.management.cluster; 2 | // 3 | //import org.springframework.session.web.context.AbstractHttpSessionApplicationInitializer; 4 | // 5 | //import com.beamofsoul.bip.management.security.CustomWebSecurityConfig; 6 | // 7 | ///** 8 | // * @ClassName CustomHttpSessionApplicationInitializer 9 | // * @Description This ensures that the Spring Bean by the name springSessionRepositoryFilter is registered with our Servlet Container for every request before Spring Security’s springSecurityFilterChain 10 | // * @author MingshuJian 11 | // * @Date 2017年6月7日 上午10:08:30 12 | // * @version 1.0.0 13 | // */ 14 | //public class CustomHttpSessionApplicationInitializer extends AbstractHttpSessionApplicationInitializer { 15 | // 16 | // public CustomHttpSessionApplicationInitializer() { 17 | // //确保Spring加载了安全框架的配置和自定义HttpSession的配置 18 | // super(CustomWebSecurityConfig.class, HttpSessionConfiguration.class); 19 | // } 20 | //} 21 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/cluster/HttpSessionConfiguration.java: -------------------------------------------------------------------------------- 1 | //package com.beamofsoul.bip.management.cluster; 2 | // 3 | ///** 4 | // * @ClassName HttpSessionConfiguration 5 | // * @Description 使用Redis为集群后HttpSession提供共享的配置类 6 | // * @author MingshuJian 7 | // * @Date 2017年6月7日 上午9:59:57 8 | // * @version 1.0.0 9 | // */ 10 | //@Configuration 11 | //@EnableRedisHttpSession 12 | //public class HttpSessionConfiguration { 13 | // 14 | //// /** 15 | //// * @Title: connectionFactory 16 | //// * @Description: 指定共享HttpSession的Redis服务器的客户端为Lettuce实现 17 | //// * @return LettuceConnectionFactory lettuce连接工厂类 18 | //// */ 19 | //// @Bean 20 | //// public LettuceConnectionFactory connectionFactory() { 21 | //// return new LettuceConnectionFactory(); 22 | //// } 23 | //} 24 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/control/CustomHttpServletRequestWrapper.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.control; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.ByteArrayInputStream; 5 | import java.io.IOException; 6 | import java.io.InputStreamReader; 7 | import java.nio.charset.Charset; 8 | 9 | import javax.servlet.ReadListener; 10 | import javax.servlet.ServletInputStream; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletRequestWrapper; 13 | 14 | import com.beamofsoul.bip.management.util.HttpServletRequestUtils; 15 | 16 | import lombok.Getter; 17 | 18 | /** 19 | * @ClassName CostomHttpServletRequestWrapper 20 | * @Description 自定义HttpServlet请求包装器 21 | * @author MingshuJian 22 | * @Date 2017年6月2日 上午10:11:17 23 | * @version 1.0.0 24 | */ 25 | public class CustomHttpServletRequestWrapper extends HttpServletRequestWrapper { 26 | 27 | @Getter 28 | private byte[] requestBody; 29 | public final static Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); 30 | 31 | public CustomHttpServletRequestWrapper(HttpServletRequest request) { 32 | super(request); 33 | requestBody = HttpServletRequestUtils.getRequestBody(request).getBytes(DEFAULT_CHARSET); 34 | } 35 | 36 | public CustomHttpServletRequestWrapper(HttpServletRequest request, String requestBody) { 37 | super(request); 38 | this.setRequestBody(requestBody); 39 | } 40 | 41 | public void setRequestBody(String requestBody) { 42 | this.requestBody = requestBody.getBytes(DEFAULT_CHARSET); 43 | } 44 | 45 | public void setRequestBody(byte[] requestBody) { 46 | this.requestBody = requestBody; 47 | } 48 | 49 | @Override 50 | public BufferedReader getReader() throws IOException { 51 | return new BufferedReader(new InputStreamReader(getInputStream())); 52 | } 53 | 54 | @Override 55 | public ServletInputStream getInputStream() throws IOException { 56 | final ByteArrayInputStream bais = new ByteArrayInputStream(requestBody); 57 | return new ServletInputStream() { 58 | @Override 59 | public boolean isFinished() { 60 | return false; 61 | } 62 | 63 | @Override 64 | public boolean isReady() { 65 | return false; 66 | } 67 | 68 | @Override 69 | public void setReadListener(ReadListener readListener) { 70 | // do nothing... 71 | } 72 | 73 | @Override 74 | public int read() throws IOException { 75 | return bais.read(); 76 | } 77 | }; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/control/CustomJSONReturnSupportFactoryBean.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.control; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.InitializingBean; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.web.method.support.HandlerMethodReturnValueHandler; 10 | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; 11 | import org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor; 12 | 13 | import lombok.extern.slf4j.Slf4j; 14 | 15 | /** 16 | * @ClassName CustomJSONReturnSupportFactoryBean 17 | * @Description 在RequestResponseBodyMethodProcessor前加入自定义的JSON返回值控制器以支持{@code @JSON}与{@code @JSONS}注解 18 | * @author MingshuJian 19 | * @Date 2017年2月17日 上午10:30:46 20 | * @version 1.0.0 21 | */ 22 | @Slf4j 23 | @Configuration 24 | public class CustomJSONReturnSupportFactoryBean implements InitializingBean { 25 | 26 | @Autowired 27 | private RequestMappingHandlerAdapter adapter; 28 | 29 | @Override 30 | public void afterPropertiesSet() throws Exception { 31 | List returnValueHandlers = adapter.getReturnValueHandlers(); 32 | adapter.setReturnValueHandlers(decorateHandlers(returnValueHandlers)); 33 | } 34 | 35 | private List decorateHandlers(List returnValueHandlers) { 36 | List newReturnValueHandlers = new ArrayList<>(); 37 | for (HandlerMethodReturnValueHandler handler : returnValueHandlers) { 38 | if (handler instanceof RequestResponseBodyMethodProcessor) { 39 | CustomJSONReturnHandler decorator = new CustomJSONReturnHandler(handler); 40 | newReturnValueHandlers.add(decorator); 41 | log.info("自定义JSON返回值控制器[CustomJSONReturnHandler]注册完毕..."); 42 | } 43 | newReturnValueHandlers.add(handler); 44 | } 45 | return newReturnValueHandlers; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/control/CustomJSONSerializer.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.control; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import com.fasterxml.jackson.core.JsonProcessingException; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | 8 | /** 9 | * @ClassName CustomJsonSerializer 10 | * @Description 为了细节控制自定义的JSON序列化器 11 | * @author MingshuJian 12 | * @Date 2017年2月16日 下午4:24:24 13 | * @version 1.0.0 14 | */ 15 | public class CustomJSONSerializer { 16 | 17 | private ObjectMapper mapper = new ObjectMapper(); 18 | private CustomJSONFilter JSONFilter = new CustomJSONFilter(); 19 | private static final String DELIMITER = ","; 20 | 21 | public void filter(JSON json) { 22 | this.filter(json.type(), json.include(), json.filter()); 23 | } 24 | 25 | public void filter(Class clazz, String include, String filter) { 26 | if (clazz == null) return; 27 | if (StringUtils.isNotBlank(include)) JSONFilter.include(clazz, include.split(DELIMITER)); 28 | if (StringUtils.isNotBlank(filter)) JSONFilter.filter(clazz, filter.split(DELIMITER)); 29 | mapper.addMixIn(clazz, JSONFilter.getClass()); 30 | } 31 | 32 | public String toJSON(Object object) throws JsonProcessingException { 33 | return mapper.setFilterProvider(JSONFilter).writeValueAsString(object); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/control/JSON.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.control; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Repeatable; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * @ClassName JSON 11 | * @Description 细节控制注解,过滤Controller中返回的JSON数据,以达到权限资源过滤的要求。使用此注解要求目标方法返回JSONObject对象 12 | * @author MingshuJian 13 | * @Date 2017年2月16日 下午4:13:35 14 | * @version 1.0.0 15 | */ 16 | @Target(ElementType.METHOD) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Repeatable(JSONS.class) 19 | public @interface JSON { 20 | 21 | Class type(); 22 | String include() default ""; 23 | String filter() default ""; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/control/JSONS.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.control; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @ClassName JONS 10 | * @Description 细节控制注解,过滤Controller中返回的JSON数据,以达到权限资源过滤的要求。使用此注解要求目标方法返回JSONObject对象 11 | * @author MingshuJian 12 | * @Date 2017年2月17日 上午9:06:35 13 | * @version 1.0.0 14 | */ 15 | @Target(ElementType.METHOD) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface JSONS { 18 | 19 | JSON[] value(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/control/Monitoring.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.control; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import com.beamofsoul.bip.entity.ActionMonitor; 9 | 10 | /** 11 | * @ClassName Monitoring 12 | * @Description 操作行为监控注解类 13 | * @author MingshuJian 14 | * @Date 2017年4月12日 下午1:38:15 15 | * @version 1.0.0 16 | */ 17 | @Target(ElementType.METHOD) 18 | @Retention(RetentionPolicy.RUNTIME) 19 | public @interface Monitoring { 20 | 21 | Class target() default Object.class; 22 | ActionMonitor.HazardLevel hazardLevel() default ActionMonitor.HazardLevel.INSIGNIFICANT; 23 | String key() default ""; 24 | String effect() default ""; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/control/Sensitive.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.control; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @ClassName Sensitive 10 | * @Description 敏感词过滤注解类 11 | * @author MingshuJian 12 | * @Date 2017年6月1日 下午2:34:15 13 | * @version 1.0.0 14 | */ 15 | @Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.TYPE}) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface Sensitive { 18 | 19 | String fields() default ""; 20 | boolean clear() default false; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/control/SensitiveWordFilter.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.control; 2 | 3 | import static com.beamofsoul.bip.management.util.ConfigurationReader.PROJECT_BASE_FILTER_SENSITIVE; 4 | import static com.beamofsoul.bip.management.util.ConfigurationReader.asBoolean; 5 | import static com.beamofsoul.bip.management.util.ConfigurationReader.getValue; 6 | 7 | import java.io.IOException; 8 | 9 | import javax.servlet.Filter; 10 | import javax.servlet.FilterChain; 11 | import javax.servlet.FilterConfig; 12 | import javax.servlet.ServletException; 13 | import javax.servlet.ServletRequest; 14 | import javax.servlet.ServletResponse; 15 | import javax.servlet.annotation.WebFilter; 16 | import javax.servlet.http.HttpServletRequest; 17 | 18 | import org.apache.commons.lang3.StringUtils; 19 | import org.springframework.web.bind.annotation.RequestMethod; 20 | 21 | import com.beamofsoul.bip.management.util.HttpServletRequestUtils; 22 | import com.beamofsoul.bip.management.util.SensitiveWordsMapping; 23 | 24 | import lombok.extern.slf4j.Slf4j; 25 | 26 | /** 27 | * @ClassName SensitiveWordFilter 28 | * @Description 敏感词过滤器(标记WebFilter注解的类会被ServletComponentScan注解扫描识别) 29 | * @author MingshuJian 30 | * @Date 2017年6月2日 上午10:02:44 31 | * @version 1.0.0 32 | */ 33 | @Slf4j 34 | @WebFilter(filterName = "sensitiveWordFilter", urlPatterns = "/*") 35 | public class SensitiveWordFilter implements Filter { 36 | 37 | public static boolean isOpen; 38 | 39 | @Override 40 | public void init(FilterConfig filterConfig) throws ServletException { 41 | isOpen = asBoolean(getValue(PROJECT_BASE_FILTER_SENSITIVE)); 42 | log.debug("初始化敏感词过滤器完毕,当前状态为:" + (isOpen ? "开启" : "关闭") + "..."); 43 | } 44 | 45 | @Override 46 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 47 | throws IOException, ServletException { 48 | 49 | HttpServletRequest httpServletRequest = (HttpServletRequest) request; 50 | if (isOpen && httpServletRequest.getMethod().equalsIgnoreCase(RequestMethod.POST.name())) { 51 | String requestBody = HttpServletRequestUtils.getRequestBody(httpServletRequest); 52 | CustomHttpServletRequestWrapper requestWrapper = new CustomHttpServletRequestWrapper(httpServletRequest,requestBody); 53 | if (StringUtils.isNotBlank(requestBody)) requestWrapper.setRequestBody(SensitiveWordsMapping.filter(requestBody)); 54 | chain.doFilter(requestWrapper, response); 55 | } else { 56 | chain.doFilter(request, response); 57 | } 58 | } 59 | 60 | @Override 61 | public void destroy() { 62 | log.debug("销毁敏感词过滤器完毕..."); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mail/ForgotPasswordMail.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mail; 2 | 3 | import java.util.Date; 4 | 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | /** 9 | * @ClassName ForgotPasswordMail 10 | * @Description 系统忘记密码邮件实例类 11 | * @author MingshuJian 12 | * @Date 2017年3月24日 上午9:07:47 13 | * @version 1.0.0 14 | */ 15 | @Getter 16 | @Setter 17 | public class ForgotPasswordMail extends UnreplyableMail { 18 | 19 | private String code; 20 | 21 | public ForgotPasswordMail(String to, String code) { 22 | super(null, to, generateSubject(), generateText(code), new Date()); 23 | this.code = code; 24 | } 25 | 26 | private static String generateSubject() { 27 | return "密码找回验证码"; 28 | } 29 | 30 | private static String generateText(String code) { 31 | StringBuffer sb = new StringBuffer(); 32 | sb.append("尊敬的CloudClass用户:
您好!此电子邮件地址正在用于找回某个CloudClass帐号密码。"); 33 | sb.append("如果是您本人启动了该密码找回流程,请输入下方显示的数字验证码,验证码的有效期为5分钟。
"); 34 | sb.append("如果您并未启动密码找回流程,并且有CloudClass帐号与此电子邮件地址相关联,则可能是其他人在尝试访问您的帐号。"); 35 | sb.append("请勿将此验证码转发给或提供给任何人。"); 36 | sb.append("请访问您账号的登录与安全设置,确保您的账号安全无虞。

"); 37 | sb.append(code); 38 | sb.append("


"); 39 | sb.append("此致
CloudClass团队敬上"); 40 | sb.append("



"); 41 | sb.append(UNREPLYABLE_NOTICE); 42 | return sb.toString(); 43 | } 44 | 45 | @Override 46 | public String getLog4Succeed() { 47 | return "email has been sent to " + to + " with change password code " + code; 48 | } 49 | 50 | @Override 51 | public String getLog4Fail() { 52 | return "failed to send email to " + to + " for forgot password business"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mail/Mail.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mail; 2 | 3 | import java.util.Date; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | 10 | /** 11 | * @ClassName Mail 12 | * @Description 系统邮件抽象父类 13 | * @author MingshuJian 14 | * @Date 2017年3月24日 上午9:02:44 15 | * @version 1.0.0 16 | */ 17 | @Getter 18 | @Setter 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | public abstract class Mail { 22 | 23 | String from; 24 | String to; 25 | String subject; 26 | String text; 27 | Date date; 28 | 29 | public abstract String getLog4Succeed(); 30 | public abstract String getLog4Fail(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mail/UnreplyableMail.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mail; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @ClassName UnreplyableMail 7 | * @Description 系统不可回复邮件抽象父类 8 | * @author MingshuJian 9 | * @Date 2017年3月24日 上午9:39:22 10 | * @version 1.0.0 11 | */ 12 | public abstract class UnreplyableMail extends Mail { 13 | 14 | public UnreplyableMail(String from, String to, String subject, String text, Date date) { 15 | super(from, to, subject, text, date); 16 | } 17 | 18 | final static String UNREPLYABLE_NOTICE = "此电子邮件地址无法接受回复。如需更多信息,请访问CloudClass官网。"; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/Attribute.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @ClassName Attribute 10 | * @Description 为目标对象赋值为从当前HttpServletRequest中解析出的特定属性,如果RequestBody中没有相应的数据,则返回null 11 | * @author MingshuJian 12 | * @Date 2017年6月12日 下午2:48:50 13 | * @version 1.0.0 14 | */ 15 | @Target(ElementType.PARAMETER) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface Attribute { 18 | 19 | String value(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/ConditionAttribute.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @ClassName ConditionAttribute 10 | * @Description 为目标对象赋值为从当前HttpServletRequest中解析出的查询条件对象,如果RequestBody中没有相应的数据,则返回null 11 | * @author MingshuJian 12 | * @Date 2017年6月12日 下午2:48:50 13 | * @version 1.0.0 14 | */ 15 | @Target(ElementType.PARAMETER) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface ConditionAttribute { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/ConditionMethodArgumentResolver.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.springframework.core.MethodParameter; 6 | import org.springframework.web.bind.support.WebDataBinderFactory; 7 | import org.springframework.web.context.request.NativeWebRequest; 8 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 9 | import org.springframework.web.method.support.ModelAndViewContainer; 10 | 11 | import com.alibaba.fastjson.JSONObject; 12 | import com.beamofsoul.bip.management.control.CustomHttpServletRequestWrapper; 13 | import com.beamofsoul.bip.management.util.JSONUtils; 14 | 15 | /** 16 | * @ClassName ConditionMethodArgumentResolver 17 | * @Description 自定义注解ConditionAttribute作为方法参数时的解析器 18 | * @author MingshuJian 19 | * @Date 2017年6月12日 下午2:52:08 20 | * @version 1.0.0 21 | */ 22 | public class ConditionMethodArgumentResolver implements HandlerMethodArgumentResolver{ 23 | 24 | private static final String CONDITION = "condition"; 25 | 26 | @Override 27 | public boolean supportsParameter(MethodParameter parameter) { 28 | //即使当前参数需要返回的类型是JSONObject或任意实现了Map接口的对象类型,仍然只能返回其他非Map关联类型,包括JSONObject 29 | //Spring MVC在解析action输入参数时,会将非@RequestBody注解标识的实现了Map接口的对象类型映射为org.springframework.validation.support.BindingAwareModelMap 30 | //所以如果action方法签名中定义了非@RequestBody注解标识的JSONObject或Map类型对象,则会报错: java.lang.IllegalArgumentException: argument type mismatch 31 | return parameter.getParameterType().isAssignableFrom(Object.class) && parameter.hasParameterAnnotation(ConditionAttribute.class); 32 | } 33 | 34 | @Override 35 | public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, 36 | NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { 37 | HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class); 38 | if (request instanceof CustomHttpServletRequestWrapper) { 39 | String requestBody = new String(((CustomHttpServletRequestWrapper) request).getRequestBody()); 40 | JSONObject attributes = JSONObject.parseObject(requestBody); 41 | if (attributes.containsKey(CONDITION)) 42 | return JSONUtils.formatAndParseObject(attributes.get(CONDITION).toString()); 43 | } 44 | return null; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/CurrentUser.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @ClassName CurrentUser 10 | * @Description 为目标对象赋值为当前登录用户,如果当前没有登录用户赋值为null 11 | * @author MingshuJian 12 | * @Date 2017年6月12日 下午2:48:50 13 | * @version 1.0.0 14 | */ 15 | @Target(ElementType.PARAMETER) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface CurrentUser { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/CurrentUserId.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @ClassName CurrentUserId 10 | * @Description 为目标对象赋值为当前登录用户id,如果当前没有登录用户赋值为null 11 | * @author MingshuJian 12 | * @Date 2017年6月12日 下午2:48:50 13 | * @version 1.0.0 14 | */ 15 | @Target(ElementType.PARAMETER) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface CurrentUserId { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/CurrentUserIdMethodArgumentResolver.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import org.springframework.core.MethodParameter; 4 | import org.springframework.web.bind.support.WebDataBinderFactory; 5 | import org.springframework.web.context.request.NativeWebRequest; 6 | import org.springframework.web.context.request.RequestAttributes; 7 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 8 | import org.springframework.web.method.support.ModelAndViewContainer; 9 | 10 | import com.beamofsoul.bip.entity.dto.UserExtension; 11 | import com.beamofsoul.bip.management.util.UserUtils; 12 | 13 | /** 14 | * @ClassName CurrentUserIdMethodArgumentResolver 15 | * @Description 自定义注解CurrentUserId作为方法参数时的解析器 16 | * @author MingshuJian 17 | * @Date 2017年6月12日 下午2:52:08 18 | * @version 1.0.0 19 | */ 20 | public class CurrentUserIdMethodArgumentResolver implements HandlerMethodArgumentResolver{ 21 | 22 | @Override 23 | public boolean supportsParameter(MethodParameter parameter) { 24 | return parameter.getParameterType().isAssignableFrom(Long.class) && parameter.hasParameterAnnotation(CurrentUserId.class); 25 | } 26 | 27 | @Override 28 | public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, 29 | NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { 30 | Object userExtension = webRequest.getAttribute(UserUtils.CURRENT_USER, RequestAttributes.SCOPE_SESSION); 31 | return userExtension != null ? ((UserExtension) userExtension).getUserId() : null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/CurrentUserMethodArgumentResolver.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.core.MethodParameter; 5 | import org.springframework.web.bind.support.WebDataBinderFactory; 6 | import org.springframework.web.context.request.NativeWebRequest; 7 | import org.springframework.web.context.request.RequestAttributes; 8 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 9 | import org.springframework.web.method.support.ModelAndViewContainer; 10 | 11 | import com.beamofsoul.bip.entity.User; 12 | import com.beamofsoul.bip.entity.dto.UserExtension; 13 | import com.beamofsoul.bip.management.util.UserUtils; 14 | import com.beamofsoul.bip.service.UserService; 15 | 16 | /** 17 | * @ClassName CurrentUserMethodArgumentResolver 18 | * @Description 自定义注解CurrentUser作为方法参数时的解析器 19 | * @author MingshuJian 20 | * @Date 2017年6月12日 下午2:52:08 21 | * @version 1.0.0 22 | */ 23 | public class CurrentUserMethodArgumentResolver implements HandlerMethodArgumentResolver{ 24 | 25 | @Autowired 26 | private UserService userService; 27 | 28 | @Override 29 | public boolean supportsParameter(MethodParameter parameter) { 30 | return parameter.getParameterType().isAssignableFrom(User.class) && parameter.hasParameterAnnotation(CurrentUser.class); 31 | } 32 | 33 | @Override 34 | public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, 35 | NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { 36 | Object userExtension = webRequest.getAttribute(UserUtils.CURRENT_USER, RequestAttributes.SCOPE_SESSION); 37 | return userExtension != null ? userService.findById(((UserExtension) userExtension).getUserId()) : null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/CustomWebMvcConfigurerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 8 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 9 | 10 | /** 11 | * @ClassName CustomWebMvcConfiguration 12 | * @Description 自定义 Web MVC 配置适配器,用以加载自定义方法参数解析器等自定义配置 13 | * @author MingshuJian 14 | * @Date 2017年6月12日 下午3:02:33 15 | * @version 1.0.0 16 | */ 17 | @Configuration 18 | public class CustomWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter { 19 | 20 | @Override 21 | public void addArgumentResolvers(List argumentResolvers) { 22 | argumentResolvers.add(currentUserMethodArgumentResolver()); 23 | argumentResolvers.add(currentUserIdMethodArgumentResolver()); 24 | argumentResolvers.add(pageableMethodArgumentResolver()); 25 | argumentResolvers.add(conditionMethodArgumentResolver()); 26 | argumentResolvers.add(idMethodArgumentResolver()); 27 | argumentResolvers.add(settingAttributeMethodArgumentResolver()); 28 | super.addArgumentResolvers(argumentResolvers); 29 | } 30 | 31 | @Bean 32 | public CurrentUserMethodArgumentResolver currentUserMethodArgumentResolver() { 33 | return new CurrentUserMethodArgumentResolver(); 34 | } 35 | 36 | @Bean 37 | public CurrentUserIdMethodArgumentResolver currentUserIdMethodArgumentResolver() { 38 | return new CurrentUserIdMethodArgumentResolver(); 39 | } 40 | 41 | @Bean 42 | public PageableMethodArgumentResolver pageableMethodArgumentResolver() { 43 | return new PageableMethodArgumentResolver(); 44 | } 45 | 46 | @Bean 47 | public ConditionMethodArgumentResolver conditionMethodArgumentResolver() { 48 | return new ConditionMethodArgumentResolver(); 49 | } 50 | 51 | @Bean 52 | public IdMethodArgumentResolver idMethodArgumentResolver() { 53 | return new IdMethodArgumentResolver(); 54 | } 55 | 56 | @Bean 57 | public SettingAttributeMethodArgumentResolver settingAttributeMethodArgumentResolver() { 58 | return new SettingAttributeMethodArgumentResolver(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/HttpServletRequestWrapperFilter.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.Filter; 6 | import javax.servlet.FilterChain; 7 | import javax.servlet.FilterConfig; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.ServletRequest; 10 | import javax.servlet.ServletResponse; 11 | import javax.servlet.annotation.WebFilter; 12 | import javax.servlet.http.HttpServletRequest; 13 | 14 | import com.beamofsoul.bip.management.control.CustomHttpServletRequestWrapper; 15 | import com.beamofsoul.bip.management.util.HttpServletRequestUtils; 16 | 17 | /** 18 | * @ClassName HttpServletRequestWrapperFilter 19 | * @Description 解决HttpServletRequest中body输入流只能读取一次的问题 20 | * @author MingshuJian 21 | * @Date 2017年6月13日 上午8:54:52 22 | * @version 1.0.0 23 | */ 24 | @WebFilter(filterName = "httpServletRequestWrapperFilter", urlPatterns = "/*") 25 | public class HttpServletRequestWrapperFilter implements Filter { 26 | 27 | @Override 28 | public void init(FilterConfig filterConfig) throws ServletException { 29 | 30 | } 31 | 32 | @Override 33 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 34 | throws IOException, ServletException { 35 | HttpServletRequest httpServletRequest = (HttpServletRequest) request; 36 | CustomHttpServletRequestWrapper requestWrapper = null; 37 | if (request instanceof HttpServletRequest) { 38 | String requestBody = HttpServletRequestUtils.getRequestBody(httpServletRequest); 39 | requestWrapper = new CustomHttpServletRequestWrapper(httpServletRequest,requestBody); 40 | } 41 | chain.doFilter(requestWrapper == null ? request : requestWrapper, response); 42 | } 43 | 44 | @Override 45 | public void destroy() { 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/IdAttribute.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @ClassName IdAttribute 10 | * @Description 为目标对象赋值为从当前HttpServletRequest中解析出的id属性,如果RequestBody中没有相应的数据,则返回null 11 | * @author MingshuJian 12 | * @Date 2017年6月12日 下午2:48:50 13 | * @version 1.0.0 14 | */ 15 | @Target(ElementType.PARAMETER) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface IdAttribute { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/IdMethodArgumentResolver.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.springframework.core.MethodParameter; 6 | import org.springframework.web.bind.support.WebDataBinderFactory; 7 | import org.springframework.web.context.request.NativeWebRequest; 8 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 9 | import org.springframework.web.method.support.ModelAndViewContainer; 10 | 11 | import com.alibaba.fastjson.JSONObject; 12 | import com.beamofsoul.bip.management.control.CustomHttpServletRequestWrapper; 13 | import com.beamofsoul.bip.management.util.Constants; 14 | 15 | /** 16 | * @ClassName IdMethodArgumentResolver 17 | * @Description 自定义注解IdAttribute作为方法参数时的解析器 18 | * @author MingshuJian 19 | * @Date 2017年6月12日 下午2:52:08 20 | * @version 1.0.0 21 | */ 22 | public class IdMethodArgumentResolver implements HandlerMethodArgumentResolver{ 23 | 24 | @Override 25 | public boolean supportsParameter(MethodParameter parameter) { 26 | return parameter.getParameterType().isAssignableFrom(Long.class) && parameter.hasParameterAnnotation(IdAttribute.class); 27 | } 28 | 29 | @Override 30 | public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, 31 | NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { 32 | HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class); 33 | if (request instanceof CustomHttpServletRequestWrapper) { 34 | String requestBody = new String(((CustomHttpServletRequestWrapper) request).getRequestBody()); 35 | JSONObject attributes = JSONObject.parseObject(requestBody); 36 | if (attributes.containsKey(Constants.DEFAULT_ENTITY_PRIMARY_KEY)) 37 | return Long.valueOf(attributes.get(Constants.DEFAULT_ENTITY_PRIMARY_KEY).toString()); 38 | } 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/PageableAttribute.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @ClassName PageableAttribute 10 | * @Description 为目标对象赋值为从当前HttpServletRequest中解析出的分页对象,如果RequestBody中没有相应的数据,则返回null 11 | * @author MingshuJian 12 | * @Date 2017年6月12日 下午2:48:50 13 | * @version 1.0.0 14 | */ 15 | @Target(ElementType.PARAMETER) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface PageableAttribute { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/mvc/PageableMethodArgumentResolver.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.mvc; 2 | 3 | import java.util.Map; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | import org.springframework.core.MethodParameter; 8 | import org.springframework.data.domain.Pageable; 9 | import org.springframework.web.bind.support.WebDataBinderFactory; 10 | import org.springframework.web.context.request.NativeWebRequest; 11 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 12 | import org.springframework.web.method.support.ModelAndViewContainer; 13 | 14 | import com.alibaba.fastjson.JSONObject; 15 | import com.beamofsoul.bip.management.control.CustomHttpServletRequestWrapper; 16 | import com.beamofsoul.bip.management.util.PageUtils; 17 | 18 | /** 19 | * @ClassName PageableMethodArgumentResolver 20 | * @Description 自定义注解PageableAttribute作为方法参数时的解析器 21 | * @author MingshuJian 22 | * @Date 2017年6月12日 下午2:52:08 23 | * @version 1.0.0 24 | */ 25 | public class PageableMethodArgumentResolver implements HandlerMethodArgumentResolver{ 26 | 27 | @Override 28 | public boolean supportsParameter(MethodParameter parameter) { 29 | return parameter.getParameterType().isAssignableFrom(Pageable.class) && parameter.hasParameterAnnotation(PageableAttribute.class); 30 | } 31 | 32 | @Override 33 | public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, 34 | NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { 35 | HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class); 36 | if (request instanceof CustomHttpServletRequestWrapper) { 37 | String requestBody = new String(((CustomHttpServletRequestWrapper) request).getRequestBody()); 38 | JSONObject attributes = JSONObject.parseObject(requestBody); 39 | if (attributes.containsKey(PageUtils.PAGEABLE_PAGE_SIZE_NAME) && attributes.containsKey(PageUtils.PAGEABLE_PAGE_NUMBER_NAME)) 40 | return PageUtils.parsePageable((Map) attributes); 41 | } 42 | return null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/repository/BaseMultielementRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.repository; 2 | 3 | import java.io.Serializable; 4 | import java.util.Collection; 5 | import java.util.List; 6 | 7 | import org.springframework.data.domain.Pageable; 8 | import org.springframework.data.domain.Sort; 9 | import org.springframework.data.jpa.repository.JpaRepository; 10 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 11 | import org.springframework.data.querydsl.QueryDslPredicateExecutor; 12 | import org.springframework.data.repository.NoRepositoryBean; 13 | 14 | import com.querydsl.core.QueryResults; 15 | import com.querydsl.core.types.Expression; 16 | import com.querydsl.core.types.Path; 17 | import com.querydsl.core.types.Predicate; 18 | import com.querydsl.core.types.dsl.PathBuilder; 19 | 20 | @SuppressWarnings("unchecked") 21 | @NoRepositoryBean 22 | public interface BaseMultielementRepository extends JpaRepository,JpaSpecificationExecutor,QueryDslPredicateExecutor { 23 | 24 | List findByIds(ID... ids); 25 | List findByAttr(String name, Object value); 26 | List findByAttrIn(String name, Object... values); 27 | List findByPredicate(Predicate predicate); 28 | List findByPredicate(Predicate predicate, Long limit); 29 | List findByPredicate(Predicate predicate, Long limit, Sort sort); 30 | T findOneByPredicate(Predicate predicate); 31 | List findByPredicateAndSort(Predicate predicate, Sort sort); 32 | long deleteByIds(ID... ids); 33 | Collection bulkSave(Collection entities); 34 | long update(Path path, S value); 35 | long update(Path path, S value, Predicate predicate); 36 | long update(List> paths, List values); 37 | long update(List> paths, List values, Predicate predicate); 38 | Long deleteByPredicate(Predicate predicate); 39 | QueryResults findPageableIds(Pageable pageable); 40 | QueryResults findPageableIds(Pageable pageable, Predicate predicate); 41 | QueryResults findSpecificDataByPredicate(Predicate predicate, Expression... selects); 42 | PathBuilder getEntityPath(); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/repository/BaseMultielementRepositoryFactory.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.repository; 2 | 3 | import javax.persistence.EntityManager; 4 | 5 | /** 6 | * @ClassName BaseMultielementRepositoryFactory 7 | * @Description 创建BaseMultielementRepository实现类的BaseMultielementRepositoryProvider实例 8 | * @author MingshuJian 9 | * @Date 2017年1月24日 上午10:03:12 10 | * @version 1.0.0 11 | */ 12 | public class BaseMultielementRepositoryFactory implements BaseMultielementRepositoryProvider { 13 | 14 | private Class domainClass; 15 | private EntityManager entityManager; 16 | 17 | private BaseMultielementRepositoryFactory() {} 18 | 19 | @Override 20 | public BaseMultielementRepositoryProvider initialize(Object... args) { 21 | if (args != null && args.length > 0) { 22 | for (Object object : args) { 23 | if (object instanceof EntityManager) { 24 | entityManager = (EntityManager) object; 25 | } else if (object instanceof Class) { 26 | domainClass = (Class) object; 27 | } 28 | } 29 | } 30 | return this; 31 | } 32 | 33 | @SuppressWarnings({ "rawtypes", "unchecked" }) 34 | private BaseMultielementRepository doProvide() { 35 | return new BaseMultielementRepositoryImpl(domainClass, entityManager); 36 | } 37 | 38 | @Override 39 | public BaseMultielementRepository provide() { 40 | if (domainClass == null || entityManager == null) { 41 | throw new RuntimeException("DomainClass or entityManager must not be null"); 42 | } 43 | return doProvide(); 44 | } 45 | 46 | @Override 47 | public BaseMultielementRepository provide(Object... args) { 48 | this.initialize(args); 49 | return doProvide(); 50 | } 51 | 52 | @Override 53 | public Class getReopositoryImplementClass() { 54 | return BaseMultielementRepositoryImpl.class; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/repository/BaseMultielementRepositoryProvider.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.repository; 2 | 3 | /** 4 | * @ClassName BaseMultielementRepositoryProvider 5 | * @Description BaseMultielementRepository实例提供器 6 | * @author MingshuJian 7 | * @Date 2017年7月24日 上午10:23:32 8 | * @version 1.0.0 9 | */ 10 | public interface BaseMultielementRepositoryProvider { 11 | 12 | BaseMultielementRepositoryProvider initialize(Object... args); 13 | BaseMultielementRepository provide(); 14 | BaseMultielementRepository provide(Object... args); 15 | Class getReopositoryImplementClass(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/repository/CustomRepositoryFactory.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.repository; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.EntityManager; 6 | 7 | import org.springframework.data.jpa.repository.JpaRepository; 8 | import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; 9 | import org.springframework.data.jpa.repository.support.SimpleJpaRepository; 10 | import org.springframework.data.repository.core.RepositoryInformation; 11 | import org.springframework.data.repository.core.RepositoryMetadata; 12 | 13 | import lombok.NonNull; 14 | 15 | public class CustomRepositoryFactory extends JpaRepositoryFactory { 16 | 17 | @SuppressWarnings("unused") 18 | private final EntityManager entityManager; 19 | 20 | private static BaseMultielementRepositoryProvider baseMultielementRepositoryProvider; 21 | 22 | public CustomRepositoryFactory(@NonNull EntityManager entityManager) { 23 | super(entityManager); 24 | this.entityManager = entityManager; 25 | 26 | if (baseMultielementRepositoryProvider == null) 27 | baseMultielementRepositoryProvider = CustomRepositoryConfiguration.getProvider(); 28 | } 29 | 30 | @SuppressWarnings("unchecked") 31 | protected JpaRepository getTargetRepository(RepositoryMetadata metadata, 32 | EntityManager entityManager) { 33 | return (JpaRepository) baseMultielementRepositoryProvider 34 | .provide((Class) metadata.getDomainType(), entityManager); 35 | } 36 | 37 | @SuppressWarnings("unchecked") 38 | @Override 39 | protected SimpleJpaRepository getTargetRepository( 40 | RepositoryInformation information, EntityManager entityManager) { 41 | return (SimpleJpaRepository) baseMultielementRepositoryProvider 42 | .provide((Class) information.getDomainType(), entityManager); 43 | } 44 | 45 | @Override 46 | protected Class getRepositoryBaseClass(RepositoryMetadata metadata) { 47 | return baseMultielementRepositoryProvider.getReopositoryImplementClass(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/repository/CustomRepositoryFactoryBean.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.repository; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.EntityManager; 6 | 7 | import org.springframework.data.jpa.repository.JpaRepository; 8 | import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean; 9 | import org.springframework.data.repository.core.support.RepositoryFactorySupport; 10 | 11 | public class CustomRepositoryFactoryBean, S, ID extends Serializable> extends JpaRepositoryFactoryBean { 12 | 13 | public CustomRepositoryFactoryBean(Class repositoryInterface) { 14 | super(repositoryInterface); 15 | } 16 | 17 | protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) { 18 | return new CustomRepositoryFactory(entityManager); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/repository/JpaRepositoryConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.repository; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 5 | import org.springframework.data.web.config.EnableSpringDataWebSupport; 6 | 7 | @Configuration 8 | @EnableJpaRepositories( 9 | basePackages={"com.beamofsoul.bip.repository"}, 10 | repositoryFactoryBeanClass=CustomRepositoryFactoryBean.class) 11 | @EnableSpringDataWebSupport 12 | public class JpaRepositoryConfiguration { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/runner/CustomDataFillingStartupRunner.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.runner; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.CommandLineRunner; 5 | import org.springframework.core.annotation.Order; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.beamofsoul.bip.management.util.AnnotationRepositoryNameMapping; 9 | import com.beamofsoul.bip.management.util.AnnotationServiceNameMapping; 10 | import com.beamofsoul.bip.management.util.DatabaseTableEntityMapping; 11 | import com.beamofsoul.bip.management.util.DatabaseUtils; 12 | import com.beamofsoul.bip.management.util.RolePermissionsMapping; 13 | import com.beamofsoul.bip.management.util.SensitiveWordsMapping; 14 | import com.beamofsoul.bip.service.RolePermissionService; 15 | import com.beamofsoul.bip.service.SensitiveWordService; 16 | 17 | import lombok.extern.slf4j.Slf4j; 18 | 19 | /** 20 | * 实现自定义CommandLineRunner 21 | * 自定义服务器启动时执行某些操作 22 | * SpringBoot在应用程序启动后,会遍历CommondLineRunner接口的实例并运行它们的run方法 23 | * @Order 该注解用于排序多个自定义实现的CommandLineRunner实例,其中数值越小,越先执行 24 | * @author MingshuJian 25 | */ 26 | @Component 27 | @Slf4j 28 | @Order(1) 29 | public class CustomDataFillingStartupRunner implements CommandLineRunner { 30 | 31 | @Autowired 32 | private RolePermissionService rolePermissionService; 33 | 34 | @Autowired 35 | private SensitiveWordService sensitiveWordService; 36 | 37 | @Override 38 | public void run(String... args) throws Exception { 39 | /** 40 | * 这里的args就是程序启动的时候进行设置的: 41 | * eg. SpringApplication.run(App.class, new String[]{"hello,","world"}); 42 | * 43 | * eclipse中给java应用传args参数的方法如下: 44 | * 1.先写好Java代码,比如文件名为IntArrqy.java 45 | * 2.在工具栏或菜单上点run as下边有个Run Configuration 46 | * 3.在弹出窗口点选第二个标签arguments 47 | * 4.把输入的参数写在program argumenst,多个参数使用空格隔开 48 | * 完成后点run即可通过运行结果看到参数使用情况了。 49 | */ 50 | log.info("服务启动执行,执行加载数据等操作..."); 51 | RolePermissionsMapping.fill(rolePermissionService.findAllRolePermissionMapping()); 52 | SensitiveWordsMapping.fill(sensitiveWordService.findAll()); 53 | DatabaseUtils.loadDatabaseTableNames(); 54 | DatabaseTableEntityMapping.initTableEntityMap(); 55 | AnnotationServiceNameMapping.loadServiceMap(); 56 | AnnotationRepositoryNameMapping.loadRepositoryMap(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/schedule/CustomJobs.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.schedule; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | /** 6 | * @ClassName CustomJobs 7 | * @Description 自定义定时任务器 8 | * @author MingshuJian 9 | * @Date 2017年3月31日 下午3:47:57 10 | * @version 1.0.0 11 | */ 12 | @Component 13 | public class CustomJobs { 14 | 15 | public static final long ONE_SECOND = 1000; 16 | public static final long ONE_MINUTE = 60 * 1000; 17 | 18 | // /** 19 | // * @Title: pushSystemLog 20 | // * @Description: 定期向后台用户推送系统日志信息 21 | // */ 22 | // @Scheduled(fixedRate = ONE_SECOND) 23 | // public void pushSystemLog() { 24 | // if (CustomSystemLogWebSocketHandler.getOnlineCount() > 0) { 25 | // CustomSystemLogWebSocketHandler.sendMessageToAll(new TextMessage(new Date().toString())); 26 | // } 27 | // } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/security/Authorize.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.security; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * @ClassName PreAuth 12 | * @Description 根据输入的权限action,判断当前用户是否已经登录并有权限进入当前目标方法,如果没有权限则抛出异常,或通过配置使方法返回null 13 | * @author MingshuJian 14 | * @Date 2017年6月12日 下午2:48:50 15 | * @version 1.0.0 16 | */ 17 | @Target(ElementType.METHOD) 18 | @Retention(RetentionPolicy.RUNTIME) 19 | @Inherited 20 | @Documented 21 | public @interface Authorize { 22 | 23 | String value(); 24 | boolean exception() default true; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/security/AuthorizeAspect.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.security; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.aspectj.lang.ProceedingJoinPoint; 6 | import org.aspectj.lang.annotation.Around; 7 | import org.aspectj.lang.annotation.Aspect; 8 | import org.aspectj.lang.annotation.Pointcut; 9 | import org.springframework.security.access.AccessDeniedException; 10 | import org.springframework.security.core.context.SecurityContextHolder; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * @ClassName AuthorizeAspect 15 | * @Description 操作action方法运行前权限判断切面实现类 16 | * @author MingshuJian 17 | * @Date 2017年6月8日 下午1:36:29 18 | * @version 1.0.0 19 | */ 20 | @Aspect 21 | @Component 22 | public class AuthorizeAspect { 23 | 24 | @Resource 25 | private CustomPermissionEvaluator customPermissionEvaluator; 26 | 27 | @Pointcut(value="@annotation(authorize)") 28 | public void locateAnnotation(Authorize authorize) {} 29 | 30 | @Around("locateAnnotation(authorize)") 31 | public Object doAround(ProceedingJoinPoint joinPoint, Authorize authorize) throws Throwable { 32 | String permissionAction = authorize.value(); 33 | boolean exception = authorize.exception(); 34 | boolean hasPermission = customPermissionEvaluator.hasPermission(SecurityContextHolder.getContext().getAuthentication(), null, permissionAction); 35 | 36 | if (!hasPermission) 37 | if (exception) 38 | throw new AccessDeniedException("403"); 39 | else 40 | return null; 41 | else 42 | return joinPoint.proceed(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/security/CustomAuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.security; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.authentication.AuthenticationProvider; 5 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 6 | import org.springframework.security.core.Authentication; 7 | import org.springframework.security.core.AuthenticationException; 8 | import org.springframework.security.core.userdetails.UserDetails; 9 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 10 | import org.springframework.stereotype.Component; 11 | 12 | import com.beamofsoul.bip.entity.dto.UserExtension; 13 | 14 | /** 15 | * @ClassName CustomAuthenticationProvider 16 | * @Description 自定义身份验证提供器 17 | * @author MingshuJian 18 | * @Date 2017年1月19日 下午4:18:21 19 | * @version 1.0.0 20 | */ 21 | @Component 22 | public class CustomAuthenticationProvider implements AuthenticationProvider { 23 | 24 | @Autowired 25 | private CustomUserDetailsService customUserDetailsService; 26 | 27 | /* 28 | * (非 Javadoc) 29 | *

Title: authenticate

30 | *

Description: 根据用户名读取用户身份信息,并提供简单的密码匹配验证

31 | * @param authentication 32 | * @return UsernamePasswordAuthenticationToken 33 | * @throws AuthenticationException 34 | * @see org.springframework.security.authentication.AuthenticationProvider#authenticate(org.springframework.security.core.Authentication) 35 | */ 36 | @Override 37 | public Authentication authenticate(Authentication authentication) throws AuthenticationException { 38 | UserDetails user = customUserDetailsService 39 | .loadUserByUsername(authentication.getName()); 40 | 41 | //此处可以增加加密验证或验证码验证等功能 42 | //先判断是否是remember-me登录 43 | if (authentication.getPrincipal() instanceof UserExtension) { 44 | if (!((UserExtension) authentication.getPrincipal()).getPassword().equals(user.getPassword())) 45 | throw new UsernameNotFoundException("密码错误"); 46 | } else if (!authentication.getCredentials().equals(user.getPassword())) { 47 | throw new UsernameNotFoundException("密码错误"); 48 | } 49 | 50 | UsernamePasswordAuthenticationToken result = 51 | new UsernamePasswordAuthenticationToken( 52 | user.getUsername(), 53 | user.getPassword(), 54 | user.getAuthorities()); 55 | result.setDetails(user); 56 | return result; 57 | } 58 | 59 | @Override 60 | public boolean supports(Class clazz) { 61 | return true; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/security/CustomPermissionEvaluator.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.security; 2 | 3 | import java.io.Serializable; 4 | 5 | import org.springframework.security.access.PermissionEvaluator; 6 | import org.springframework.security.core.Authentication; 7 | import org.springframework.stereotype.Component; 8 | 9 | import com.beamofsoul.bip.management.util.RolePermissionsMapping; 10 | 11 | /** 12 | * @ClassName CustomPermissionEvaluator 13 | * @Description 自定义权限鉴别器 14 | * @author MingshuJian 15 | * @Date 2017年1月19日 下午4:25:34 16 | * @version 1.0.0 17 | */ 18 | @Component 19 | public class CustomPermissionEvaluator implements PermissionEvaluator { 20 | 21 | /* 22 | * (非 Javadoc) 23 | *

Title: hasPermission

24 | *

Description: 判断用户是否拥有权限

25 | * @param authentication 26 | * @param targetDomainObject 27 | * @param permission 28 | * @return 29 | * @see org.springframework.security.access.PermissionEvaluator#hasPermission(org.springframework.security.core.Authentication, java.lang.Object, java.lang.Object) 30 | */ 31 | @Override 32 | public boolean hasPermission(Authentication authentication, 33 | Object targetDomainObject, Object permission) { 34 | return RolePermissionsMapping.actionContains(authentication.getAuthorities(), permission); 35 | } 36 | 37 | @Override 38 | public boolean hasPermission(Authentication authentication, 39 | Serializable targetId, String targetType, Object permission) { 40 | // not supported 41 | return false; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/security/CustomSecurityConfigurationProperties.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.security; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * @ClassName CustomSecurityConfigurationProperties 11 | * @Description 自定义安全配置属性值读取器 12 | * @author MingshuJian 13 | * @Date 2017年1月19日 下午4:27:30 14 | * @version 1.0.0 15 | */ 16 | @Getter 17 | @Setter 18 | @Component 19 | @ConfigurationProperties(prefix = "project.base.security") 20 | public class CustomSecurityConfigurationProperties { 21 | 22 | private String[] adminRoleMatchers; 23 | private String[] adminRoles; 24 | private String[] nonAuthenticatedMatchers; 25 | private String loginPage; 26 | private String defaultLoginSuccessUrl; 27 | private boolean alwaysUseDefaultSuccessUrl; 28 | private String logoutUrl; 29 | private String defaultLogoutSuccessUrl; 30 | private int maximumSessions; 31 | private boolean maxSessionsPreventsLogin; 32 | private String expiredUrl; 33 | private int tokenValiditySeconds; 34 | private String rememberMeParameter; 35 | private String rememberMeCookieName; 36 | private String[] ignoringMatchers; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/AnnotationRepositoryNameMapping.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.springframework.stereotype.Repository; 7 | 8 | import lombok.extern.slf4j.Slf4j; 9 | 10 | /** 11 | * @ClassName AnnotationRepositoryClassMapping 12 | * @Description 注解'@Repository'的持久化类映射工具类 13 | * @author MingshuJian 14 | * @Date 2017年4月7日 下午2:37:33 15 | * @version 1.0.0 16 | */ 17 | @Slf4j 18 | public class AnnotationRepositoryNameMapping { 19 | 20 | public static Map repositoryMap = new HashMap<>(); 21 | 22 | public static void loadRepositoryMap() { 23 | log.debug("开始加载持久化注解名称映射信息..."); 24 | if (repositoryMap.size() > 0) repositoryMap.clear(); 25 | Map beansWithAnnotation = SpringUtils.getApplicationContext().getBeansWithAnnotation(Repository.class); 26 | for (String key : beansWithAnnotation.keySet()) repositoryMap.put(key.replace("Repository", "").toLowerCase(), key); 27 | log.debug("持久化注解名称映射信息加载完毕..."); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/AnnotationServiceNameMapping.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.springframework.stereotype.Service; 7 | 8 | import lombok.extern.slf4j.Slf4j; 9 | 10 | /** 11 | * @ClassName AnnotationServiceNameMapping 12 | * @Description 注解'@Service'的服务类映射工具类 13 | * @author MingshuJian 14 | * @Date 2017年4月7日 下午2:37:33 15 | * @version 1.0.0 16 | */ 17 | @Slf4j 18 | public class AnnotationServiceNameMapping { 19 | 20 | public static Map serviceMap = new HashMap<>(); 21 | 22 | public static void loadServiceMap() { 23 | log.debug("开始加载服务注解名称映射信息..."); 24 | if (serviceMap.size() > 0) serviceMap.clear(); 25 | Map beansWithAnnotation = SpringUtils.getApplicationContext().getBeansWithAnnotation(Service.class); 26 | for (String key : beansWithAnnotation.keySet()) serviceMap.put(key.replace("Service", "").toLowerCase(), key); 27 | log.debug("服务注解名称映射信息加载完毕..."); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/CacheUtils.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.cache.Cache; 7 | import org.springframework.cache.Cache.ValueWrapper; 8 | import org.springframework.cache.ehcache.EhCacheCacheManager; 9 | 10 | import net.sf.ehcache.Ehcache; 11 | 12 | public final class CacheUtils { 13 | 14 | private static EhCacheCacheManager manager; 15 | static { 16 | manager = SpringUtils.getBean(EhCacheCacheManager.class); 17 | } 18 | 19 | //不应被实例化的缓存工具类 20 | private CacheUtils() { 21 | //避免不小心在类内部调用构造器 Effective Java Edition 2 p.16 22 | throw new AssertionError(); 23 | } 24 | 25 | public static Cache getCache(String cacheName) { 26 | return manager.getCache(cacheName); 27 | } 28 | 29 | public static Object get(String cacheName, Object key) { 30 | Cache cache = getCache(cacheName); 31 | if (cache != null) { 32 | ValueWrapper wrapper = cache.get(key); 33 | return wrapper == null ? null : wrapper.get(); 34 | } 35 | return null; 36 | } 37 | 38 | public static void put(String cacheName, Object key, Object value) { 39 | Cache cache = getCache(cacheName); 40 | if (cache != null) cache.put(key, value); 41 | } 42 | 43 | public static void remove(String cacheName, Object key) { 44 | Cache cache = getCache(cacheName); 45 | if (cache != null) cache.evict(key); 46 | } 47 | 48 | public static List getKeys(String cacheName) { 49 | Cache cache = getCache(cacheName); 50 | return cache == null 51 | ? new ArrayList(0) 52 | : ((Ehcache)cache.getNativeCache()).getKeys(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/Callback.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | @FunctionalInterface 4 | public interface Callback { 5 | 6 | public void doCallback(Object... objects); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/CodeGenerator.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * @ClassName CodeGenerator 7 | * @Description 邀请码生成器 8 | * @author MingshuJian 9 | * @Date 2017年1月20日 上午10:54:15 10 | * @version 1.0.0 11 | */ 12 | public class CodeGenerator { 13 | 14 | private static final String INVITATION_CODE_SIZE = "%05d"; 15 | 16 | private static final int INVITATION_CODE_ENCRY_KEY = 1; 17 | 18 | public static String generateInvitationCode() throws Exception { 19 | return RC4.encry2String(String.format(INVITATION_CODE_SIZE, INVITATION_CODE_ENCRY_KEY), 20 | UUID.randomUUID().toString()).toUpperCase(); 21 | } 22 | 23 | public static String generateSixDigitCode() { 24 | return String.valueOf(getRandomNumber(100000,999999)); 25 | } 26 | 27 | public static int getRandomNumber(int min, int max) { 28 | return min + (int)(Math.random() * ((max - min) + 1)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/CollectionUtils.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.List; 6 | 7 | import org.apache.commons.lang3.StringUtils; 8 | 9 | /** 10 | * @ClassName CollectionUtils 11 | * @Description 实现Collection接口实现类对象的工具类 12 | * @author MingshuJian 13 | * @Date 2017年2月16日 下午1:53:41 14 | * @version 1.0.0 15 | */ 16 | public class CollectionUtils { 17 | 18 | public static boolean isBlank(Collection collection) { 19 | boolean isBlank = false; 20 | if (collection == null) { 21 | isBlank = true; 22 | } else if (collection.size() == 0) { 23 | isBlank = true; 24 | } else { 25 | if (collection instanceof List) { 26 | List list = new ArrayList<>(collection); 27 | boolean isEmptyList = true; 28 | for (Object obj : list) { 29 | if (obj != null) { 30 | if (obj instanceof String && StringUtils.isBlank(obj.toString())) { 31 | continue; 32 | } 33 | isEmptyList = false; 34 | break; 35 | } 36 | } 37 | isBlank = isEmptyList; 38 | } 39 | } 40 | return isBlank; 41 | } 42 | 43 | public static boolean isNotBlank(Collection collection) { 44 | return !isBlank(collection); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/CommonConvertUtils.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | public class CommonConvertUtils { 4 | 5 | public static Long[] convertToLongArray(String formattedStr, String delimiter) { 6 | String[] strArray = formattedStr.split(delimiter); 7 | Long[] longArray = new Long[strArray.length]; 8 | for (int i = 0; i < strArray.length; i++) { 9 | longArray[i] = Long.valueOf(strArray[i]); 10 | } 11 | return longArray; 12 | } 13 | 14 | public static Long[] convertToLongArray(String formattedStr) { 15 | return convertToLongArray(formattedStr,","); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/CommonUtils.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.lang.reflect.Method; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.springframework.util.StringUtils; 9 | 10 | import lombok.NonNull; 11 | 12 | public class CommonUtils { 13 | 14 | public static boolean isNotBlank(Object... objects) { 15 | return objects != null && objects.length > 0; 16 | } 17 | 18 | public static boolean isBlank(Object... objects) { 19 | return objects == null || (objects != null && objects.length == 0); 20 | } 21 | 22 | public static Long getLongEntityId(@NonNull Map map) { 23 | Object entityId = map.get(Constants.DEFAULT_ENTITY_PRIMARY_KEY); 24 | return entityId == null ? 0L : Long.valueOf(entityId.toString()); 25 | } 26 | 27 | public static List getIds(@NonNull List list) { 28 | List returnList = new ArrayList(list.size()); 29 | try { 30 | for (Object object : list) { 31 | Method method = object.getClass().getMethod("getId", new Class[]{}); 32 | if (method != null) 33 | returnList.add(Long.valueOf(method.invoke(object).toString())); 34 | } 35 | } catch (Exception e) { 36 | throw new RuntimeException("转换对象Id不是长整形",e); 37 | } 38 | return returnList; 39 | } 40 | 41 | @SuppressWarnings("unchecked") 42 | public static List getAttributeList(@NonNull List list,@NonNull String attributeName) { 43 | List returnList = new ArrayList(list.size()); 44 | Method method = null; 45 | try { 46 | if (list.size() > 0 && list.get(0) != null) { 47 | method = list.get(0).getClass().getMethod("get" + StringUtils.capitalize(attributeName), new Class[]{}); 48 | } 49 | for (Object object : list) { 50 | returnList.add((T) method.invoke(object)); 51 | } 52 | } catch (Exception e) { 53 | throw new RuntimeException("反射方法执行失败",e); 54 | } 55 | return returnList; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/Constants.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | public final class Constants { 4 | 5 | public static final String CURRENT_USER = "CURRENT_USER"; 6 | public static final String ADMIN_USER = "ADMIN_USER"; 7 | public static final String SESSION_FORCE_LOGOUT_KEY = "SESSION_FORCE_LOGOUT_KEY"; 8 | public static final String VICTIM = "VICTIM"; 9 | 10 | public static final String DEFAULT_JSON_BUSSINESS_OBJECT_NAME = "entity"; 11 | public static final String DEFAULT_ENTITY_PRIMARY_KEY = "id"; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/CurrentThreadDataManager.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * @ClassName CurrentThreadDataManager 8 | * @Description 当前线程数据管理器 9 | * @author MingshuJian 10 | * @Date 2017年4月12日 上午9:55:11 11 | * @version 1.0.0 12 | */ 13 | public class CurrentThreadDataManager { 14 | 15 | private static ThreadLocal> dataHolder = new ThreadLocal<>(); 16 | 17 | public static Map getDataHolder() { 18 | Map dataMap = dataHolder.get(); 19 | if (dataMap == null) { 20 | dataMap = new HashMap(); 21 | dataHolder.set(dataMap); 22 | } 23 | return dataMap; 24 | } 25 | 26 | public static Object getData(String key) { 27 | return getDataHolder().get(key); 28 | } 29 | 30 | public static void setData(String key, Object value) { 31 | getDataHolder().put(key, value); 32 | } 33 | 34 | public static boolean containsKey(String key) { 35 | return getDataHolder().containsKey(key); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/DatabaseTableEntityMapping.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.util.Map; 4 | import java.util.stream.Collectors; 5 | 6 | import javax.persistence.Table; 7 | 8 | import lombok.extern.slf4j.Slf4j; 9 | 10 | /** 11 | * @ClassName DatabaseTableEntityMapping 12 | * @Description 数据库表和实体类映射工具类 13 | * @author MingshuJian 14 | * @Date 2017年4月7日 上午11:08:24 15 | * @version 1.0.0 16 | */ 17 | @Slf4j 18 | public class DatabaseTableEntityMapping { 19 | 20 | public static Map tableEntityMap; 21 | 22 | public static void initTableEntityMap() { 23 | if (tableEntityMap == null) { 24 | log.debug("开始加载数据库表与业务实体类映射信息..."); 25 | tableEntityMap = 26 | DatabaseUtils.entityManager.getMetamodel().getEntities() 27 | .stream().collect( 28 | Collectors.toMap( 29 | e-> e.getJavaType().getAnnotation(Table.class).name().toLowerCase(), 30 | e-> e.getJavaType().getName())); 31 | log.debug("数据库表与业务实体类映射信息加载完毕..."); 32 | } 33 | } 34 | 35 | public static String getEntity(String tableName) { 36 | initTableEntityMap(); 37 | return tableEntityMap.get(tableName); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/DatabaseUtils.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DatabaseMetaData; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.util.Set; 8 | import java.util.TreeSet; 9 | 10 | import javax.persistence.EntityManager; 11 | 12 | import org.hibernate.engine.spi.SessionImplementor; 13 | 14 | import lombok.Cleanup; 15 | import lombok.extern.slf4j.Slf4j; 16 | 17 | /** 18 | * @ClassName DatabaseMetadataUtils 19 | * @Description 项目所使用数据库相关的工具类 20 | * @author MingshuJian 21 | * @Date 2017年4月7日 上午8:52:09 22 | * @version 1.0.0 23 | */ 24 | @Slf4j 25 | public class DatabaseUtils { 26 | 27 | public static EntityManager entityManager = SpringUtils.getBean(EntityManager.class); 28 | public static Set tableNames = new TreeSet<>(); 29 | 30 | public static DatabaseMetaData getDatabaseMetaData() throws SQLException { 31 | SessionImplementor sessionImplementor = (SessionImplementor) entityManager.getDelegate(); 32 | @Cleanup Connection connection = sessionImplementor.isConnected() ? sessionImplementor.connection() : sessionImplementor.getJdbcConnectionAccess().obtainConnection(); 33 | return connection.getMetaData(); 34 | } 35 | 36 | public static ResultSet getDatabaseTables() throws SQLException { 37 | return getDatabaseMetaData().getTables(null, null, "", new String[]{"TABLE"}); 38 | } 39 | 40 | public static void loadDatabaseTableNames() throws SQLException { 41 | log.debug("开始加载数据库表名信息..."); 42 | ResultSet tables = getDatabaseTables(); 43 | if (tableNames.size() != 0) tableNames.clear(); 44 | while (tables.next()) tableNames.add(tables.getString(3)); 45 | log.debug("数据库表名信息加载完毕..."); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/HttpServletRequestUtils.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import java.nio.charset.Charset; 8 | 9 | import javax.servlet.ServletRequest; 10 | 11 | /** 12 | * @ClassName HttpServletRequestUtils 13 | * @Description 为处理HttpServletRequest对象提供的工具类 14 | * @author MingshuJian 15 | * @Date 2017年6月2日 上午10:12:42 16 | * @version 1.0.0 17 | */ 18 | public class HttpServletRequestUtils { 19 | 20 | public static String getRequestBody(ServletRequest request) { 21 | StringBuffer buffer = new StringBuffer(); 22 | try (InputStream in = request.getInputStream();BufferedReader reader = new BufferedReader(new InputStreamReader(in, Charset.forName("UTF-8")))) { 23 | reader.lines().forEach(buffer::append); 24 | } catch (IOException e) { 25 | e.printStackTrace(); 26 | } 27 | return buffer.toString(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/MailUtils.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import static com.beamofsoul.bip.management.util.ConfigurationReader.asString; 4 | import static com.beamofsoul.bip.management.util.ConfigurationReader.getValue; 5 | 6 | import javax.mail.internet.MimeMessage; 7 | 8 | import org.springframework.mail.javamail.JavaMailSender; 9 | import org.springframework.mail.javamail.MimeMessageHelper; 10 | 11 | import com.beamofsoul.bip.management.mail.Mail; 12 | 13 | import lombok.extern.slf4j.Slf4j; 14 | 15 | /** 16 | * @ClassName MailUtils 17 | * @Description 系统邮件操作工具类 18 | * @author MingshuJian 19 | * @Date 2017年3月23日 下午4:01:40 20 | * @version 1.0.0 21 | */ 22 | @Slf4j 23 | public class MailUtils { 24 | 25 | private static JavaMailSender sender = SpringUtils.getBean(JavaMailSender.class); 26 | private static String from = asString(getValue(ConfigurationReader.SPRING_MAIL_USERNAME)); 27 | 28 | public static boolean send(Mail mail) { 29 | try { 30 | final MimeMessage message = sender.createMimeMessage(); 31 | final MimeMessageHelper helper = new MimeMessageHelper(message, true); 32 | helper.setFrom(from); 33 | helper.setTo(mail.getTo()); 34 | helper.setSubject(mail.getSubject()); 35 | helper.setText(mail.getText(), true); 36 | sender.send(message); 37 | log.debug(mail.getLog4Succeed()); 38 | return true; 39 | } catch (Exception e) { 40 | log.error(mail.getLog4Fail(), e); 41 | return false; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/SensitiveWordsMapping.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import com.beamofsoul.bip.entity.SensitiveWord; 8 | 9 | import lombok.extern.slf4j.Slf4j; 10 | 11 | @Slf4j 12 | public final class SensitiveWordsMapping { 13 | 14 | public final static Map SENSITIVEWORD_REPLACEMENT_MAP = new HashMap(); 15 | 16 | public static void fill(List sws) { 17 | log.debug("开始加载敏感词映射信息..."); 18 | sws.stream().forEach(e -> SENSITIVEWORD_REPLACEMENT_MAP.put(e.getWord(), e)); 19 | log.debug("敏感词映射信息加载完毕..."); 20 | } 21 | 22 | public static void refill(List sws) { 23 | SENSITIVEWORD_REPLACEMENT_MAP.clear(); 24 | fill(sws); 25 | } 26 | 27 | public static String filter(String words) { 28 | return filter(words, null); 29 | } 30 | 31 | public static String filter(String words, final String replacement) { 32 | boolean clear = replacement != null; 33 | SensitiveWord sw = null; 34 | for (Map.Entry entry : SENSITIVEWORD_REPLACEMENT_MAP.entrySet()) { 35 | sw = entry.getValue(); 36 | if (sw.getAvailable()) 37 | words = sw.getRegular() ? 38 | words.replaceAll(entry.getKey(), clear ? replacement : sw.getReplacement()) : 39 | words.replace(entry.getKey(), clear ? replacement : sw.getReplacement()); 40 | } 41 | return words; 42 | } 43 | 44 | public static String clear(String words) { 45 | return filter(words, ""); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/SerializationUtils.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.io.ObjectInputStream; 8 | import java.io.ObjectOutputStream; 9 | import java.io.OutputStream; 10 | import java.io.Serializable; 11 | 12 | import javax.annotation.Nonnull; 13 | 14 | import org.apache.commons.lang3.SerializationException; 15 | 16 | import lombok.Cleanup; 17 | import lombok.NonNull; 18 | 19 | public class SerializationUtils { 20 | 21 | @SuppressWarnings("unchecked") 22 | public static T clone(T object) { 23 | return (T) deserialize(serialize(object)); 24 | } 25 | 26 | public static void serialize(Serializable obj,@Nonnull OutputStream outputStream) { 27 | try { 28 | @Cleanup ObjectOutputStream out = new ObjectOutputStream(outputStream); 29 | out.writeObject(obj); 30 | } catch (IOException ex) { 31 | throw new SerializationException(ex); 32 | } 33 | } 34 | 35 | public static byte[] serialize(Serializable obj) { 36 | ByteArrayOutputStream baos = new ByteArrayOutputStream(512); 37 | serialize(obj, baos); 38 | return baos.toByteArray(); 39 | } 40 | 41 | public static Object deserialize(@NonNull InputStream inputStream) { 42 | try { 43 | @Cleanup ObjectInputStream in = new ObjectInputStream(inputStream); 44 | return in.readObject(); 45 | } catch (Exception ex) { 46 | throw new SerializationException(ex); 47 | } 48 | } 49 | 50 | public static Object deserialize(@NonNull byte[] objectData) { 51 | return deserialize(new ByteArrayInputStream(objectData)); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/SpringUtils.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | import lombok.NonNull; 9 | 10 | @Component 11 | public class SpringUtils implements ApplicationContextAware { 12 | 13 | private static ApplicationContext applicationContext = null; 14 | 15 | public static void setApplicationContext0(@NonNull ApplicationContext applicationContext) { 16 | if (SpringUtils.applicationContext == null) SpringUtils.applicationContext = applicationContext; 17 | } 18 | 19 | @Override 20 | public void setApplicationContext(ApplicationContext applicationContext) 21 | throws BeansException { 22 | SpringUtils.setApplicationContext0(applicationContext); 23 | } 24 | 25 | public static ApplicationContext getApplicationContext() { 26 | return applicationContext; 27 | } 28 | 29 | public static Object getBean(String name) { 30 | return getApplicationContext().getBean(name); 31 | } 32 | 33 | public static T getBean(Class clazz) { 34 | return getApplicationContext().getBean(clazz); 35 | } 36 | 37 | public static T getBean(String name, Class clazz) { 38 | return getApplicationContext().getBean(name,clazz); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/util/UserUtils.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.util; 2 | 3 | import javax.servlet.http.HttpSession; 4 | 5 | import com.beamofsoul.bip.entity.User; 6 | import com.beamofsoul.bip.entity.dto.UserExtension; 7 | 8 | public class UserUtils { 9 | 10 | public static final String CURRENT_USER = "CURRENT_USER"; 11 | 12 | public static void saveCurrentUser(HttpSession session, UserExtension userExtension) { 13 | session.setAttribute(CURRENT_USER, userExtension); 14 | } 15 | 16 | public static UserExtension getCurrentUser(HttpSession session) { 17 | return (UserExtension) session.getAttribute(CURRENT_USER); 18 | } 19 | 20 | public static boolean isExist(HttpSession session) { 21 | return getCurrentUser(session) != null; 22 | } 23 | 24 | public static long getLongUserId(HttpSession session) { 25 | return getCurrentUser(session).getUserId(); 26 | } 27 | 28 | public static String getStringUserId(HttpSession session) { 29 | return String.valueOf(getLongUserId(session)); 30 | } 31 | 32 | public static User getTraditionalUser(HttpSession session) { 33 | return new User(getLongUserId(session)); 34 | } 35 | 36 | public static void trySavingCurrentUser(HttpSession session, Object user) { 37 | if (user instanceof UserExtension) saveCurrentUser(session, (UserExtension)user); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/management/websocket/CustomWebSocketConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.management.websocket; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.socket.WebSocketHandler; 7 | import org.springframework.web.socket.config.annotation.EnableWebSocket; 8 | import org.springframework.web.socket.config.annotation.WebSocketConfigurer; 9 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; 10 | 11 | /** 12 | * @ClassName CustomWebSocketConfiguration 13 | * @Description 自定义websocket配置类 14 | * @author MingshuJian 15 | * @Date 2017年3月21日 下午3:17:47 16 | * @version 1.0.0 17 | */ 18 | @Configuration 19 | @EnableWebSocket 20 | public class CustomWebSocketConfiguration implements WebSocketConfigurer { 21 | 22 | @Resource 23 | private WebSocketHandler customSystemLogWebSocketHandler; 24 | 25 | @Override 26 | public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { 27 | //系统日志WebSocket 28 | registry.addHandler(customSystemLogWebSocketHandler, "/systemLog").withSockJS(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/ActionMonitorRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.beamofsoul.bip.entity.ActionMonitor; 6 | import com.beamofsoul.bip.management.repository.BaseMultielementRepository; 7 | 8 | @Repository 9 | public interface ActionMonitorRepository extends BaseMultielementRepository { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/DepartmentRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import java.math.BigInteger; 4 | import java.util.List; 5 | 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import com.beamofsoul.bip.entity.Department; 10 | import com.beamofsoul.bip.management.repository.BaseMultielementRepository; 11 | 12 | @Repository 13 | public interface DepartmentRepository extends BaseMultielementRepository { 14 | 15 | @Query(nativeQuery = true, value="select id from (select * from t_department order by parent_id, id) department, (select @pv \\:= ?1) initialisation where find_in_set(parent_id, @pv) > 0 and @pv \\:= concat(@pv, ',', id)") 16 | public List findChildrenIds(Long id); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/DetailControlRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import com.beamofsoul.bip.entity.DetailControl; 10 | 11 | @Repository 12 | public interface DetailControlRepository extends JpaRepository,JpaSpecificationExecutor { 13 | 14 | List findByRoleIdAndEntityClassOrderByPriorityAsc(Long roleId, String entityClass); 15 | List findByRoleIdAndEntityClassAndEnabledOrderByPriorityAsc(Long roleId, String entityClass, Boolean enabled); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/LoginRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.beamofsoul.bip.entity.Login; 6 | import com.beamofsoul.bip.management.repository.BaseMultielementRepository; 7 | 8 | @Repository 9 | public interface LoginRepository extends BaseMultielementRepository { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/MessageRepositoryCustom.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | public interface MessageRepositoryCustom { 4 | 5 | long updateStatusByIds(boolean status, Long... ids); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/OrganizationRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import java.math.BigInteger; 4 | import java.util.List; 5 | 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import com.beamofsoul.bip.entity.Organization; 10 | import com.beamofsoul.bip.management.repository.BaseMultielementRepository; 11 | 12 | @Repository 13 | public interface OrganizationRepository extends BaseMultielementRepository, OrganizationRepositoryCustom { 14 | 15 | @Query(nativeQuery = true, value="select id from (select * from t_organization order by parent_id, id) organization, (select @pv \\:= ?1) initialisation where find_in_set(parent_id, @pv) > 0 and @pv \\:= concat(@pv, ',', id)") 16 | public List findChildrenIds(Long id); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/OrganizationRepositoryCustom.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | 6 | import com.beamofsoul.bip.entity.Organization; 7 | import com.beamofsoul.bip.entity.UserRoleCombineRole; 8 | 9 | public interface OrganizationRepositoryCustom { 10 | 11 | Page findAllChildrenOrganizations(Pageable pageable, Object condition); 12 | // Organization findOrganizationMaxSort(Long parentId); 13 | Integer findOrganizationMaxSort(Long parentId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/PermissionRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.beamofsoul.bip.entity.Permission; 6 | import com.beamofsoul.bip.management.repository.BaseMultielementRepository; 7 | 8 | /** 9 | * @ClassName PermissionRepository 10 | * @Description 系统权限持久化层接口 11 | * @author MingshuJian 12 | * @Date 2017年2月7日 上午11:12:56 13 | * @version 1.0.0 14 | */ 15 | @Repository 16 | public interface PermissionRepository extends BaseMultielementRepository { 17 | 18 | Permission findByName(String name); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/RolePermissionRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.beamofsoul.bip.entity.RolePermission; 6 | import com.beamofsoul.bip.management.repository.BaseMultielementRepository; 7 | 8 | @Repository 9 | public interface RolePermissionRepository extends BaseMultielementRepository, RolePermissionRepositoryCustom { 10 | 11 | // @Query("SELECT new com.beamofsoul.bip.entity.dto.RolePermissionDTO(r.id AS roleId,r.name AS roleName,p.id AS permissionId,p.name AS permissionName,p.available AS permissionAvailable,p.parentId AS permissionParentId,p.resourceType AS permissionResourceType,p.url AS permissionUrl,p.action AS permissionAction) FROM RolePermission rp RIGHT JOIN rp.role r LEFT JOIN rp.permission p WHERE 1 = 1 ORDER BY roleId, permissionParentId ASC") 12 | // public List findAllRolePermissionMapping(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/RolePermissionRepositoryCustom.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.beamofsoul.bip.entity.dto.RolePermissionDTO; 6 | 7 | public interface RolePermissionRepositoryCustom { 8 | 9 | List findAllRolePermissionMapping(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.beamofsoul.bip.entity.Role; 7 | import com.beamofsoul.bip.management.repository.BaseMultielementRepository; 8 | 9 | /** 10 | * @ClassName RoleRepository 11 | * @Description 系统角色持久化层接口 12 | * @author MingshuJian 13 | * @Date 2017年2月7日 上午11:12:56 14 | * @version 1.0.0 15 | */ 16 | @Repository 17 | public interface RoleRepository extends BaseMultielementRepository { 18 | 19 | Role findByName(String name); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/SensitiveWordRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.beamofsoul.bip.entity.SensitiveWord; 6 | import com.beamofsoul.bip.management.repository.BaseMultielementRepository; 7 | 8 | @Repository 9 | public interface SensitiveWordRepository extends BaseMultielementRepository { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.beamofsoul.bip.entity.User; 6 | import com.beamofsoul.bip.management.repository.BaseMultielementRepository; 7 | 8 | /** 9 | * @ClassName UserRepository 10 | * @Description 系统用户持久化层接口 11 | * @author MingshuJian 12 | * @Date 2017年2月7日 上午11:13:41 13 | * @version 1.0.0 14 | */ 15 | @Repository 16 | public interface UserRepository extends BaseMultielementRepository { 17 | 18 | User findByUsername(String username); 19 | User findByNickname(String nickname); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/UserRoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.beamofsoul.bip.entity.UserRole; 6 | import com.beamofsoul.bip.management.repository.BaseMultielementRepository; 7 | 8 | /** 9 | * JpaRepository 该接口提供了支持常规增删改查和分页查询的功能 10 | * JpaSpecificationExecutor 该接口提供支持复杂查询的功能 11 | * @author MingshuJian 12 | */ 13 | @Repository 14 | public interface UserRoleRepository extends BaseMultielementRepository, UserRoleRepositoryCustom { 15 | 16 | int deleteByUser_IdAndRole_Id(Long userId, Long roleId); 17 | 18 | // @Modifying 19 | // @Query(value="DELETE FROM t_user WHERE user_id = ?1",nativeQuery=true) 20 | // int deleteByUserId(Long userId); 21 | // 22 | // @Modifying 23 | // @Query(value="DELETE FROM t_user_role WHERE user_id in ?1",nativeQuery=true) 24 | // int deleteByUserIds(Long... userIds); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/UserRoleRepositoryCustom.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository; 2 | 3 | 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | 7 | import com.beamofsoul.bip.entity.UserRoleCombineRole; 8 | import com.beamofsoul.bip.entity.dto.UserRoleDTO; 9 | 10 | public interface UserRoleRepositoryCustom { 11 | 12 | Page findAllUserRoleMapping(Pageable pageable); 13 | Page findAllUserRoleMappingViaView(Pageable pageable); 14 | Page findUserRoleMappingByCondition(Pageable pageable, Object condition); 15 | Page findUserRoleMappingByConditionViaView(Pageable pageable, Object condition); 16 | 17 | UserRoleCombineRole findUserRoleMappingByUserId(Long userId); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/repository/impl/RolePermissionRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.repository.impl; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.data.repository.NoRepositoryBean; 9 | 10 | import com.beamofsoul.bip.entity.dto.RolePermissionDTO; 11 | import com.beamofsoul.bip.entity.query.QRolePermission; 12 | import com.beamofsoul.bip.repository.RolePermissionRepositoryCustom; 13 | import com.querydsl.core.types.Projections; 14 | import com.querydsl.jpa.impl.JPAQuery; 15 | 16 | @NoRepositoryBean 17 | public class RolePermissionRepositoryImpl implements RolePermissionRepositoryCustom { 18 | 19 | @Autowired 20 | private EntityManager entityManager; 21 | 22 | @Override 23 | public List findAllRolePermissionMapping() { 24 | JPAQuery query = new JPAQuery(entityManager); 25 | QRolePermission rolePermission = QRolePermission.rolePermission; 26 | List rpDTOList = 27 | query.select(Projections.constructor(RolePermissionDTO.class, 28 | rolePermission.role.id, 29 | rolePermission.role.name, 30 | rolePermission.permission.id, 31 | rolePermission.permission.name, 32 | rolePermission.permission.available, 33 | rolePermission.permission.parentId, 34 | rolePermission.permission.resourceType, 35 | rolePermission.permission.url, 36 | rolePermission.permission.action, 37 | rolePermission.permission.sort)) 38 | .from(rolePermission) 39 | .rightJoin(rolePermission.role) 40 | .leftJoin(rolePermission.permission) 41 | .orderBy(rolePermission.role.id.desc(),rolePermission.permission.id.asc()) 42 | .fetch(); 43 | return rpDTOList; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/ActionMonitorService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import com.alibaba.fastjson.JSONObject; 9 | import com.beamofsoul.bip.entity.ActionMonitor; 10 | import com.querydsl.core.types.Predicate; 11 | import com.querydsl.core.types.dsl.BooleanExpression; 12 | 13 | public interface ActionMonitorService { 14 | 15 | ActionMonitor create(ActionMonitor actionMonitor); 16 | ActionMonitor update(ActionMonitor actionMonitor); 17 | long delete(Long... ids); 18 | 19 | ActionMonitor findById(Long id); 20 | List findAll(); 21 | Page findAll(Pageable pageable); 22 | Page findAll(Pageable pageable, Predicate predicate); 23 | 24 | BooleanExpression onSearch(JSONObject content); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/BaseServiceInterface.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | /** 4 | * @ClassName BaseServiceInterface 5 | * @Description 基础服务抽象接口类 6 | * @author MingshuJian 7 | * @Date 2017年3月20日 上午11:01:21 8 | * @version 1.0.0 9 | */ 10 | public interface BaseServiceInterface { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/DepartmentService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import com.alibaba.fastjson.JSONObject; 9 | import com.beamofsoul.bip.entity.Department; 10 | import com.querydsl.core.types.Predicate; 11 | import com.querydsl.core.types.dsl.BooleanExpression; 12 | 13 | public interface DepartmentService { 14 | 15 | Department create(Department department); 16 | Department update(Department department); 17 | long delete(Long... ids); 18 | 19 | Department findById(Long id); 20 | 21 | List findAll(); 22 | Page findAll(Pageable pageable); 23 | Page findAll(Pageable pageable, Predicate predicate); 24 | List findAllAvailableDepartments(); 25 | List findChildrenIds(Long id); 26 | List findRelationalAll(Predicate predicate); 27 | 28 | BooleanExpression onSearch(JSONObject content); 29 | BooleanExpression onRelationalSearch(JSONObject content); 30 | boolean checkDepartmentCodeUnique(String code, Long id); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/DetailControlService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.List; 4 | 5 | import com.beamofsoul.bip.entity.DetailControl; 6 | 7 | public interface DetailControlService { 8 | 9 | DetailControl findById(Long id); 10 | List findByRoleIdAndEntityClass(Long roleId,String entityClass); 11 | List findByRoleIdAndEntityClass(Long roleId,String entityClass,Boolean enabled); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/LoginService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import com.alibaba.fastjson.JSONObject; 9 | import com.beamofsoul.bip.entity.Login; 10 | import com.querydsl.core.types.Predicate; 11 | import com.querydsl.core.types.dsl.BooleanExpression; 12 | 13 | public interface LoginService { 14 | 15 | Login create(Login login); 16 | Login update(Login login); 17 | long delete(Long... ids); 18 | 19 | Login findById(Long id); 20 | 21 | List findAll(); 22 | Page findAll(Pageable pageable); 23 | Page findAll(Pageable pageable, Predicate predicate); 24 | 25 | BooleanExpression onSearch(JSONObject content); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/OrganizationService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import com.alibaba.fastjson.JSONObject; 9 | import com.beamofsoul.bip.entity.Organization; 10 | import com.querydsl.core.types.Predicate; 11 | import com.querydsl.core.types.dsl.BooleanExpression; 12 | 13 | public interface OrganizationService { 14 | 15 | Organization create(Organization organization); 16 | Organization update(Organization organization); 17 | // Organization moveUp(Organization organization); 18 | List changeSort(Long beforeId,Long afterId); 19 | long delete(Long... ids); 20 | long deleteNodes(List parentIds,List childrenIds); 21 | // long deleteNodes(Long[] parentIds,Long[] childrenIds); 22 | 23 | Organization findById(Long id); 24 | 25 | List findAll(); 26 | List findRelationalAll(Predicate predicate); 27 | Page findAll(Pageable pageable); 28 | Page findAll(Pageable pageable, Predicate predicate); 29 | Page findAllChildrenOrganizations(Pageable pageable, Object condition); 30 | List findAllAvailableOrganizations(); 31 | 32 | BooleanExpression onSearch(JSONObject content,List idsLong); 33 | BooleanExpression onRelationalSearch(JSONObject content); 34 | 35 | boolean checkNameUnique(String name, Long id); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/PermissionService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import com.alibaba.fastjson.JSONObject; 9 | import com.beamofsoul.bip.entity.Permission; 10 | import com.querydsl.core.types.Predicate; 11 | import com.querydsl.core.types.dsl.BooleanExpression; 12 | 13 | public interface PermissionService { 14 | 15 | Permission create(Permission permission); 16 | Permission update(Permission permission); 17 | long delete(Long[] ids); 18 | 19 | List findAll(); 20 | List findRelationalAll(Predicate predicate); 21 | Page findAll(Pageable pageable); 22 | Page findAll(Pageable pageable, Predicate predicate); 23 | BooleanExpression onSearch(JSONObject content); 24 | BooleanExpression onRelationalSearch(JSONObject content); 25 | List findAllAvailableData(); 26 | Permission findByName(String name); 27 | Permission findById(Long id); 28 | 29 | boolean checkPermissionNameUnique(String permissionName, Long permissionId); 30 | boolean isUsedPermissions(Long... permissionId); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/RolePermissionService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | 6 | import com.beamofsoul.bip.entity.RolePermission; 7 | import com.beamofsoul.bip.entity.dto.RolePermissionDTO; 8 | import com.beamofsoul.bip.entity.dto.RolePermissionMappingDTO; 9 | 10 | public interface RolePermissionService { 11 | 12 | List findAllRolePermissionMapping(); 13 | boolean updateRolePermissionMapping(RolePermissionMappingDTO rolePermissionMappingDTO); 14 | Collection bulkCreate(Collection rolePermissions); 15 | Long deleteByRoleIdAndPermissionIds(Long roleId, Collection permissionIds); 16 | void refreshRolePermissionMapping(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import com.beamofsoul.bip.entity.Role; 9 | import com.querydsl.core.types.Predicate; 10 | 11 | public interface RoleService { 12 | 13 | Role create(Role role); 14 | Role update(Role role); 15 | long delete(Long... ids); 16 | 17 | List findAll(); 18 | Page findAll(Pageable pageable); 19 | Page findAll(Pageable pageable, Predicate predicate); 20 | Role findByName(String name); 21 | Role findById(Long id); 22 | 23 | boolean checkRoleNameUnique(String roleName, Long roleId); 24 | boolean isUsedRoles(String roleIds); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/SensitiveWordService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import com.alibaba.fastjson.JSONObject; 9 | import com.beamofsoul.bip.entity.SensitiveWord; 10 | import com.querydsl.core.types.Predicate; 11 | import com.querydsl.core.types.dsl.BooleanExpression; 12 | 13 | public interface SensitiveWordService { 14 | 15 | SensitiveWord create(SensitiveWord sensitiveWord); 16 | SensitiveWord update(SensitiveWord sensitiveWord); 17 | long delete(Long... ids); 18 | 19 | SensitiveWord findById(Long id); 20 | 21 | List findAll(); 22 | Page findAll(Pageable pageable); 23 | Page findAll(Pageable pageable, Predicate predicate); 24 | 25 | BooleanExpression onSearch(JSONObject content); 26 | boolean findSensitiveFilterOpen(); 27 | void setSensitiveFilterOpen(boolean isOpen); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/UserRoleService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.Collection; 4 | 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import com.beamofsoul.bip.entity.UserRole; 9 | import com.beamofsoul.bip.entity.UserRoleCombineRole; 10 | 11 | public interface UserRoleService { 12 | 13 | Page findAllUserRoleMapping(Pageable pageable); 14 | Page findUserRoleMappingByCondition(Pageable pageable, Object condition); 15 | UserRoleCombineRole findUserRoleMappingByUserId(Long userId); 16 | UserRoleCombineRole updateUserRoleMapping(UserRoleCombineRole userRoleCombineRole); 17 | 18 | UserRole create(UserRole userRole); 19 | Collection bulkCreate(Collection userRoles); 20 | void delete(Long id); 21 | Long deleteByIds(Long... ids); 22 | Long deleteByUserIdAndRoleIds(Long userId, Long[] roleIds); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import com.alibaba.fastjson.JSONObject; 9 | import com.beamofsoul.bip.entity.User; 10 | import com.querydsl.core.types.Predicate; 11 | import com.querydsl.core.types.dsl.BooleanExpression; 12 | 13 | public interface UserService { 14 | 15 | User create(User user); 16 | 17 | User update(User user); 18 | 19 | long delete(Long... ids); 20 | 21 | boolean changePassword(Long userId, String currentPassword, String latestPassword); 22 | 23 | int updateStatus(Long userId, int status); 24 | 25 | User findById(Long userId); 26 | 27 | User findByUsername(String username); 28 | 29 | List findByUsername(String... usernames); 30 | 31 | List findByNickname(String... nicknames); 32 | 33 | List findAll(); 34 | 35 | Page findAll(Pageable pageable); 36 | 37 | Page findAll(Pageable pageable, Predicate predicate); 38 | 39 | BooleanExpression onSearch(JSONObject content); 40 | 41 | boolean checkUsernameUnique(String username, Long userId); 42 | 43 | boolean checkNicknameUnique(String nickname, Long userId); 44 | 45 | boolean isUsed(String objectIds); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/impl/BaseAbstractServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service.impl; 2 | 3 | import org.slf4j.Logger; 4 | 5 | import com.beamofsoul.bip.service.BaseServiceInterface; 6 | 7 | import lombok.extern.slf4j.Slf4j; 8 | 9 | /** 10 | * @ClassName BaseAbstractService 11 | * @Description 基础服务抽象实现类 12 | * @author MingshuJian 13 | * @Date 2017年3月20日 上午10:18:34 14 | * @version 1.0.0 15 | */ 16 | @Slf4j 17 | public abstract class BaseAbstractServiceImpl implements BaseServiceInterface { 18 | 19 | protected static Logger logger = log; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/beamofsoul/bip/service/impl/DetailControlServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.beamofsoul.bip.service.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.beamofsoul.bip.entity.DetailControl; 9 | import com.beamofsoul.bip.repository.DetailControlRepository; 10 | import com.beamofsoul.bip.service.DetailControlService; 11 | 12 | @Service("detailControlService") 13 | public class DetailControlServiceImpl extends BaseAbstractServiceImpl implements DetailControlService { 14 | 15 | @Autowired 16 | private DetailControlRepository detailControlRepository; 17 | 18 | @Override 19 | public DetailControl findById(Long id) { 20 | return detailControlRepository.findOne(id); 21 | } 22 | 23 | @Override 24 | public List findByRoleIdAndEntityClass(Long roleId, 25 | String entityClass) { 26 | return detailControlRepository.findByRoleIdAndEntityClassOrderByPriorityAsc(roleId,entityClass); 27 | } 28 | 29 | @Override 30 | public List findByRoleIdAndEntityClass(Long roleId, 31 | String entityClass, Boolean enabled) { 32 | return detailControlRepository.findByRoleIdAndEntityClassAndEnabledOrderByPriorityAsc(roleId,entityClass,enabled); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ______ ___ ___ 2 | /\__ _\ __ /\_ \ /\_ \ 3 | \/_/\ \/ _ __ /\_\ __ \//\ \\//\ \ 4 | \ \ \/\`'__\/\ \ /'__`\ \ \ \ \ \ \ 5 | \ \ \ \ \/ \ \ \/\ \L\.\_\_\ \_\_\ \_ 6 | \ \_\ \_\ \ \_\ \__/.\_\\____\\____\ 7 | \/_/\/_/ \/_/\/__/\/_//____//____/ 8 | -------------------------------------------------------------------------------- /src/main/resources/ehcache.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 34 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/resources/static/css/business/admin-index-iview.css: -------------------------------------------------------------------------------- 1 | .layout{ 2 | border: 1px solid #d7dde4; 3 | background: #f5f7f9; 4 | position: relative; 5 | border-radius: 4px; 6 | overflow: hidden; 7 | } 8 | .layout-breadcrumb{ 9 | padding: 10px 15px 0; 10 | } 11 | .layout-content{ 12 | min-height: 800px; 13 | margin: 15px; 14 | overflow: hidden; 15 | background: #fff; 16 | border-radius: 4px; 17 | } 18 | .layout-content-main{ 19 | padding: 10px; 20 | } 21 | .layout-copy{ 22 | text-align: center; 23 | padding: 10px 0 20px; 24 | color: #9ea7b4; 25 | } 26 | .layout-menu-left{ 27 | background: #464c5b; 28 | } 29 | .layout-header{ 30 | height: 60px; 31 | background: #fff; 32 | box-shadow: 0 1px 1px rgba(0,0,0,.1); 33 | } 34 | .layout-logo-left{ 35 | width: 90%; 36 | height: 30px; 37 | background: #5b6270; 38 | border-radius: 3px; 39 | margin: 15px auto; 40 | } 41 | .layout-ceiling-main a{ 42 | color: #9ba7b5; 43 | } 44 | .layout-hide-text .layout-text{ 45 | display: none; 46 | } 47 | .ivu-col{ 48 | transition: width .2s ease-in-out; 49 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/business/admin-index.css: -------------------------------------------------------------------------------- 1 | .layout{ 2 | border: 1px solid #d7dde4; 3 | background: #f5f7f9; 4 | position: relative; 5 | border-radius: 4px; 6 | overflow: hidden; 7 | } 8 | .layout-breadcrumb{ 9 | padding: 10px 15px 0; 10 | } 11 | .layout-content{ 12 | min-height: 800px; 13 | margin: 15px; 14 | overflow: hidden; 15 | background: #fff; 16 | border-radius: 4px; 17 | } 18 | .layout-content-main{ 19 | padding: 10px; 20 | } 21 | .layout-copy{ 22 | text-align: center; 23 | padding: 10px 0 20px; 24 | color: #9ea7b4; 25 | } 26 | .layout-menu-left{ 27 | background: #464c5b; 28 | } 29 | .layout-header{ 30 | height: 60px; 31 | background: #fff; 32 | box-shadow: 0 1px 1px rgba(0,0,0,.1); 33 | } 34 | .layout-logo-left{ 35 | width: 90%; 36 | height: 30px; 37 | background: #5b6270; 38 | border-radius: 3px; 39 | margin: 15px auto; 40 | } 41 | .layout-ceiling-main a{ 42 | color: #9ba7b5; 43 | } 44 | .layout-hide-text .layout-text{ 45 | display: none; 46 | } 47 | .ivu-col{ 48 | transition: width .2s ease-in-out; 49 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/business/backend-biz.css: -------------------------------------------------------------------------------- 1 | .sb-navbar-message-menu { 2 | background: #fff; 3 | border: 1px solid #ddd; 4 | } 5 | @media screen and (max-width: 601px) { 6 | .sb-navbar-message-menu { 7 | width: 100%; 8 | } 9 | } 10 | @media screen and (min-width: 1024px) { 11 | .sb-navbar-message-menu { 12 | width: 400px; 13 | } 14 | } 15 | .sb-navbar-message-item { 16 | padding-left: 6px; 17 | padding-right: 6px; 18 | } 19 | .sb-navbar-message-item-td { 20 | float: right; 21 | text-align: right; 22 | font-size: 11px; 23 | width: 40px; 24 | margin-left: 10px; 25 | } 26 | .sb-navbar-message-item-c { 27 | display: block; 28 | font-size: 13px; 29 | margin-right: 50px; 30 | text-overflow: ellipsis; 31 | } 32 | .sb-navbar-message-item-t { 33 | font-size: 14px; 34 | } 35 | .sb-navbar-message-item-dt { 36 | margin-top: 3px; 37 | font-size: 11px; 38 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/business/user-biz.css: -------------------------------------------------------------------------------- 1 | .container { 2 | max-width: 640px; 3 | margin: 20px auto; 4 | } 5 | 6 | img { 7 | max-width: 100%; 8 | } 9 | 10 | /* Override Cropper's styles */ 11 | .cropper-view-box, 12 | .cropper-face { 13 | border-radius: 50%; 14 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/web/index.css: -------------------------------------------------------------------------------- 1 | @CHARSET "UTF-8"; 2 | 3 | @media only screen and (min-width: 641px) { 4 | .smh{ 5 | height: 600px; 6 | } 7 | } 8 | 9 | @media only screen and (max-width: 640px) { 10 | .smh{ 11 | height: 200px; 12 | } 13 | } 14 | 15 | .detail { 16 | background: #fff; 17 | } 18 | 19 | .detail-h2 { 20 | text-align: center; 21 | font-size: 150%; 22 | margin: 40px 0; 23 | } 24 | 25 | .detail-h3 { 26 | color: #1f8dd6; 27 | } 28 | 29 | .detail-p { 30 | color: #7f8c8d; 31 | } 32 | 33 | .detail-mb { 34 | margin-bottom: 30px; 35 | } 36 | 37 | .hope { 38 | background: #0bb59b; 39 | padding: 50px 0; 40 | } 41 | 42 | .hope-img { 43 | text-align: center; 44 | } 45 | 46 | .hope-hr { 47 | border-color: #149C88; 48 | } 49 | 50 | .hope-title { 51 | font-size: 140%; 52 | } 53 | 54 | .about { 55 | background: #fff; 56 | padding: 40px 0; 57 | color: #7f8c8d; 58 | } 59 | 60 | .about-color { 61 | color: #34495e; 62 | } 63 | 64 | .about-title { 65 | font-size: 180%; 66 | padding: 30px 0 50px 0; 67 | text-align: center; 68 | } 69 | 70 | .footer p { 71 | color: #7f8c8d; 72 | margin: 0; 73 | padding: 15px 0; 74 | text-align: center; 75 | background: #2d3e50; 76 | } -------------------------------------------------------------------------------- /src/main/resources/static/image/SpringSecurityExecutionFlowDiagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beamofsoul/BusinessInfrastructurePlatformGroupVersion/423e7b1581c4b8f2eea36bd6ab678db5f713759f/src/main/resources/static/image/SpringSecurityExecutionFlowDiagram.jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/default_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beamofsoul/BusinessInfrastructurePlatformGroupVersion/423e7b1581c4b8f2eea36bd6ab678db5f713759f/src/main/resources/static/image/default_avatar.png -------------------------------------------------------------------------------- /src/main/resources/static/image/logo_qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beamofsoul/BusinessInfrastructurePlatformGroupVersion/423e7b1581c4b8f2eea36bd6ab678db5f713759f/src/main/resources/static/image/logo_qrcode.png -------------------------------------------------------------------------------- /src/main/resources/static/image/temp/timg (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beamofsoul/BusinessInfrastructurePlatformGroupVersion/423e7b1581c4b8f2eea36bd6ab678db5f713759f/src/main/resources/static/image/temp/timg (1).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/temp/timg (2).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beamofsoul/BusinessInfrastructurePlatformGroupVersion/423e7b1581c4b8f2eea36bd6ab678db5f713759f/src/main/resources/static/image/temp/timg (2).jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/temp/timg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beamofsoul/BusinessInfrastructurePlatformGroupVersion/423e7b1581c4b8f2eea36bd6ab678db5f713759f/src/main/resources/static/image/temp/timg.jpg -------------------------------------------------------------------------------- /src/main/resources/static/image/user2-160x160.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beamofsoul/BusinessInfrastructurePlatformGroupVersion/423e7b1581c4b8f2eea36bd6ab678db5f713759f/src/main/resources/static/image/user2-160x160.jpg -------------------------------------------------------------------------------- /src/main/resources/static/iview/fonts/ionicons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beamofsoul/BusinessInfrastructurePlatformGroupVersion/423e7b1581c4b8f2eea36bd6ab678db5f713759f/src/main/resources/static/iview/fonts/ionicons.eot -------------------------------------------------------------------------------- /src/main/resources/static/iview/fonts/ionicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beamofsoul/BusinessInfrastructurePlatformGroupVersion/423e7b1581c4b8f2eea36bd6ab678db5f713759f/src/main/resources/static/iview/fonts/ionicons.ttf -------------------------------------------------------------------------------- /src/main/resources/static/iview/fonts/ionicons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beamofsoul/BusinessInfrastructurePlatformGroupVersion/423e7b1581c4b8f2eea36bd6ab678db5f713759f/src/main/resources/static/iview/fonts/ionicons.woff -------------------------------------------------------------------------------- /src/main/resources/static/iview/iview-custom.css: -------------------------------------------------------------------------------- 1 | /* form 间距 */ 2 | /* .ivu-form-item{margin-bottom: 10px;} */ 3 | /* 折叠面板内 超出部分显示 */ 4 | .ivu-collapse-content{overflow:visible;} 5 | 6 | .ivu-tree ul {list-style:none;margin:0;padding:0;font-size:14px} 7 | .ivu-tree-title-selected,.ivu-tree-title-selected:hover {color:#fff;background-color:#00a5ff} 8 | -------------------------------------------------------------------------------- /src/main/resources/static/js/business/action-monitor-biz.js: -------------------------------------------------------------------------------- 1 | if (vueContentObject) getVueObject().$destroy(); 2 | 3 | const levels = ['毁灭性的','极恶性的','恶性的','良性的','可忽略的']; 4 | [loadPageableDataUrl, tableColumnsName, tableColumnsKey] = [ 5 | 'actionMonitorsByPage', 6 | ['','ID','用户','行为','目标','影响','危害级别','IP地址','MAC地址','具体时间'], 7 | ['selection','id','user','specificAction','target','effect','hazardLevel','ipAddress','macAddress','createDate'] 8 | ]; 9 | 10 | parseValuesOnTableEachRow = obj => ({ 11 | id: obj.id, 12 | user: obj.user.nickname, 13 | specificAction: obj.specificAction, 14 | target: obj.target, 15 | effect: obj.effect, 16 | hazardLevel: levels[obj.hazardLevel], 17 | ipAddress: obj.ipAddress, 18 | macAddress: obj.macAddress, 19 | createDate:formatDate(obj.createDate) 20 | }); 21 | 22 | vueContentBeforeCreate = () => { 23 | hazardLevelDataSelect = [{value: '0', label: levels[0]},{value: '1', label: levels[1]},{value: '2', label: levels[2]},{value: '3', label: levels[3]},{value: '4', label: levels[4]}]; 24 | }; 25 | 26 | [queryFormItemName, queryFormItemKey, queryFormItemType] = [ 27 | ['ID','用户','行为','目标','影响','危害级别','IP地址','MAC地址'], 28 | ['id','user','specificAction','target','effect','hazardLevel','ipAddress','macAddress'], 29 | ['string','string','string','string','string','select#hazardLevelDataSelect','string','string'] 30 | ]; 31 | 32 | vueContentObject = new Vue(initializeContentOptions()); -------------------------------------------------------------------------------- /src/main/resources/static/js/business/admin-index-biz.js: -------------------------------------------------------------------------------- 1 | var vueElementSelector = '.layout'; 2 | var vueData = {spanLeft: 3, spanRight: 21, breadcrumb: [{href: '#', content: '首页内容'}]}; 3 | var vueComputed = {iconSize: getIconSize}; 4 | var vueMethods = {toggleClick: toggleMenu, contentClick: loadContent}; 5 | 6 | function getIconSize() { 7 | return this.spanLeft === 3 ? 18 : 24; 8 | } 9 | 10 | function toggleMenu () { 11 | setGridScale(this.spanLeft === 3 ? 1 : 3, this); 12 | } 13 | 14 | function setGridScale(left,element) { 15 | element.spanLeft = left; 16 | element.spanRight = 24 - left; 17 | } 18 | 19 | function initBreadcrumbContent(name) { 20 | if (name === 'adminIndexContent') vueObject.breadcrumb = [{href: '#', content: '首页内容'}]; 21 | if (name.indexOf('permission/') == 0) vueObject.breadcrumb = [{href: '#', content: '权限管理'}]; 22 | if (name.indexOf('department/') == 0) vueObject.breadcrumb = [{href: '#', content: '部门管理'}]; 23 | if (name.indexOf('login/') == 0) vueObject.breadcrumb = [{href: '#', content: '登录记录'}]; 24 | if (name.indexOf('sensitiveWord/') == 0) vueObject.breadcrumb = [{href: '#', content: '敏感词管理'}]; 25 | if (name.indexOf('development/') == 0) vueObject.breadcrumb = [{href: '#', content: '开发者模式'}]; 26 | } 27 | 28 | function loadContent(name) { 29 | initBreadcrumbContent(name); 30 | initCurrentRequestMappingRootPath(name);//设置当前点击path所属的requestMapping 模块名 31 | if (name.indexOf('logout') != -1) $(window).attr('location',name); 32 | else $('.layout-content-main').load(name); 33 | } 34 | 35 | function initializeOptions() { 36 | return {el: vueElementSelector, data: vueData, computed: vueComputed, methods: vueMethods}; 37 | } 38 | 39 | var vueObject = new Vue(initializeOptions()); 40 | 41 | loadContent('adminIndexContent'); 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/main/resources/static/js/business/backend-biz.js: -------------------------------------------------------------------------------- 1 | loadTreeRootUrl = 'permission/single'; 2 | loadTreeRootDataFunction = () => {id: 1} 3 | loadTreeNodeUrl = 'permission/children'; 4 | 5 | let vueContentElementSelector = '#contentContainer'; 6 | let vueContentData = {treeData: generateRootNode()}; 7 | let vueContentComputed = {}; 8 | let vueContentMethods = {toggleExpand: toggleExpand, selectChange: selectChange, checkChange: checkChange}; 9 | 10 | function initializeContentOptions() { 11 | return {el: vueContentElementSelector, data: vueContentData, computed: vueContentComputed, methods: vueContentMethods}; 12 | } 13 | 14 | vueContentObject = new Vue(initializeContentOptions()); 15 | vueContentObject.$refs.tree.$children[0].handleExpand(toggleExpand); -------------------------------------------------------------------------------- /src/main/resources/static/js/business/login-biz.js: -------------------------------------------------------------------------------- 1 | if (vueContentObject) getVueObject().$destroy(); 2 | 3 | [vuePageSize, loadPageableDataUrl, tableColumnsName, tableColumnsKey] = [ 4 | 10, 5 | 'loginsByPage', 6 | ['','ID','用户','电子邮箱','操作系统','浏览器(版本)','IP地址','品牌','型号','屏幕尺寸','登录时间'], 7 | ['selection','id','user','email','operatingSystem','browser','ipAddress','brand','model','screenSize','createDate'] 8 | ]; 9 | 10 | parseValuesOnTableEachRow = obj => ({ 11 | id: obj.id, 12 | user: obj.user.nickname, 13 | email: obj.user.email, 14 | operatingSystem: obj.operatingSystem, 15 | browser: obj.browser, 16 | ipAddress: obj.ipAddress, 17 | brand: obj.brand ? obj.brand : '-', 18 | model: obj.model ? obj.model : '-', 19 | screenSize: obj.screenSize ? obj.screenSize : '-', 20 | createDate:formatDate(obj.createDate,true) 21 | }); 22 | 23 | [queryFormItemName, queryFormItemKey, queryFormItemType] = [ 24 | ['ID','用户','电子邮箱','操作系统','浏览器','IP地址','品牌','型号','屏幕尺寸'], 25 | ['id','user','email','operatingSystem','browser','ipAddress','brand','model','screenSize'], 26 | ['string','string','string','string','string','string','string','string','string'] 27 | ]; 28 | 29 | var vueContentObject = new Vue(initializeContentOptions()); 30 | -------------------------------------------------------------------------------- /src/main/resources/static/js/business/sensitive-word-biz.js: -------------------------------------------------------------------------------- 1 | if (vueContentObject) getVueObject().$destroy(); 2 | 3 | const [regulars, availables] = [['否','是'],['弃用','启用']]; 4 | 5 | [vuePageSize, loadPageableDataUrl, tableColumnsName, tableColumnsKey, tableButtonsOnEachRow] = [ 6 | 10, 7 | 'sensitiveWordsByPage', 8 | ['','ID','敏感词','替换词','是否正则表达式','可用状态','注册日期','最后修改日期','操作'], 9 | ['selection','id','word','replacement','regular','available','createDate','modifyDate','operation'], 10 | ['rowUpdateButton#修改','rowDeleteButton#删除'] 11 | ]; 12 | 13 | parseValuesOnTableEachRow = obj => ({ 14 | id: obj.id, 15 | word: obj.word, 16 | replacement: obj.replacement, 17 | regular: regulars[Number(obj.regular)], 18 | available: availables[Number(obj.available)], 19 | createDate:formatDate(obj.createDate,true), 20 | modifyDate:formatDate(obj.modifyDate,true) 21 | }); 22 | 23 | vueContentBeforeCreate = () => { 24 | [regularDataSelect, availableDataSelect, isOpen] = [ 25 | [{value: 'true', label: regulars[1]},{value: 'false', label: regulars[0]}], 26 | [{value: 'true', label: availables[1]},{value: 'false', label: availables[0]}], 27 | getOpenStatus() 28 | ]; 29 | }; 30 | 31 | setFormDataObject({id: -1, word: '', replacement: '', regular: false, available: true}); 32 | 33 | [queryFormItemName, queryFormItemKey, queryFormItemType] = [ 34 | ['ID','敏感词','替换词','是否正则表达式','可用状态'], 35 | ['id','word','replacement','regular','available'], 36 | ['string','string','string','select#regularDataSelect','select#availableDataSelect'] 37 | ]; 38 | 39 | setFormRulesObject({ 40 | 'word': [{trigger: 'blur',type: 'string', required: true}], 41 | 'replacement': [{trigger: 'blur',type: 'string', required: true}] 42 | }); 43 | 44 | vueContentObject = new Vue(initializeContentOptions()); 45 | 46 | function getOpenStatus() { 47 | let isOpen = false; 48 | $.igety('getOpen', (data) => isOpen = data.open); 49 | return isOpen; 50 | } 51 | 52 | function turnFilter(status) { 53 | $.iposty('open', {isOpen: status}); 54 | } 55 | -------------------------------------------------------------------------------- /src/main/resources/static/js/system/global-ajax-exception-handler.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | //.ajaxError事件定位到document对象,文档内所有元素发生ajax请求异常 3 | //都将冒泡到document对象的ajaxError事件执行处理 4 | $(document).ajaxError( 5 | function(event, xhr, options, exc) { 6 | if (xhr.status == 'undefined') { 7 | return; 8 | } 9 | let duration = 5; 10 | let error = ''; 11 | switch (xhr.status) { 12 | case 403: 13 | error = '系统拒绝:您没有访问权限。'; 14 | break; 15 | case 404: 16 | error = '您访问的资源不存在。'; 17 | break; 18 | case 500: 19 | error = '系统内部错误,请联系管理员。'; 20 | break; 21 | default: 22 | error = '未知系统错误,请联系管理员。'; 23 | } 24 | toastError(error,duration); 25 | }); 26 | }); -------------------------------------------------------------------------------- /src/main/resources/static/js/utils/common-utils.js: -------------------------------------------------------------------------------- 1 | //项目根路径 2 | var projectRootPath = window.document.location.pathname.substring(0,window.document.location.pathname.substr(1).indexOf('/')+1); 3 | //当前请求映射根路径 4 | var currentRequestMappingRootPath; 5 | 6 | const nullAsNumber = -999999999; 7 | 8 | /** 9 | * 初始化当前请求映射根路径,在点击菜单加载子页面时使用 10 | * @param currentRequestPath 当前请求路径,例如: user/usersByPage 11 | */ 12 | function initCurrentRequestMappingRootPath(currentRequestPath){ 13 | currentRequestMappingRootPath = (!currentRequestPath) ? null : currentRequestPath.split('/')[0]; 14 | } 15 | 16 | var arrayContains = function (array, value) { 17 | for (i in array) { 18 | if (array[i] == value) return true; 19 | } 20 | return false; 21 | } -------------------------------------------------------------------------------- /src/main/resources/static/js/utils/hotkey-utils.js: -------------------------------------------------------------------------------- 1 | function hotkey(keys,fn) { 2 | hotkeys(keys, function(event,handler){if(fn) fn();event.preventDefault()}); 3 | } 4 | 5 | (function() { 6 | var k = function(action){ 7 | var eventObj = document.createEvent("Events"); 8 | eventObj.initEvent("keydown", true, true); 9 | eventObj.keyCode = 75; 10 | eventObj.which = 75; 11 | document.body.dispatchEvent(eventObj); 12 | }; 13 | 14 | var killSpaceBar = function(evt) { 15 | 16 | var target = evt.target || {}, 17 | isInput = ("INPUT" == target.tagName || "TEXTAREA" == target.tagName || "SELECT" == target.tagName || "EMBED" == target.tagName); 18 | 19 | // if we're an input or not a real target exit 20 | if(isInput || !target.tagName) return; 21 | 22 | // if we're a fake input like the comments exit 23 | if(target && target.getAttribute && target.getAttribute('role') === 'textbox') return; 24 | 25 | // ignore the space and send a 'k' to pause 26 | if (evt.keyCode === 32) { 27 | evt.preventDefault(); 28 | k(); 29 | } 30 | }; 31 | 32 | document.addEventListener("keydown", killSpaceBar, false); 33 | })(); 34 | 35 | $(document).ready(function(){ 36 | //伸出与收缩queryForm 37 | hotkey('alt+q', function() {getVueRefObject('vueQueryFormVisible').value = String(parseInt(getVueRefObject('vueQueryFormVisible').value) * -1)}); 38 | //弹出与关闭addForm 39 | hotkey('alt+a', function() {if(!vueContentObject.vueAddModalVisible) vueContentObject.doAddButton(); else vueContentObject.defaultVueBindModalAddData = false}); 40 | //弹出addForm后,进行自动提交表单 41 | hotkey('alt+s', function() {if(vueContentObject.vueAddModalVisible) vueContentObject.submitAddForm()}); 42 | //弹出addForm后,进行表单重置 43 | hotkey('alt+r', function() {if(vueContentObject.vueAddModalVisible) resetVueFormData('vueAddForm')}); 44 | //回归页面顶部 45 | hotkey('alt+b', function() {$('.ivu-back-top').click()}); 46 | //数据表格上一页 47 | hotkey('alt+n', function() {$('.ivu-page-prev').click()}); 48 | //数据表格下一页 49 | hotkey('alt+m', function() {$('.ivu-page-next').click()}); 50 | //数据表格第一页 51 | hotkey('alt+,', function() {vueContentObject.vueCurrentPage = 1;vueContentObject.doPageTurning(1)}); 52 | //数据表格最后一页 53 | hotkey('alt+.', function() {var pageFinal = Math.ceil(vueContentObject.vueRecordTotal / vueContentObject.vuePageSize);vueContentObject.vueCurrentPage = pageFinal;vueContentObject.doPageTurning(pageFinal)}); 54 | }); 55 | -------------------------------------------------------------------------------- /src/main/resources/templates/action_monitor/admin_action_monitor_list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 |
9 |
10 |
11 | 12 |
13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 |
13 |
14 | 15 |
16 | 17 | 18 | 19 | 20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/main/resources/templates/development/admin_development_main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 数据库表名     17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 提交 36 | 重置 37 | 38 | 39 | 40 |
41 | 42 | 43 | 44 |
45 |
46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/main/resources/templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ERROR PAGE 5 | 6 | 7 |

8 |
9 |
    10 |
  • 11 |
    12 | 13 | 14 | 15 | 16 |
    17 |
  • 18 |
  • 19 | 20 |
  • 21 |
  • 22 | 23 |
  • 24 |
25 |
26 |
    27 |
  • 28 | 29 | Please access index page or try the current operation later... 30 | 31 |
  • 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragment/admin_breadcrumb.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 |  首页 8 | 9 | 10 |  {{item.content}} 11 | 12 | 13 |
14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragment/admin_content.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | TOP 8 | 9 |
10 | 11 |
12 | 13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | 24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | 35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | 46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | 57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | 68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | 79 | BOTTOM 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragment/admin_content_delete_modal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

6 | 7 | 删除确认 8 |

9 |
10 |

{{vueDeleteMessage}}

11 |
12 |
13 | 删除 14 | 取消 15 |
16 |
17 | 18 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragment/admin_content_query_form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |   综合查询

7 |
8 | 9 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragment/admin_content_scripts.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragment/admin_content_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
10 | 11 |
12 |
13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragment/admin_footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
2017-2018 © Thymeleaf
5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragment/admin_header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |
9 | 10 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragment/header.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 |
7 |
8 | Justin 9 | 10 |
11 | 后台管理 12 |
13 | 退出 14 |
15 | 16 |
17 | 18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Triall 7 | 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /src/main/resources/templates/login.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Triall 登录 7 | 8 | 9 |
10 |
11 |
12 | 自动登录

13 |
14 | 15 | 16 |
17 | 18 |
19 | 没有任何提示信息... 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/resources/templates/login/admin_login_list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 |
9 |
10 |
11 | 12 |
13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/templates/system_log/admin_system_log_list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | // $(document).ready(function() { 23 | // var url = projectPath + '/systemLog'; 24 | // var websocket = new SockJS(url, undefined, {transports: []}); 25 | // websocket.onopen = function() {console.log('日志系统连接开启...')}; 26 | // websocket.onmessage = function(e) { 27 | // // 接收服务端的实时日志并添加到HTML页面中 28 | // $('#log_container').append('' + event.data.toLocaleString() + '
'); 29 | // }; 30 | // websocket.onclose = function() {console.log('日志系统连接终止!')}; 31 | // websocket.onheartbeat = function() {console.log('日志系统保持连接...')}; 32 | // }); 33 | 34 | 35 | 36 | 37 | --------------------------------------------------------------------------------