├── mybatis-flex.config ├── app └── src │ ├── main │ ├── resources │ │ ├── i18n │ │ │ ├── messages.properties │ │ │ └── messages_zh_CN.properties │ │ ├── banner.txt │ │ └── mybatis │ │ │ └── mybatis-config.xml │ └── java │ │ └── com │ │ └── wangboot │ │ └── app │ │ ├── analysis │ │ ├── exception │ │ │ └── MoonShotRequestException.java │ │ ├── model │ │ │ ├── ChatMessage.java │ │ │ ├── ErrorResponseBody.java │ │ │ ├── ChatCompletionsRequestBody.java │ │ │ ├── FileContentResponseBody.java │ │ │ ├── FileUploadResponseBody.java │ │ │ └── ChatCompletionsResponseBody.java │ │ ├── config │ │ │ ├── AnalysisProperties.java │ │ │ └── AnalysisAutoConfiguration.java │ │ └── AnalysisManager.java │ │ ├── template │ │ ├── mapper │ │ │ ├── TplTemplateMapper.java │ │ │ ├── TplDatasourceMapper.java │ │ │ ├── TplDatasourceParamMapper.java │ │ │ ├── TplExecutionResultMapper.java │ │ │ └── TplRenderExecutionMapper.java │ │ ├── service │ │ │ ├── TplTemplateService.java │ │ │ ├── TplDatasourceParamService.java │ │ │ ├── TplExecutionResultService.java │ │ │ ├── TplRenderExecutionService.java │ │ │ ├── impl │ │ │ │ ├── TplDatasourceParamServiceImpl.java │ │ │ │ ├── TplExecutionResultServiceImpl.java │ │ │ │ ├── TplRenderExecutionServiceImpl.java │ │ │ │ └── TplTemplateServiceImpl.java │ │ │ └── TplDatasourceService.java │ │ └── entity │ │ │ ├── dto │ │ │ ├── TplRenderExecutionDto.java │ │ │ ├── TplDatasourceParamListDto.java │ │ │ └── TplDatasourceDto.java │ │ │ ├── ExecutionStatus.java │ │ │ ├── TplDatasourceParam.java │ │ │ ├── TplDatasource.java │ │ │ ├── TplRenderExecution.java │ │ │ ├── TplExecutionResult.java │ │ │ └── TplTemplate.java │ │ ├── execution │ │ ├── datasource │ │ │ ├── DatasourceParamHolder.java │ │ │ ├── IDatasourceFactory.java │ │ │ ├── dbsql │ │ │ │ ├── DatabaseSqlConfig.java │ │ │ │ └── DatabaseSqlFactory.java │ │ │ └── IDatasource.java │ │ ├── render │ │ │ ├── RenderContext.java │ │ │ ├── BaseTemplateRender.java │ │ │ ├── ITemplateRender.java │ │ │ ├── word │ │ │ │ └── PoiWordTemplateRender.java │ │ │ ├── TemplateRenderFactory.java │ │ │ └── text │ │ │ │ └── FreeMarkerTemplateRender.java │ │ ├── RenderExecutionEvent.java │ │ ├── RenderErrorCode.java │ │ └── RenderExecutionConfig.java │ │ ├── ServletInitializer.java │ │ ├── commands │ │ └── PrepareDatasource.java │ │ └── Application.java │ └── test │ ├── resources │ ├── text.tpl │ └── word.docx │ └── java │ └── com │ └── wangboot │ └── app │ ├── AITest.java │ └── TemplateTest.java ├── images ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── report.png └── template.png ├── lombok.config ├── run_server.sh ├── .editorconfig ├── system ├── src │ └── main │ │ └── java │ │ └── com │ │ └── wangboot │ │ └── system │ │ ├── mapper │ │ ├── SysBgTaskMapper.java │ │ ├── SysUserLogMapper.java │ │ ├── SysUserViewMapper.java │ │ ├── SysAttachmentMapper.java │ │ ├── SysAnnouncementMapper.java │ │ ├── SysOperationLogMapper.java │ │ ├── SysUserRoleRelMapper.java │ │ ├── SysPolicyMenuRelMapper.java │ │ ├── SysRolePolicyRelMapper.java │ │ ├── SysJobMapper.java │ │ ├── SysPolicyDataScopeRelMapper.java │ │ ├── SysMenuMapper.java │ │ ├── SysPolicyPermissionRelMapper.java │ │ ├── SysRoleMapper.java │ │ ├── SysUserMapper.java │ │ ├── SysParamMapper.java │ │ ├── SysPolicyMapper.java │ │ ├── SysFrontendMapper.java │ │ ├── SysUserDictMapper.java │ │ ├── SysDataScopeMapper.java │ │ ├── SysDepartmentMapper.java │ │ └── SysPermissionMapper.java │ │ ├── service │ │ ├── SysUserLogService.java │ │ ├── SysUserViewService.java │ │ ├── SysOperationLogService.java │ │ ├── SysUserRoleRelService.java │ │ ├── SysPolicyMenuRelService.java │ │ ├── SysRolePolicyRelService.java │ │ ├── SysJobService.java │ │ ├── SysMenuService.java │ │ ├── SysPolicyDataScopeRelService.java │ │ ├── SysPolicyPermissionRelService.java │ │ ├── SysDataScopeService.java │ │ ├── SysDepartmentService.java │ │ ├── SysPermissionService.java │ │ ├── SysParamService.java │ │ ├── SysFrontendService.java │ │ ├── SysUserDictService.java │ │ ├── impl │ │ │ ├── SysUserLogServiceImpl.java │ │ │ ├── SysJobServiceImpl.java │ │ │ ├── SysOperationLogServiceImpl.java │ │ │ ├── SysUserRoleRelServiceImpl.java │ │ │ ├── SysPolicyMenuRelServiceImpl.java │ │ │ ├── SysRolePolicyRelServiceImpl.java │ │ │ ├── SysPolicyDataScopeRelServiceImpl.java │ │ │ ├── SysPolicyPermissionRelServiceImpl.java │ │ │ ├── SysUserViewServiceImpl.java │ │ │ ├── SysDepartmentServiceImpl.java │ │ │ ├── SysParamServiceImpl.java │ │ │ ├── SysUserDictServiceImpl.java │ │ │ ├── SysMenuServiceImpl.java │ │ │ ├── SysAnnouncementServiceImpl.java │ │ │ ├── SysFrontendServiceImpl.java │ │ │ └── SysPermissionServiceImpl.java │ │ ├── SysBgTaskService.java │ │ ├── SysAnnouncementService.java │ │ ├── SysRoleService.java │ │ ├── SysUserService.java │ │ ├── AuthService.java │ │ └── SysPolicyService.java │ │ ├── entity │ │ ├── vo │ │ │ ├── SysUserSearchVo.java │ │ │ ├── FrontendVo.java │ │ │ ├── AttachmentVo.java │ │ │ └── SysUserView.java │ │ ├── dto │ │ │ ├── SysJobExcel.java │ │ │ └── SysUserExcel.java │ │ ├── SysOperationLog.java │ │ ├── SysUserLog.java │ │ ├── SysJob.java │ │ ├── relation │ │ │ ├── SysUserRoleRel.java │ │ │ ├── SysPolicyMenuRel.java │ │ │ ├── SysRolePolicyRel.java │ │ │ ├── SysPolicyDataScopeRel.java │ │ │ └── SysPolicyPermissionRel.java │ │ ├── SysDepartment.java │ │ ├── SysAttachment.java │ │ ├── SysDataScope.java │ │ ├── SysMenu.java │ │ ├── SysRole.java │ │ ├── SysPermission.java │ │ ├── SysBgTask.java │ │ ├── SysParam.java │ │ ├── SysUserDict.java │ │ ├── SysAnnouncement.java │ │ └── SysFrontend.java │ │ ├── model │ │ ├── TokenResponseBody.java │ │ ├── ChangePasswordBody.java │ │ ├── RegisterBody.java │ │ ├── AnnouncementType.java │ │ ├── BgTaskStatus.java │ │ ├── ParamType.java │ │ └── ClientType.java │ │ ├── event │ │ ├── BgTaskEvent.java │ │ ├── BgTaskResult.java │ │ └── BgTaskObject.java │ │ ├── command │ │ ├── BaseInitDatabaseCommand.java │ │ └── CreateUser.java │ │ ├── listener │ │ └── EntityChangeListener.java │ │ ├── controller │ │ ├── SysBgTaskController.java │ │ ├── SysMenuController.java │ │ ├── SysDataScopeController.java │ │ ├── SysFrontendController.java │ │ ├── SysPermissionController.java │ │ ├── SysAnnouncementController.java │ │ ├── SysParamController.java │ │ ├── SysOperationLogController.java │ │ ├── SysUserDictController.java │ │ ├── SysDepartmentController.java │ │ └── SysUserLogController.java │ │ └── attachment │ │ ├── ContentTypes.java │ │ └── EasyBytesExporter.java └── pom.xml ├── task ├── src │ └── main │ │ └── java │ │ └── com │ │ └── wangboot │ │ └── task │ │ ├── mapper │ │ ├── TaskQuickLinkMapper.java │ │ └── TaskInsideMessageMapper.java │ │ ├── service │ │ ├── TaskQuickLinkService.java │ │ ├── impl │ │ │ └── TaskQuickLinkServiceImpl.java │ │ └── TaskInsideMessageService.java │ │ ├── entity │ │ ├── vo │ │ │ └── TaskInsideMessageWithUser.java │ │ ├── TaskInsideMessage.java │ │ └── TaskQuickLink.java │ │ └── controller │ │ └── TaskQuickLinkController.java └── pom.xml ├── Dockerfile ├── framework ├── src │ └── main │ │ └── java │ │ └── com │ │ └── wangboot │ │ └── framework │ │ ├── config │ │ ├── MyBatisFlexConfiguration.java │ │ ├── properties │ │ │ └── CorsProperties.java │ │ └── AsyncConfig.java │ │ ├── validator │ │ ├── IdCardValidator.java │ │ ├── IdCard.java │ │ ├── Telephone.java │ │ └── TelephoneValidator.java │ │ ├── ParamConstants.java │ │ └── command │ │ ├── GenerateRSAPair.java │ │ ├── GenerateSM2Pair.java │ │ └── IBaseCommand.java └── pom.xml ├── .gitignore └── report └── pom.xml /mybatis-flex.config: -------------------------------------------------------------------------------- 1 | processor.enable=true -------------------------------------------------------------------------------- /app/src/main/resources/i18n/messages.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/src/test/resources/text.tpl: -------------------------------------------------------------------------------- 1 | hello ${data.title} 2 | haha -------------------------------------------------------------------------------- /images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52jing/wang-template-backend/HEAD/images/1.png -------------------------------------------------------------------------------- /images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52jing/wang-template-backend/HEAD/images/2.png -------------------------------------------------------------------------------- /images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52jing/wang-template-backend/HEAD/images/3.png -------------------------------------------------------------------------------- /images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52jing/wang-template-backend/HEAD/images/4.png -------------------------------------------------------------------------------- /images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52jing/wang-template-backend/HEAD/images/5.png -------------------------------------------------------------------------------- /images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52jing/wang-template-backend/HEAD/images/6.png -------------------------------------------------------------------------------- /images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52jing/wang-template-backend/HEAD/images/7.png -------------------------------------------------------------------------------- /lombok.config: -------------------------------------------------------------------------------- 1 | config.stopbubbling = true 2 | lombok.addLombokGeneratedAnnotation = true -------------------------------------------------------------------------------- /images/report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52jing/wang-template-backend/HEAD/images/report.png -------------------------------------------------------------------------------- /images/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52jing/wang-template-backend/HEAD/images/template.png -------------------------------------------------------------------------------- /run_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | java -jar app.jar --spring.profiles.active=$PROFILE $* 4 | -------------------------------------------------------------------------------- /app/src/test/resources/word.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52jing/wang-template-backend/HEAD/app/src/test/resources/word.docx -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = false 9 | max_line_length = 120 10 | tab_width = 2 11 | 12 | [*.xml] 13 | indent_size = 4 14 | tab_width = 4 15 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysBgTaskMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysBgTask; 5 | 6 | public interface SysBgTaskMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysUserLogMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysUserLog; 5 | 6 | public interface SysUserLogMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysUserViewMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.vo.SysUserView; 5 | 6 | public interface SysUserViewMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /task/src/main/java/com/wangboot/task/mapper/TaskQuickLinkMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.task.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.task.entity.TaskQuickLink; 5 | 6 | public interface TaskQuickLinkMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysAttachmentMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysAttachment; 5 | 6 | public interface SysAttachmentMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/analysis/exception/MoonShotRequestException.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.analysis.exception; 2 | 3 | public class MoonShotRequestException extends RuntimeException { 4 | 5 | public MoonShotRequestException(String message) { 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/mapper/TplTemplateMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.app.template.entity.TplTemplate; 5 | 6 | public interface TplTemplateMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysAnnouncementMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysAnnouncement; 5 | 6 | public interface SysAnnouncementMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysOperationLogMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysOperationLog; 5 | 6 | public interface SysOperationLogMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /task/src/main/java/com/wangboot/task/mapper/TaskInsideMessageMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.task.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.task.entity.TaskInsideMessage; 5 | 6 | public interface TaskInsideMessageMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/mapper/TplDatasourceMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.app.template.entity.TplDatasource; 5 | 6 | public interface TplDatasourceMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysUserRoleRelMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.relation.SysUserRoleRel; 5 | 6 | public interface SysUserRoleRelMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysPolicyMenuRelMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.relation.SysPolicyMenuRel; 5 | 6 | public interface SysPolicyMenuRelMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysRolePolicyRelMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.relation.SysRolePolicyRel; 5 | 6 | public interface SysRolePolicyRelMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysUserLogService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.SysUserLog; 5 | 6 | public interface SysUserLogService extends IFlexRestfulService {} 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/analysis/model/ChatMessage.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.analysis.model; 2 | 3 | import lombok.*; 4 | 5 | @Data 6 | @ToString 7 | @AllArgsConstructor 8 | @NoArgsConstructor 9 | public class ChatMessage { 10 | private String role; 11 | private String content; 12 | } 13 | -------------------------------------------------------------------------------- /task/src/main/java/com/wangboot/task/service/TaskQuickLinkService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.task.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.task.entity.TaskQuickLink; 5 | 6 | public interface TaskQuickLinkService extends IFlexRestfulService {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysUserViewService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.vo.SysUserView; 5 | 6 | public interface SysUserViewService extends IFlexRestfulService {} 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/mapper/TplDatasourceParamMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.app.template.entity.TplDatasourceParam; 5 | 6 | public interface TplDatasourceParamMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/mapper/TplExecutionResultMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.app.template.entity.TplExecutionResult; 5 | 6 | public interface TplExecutionResultMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/mapper/TplRenderExecutionMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.app.template.entity.TplRenderExecution; 5 | 6 | public interface TplRenderExecutionMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysJobMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysJob; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysJobMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysPolicyDataScopeRelMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.relation.SysPolicyDataScopeRel; 5 | 6 | public interface SysPolicyDataScopeRelMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysOperationLogService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.SysOperationLog; 5 | 6 | public interface SysOperationLogService extends IFlexRestfulService {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysMenuMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysMenu; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysMenuMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysPolicyPermissionRelMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.relation.SysPolicyPermissionRel; 5 | 6 | public interface SysPolicyPermissionRelMapper extends BaseMapper {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysRole; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysRoleMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysUser; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysUserMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysUserRoleRelService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.relation.SysUserRoleRel; 5 | 6 | public interface SysUserRoleRelService extends IFlexRestfulService {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysParamMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysParam; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysParamMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | 3 | LABEL author=wwtg99 4 | ENV PROFILE=prod 5 | RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && useradd app && chown -R app /opt 6 | USER app 7 | WORKDIR /opt 8 | COPY run_server.sh /opt/ 9 | COPY app/target/app.jar /opt/app.jar 10 | VOLUME ["/opt/config"] 11 | ENTRYPOINT ["sh", "run_server.sh"] 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysPolicyMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysPolicy; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysPolicyMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysPolicyMenuRelService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.relation.SysPolicyMenuRel; 5 | 6 | public interface SysPolicyMenuRelService extends IFlexRestfulService {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysRolePolicyRelService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.relation.SysRolePolicyRel; 5 | 6 | public interface SysRolePolicyRelService extends IFlexRestfulService {} 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/service/TplTemplateService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.service; 2 | 3 | import com.wangboot.app.template.entity.TplTemplate; 4 | import com.wangboot.system.attachment.IAttachmentRelatedService; 5 | 6 | public interface TplTemplateService extends IAttachmentRelatedService {} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysFrontendMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysFrontend; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysFrontendMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysUserDictMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysUserDict; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysUserDictMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/vo/SysUserSearchVo.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 用户搜索结果模型 7 | * 8 | * @author wwtg99 9 | */ 10 | @Data 11 | public class SysUserSearchVo { 12 | private String id; 13 | private String username; 14 | private String nickname; 15 | } 16 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysDataScopeMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysDataScope; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysDataScopeMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /app/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | _ _ 2 | __ ____ _ _ __ __ _| |__ ___ ___ | |_ 3 | \ \ /\ / / _` | '_ \ / _` | '_ \ / _ \ / _ \| __| 4 | \ V V / (_| | | | | (_| | |_) | (_) | (_) | |_ 5 | \_/\_/ \__,_|_| |_|\__, |_.__/ \___/ \___/ \__| 6 | |___/ on Spring Boot ${spring-boot.version} 7 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysDepartmentMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysDepartment; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysDepartmentMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/mapper/SysPermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.mapper; 2 | 3 | import com.mybatisflex.core.BaseMapper; 4 | import com.wangboot.system.entity.SysPermission; 5 | 6 | /** 7 | * 映射层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysPermissionMapper extends BaseMapper {} 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/service/TplDatasourceParamService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.service; 2 | 3 | import com.wangboot.app.template.entity.TplDatasourceParam; 4 | import com.wangboot.model.flex.IFlexRestfulService; 5 | 6 | public interface TplDatasourceParamService 7 | extends IFlexRestfulService {} 8 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysJobService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.SysJob; 5 | 6 | /** 7 | * 服务层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysJobService extends IFlexRestfulService {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysMenuService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.SysMenu; 5 | 6 | /** 7 | * 服务层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysMenuService extends IFlexRestfulService {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysPolicyDataScopeRelService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.relation.SysPolicyDataScopeRel; 5 | 6 | public interface SysPolicyDataScopeRelService 7 | extends IFlexRestfulService {} 8 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysPolicyPermissionRelService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.relation.SysPolicyPermissionRel; 5 | 6 | public interface SysPolicyPermissionRelService 7 | extends IFlexRestfulService {} 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/service/TplExecutionResultService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.service; 2 | 3 | import com.wangboot.app.template.entity.TplExecutionResult; 4 | import com.wangboot.system.attachment.IAttachmentRelatedService; 5 | 6 | public interface TplExecutionResultService 7 | extends IAttachmentRelatedService {} 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/analysis/model/ErrorResponseBody.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.analysis.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | @Data 7 | @ToString 8 | public class ErrorResponseBody { 9 | 10 | private Error error; 11 | 12 | static class Error { 13 | private String message; 14 | private String type; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysDataScopeService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.SysDataScope; 5 | 6 | /** 7 | * 服务层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysDataScopeService extends IFlexRestfulService {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysDepartmentService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.SysDepartment; 5 | 6 | /** 7 | * 服务层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysDepartmentService extends IFlexRestfulService {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysPermissionService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.SysPermission; 5 | 6 | /** 7 | * 服务层。 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface SysPermissionService extends IFlexRestfulService {} 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/analysis/model/ChatCompletionsRequestBody.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.analysis.model; 2 | 3 | import java.util.List; 4 | import lombok.*; 5 | 6 | @Data 7 | @ToString 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ChatCompletionsRequestBody { 11 | private String model; 12 | private List messages; 13 | private double temperature; 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/analysis/model/FileContentResponseBody.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.analysis.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | @Data 7 | @ToString 8 | public class FileContentResponseBody { 9 | 10 | private String content; 11 | private String fileType; 12 | private String filename; 13 | private String title; 14 | private String type; 15 | } 16 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/model/TokenResponseBody.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.model; 2 | 3 | import com.wangboot.core.web.response.IStatusBody; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | public class TokenResponseBody implements IStatusBody { 10 | private String accessToken; 11 | private String refreshToken; 12 | private int status; 13 | } 14 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysParamService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.core.web.param.IParamConfig; 4 | import com.wangboot.model.flex.IFlexRestfulService; 5 | import com.wangboot.system.entity.SysParam; 6 | 7 | /** 8 | * 服务层。 9 | * 10 | * @author wwtg99 11 | */ 12 | public interface SysParamService extends IFlexRestfulService, IParamConfig {} 13 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/event/BgTaskEvent.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.event; 2 | 3 | import com.wangboot.core.event.RequestEvent; 4 | import javax.servlet.http.HttpServletRequest; 5 | import org.springframework.lang.Nullable; 6 | 7 | public class BgTaskEvent extends RequestEvent { 8 | 9 | public BgTaskEvent(BgTaskObject taskObject, @Nullable HttpServletRequest request) { 10 | super(taskObject, request); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/event/BgTaskResult.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.event; 2 | 3 | import com.wangboot.system.model.BgTaskStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class BgTaskResult { 12 | private String attachmentId; 13 | private String result; 14 | private BgTaskStatus status; 15 | } 16 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysFrontendService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.core.auth.frontend.IFrontendService; 4 | import com.wangboot.model.flex.IFlexRestfulService; 5 | import com.wangboot.system.entity.SysFrontend; 6 | 7 | /** 8 | * 服务层。 9 | * 10 | * @author wwtg99 11 | */ 12 | public interface SysFrontendService 13 | extends IFlexRestfulService, IFrontendService {} 14 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysUserDictService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.SysUserDict; 5 | import java.util.List; 6 | 7 | /** 8 | * 服务层。 9 | * 10 | * @author wwtg99 11 | */ 12 | public interface SysUserDictService extends IFlexRestfulService { 13 | 14 | List getByGroup(String group, String code); 15 | } 16 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/dto/SysJobExcel.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.dto; 2 | 3 | import com.alibaba.excel.annotation.ExcelProperty; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class SysJobExcel { 8 | 9 | @ExcelProperty("ID") 10 | private String id; 11 | 12 | @ExcelProperty("名称") 13 | private String name; 14 | 15 | @ExcelProperty("类型") 16 | private String type; 17 | 18 | @ExcelProperty("备注") 19 | private String remark; 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/analysis/model/FileUploadResponseBody.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.analysis.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | @Data 7 | @ToString 8 | public class FileUploadResponseBody { 9 | private String id; 10 | private String object; 11 | private long bytes; 12 | private long createdAt; 13 | private String filename; 14 | private String purpose; 15 | private String status; 16 | private String status_details; 17 | } 18 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/model/ChangePasswordBody.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.model; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class ChangePasswordBody { 12 | private String oldPwd = ""; 13 | 14 | @NotBlank(message = "message.pwd_not_blank") 15 | private String newPwd = ""; 16 | } 17 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/vo/FrontendVo.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import lombok.ToString; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @ToString 12 | public class FrontendVo { 13 | private String id; 14 | private String title; 15 | private String description; 16 | private String author; 17 | private String domain; 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/datasource/DatasourceParamHolder.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.datasource; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * 数据源参数持有者 9 | * 10 | * @author wwtg99 11 | */ 12 | @NoArgsConstructor 13 | public class DatasourceParamHolder extends HashMap { 14 | 15 | public DatasourceParamHolder(Map params) { 16 | this.putAll(params); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/datasource/IDatasourceFactory.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.datasource; 2 | 3 | import org.springframework.lang.Nullable; 4 | 5 | /** 6 | * 数据源工厂接口 7 | * 8 | * @author wwtg99 9 | */ 10 | public interface IDatasourceFactory { 11 | 12 | /** 13 | * 连接数据源 14 | * 15 | * @param id 数据源ID 16 | * @param name 数据源名称 17 | * @param config 数据源配置 18 | * @return 数据源 19 | */ 20 | @Nullable 21 | IDatasource connectDatasource(String id, String name, String config); 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/entity/dto/TplRenderExecutionDto.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.entity.dto; 2 | 3 | import java.util.Map; 4 | import javax.validation.constraints.NotBlank; 5 | import javax.validation.constraints.NotNull; 6 | import lombok.Data; 7 | 8 | @Data 9 | public class TplRenderExecutionDto { 10 | 11 | @NotBlank private String datasourceId; 12 | 13 | @NotBlank private String templateId; 14 | 15 | private String filename = ""; 16 | 17 | @NotNull private Map params; 18 | } 19 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysUserLogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.system.entity.SysUserLog; 5 | import com.wangboot.system.mapper.SysUserLogMapper; 6 | import com.wangboot.system.service.SysUserLogService; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class SysUserLogServiceImpl extends ServiceImpl 11 | implements SysUserLogService {} 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/entity/dto/TplDatasourceParamListDto.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.entity.dto; 2 | 3 | import com.wangboot.app.template.entity.TplDatasourceParam; 4 | import java.util.List; 5 | import javax.validation.constraints.NotNull; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class TplDatasourceParamListDto { 14 | 15 | @NotNull private List params; 16 | } 17 | -------------------------------------------------------------------------------- /task/src/main/java/com/wangboot/task/service/impl/TaskQuickLinkServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.task.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.task.entity.TaskQuickLink; 5 | import com.wangboot.task.mapper.TaskQuickLinkMapper; 6 | import com.wangboot.task.service.TaskQuickLinkService; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class TaskQuickLinkServiceImpl extends ServiceImpl 11 | implements TaskQuickLinkService {} 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/ServletInitializer.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app; 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder; 4 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 5 | 6 | /** 7 | * web容器中进行部署 8 | * 9 | * @author wwtg99 10 | */ 11 | public class ServletInitializer extends SpringBootServletInitializer { 12 | @Override 13 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 14 | return application.sources(Application.class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysJobServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.system.entity.SysJob; 5 | import com.wangboot.system.mapper.SysJobMapper; 6 | import com.wangboot.system.service.SysJobService; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * 服务层实现。 11 | * 12 | * @author wwtg99 13 | */ 14 | @Service 15 | public class SysJobServiceImpl extends ServiceImpl implements SysJobService {} 16 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysOperationLogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.system.entity.SysOperationLog; 5 | import com.wangboot.system.mapper.SysOperationLogMapper; 6 | import com.wangboot.system.service.SysOperationLogService; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class SysOperationLogServiceImpl extends ServiceImpl 11 | implements SysOperationLogService {} 12 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysUserRoleRelServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.system.entity.relation.SysUserRoleRel; 5 | import com.wangboot.system.mapper.SysUserRoleRelMapper; 6 | import com.wangboot.system.service.SysUserRoleRelService; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class SysUserRoleRelServiceImpl extends ServiceImpl 11 | implements SysUserRoleRelService {} 12 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/config/MyBatisFlexConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework.config; 2 | 3 | import com.mybatisflex.core.FlexGlobalConfig; 4 | import com.mybatisflex.spring.boot.MyBatisFlexCustomizer; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * MyBatisFlex 配置 9 | * 10 | * @author wuwentao 11 | */ 12 | @Configuration 13 | public class MyBatisFlexConfiguration implements MyBatisFlexCustomizer { 14 | @Override 15 | public void customize(FlexGlobalConfig flexGlobalConfig) { 16 | // TODO 添加自定义配置 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysBgTaskService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.core.web.task.IBackgroundService; 4 | import com.wangboot.model.flex.IFlexRestfulService; 5 | import com.wangboot.system.attachment.IAttachmentRelatedService; 6 | import com.wangboot.system.entity.SysBgTask; 7 | import com.wangboot.system.event.BgTaskResult; 8 | 9 | public interface SysBgTaskService 10 | extends IFlexRestfulService, 11 | IAttachmentRelatedService, 12 | IBackgroundService {} 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/service/TplRenderExecutionService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.service; 2 | 3 | import com.wangboot.app.template.entity.TplExecutionResult; 4 | import com.wangboot.app.template.entity.TplRenderExecution; 5 | import com.wangboot.model.flex.IFlexRestfulService; 6 | import java.util.List; 7 | 8 | public interface TplRenderExecutionService extends IFlexRestfulService { 9 | 10 | /** 11 | * 获取执行结果 12 | * 13 | * @param id 执行ID 14 | * @return 结果列表 15 | */ 16 | List getResults(String id); 17 | } 18 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysPolicyMenuRelServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.system.entity.relation.SysPolicyMenuRel; 5 | import com.wangboot.system.mapper.SysPolicyMenuRelMapper; 6 | import com.wangboot.system.service.SysPolicyMenuRelService; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class SysPolicyMenuRelServiceImpl 11 | extends ServiceImpl 12 | implements SysPolicyMenuRelService {} 13 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysRolePolicyRelServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.system.entity.relation.SysRolePolicyRel; 5 | import com.wangboot.system.mapper.SysRolePolicyRelMapper; 6 | import com.wangboot.system.service.SysRolePolicyRelService; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class SysRolePolicyRelServiceImpl 11 | extends ServiceImpl 12 | implements SysRolePolicyRelService {} 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/datasource/dbsql/DatabaseSqlConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.datasource.dbsql; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * 数据库SQL数据源配置类 10 | * 11 | * @author wwtg99 12 | */ 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @Builder 17 | public class DatabaseSqlConfig { 18 | 19 | private String url; 20 | private String username; 21 | private String password; 22 | private String sql; 23 | private Boolean expandOnOne; 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/render/RenderContext.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.render; 2 | 3 | import com.wangboot.app.execution.datasource.DatasourceParamHolder; 4 | import java.util.Map; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class RenderContext { 13 | 14 | private String templateName; 15 | 16 | private String datasourceName; 17 | 18 | private DatasourceParamHolder params; 19 | 20 | private Map envs; 21 | 22 | private Object data; 23 | } 24 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/event/BgTaskObject.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.event; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.wangboot.core.web.task.IBackgroundTask; 5 | import java.util.function.Supplier; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class BgTaskObject implements IBackgroundTask { 14 | private String id; 15 | private String name; 16 | private String group; 17 | @JsonIgnore private Supplier resultSupplier; 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/service/impl/TplDatasourceParamServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.app.template.entity.TplDatasourceParam; 5 | import com.wangboot.app.template.mapper.TplDatasourceParamMapper; 6 | import com.wangboot.app.template.service.TplDatasourceParamService; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class TplDatasourceParamServiceImpl 11 | extends ServiceImpl 12 | implements TplDatasourceParamService {} 13 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysPolicyDataScopeRelServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.system.entity.relation.SysPolicyDataScopeRel; 5 | import com.wangboot.system.mapper.SysPolicyDataScopeRelMapper; 6 | import com.wangboot.system.service.SysPolicyDataScopeRelService; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class SysPolicyDataScopeRelServiceImpl 11 | extends ServiceImpl 12 | implements SysPolicyDataScopeRelService {} 13 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysAnnouncementService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.attachment.IAttachmentRelatedService; 5 | import com.wangboot.system.entity.SysAnnouncement; 6 | import java.util.List; 7 | import org.springframework.lang.NonNull; 8 | 9 | public interface SysAnnouncementService 10 | extends IFlexRestfulService, 11 | IAttachmentRelatedService { 12 | 13 | /** 获取展示的公告 */ 14 | @NonNull 15 | List getDisplayedAnnouncements(String type); 16 | } 17 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysPolicyPermissionRelServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.system.entity.relation.SysPolicyPermissionRel; 5 | import com.wangboot.system.mapper.SysPolicyPermissionRelMapper; 6 | import com.wangboot.system.service.SysPolicyPermissionRelService; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class SysPolicyPermissionRelServiceImpl 11 | extends ServiceImpl 12 | implements SysPolicyPermissionRelService {} 13 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/validator/IdCardValidator.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework.validator; 2 | 3 | import cn.hutool.core.util.IdcardUtil; 4 | import javax.validation.ConstraintValidator; 5 | import javax.validation.ConstraintValidatorContext; 6 | import org.springframework.util.StringUtils; 7 | 8 | /** 9 | * 身份证验证类 10 | * 11 | * @author wuwentao 12 | */ 13 | public class IdCardValidator implements ConstraintValidator { 14 | @Override 15 | public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) { 16 | return !StringUtils.hasText(s) || IdcardUtil.isValidCard(s); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### STS ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | 15 | ### IntelliJ IDEA ### 16 | .idea 17 | *.iws 18 | *.iml 19 | *.ipr 20 | 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | build/ 28 | !**/src/main/**/build/ 29 | !**/src/test/**/build/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | 34 | ### Configure ### 35 | application-*.yml 36 | application-*.properties 37 | 38 | ### Logs ### 39 | logs/ 40 | *.log 41 | 42 | ### Others ### 43 | .DS_Store 44 | tmp/ 45 | data/ 46 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/vo/AttachmentVo.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.vo; 2 | 3 | import com.wangboot.model.attachment.IAttachmentModel; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * 附件对外视图对象 10 | * 11 | * @author wwtg99 12 | */ 13 | @Data 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class AttachmentVo implements IAttachmentModel { 17 | private String id; 18 | private String url; 19 | private long size; 20 | private String originalFilename; 21 | private String contentType; 22 | private String thUrl; 23 | private long thSize; 24 | private String thContentType; 25 | private String hashInfo; 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/analysis/config/AnalysisProperties.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.analysis.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.boot.context.properties.NestedConfigurationProperty; 6 | 7 | @Data 8 | @ConfigurationProperties(prefix = AnalysisProperties.PREFIX, ignoreInvalidFields = true) 9 | public class AnalysisProperties { 10 | public static final String PREFIX = "analysis"; 11 | 12 | @NestedConfigurationProperty private MoonShot moonShot; 13 | private boolean indicatorAnalysis = false; 14 | 15 | @Data 16 | static class MoonShot { 17 | private String baseUrl; 18 | private String accessToken; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/validator/IdCard.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework.validator; 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 | import javax.validation.Constraint; 8 | import javax.validation.Payload; 9 | 10 | /** 11 | * 身份证验证注解 12 | * 13 | * @author wuwentao 14 | */ 15 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE}) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Constraint(validatedBy = IdCardValidator.class) 18 | public @interface IdCard { 19 | String message() default "message.invalid_idcard_format"; 20 | 21 | Class[] groups() default {}; 22 | 23 | Class[] payload() default {}; 24 | } 25 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysUserViewServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.system.entity.vo.SysUserView; 5 | import com.wangboot.system.mapper.SysUserViewMapper; 6 | import com.wangboot.system.service.SysUserViewService; 7 | import org.springframework.lang.NonNull; 8 | import org.springframework.lang.Nullable; 9 | import org.springframework.stereotype.Service; 10 | 11 | @Service 12 | public class SysUserViewServiceImpl extends ServiceImpl 13 | implements SysUserViewService { 14 | 15 | @Override 16 | @Nullable 17 | public SysUserView getDataById(@NonNull String id) { 18 | return this.getMapper().selectOneWithRelationsById(id); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /task/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | wang-template-backend 7 | wang.52jing 8 | ${revision} 9 | 10 | 4.0.0 11 | 12 | task 13 | 14 | 15 | 16 | wang.52jing 17 | system 18 | ${project.parent.version} 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/RenderExecutionEvent.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution; 2 | 3 | import com.wangboot.app.execution.datasource.DatasourceParamHolder; 4 | import com.wangboot.app.template.entity.TplRenderExecution; 5 | import lombok.Getter; 6 | import org.springframework.context.ApplicationEvent; 7 | 8 | /** 9 | * 渲染执行事件 10 | * 11 | * @author wwtg99 12 | */ 13 | public class RenderExecutionEvent extends ApplicationEvent { 14 | 15 | @Getter private final DatasourceParamHolder params; 16 | 17 | public RenderExecutionEvent(TplRenderExecution renderExecution, DatasourceParamHolder params) { 18 | super(renderExecution); 19 | this.params = params; 20 | } 21 | 22 | public TplRenderExecution getRenderExecution() { 23 | return (TplRenderExecution) this.getSource(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/validator/Telephone.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework.validator; 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 | import javax.validation.Constraint; 8 | import javax.validation.Payload; 9 | 10 | /** 11 | * 手机号码验证注解 12 | * 13 | * @author wuwentao 14 | */ 15 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE}) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Constraint(validatedBy = TelephoneValidator.class) 18 | public @interface Telephone { 19 | String message() default "message.invalid_telephone_format"; 20 | 21 | Class[] groups() default {}; 22 | 23 | Class[] payload() default {}; 24 | } 25 | -------------------------------------------------------------------------------- /task/src/main/java/com/wangboot/task/entity/vo/TaskInsideMessageWithUser.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.task.entity.vo; 2 | 3 | import com.mybatisflex.annotation.RelationManyToOne; 4 | import com.wangboot.task.entity.TaskInsideMessage; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | @Data 9 | @EqualsAndHashCode(callSuper = true) 10 | public class TaskInsideMessageWithUser extends TaskInsideMessage { 11 | 12 | @RelationManyToOne( 13 | selfField = "fromUserId", 14 | targetTable = "wb_sys_user", 15 | targetField = "id", 16 | valueField = "username") 17 | private String fromUser; 18 | 19 | @RelationManyToOne( 20 | selfField = "toUserId", 21 | targetTable = "wb_sys_user", 22 | targetField = "id", 23 | valueField = "username") 24 | private String toUser; 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/analysis/model/ChatCompletionsResponseBody.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.analysis.model; 2 | 3 | import java.util.List; 4 | import lombok.Data; 5 | import lombok.ToString; 6 | 7 | @Data 8 | @ToString 9 | public class ChatCompletionsResponseBody { 10 | private String id; 11 | private String object; 12 | private long created; 13 | private String model; 14 | private List choices; 15 | private Usage usage; 16 | 17 | @Data 18 | @ToString 19 | public static class Choice { 20 | private long index; 21 | private ChatMessage message; 22 | private String finishReason; 23 | } 24 | 25 | @Data 26 | @ToString 27 | public static class Usage { 28 | private long promptTokens; 29 | private long completionTokens; 30 | private long totalTokens; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/model/RegisterBody.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.model; 2 | 3 | import com.wangboot.framework.validator.Telephone; 4 | import javax.validation.constraints.Email; 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.Size; 7 | import lombok.Data; 8 | 9 | @Data 10 | public class RegisterBody { 11 | 12 | private String frontendId; 13 | 14 | @NotBlank(message = "message.username_not_blank") 15 | @Size(max = 100) 16 | private String username; 17 | 18 | @Size(min = 3, max = 100) 19 | private String nickname; 20 | 21 | @NotBlank(message = "message.pwd_not_blank") 22 | private String password; 23 | 24 | @Email(message = "message.invalid_email") 25 | @Size(max = 100) 26 | private String email; 27 | 28 | @Telephone 29 | @Size(max = 20) 30 | private String tel; 31 | } 32 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/validator/TelephoneValidator.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework.validator; 2 | 3 | import java.util.regex.Pattern; 4 | import javax.validation.ConstraintValidator; 5 | import javax.validation.ConstraintValidatorContext; 6 | import org.springframework.util.StringUtils; 7 | 8 | /** 9 | * 手机号码验证类 10 | * 11 | * @author wuwentao 12 | */ 13 | public class TelephoneValidator implements ConstraintValidator { 14 | 15 | public static final String TEL_PATTERN = "^1[3-9]\\d{9}$"; 16 | 17 | private Pattern pattern; 18 | 19 | @Override 20 | public void initialize(Telephone constraintAnnotation) { 21 | this.pattern = Pattern.compile(TEL_PATTERN); 22 | } 23 | 24 | @Override 25 | public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) { 26 | return !StringUtils.hasText(s) || this.pattern.matcher(s).matches(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/config/properties/CorsProperties.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework.config.properties; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | 6 | /** 7 | * CORS 配置属性 8 | * 9 | * @author wwtg99 10 | */ 11 | @Data 12 | @ConfigurationProperties(prefix = CorsProperties.PREFIX, ignoreInvalidFields = true) 13 | public class CorsProperties { 14 | public static final String PREFIX = "cors"; 15 | 16 | /** 是否启用 */ 17 | private boolean enabled = false; 18 | 19 | /** 允许的方法 */ 20 | private String[] methods; 21 | 22 | /** 允许的来源 */ 23 | private String[] origins; 24 | 25 | /** 允许的请求头 */ 26 | private String[] headers; 27 | 28 | /** 暴露的请求头 */ 29 | private String[] exposeHeaders; 30 | 31 | /** 是否允许 Credentials */ 32 | private boolean allowCredentials = false; 33 | 34 | /** 缓存时间 */ 35 | private long maxAge = 86400L; 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/render/BaseTemplateRender.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.render; 2 | 3 | import com.wangboot.app.execution.RenderErrorCode; 4 | import com.wangboot.core.errorcode.ErrorCodeException; 5 | import java.util.Objects; 6 | import lombok.Getter; 7 | import org.springframework.util.StringUtils; 8 | 9 | /** 10 | * 模板渲染器抽象基类 11 | * 12 | * @author wwtg99 13 | */ 14 | public abstract class BaseTemplateRender implements ITemplateRender { 15 | 16 | @Getter private String templateName; 17 | 18 | @Getter private byte[] templateBytes; 19 | 20 | @Override 21 | public ITemplateRender setTemplate(String name, byte[] bytes) { 22 | if (!StringUtils.hasText(name) || Objects.isNull(bytes) || bytes.length == 0) { 23 | throw new ErrorCodeException(RenderErrorCode.INVALID_TEMPLATE); 24 | } 25 | this.templateName = name; 26 | this.templateBytes = bytes; 27 | return this; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysOperationLog.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.mybatisflex.annotation.Id; 4 | import com.mybatisflex.annotation.KeyType; 5 | import com.mybatisflex.annotation.Table; 6 | import com.mybatisflex.core.keygen.KeyGenerators; 7 | import com.wangboot.model.entity.IdEntity; 8 | import com.wangboot.model.entity.impl.AppendOnlyEntity; 9 | import lombok.*; 10 | 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | @Builder 16 | @Table(value = "wb_sys_operation_log") 17 | public class SysOperationLog extends AppendOnlyEntity implements IdEntity { 18 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 19 | private String id; 20 | 21 | private String event; 22 | 23 | private String resource; 24 | 25 | private String resourceId; 26 | 27 | private String obj; 28 | 29 | private String username; 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/datasource/IDatasource.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.datasource; 2 | 3 | import cn.hutool.core.bean.BeanUtil; 4 | import org.springframework.lang.Nullable; 5 | 6 | /** 7 | * 数据源接口 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface IDatasource { 12 | 13 | /** 14 | * 数据源名称 15 | * 16 | * @return 名称 17 | */ 18 | String getName(); 19 | 20 | /** 21 | * 获取数据 22 | * 23 | * @param params 参数 24 | * @return 数据 25 | */ 26 | @Nullable 27 | Object retrieveData(DatasourceParamHolder params); 28 | 29 | /** 30 | * 获取数据 31 | * 32 | * @param params 参数 33 | * @param dataClass 数据类 34 | * @param 数据类型 35 | * @return 数据 36 | */ 37 | @Nullable 38 | default T retrieveData(DatasourceParamHolder params, Class dataClass) { 39 | return BeanUtil.toBean(retrieveData(params), dataClass); 40 | } 41 | 42 | /** 关闭数据源 */ 43 | void close(); 44 | } 45 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/ParamConstants.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework; 2 | 3 | public class ParamConstants { 4 | 5 | public static final String INIT_DATABASE_KEY = "init_database"; 6 | 7 | public static final String PASSWORD_MIN_LENGTH_KEY = "password_min_length"; 8 | 9 | public static final String PASSWORD_REQUIRE_NUMBER_KEY = "password_require_number"; 10 | 11 | public static final String PASSWORD_REQUIRE_UPPER_KEY = "password_require_upper"; 12 | 13 | public static final String PASSWORD_REQUIRE_LOWER_KEY = "password_require_lower"; 14 | 15 | public static final String PASSWORD_REQUIRE_SYMBOL_KEY = "password_require_symbol"; 16 | 17 | public static final String LOGIN_FAILED_THRESHOLD_KEY = "login_failed_threshold"; 18 | 19 | public static final String LOGIN_FAILED_COUNT_SECONDS_KEY = "login_failed_count_seconds"; 20 | 21 | public static final String LOGIN_FAILED_LOCK_SECONDS_KEY = "login_failed_lock_seconds"; 22 | } 23 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysRoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.SysPolicy; 5 | import com.wangboot.system.entity.SysRole; 6 | import java.util.Collection; 7 | import java.util.List; 8 | import org.springframework.lang.NonNull; 9 | import org.springframework.lang.Nullable; 10 | 11 | /** 12 | * 服务层。 13 | * 14 | * @author wwtg99 15 | */ 16 | public interface SysRoleService extends IFlexRestfulService { 17 | 18 | /** 获取策略 */ 19 | @NonNull 20 | List getRolePolicies(@Nullable Collection ids); 21 | 22 | /** 添加角色策略 */ 23 | boolean addRolePolicies(String id, @Nullable List entities); 24 | 25 | /** 设置角色策略 */ 26 | boolean setRolePolicies(String id, @Nullable List entities); 27 | 28 | /** 移除角色策略 */ 29 | boolean removeRolePolicies(String id, @Nullable List entityIds); 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/resources/mybatis/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /task/src/main/java/com/wangboot/task/service/TaskInsideMessageService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.task.service; 2 | 3 | import com.mybatisflex.core.paginate.Page; 4 | import com.wangboot.model.flex.IFlexRestfulService; 5 | import com.wangboot.task.entity.TaskInsideMessage; 6 | import com.wangboot.task.entity.vo.TaskInsideMessageWithUser; 7 | import org.springframework.lang.NonNull; 8 | import org.springframework.lang.Nullable; 9 | 10 | public interface TaskInsideMessageService extends IFlexRestfulService { 11 | 12 | @NonNull 13 | Page getUserSentMessages(String userId, long page, long pageSize); 14 | 15 | @NonNull 16 | Page getUserReceivedMessages( 17 | boolean unread, String userId, long page, long pageSize); 18 | 19 | boolean sendMessage(@Nullable TaskInsideMessage message, String sendUserId); 20 | 21 | boolean readMessage(String id, String userId); 22 | 23 | boolean markAllRead(String userId); 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/render/ITemplateRender.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.render; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | /** 7 | * 模板渲染器接口 8 | * 9 | * @author wwtg99 10 | */ 11 | public interface ITemplateRender { 12 | 13 | /** 14 | * 设置模板 15 | * 16 | * @param name 模板名称 17 | * @param bytes 模板字节数组 18 | * @return 模板渲染器 19 | */ 20 | ITemplateRender setTemplate(String name, byte[] bytes); 21 | 22 | /** 23 | * 获取模板名称 24 | * 25 | * @return 模板名称 26 | */ 27 | String getTemplateName(); 28 | 29 | /** 30 | * 获取模板内容 31 | * 32 | * @return 字节数组 33 | */ 34 | byte[] getTemplateBytes(); 35 | 36 | /** 37 | * 获取文档类型 38 | * 39 | * @return 文档类型 40 | */ 41 | String getContentType(); 42 | 43 | /** 44 | * 渲染并输出 45 | * 46 | * @param context 上下文 47 | * @param outputStream 输出流 48 | * @throws IOException IO异常 49 | */ 50 | void renderAndOutput(RenderContext context, OutputStream outputStream) throws IOException; 51 | } 52 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysUserLog.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.mybatisflex.annotation.Id; 4 | import com.mybatisflex.annotation.KeyType; 5 | import com.mybatisflex.annotation.Table; 6 | import com.mybatisflex.core.keygen.KeyGenerators; 7 | import com.wangboot.core.auth.event.LogStatus; 8 | import com.wangboot.model.entity.IdEntity; 9 | import com.wangboot.model.entity.impl.AppendOnlyEntity; 10 | import lombok.*; 11 | 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | @Builder 17 | @Table(value = "wb_sys_user_log") 18 | public class SysUserLog extends AppendOnlyEntity implements IdEntity { 19 | 20 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 21 | private String id; 22 | 23 | private String event; 24 | 25 | private LogStatus status; 26 | 27 | private String message; 28 | 29 | private String userId; 30 | 31 | private String username; 32 | 33 | private String frontendId; 34 | 35 | private String frontendName; 36 | 37 | private String ip; 38 | 39 | private String ua; 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/entity/dto/TplDatasourceDto.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.entity.dto; 2 | 3 | import java.util.List; 4 | import javax.validation.constraints.NotBlank; 5 | import javax.validation.constraints.Size; 6 | import lombok.Data; 7 | 8 | @Data 9 | public class TplDatasourceDto { 10 | 11 | private String id; 12 | 13 | @NotBlank(message = "message.name_not_blank") 14 | @Size(max = 100) 15 | private String name; 16 | 17 | @NotBlank(message = "message.type_not_blank") 18 | @Size(max = 100) 19 | private String type; 20 | 21 | private String config = ""; 22 | private String remark = ""; 23 | private List params; 24 | 25 | @Data 26 | public static class TplDatasourceParamDto { 27 | private String id; 28 | 29 | @NotBlank(message = "message.name_not_blank") 30 | @Size(max = 100) 31 | private String name; 32 | 33 | @Size(max = 100) 34 | private String label; 35 | 36 | private Boolean required = false; 37 | 38 | @Size(max = 500) 39 | private String defVal = ""; 40 | 41 | private String config = ""; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/vo/SysUserView.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.vo; 2 | 3 | import com.mybatisflex.annotation.Column; 4 | import com.mybatisflex.annotation.RelationManyToMany; 5 | import com.mybatisflex.annotation.Table; 6 | import com.wangboot.system.entity.SysRole; 7 | import com.wangboot.system.entity.SysUser; 8 | import java.util.List; 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.EqualsAndHashCode; 12 | import lombok.NoArgsConstructor; 13 | 14 | @Data 15 | @EqualsAndHashCode(callSuper = true) 16 | @NoArgsConstructor 17 | @AllArgsConstructor 18 | @Table(value = "wb_sys_user_view") 19 | public class SysUserView extends SysUser { 20 | 21 | private String sexVal; 22 | 23 | private String department; 24 | 25 | private String job; 26 | 27 | @Column(ignore = true) 28 | private String password; 29 | 30 | @RelationManyToMany( 31 | joinTable = "wb_sys_user_role_rel", 32 | joinSelfColumn = "user_id", 33 | joinTargetColumn = "role_id") 34 | private List roles; 35 | 36 | @Column(ignore = true) 37 | private List authorities; 38 | } 39 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysDepartmentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.model.entity.exception.DeleteCascadeFailedException; 5 | import com.wangboot.system.entity.SysDepartment; 6 | import com.wangboot.system.mapper.SysDepartmentMapper; 7 | import com.wangboot.system.service.SysDepartmentService; 8 | import org.springframework.lang.NonNull; 9 | import org.springframework.stereotype.Service; 10 | 11 | /** 12 | * 服务层实现。 13 | * 14 | * @author wwtg99 15 | */ 16 | @Service 17 | public class SysDepartmentServiceImpl extends ServiceImpl 18 | implements SysDepartmentService { 19 | 20 | @Override 21 | @NonNull 22 | public SysDepartment checkBeforeDeleteObject(@NonNull SysDepartment entity) { 23 | entity = SysDepartmentService.super.checkBeforeDeleteObject(entity); 24 | // 存在子节点则不允许删除 25 | if (this.getDirectChildrenCount(entity.getId()) > 0) { 26 | throw new DeleteCascadeFailedException(entity.getId()); 27 | } 28 | return entity; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /system/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | wang-template-backend 7 | wang.52jing 8 | ${revision} 9 | 10 | 4.0.0 11 | 12 | system 13 | 14 | 15 | 16 | org.dromara.x-file-storage 17 | x-file-storage-spring 18 | 19 | 20 | com.alibaba 21 | easyexcel 22 | 23 | 24 | wang.52jing 25 | framework 26 | ${project.parent.version} 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/service/impl/TplExecutionResultServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.app.template.entity.TplExecutionResult; 5 | import com.wangboot.app.template.mapper.TplExecutionResultMapper; 6 | import com.wangboot.app.template.service.TplExecutionResultService; 7 | import com.wangboot.model.attachment.IAttachmentService; 8 | import com.wangboot.system.service.SysAttachmentService; 9 | import lombok.RequiredArgsConstructor; 10 | import org.springframework.lang.NonNull; 11 | import org.springframework.stereotype.Service; 12 | 13 | @Service 14 | @RequiredArgsConstructor 15 | public class TplExecutionResultServiceImpl 16 | extends ServiceImpl 17 | implements TplExecutionResultService { 18 | 19 | private final SysAttachmentService attachmentService; 20 | 21 | @Override 22 | @NonNull 23 | public IAttachmentService getAttachmentService() { 24 | return this.attachmentService; 25 | } 26 | 27 | @Override 28 | public String getObjectType() { 29 | return this.getEntityClass().getName(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/model/AnnouncementType.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.mybatisflex.annotation.EnumValue; 5 | import com.wangboot.core.utils.ISystemDict; 6 | import lombok.Getter; 7 | import org.springframework.lang.Nullable; 8 | 9 | /** 10 | * 公告类型 11 | * 12 | * @author wwtg99 13 | */ 14 | public enum AnnouncementType implements ISystemDict { 15 | IMPORTANT("IMPORTANT", "重要公告"), 16 | NOTIFICATION("NOTIFICATION", "弹窗公告"), 17 | NORMAL("NORMAL", "普通公告"); 18 | 19 | @Getter @EnumValue private final String code; 20 | 21 | @Getter private final String name; 22 | 23 | AnnouncementType(String code, String name) { 24 | this.code = code; 25 | this.name = name; 26 | } 27 | 28 | @Nullable 29 | @JsonCreator 30 | public static AnnouncementType resolve(String code) { 31 | for (AnnouncementType type : AnnouncementType.values()) { 32 | if (type.getCode().equals(code) || type.getName().equals(code)) { 33 | return type; 34 | } 35 | } 36 | return null; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return this.name; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/analysis/config/AnalysisAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.analysis.config; 2 | 3 | import com.wangboot.app.analysis.MoonShotClient; 4 | import lombok.RequiredArgsConstructor; 5 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.util.StringUtils; 9 | 10 | @Configuration 11 | @EnableConfigurationProperties({AnalysisProperties.class}) 12 | @RequiredArgsConstructor 13 | public class AnalysisAutoConfiguration { 14 | 15 | private final AnalysisProperties analysisProperties; 16 | 17 | @Bean 18 | public MoonShotClient moonShotClient() { 19 | String baseUrl = 20 | StringUtils.hasText(analysisProperties.getMoonShot().getBaseUrl()) 21 | ? analysisProperties.getMoonShot().getBaseUrl() 22 | : MoonShotClient.MOONSHOT_BASE; 23 | String accessToken = analysisProperties.getMoonShot().getAccessToken(); 24 | if (StringUtils.hasText(accessToken)) { 25 | return new MoonShotClient(baseUrl, accessToken, null); 26 | } 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/model/BgTaskStatus.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.mybatisflex.annotation.EnumValue; 5 | import com.wangboot.core.utils.ISystemDict; 6 | import lombok.Getter; 7 | import org.springframework.lang.Nullable; 8 | 9 | /** 10 | * 后台任务状态 11 | * 12 | * @author wwtg99 13 | */ 14 | public enum BgTaskStatus implements ISystemDict { 15 | PENDING("PENDING", "运行中"), 16 | COMPLETED("COMPLETED", "已完成"), 17 | FAILED("FAILED", "已失败"), 18 | CANCELED("CANCELED", "已取消"); 19 | 20 | @Getter @EnumValue private final String code; 21 | 22 | @Getter private final String name; 23 | 24 | BgTaskStatus(String code, String name) { 25 | this.code = code; 26 | this.name = name; 27 | } 28 | 29 | @Nullable 30 | @JsonCreator 31 | public static BgTaskStatus resolve(String code) { 32 | for (BgTaskStatus status : BgTaskStatus.values()) { 33 | if (status.getCode().equals(code) || status.getName().equals(code)) { 34 | return status; 35 | } 36 | } 37 | return null; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return this.name; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/entity/ExecutionStatus.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.mybatisflex.annotation.EnumValue; 5 | import com.wangboot.core.utils.ISystemDict; 6 | import lombok.Getter; 7 | import org.springframework.lang.Nullable; 8 | 9 | public enum ExecutionStatus implements ISystemDict { 10 | WAITING("1", "等待中"), 11 | PENDING("2", "处理中"), 12 | COMPLETED("3", "已完成"), 13 | FAILED("4", "已失败"), 14 | CANCELED("5", "已取消"); 15 | 16 | @Getter @EnumValue private final String code; 17 | 18 | @Getter private final String name; 19 | 20 | ExecutionStatus(String code, String name) { 21 | this.code = code; 22 | this.name = name; 23 | } 24 | 25 | @Nullable 26 | @JsonCreator 27 | public static ExecutionStatus resolve(String code) { 28 | for (ExecutionStatus executionStatus : ExecutionStatus.values()) { 29 | if (executionStatus.getCode().equals(code) || executionStatus.getName().equals(code)) { 30 | return executionStatus; 31 | } 32 | } 33 | return null; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return this.name; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/command/BaseInitDatabaseCommand.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.command; 2 | 3 | import com.wangboot.core.web.param.IParamConfig; 4 | import com.wangboot.framework.command.IBaseCommand; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.boot.ApplicationArguments; 7 | 8 | @Slf4j 9 | public abstract class BaseInitDatabaseCommand implements IBaseCommand { 10 | 11 | @Override 12 | public void callCommand(ApplicationArguments args) { 13 | log.info("启动{}模块数据初始化...", this.getModuleName()); 14 | this.init(); 15 | this.setInitialized(); 16 | log.info("模块{}数据初始化完成", this.getModuleName()); 17 | } 18 | 19 | @Override 20 | public boolean whetherToRun(ApplicationArguments args) { 21 | return !args.containsOption("without-init-data") && this.notInitialized(); 22 | } 23 | 24 | public abstract IParamConfig getParamConfig(); 25 | 26 | public abstract String getModuleName(); 27 | 28 | /** 执行初始化 */ 29 | protected abstract void init(); 30 | 31 | /** 32 | * 是否未初始化 33 | * 34 | * @return boolean 35 | */ 36 | protected abstract boolean notInitialized(); 37 | 38 | /** 设置已初始化 */ 39 | protected abstract void setInitialized(); 40 | } 41 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysParamServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.system.entity.SysParam; 5 | import com.wangboot.system.entity.table.SysParamTableDef; 6 | import com.wangboot.system.mapper.SysParamMapper; 7 | import com.wangboot.system.service.SysParamService; 8 | import java.util.Optional; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.util.StringUtils; 11 | 12 | /** 13 | * 服务层实现。 14 | * 15 | * @author wwtg99 16 | */ 17 | @Service 18 | public class SysParamServiceImpl extends ServiceImpl 19 | implements SysParamService { 20 | 21 | @Override 22 | public void setParamConfig(String key, String value) { 23 | this.updateChain() 24 | .where(SysParamTableDef.SYS_PARAM.PARAM_KEY.eq(key)) 25 | .set(SysParamTableDef.SYS_PARAM.PARAM_VAL, value) 26 | .update(); 27 | } 28 | 29 | @Override 30 | public String getParamConfig(String key) { 31 | if (!StringUtils.hasText(key)) { 32 | return ""; 33 | } 34 | return Optional.ofNullable( 35 | this.getOne(query().where(SysParamTableDef.SYS_PARAM.PARAM_KEY.eq(key)))) 36 | .map(SysParam::getParamVal) 37 | .orElse(""); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/render/word/PoiWordTemplateRender.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.render.word; 2 | 3 | import com.deepoove.poi.XWPFTemplate; 4 | import com.deepoove.poi.config.Configure; 5 | import com.deepoove.poi.config.ConfigureBuilder; 6 | import com.wangboot.app.execution.render.BaseTemplateRender; 7 | import com.wangboot.app.execution.render.RenderContext; 8 | import java.io.ByteArrayInputStream; 9 | import java.io.IOException; 10 | import java.io.OutputStream; 11 | import lombok.extern.slf4j.Slf4j; 12 | 13 | @Slf4j 14 | public class PoiWordTemplateRender extends BaseTemplateRender { 15 | 16 | private static final String CONTENT_TYPE = 17 | "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; 18 | 19 | @Override 20 | public String getContentType() { 21 | return CONTENT_TYPE; 22 | } 23 | 24 | @Override 25 | public void renderAndOutput(RenderContext context, OutputStream outputStream) throws IOException { 26 | try (ByteArrayInputStream bai = new ByteArrayInputStream(this.getTemplateBytes())) { 27 | ConfigureBuilder builder = Configure.builder(); 28 | builder.buildGramer("${", "}"); 29 | XWPFTemplate xwpfTemplate = XWPFTemplate.compile(bai, builder.build()); 30 | xwpfTemplate.render(context).writeAndClose(outputStream); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysUserDictServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.core.query.QueryWrapper; 4 | import com.mybatisflex.spring.service.impl.ServiceImpl; 5 | import com.wangboot.system.entity.SysUserDict; 6 | import com.wangboot.system.entity.table.SysUserDictTableDef; 7 | import com.wangboot.system.mapper.SysUserDictMapper; 8 | import com.wangboot.system.service.SysUserDictService; 9 | import java.util.Collections; 10 | import java.util.List; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.util.StringUtils; 13 | 14 | /** 15 | * 服务层实现。 16 | * 17 | * @author wwtg99 18 | */ 19 | @Service 20 | public class SysUserDictServiceImpl extends ServiceImpl 21 | implements SysUserDictService { 22 | @Override 23 | public List getByGroup(String group, String code) { 24 | if (StringUtils.hasText(group)) { 25 | QueryWrapper wrapper = 26 | this.getListQueryWrapper().where(SysUserDictTableDef.SYS_USER_DICT.DICT_GROUP.eq(group)); 27 | if (StringUtils.hasText(code)) { 28 | wrapper.and(SysUserDictTableDef.SYS_USER_DICT.DICT_CODE.eq(code)); 29 | } 30 | return this.list(wrapper); 31 | } else { 32 | return Collections.emptyList(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/model/ParamType.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.mybatisflex.annotation.EnumValue; 5 | import com.wangboot.core.utils.ISystemDict; 6 | import lombok.Getter; 7 | import org.springframework.lang.Nullable; 8 | 9 | /** 10 | * 参数类型枚举 11 | * 12 | * @author wwtg99 13 | */ 14 | public enum ParamType implements ISystemDict { 15 | STR("str", "字符串"), 16 | INT("int", "整数"), 17 | FLOAT("float", "浮点数"), 18 | BOOL("bool", "布尔值"), 19 | STR_LIST("str_list", "字符串数组"), 20 | INT_LIST("int_list", "整数数组"), 21 | FLOAT_LIST("float_list", "浮点数数组"), 22 | BOOL_LIST("bool_list", "布尔值数组"); 23 | 24 | @Getter @EnumValue private final String code; 25 | @Getter private final String name; 26 | 27 | ParamType(String code, String name) { 28 | this.code = code; 29 | this.name = name; 30 | } 31 | 32 | @Nullable 33 | @JsonCreator 34 | public static ParamType resolve(String code) { 35 | for (ParamType paramType : ParamType.values()) { 36 | if (paramType.getCode().equalsIgnoreCase(code) 37 | || paramType.getName().equalsIgnoreCase(code)) { 38 | return paramType; 39 | } 40 | } 41 | return null; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return this.name; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/listener/EntityChangeListener.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.listener; 2 | 3 | import com.mybatisflex.annotation.InsertListener; 4 | import com.mybatisflex.annotation.UpdateListener; 5 | import com.wangboot.core.web.utils.AuthUtils; 6 | import com.wangboot.model.entity.IAppendOnlyEntity; 7 | import com.wangboot.model.entity.ICommonEntity; 8 | import java.time.OffsetDateTime; 9 | 10 | /** 11 | * 实体变更监听器 12 | * 13 | * @author wwtg99 14 | */ 15 | public class EntityChangeListener implements InsertListener, UpdateListener { 16 | @Override 17 | public void onInsert(Object o) { 18 | if (o instanceof ICommonEntity) { 19 | ((ICommonEntity) o).setCreatedBy(AuthUtils.getUserId()); 20 | ((ICommonEntity) o).setCreatedTime(OffsetDateTime.now()); 21 | ((ICommonEntity) o).setUpdatedBy(AuthUtils.getUserId()); 22 | ((ICommonEntity) o).setUpdatedTime(OffsetDateTime.now()); 23 | } else if (o instanceof IAppendOnlyEntity) { 24 | ((IAppendOnlyEntity) o).setCreatedBy(AuthUtils.getUserId()); 25 | ((IAppendOnlyEntity) o).setCreatedTime(OffsetDateTime.now()); 26 | } 27 | } 28 | 29 | @Override 30 | public void onUpdate(Object o) { 31 | if (o instanceof ICommonEntity) { 32 | ((ICommonEntity) o).setUpdatedBy(AuthUtils.getUserId()); 33 | ((ICommonEntity) o).setUpdatedTime(OffsetDateTime.now()); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysJob.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.mybatisflex.annotation.Id; 4 | import com.mybatisflex.annotation.KeyType; 5 | import com.mybatisflex.annotation.Table; 6 | import com.mybatisflex.core.keygen.KeyGenerators; 7 | import com.wangboot.model.entity.IdEntity; 8 | import com.wangboot.model.entity.event.EnableOperationLog; 9 | import com.wangboot.model.entity.impl.CommonEntity; 10 | import com.wangboot.system.listener.EntityChangeListener; 11 | import javax.validation.constraints.NotBlank; 12 | import javax.validation.constraints.Size; 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.EqualsAndHashCode; 16 | import lombok.NoArgsConstructor; 17 | 18 | /** 19 | * 实体类。 20 | * 21 | * @author wwtg99 22 | */ 23 | @Data 24 | @EqualsAndHashCode(callSuper = false) 25 | @NoArgsConstructor 26 | @AllArgsConstructor 27 | @EnableOperationLog 28 | @Table( 29 | value = "wb_sys_job", 30 | onInsert = EntityChangeListener.class, 31 | onUpdate = EntityChangeListener.class) 32 | public class SysJob extends CommonEntity implements IdEntity { 33 | 34 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 35 | private String id; 36 | 37 | @NotBlank(message = "message.name_not_blank") 38 | @Size(max = 90) 39 | private String name; 40 | 41 | @Size(max = 90) 42 | private String type = ""; 43 | } 44 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/dto/SysUserExcel.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.dto; 2 | 3 | import com.alibaba.excel.annotation.ExcelProperty; 4 | import java.time.OffsetDateTime; 5 | import lombok.Data; 6 | 7 | @Data 8 | public class SysUserExcel { 9 | 10 | @ExcelProperty("ID") 11 | private String id; 12 | 13 | @ExcelProperty("用户名") 14 | private String username; 15 | 16 | @ExcelProperty("昵称") 17 | private String nickname; 18 | 19 | @ExcelProperty("邮箱") 20 | private String email; 21 | 22 | @ExcelProperty("手机") 23 | private String tel; 24 | 25 | @ExcelProperty("是否激活") 26 | private Boolean active; 27 | 28 | @ExcelProperty("是否超级管理员") 29 | private Boolean superuser; 30 | 31 | @ExcelProperty("是否内部用户") 32 | private Boolean staff; 33 | 34 | @ExcelProperty("失效时间") 35 | private OffsetDateTime expiredTime; 36 | 37 | @ExcelProperty("性别") 38 | private String sexVal; 39 | 40 | @ExcelProperty("部门") 41 | private String department; 42 | 43 | @ExcelProperty("岗位") 44 | private String job; 45 | 46 | @ExcelProperty("省") 47 | private String province; 48 | 49 | @ExcelProperty("市") 50 | private String city; 51 | 52 | @ExcelProperty("区") 53 | private String area; 54 | 55 | @ExcelProperty("县") 56 | private String town; 57 | 58 | @ExcelProperty("详细地址") 59 | private String address; 60 | 61 | @ExcelProperty("备注") 62 | private String remark; 63 | } 64 | -------------------------------------------------------------------------------- /task/src/main/java/com/wangboot/task/entity/TaskInsideMessage.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.task.entity; 2 | 3 | import com.mybatisflex.annotation.Id; 4 | import com.mybatisflex.annotation.KeyType; 5 | import com.mybatisflex.annotation.Table; 6 | import com.mybatisflex.core.keygen.KeyGenerators; 7 | import com.wangboot.model.entity.IdEntity; 8 | import com.wangboot.model.entity.impl.AppendOnlyEntity; 9 | import com.wangboot.system.listener.EntityChangeListener; 10 | import java.time.OffsetDateTime; 11 | import javax.validation.constraints.Size; 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.EqualsAndHashCode; 15 | import lombok.NoArgsConstructor; 16 | 17 | @Data 18 | @EqualsAndHashCode(callSuper = true) 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | @Table( 22 | value = "wb_task_inside_message", 23 | onInsert = EntityChangeListener.class, 24 | onUpdate = EntityChangeListener.class) 25 | public class TaskInsideMessage extends AppendOnlyEntity implements IdEntity { 26 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 27 | private String id; 28 | 29 | @Size(max = 200) 30 | private String title = ""; 31 | 32 | private String content = ""; 33 | 34 | @Size(max = 100) 35 | private String type = ""; 36 | 37 | private String fromUserId; 38 | 39 | @Size(max = 64) 40 | private String toUserId; 41 | 42 | private OffsetDateTime readTime; 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/RenderErrorCode.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution; 2 | 3 | import com.wangboot.core.errorcode.IErrorCode; 4 | import lombok.Generated; 5 | import lombok.Getter; 6 | 7 | @Generated 8 | public enum RenderErrorCode implements IErrorCode { 9 | // 渲染错误 10 | INVALID_TEMPLATE(400, "440001", "error.invalid_template"), 11 | INVALID_DATASOURCE(400, "440001", "error.invalid_datasource"), 12 | INVALID_DATASOURCE_CONFIG(400, "440002", "error.invalid_datasource_config"), 13 | PARAM_IS_REQUIRED(400, "440003", "error.param_is_required"), 14 | RENDER_FAILED(400, "440004", "error.render_failed"), 15 | RETRIEVE_EMPTY_DATA(400, "440005", "error.retrieve_empty_data"), 16 | CONNECT_DATASOURCE_FAILED(400, "440006", "error.connect_datasource_failed"), 17 | ANALYSIS_NOT_ENABLED(500, "510003", "error.analysis_not_enabled"), 18 | ANALYSIS_FAILED(500, "510004", "error.analysis_failed"); 19 | 20 | /** Http Status Code */ 21 | @Getter private final int statusCode; 22 | 23 | /** Error Code */ 24 | @Getter private final String errCode; 25 | 26 | /** Error Message */ 27 | @Getter private final String errMsg; 28 | 29 | RenderErrorCode(int statusCode, String errCode, String errMsg) { 30 | this.statusCode = statusCode; 31 | this.errCode = errCode; 32 | this.errMsg = errMsg; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return this.errCode + " " + this.errMsg; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/command/GenerateRSAPair.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework.command; 2 | 3 | import cn.hutool.crypto.SecureUtil; 4 | import com.wangboot.core.utils.StrUtils; 5 | import java.security.KeyPair; 6 | import java.util.Base64; 7 | import org.springframework.boot.ApplicationArguments; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * 生成 RSA 密钥对
12 | * 使用参数 --generate-rsa 13 | * 14 | * @author wwtg99 15 | */ 16 | @Component 17 | public class GenerateRSAPair implements IBaseCommand { 18 | 19 | private static final int LINE_WIDTH = 80; 20 | 21 | @Override 22 | public void callCommand(ApplicationArguments args) { 23 | KeyPair pair = SecureUtil.generateKeyPair("RSA"); 24 | String privateKeyStr = Base64.getEncoder().encodeToString(pair.getPrivate().getEncoded()); 25 | this.println("=== Private Key: ==="); 26 | StrUtils.splitStrByLineWidth(privateKeyStr, LINE_WIDTH).forEach(this::println); 27 | String publicKeyStr = Base64.getEncoder().encodeToString(pair.getPublic().getEncoded()); 28 | this.println("=== Public Key: ==="); 29 | StrUtils.splitStrByLineWidth(publicKeyStr, LINE_WIDTH).forEach(this::println); 30 | } 31 | 32 | @Override 33 | public boolean whetherToRun(ApplicationArguments args) { 34 | return args.containsOption("generate-rsa"); 35 | } 36 | 37 | @Override 38 | public boolean exitAfterCompletion() { 39 | return true; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysUserService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.core.auth.authorization.IAuthorizerService; 4 | import com.wangboot.core.auth.user.IUserService; 5 | import com.wangboot.model.flex.IFlexRestfulService; 6 | import com.wangboot.system.entity.*; 7 | import java.io.Serializable; 8 | import java.util.Collection; 9 | import java.util.List; 10 | import org.springframework.lang.NonNull; 11 | import org.springframework.lang.Nullable; 12 | 13 | /** 14 | * 服务层。 15 | * 16 | * @author wwtg99 17 | */ 18 | public interface SysUserService 19 | extends IUserService, IAuthorizerService, IFlexRestfulService { 20 | 21 | boolean updateProfile(@Nullable SysUser user); 22 | 23 | /** 获取用户角色 */ 24 | @NonNull 25 | List getUserRoles(@Nullable Collection ids); 26 | 27 | /** 添加用户角色 */ 28 | boolean addUserRoles(String id, @Nullable List entities); 29 | 30 | /** 设置用户角色 */ 31 | boolean setUserRoles(String id, @Nullable List entities); 32 | 33 | /** 移除用户角色 */ 34 | boolean removeUserRoles(String id, @Nullable List entityIds); 35 | 36 | @NonNull 37 | List getUserPolicies(String id); 38 | 39 | @NonNull 40 | List getUserPermissions(String id); 41 | 42 | @NonNull 43 | List getUserDataScopes(String id); 44 | 45 | @NonNull 46 | List getUserMenus(String id); 47 | } 48 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/relation/SysUserRoleRel.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.relation; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.model.entity.IUniqueEntity; 9 | import com.wangboot.model.entity.IdEntity; 10 | import com.wangboot.system.entity.relation.table.SysUserRoleRelTableDef; 11 | import javax.validation.constraints.NotBlank; 12 | import lombok.*; 13 | 14 | /** 15 | * 实体类。 16 | * 17 | * @author wwtg99 18 | */ 19 | @Data 20 | @EqualsAndHashCode 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @Builder 24 | @Table(value = "wb_sys_user_role_rel") 25 | public class SysUserRoleRel implements IdEntity, IUniqueEntity { 26 | 27 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 28 | private String id; 29 | 30 | @NotBlank(message = "message.relation_not_empty") 31 | private String userId; 32 | 33 | @NotBlank(message = "message.relation_not_empty") 34 | private String roleId; 35 | 36 | @Override 37 | @JsonIgnore 38 | public String[][] getUniqueTogetherFields() { 39 | return new String[][] { 40 | { 41 | SysUserRoleRelTableDef.SYS_USER_ROLE_REL.USER_ID.getName(), 42 | SysUserRoleRelTableDef.SYS_USER_ROLE_REL.ROLE_ID.getName() 43 | } 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/entity/TplDatasourceParam.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.entity; 2 | 3 | import com.mybatisflex.annotation.Id; 4 | import com.mybatisflex.annotation.KeyType; 5 | import com.mybatisflex.annotation.Table; 6 | import com.mybatisflex.core.keygen.KeyGenerators; 7 | import com.wangboot.model.entity.IdEntity; 8 | import com.wangboot.model.entity.impl.CommonEntity; 9 | import com.wangboot.system.listener.EntityChangeListener; 10 | import javax.validation.constraints.NotBlank; 11 | import javax.validation.constraints.Size; 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.EqualsAndHashCode; 15 | import lombok.NoArgsConstructor; 16 | 17 | @Data 18 | @EqualsAndHashCode(callSuper = false) 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | @Table( 22 | value = "wb_template_datasource_param", 23 | onInsert = EntityChangeListener.class, 24 | onUpdate = EntityChangeListener.class) 25 | public class TplDatasourceParam extends CommonEntity implements IdEntity { 26 | 27 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 28 | private String id; 29 | 30 | @NotBlank(message = "message.name_not_blank") 31 | @Size(max = 100) 32 | private String name; 33 | 34 | @Size(max = 100) 35 | private String label = ""; 36 | 37 | private String datasourceId; 38 | 39 | private Boolean required = false; 40 | 41 | @Size(max = 500) 42 | private String defVal = ""; 43 | 44 | private String config = ""; 45 | } 46 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/relation/SysPolicyMenuRel.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.relation; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.model.entity.IUniqueEntity; 9 | import com.wangboot.model.entity.IdEntity; 10 | import com.wangboot.system.entity.relation.table.SysPolicyMenuRelTableDef; 11 | import javax.validation.constraints.NotBlank; 12 | import lombok.*; 13 | 14 | /** 15 | * 实体类。 16 | * 17 | * @author wwtg99 18 | */ 19 | @Data 20 | @EqualsAndHashCode 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @Builder 24 | @Table(value = "wb_sys_policy_menu_rel") 25 | public class SysPolicyMenuRel implements IdEntity, IUniqueEntity { 26 | 27 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 28 | private String id; 29 | 30 | @NotBlank(message = "message.relation_not_empty") 31 | private String policyId; 32 | 33 | @NotBlank(message = "message.relation_not_empty") 34 | private String menuId; 35 | 36 | @Override 37 | @JsonIgnore 38 | public String[][] getUniqueTogetherFields() { 39 | return new String[][] { 40 | { 41 | SysPolicyMenuRelTableDef.SYS_POLICY_MENU_REL.POLICY_ID.getName(), 42 | SysPolicyMenuRelTableDef.SYS_POLICY_MENU_REL.MENU_ID.getName() 43 | } 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/relation/SysRolePolicyRel.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.relation; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.model.entity.IUniqueEntity; 9 | import com.wangboot.model.entity.IdEntity; 10 | import com.wangboot.system.entity.relation.table.SysRolePolicyRelTableDef; 11 | import javax.validation.constraints.NotBlank; 12 | import lombok.*; 13 | 14 | /** 15 | * 实体类。 16 | * 17 | * @author wwtg99 18 | */ 19 | @Data 20 | @EqualsAndHashCode 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @Builder 24 | @Table(value = "wb_sys_role_policy_rel") 25 | public class SysRolePolicyRel implements IdEntity, IUniqueEntity { 26 | 27 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 28 | private String id; 29 | 30 | @NotBlank(message = "message.relation_not_empty") 31 | private String roleId; 32 | 33 | @NotBlank(message = "message.relation_not_empty") 34 | private String policyId; 35 | 36 | @Override 37 | @JsonIgnore 38 | public String[][] getUniqueTogetherFields() { 39 | return new String[][] { 40 | { 41 | SysRolePolicyRelTableDef.SYS_ROLE_POLICY_REL.ROLE_ID.getName(), 42 | SysRolePolicyRelTableDef.SYS_ROLE_POLICY_REL.POLICY_ID.getName() 43 | } 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/entity/TplDatasource.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.entity; 2 | 3 | import com.mybatisflex.annotation.Id; 4 | import com.mybatisflex.annotation.KeyType; 5 | import com.mybatisflex.annotation.Table; 6 | import com.mybatisflex.core.keygen.KeyGenerators; 7 | import com.wangboot.model.entity.IdEntity; 8 | import com.wangboot.model.entity.event.EnableOperationLog; 9 | import com.wangboot.model.entity.impl.CommonEntity; 10 | import com.wangboot.system.listener.EntityChangeListener; 11 | import javax.validation.constraints.NotBlank; 12 | import javax.validation.constraints.Size; 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.EqualsAndHashCode; 16 | import lombok.NoArgsConstructor; 17 | 18 | @Data 19 | @EqualsAndHashCode(callSuper = false) 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | @EnableOperationLog 23 | @Table( 24 | value = "wb_template_datasource", 25 | onInsert = EntityChangeListener.class, 26 | onUpdate = EntityChangeListener.class) 27 | public class TplDatasource extends CommonEntity implements IdEntity { 28 | 29 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 30 | private String id; 31 | 32 | @NotBlank(message = "message.name_not_blank") 33 | @Size(max = 100) 34 | private String name; 35 | 36 | @NotBlank(message = "message.type_not_blank") 37 | @Size(max = 100) 38 | private String type; 39 | 40 | private String config = ""; 41 | 42 | private Boolean connected = false; 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/entity/TplRenderExecution.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.entity; 2 | 3 | import com.mybatisflex.annotation.Id; 4 | import com.mybatisflex.annotation.KeyType; 5 | import com.mybatisflex.annotation.Table; 6 | import com.mybatisflex.core.keygen.KeyGenerators; 7 | import com.wangboot.model.entity.IdEntity; 8 | import com.wangboot.model.entity.event.EnableOperationLog; 9 | import com.wangboot.model.entity.impl.CommonEntity; 10 | import com.wangboot.system.listener.EntityChangeListener; 11 | import lombok.AllArgsConstructor; 12 | import lombok.Data; 13 | import lombok.EqualsAndHashCode; 14 | import lombok.NoArgsConstructor; 15 | 16 | @Data 17 | @EqualsAndHashCode(callSuper = false) 18 | @NoArgsConstructor 19 | @AllArgsConstructor 20 | @EnableOperationLog 21 | @Table( 22 | value = "wb_template_render_execution", 23 | onInsert = EntityChangeListener.class, 24 | onUpdate = EntityChangeListener.class) 25 | public class TplRenderExecution extends CommonEntity implements IdEntity { 26 | 27 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 28 | private String id; 29 | 30 | private String templateId; 31 | 32 | private String templateName; 33 | 34 | private String templateType; 35 | 36 | private String datasourceId; 37 | 38 | private String datasourceName; 39 | 40 | private String datasourceType; 41 | 42 | private String params; 43 | 44 | private ExecutionStatus status = ExecutionStatus.WAITING; 45 | 46 | private String filename; 47 | } 48 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysDepartment.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.mybatisflex.annotation.Id; 4 | import com.mybatisflex.annotation.KeyType; 5 | import com.mybatisflex.annotation.Table; 6 | import com.mybatisflex.core.keygen.KeyGenerators; 7 | import com.wangboot.model.entity.event.EnableOperationLog; 8 | import com.wangboot.model.entity.impl.CommonTreeEntity; 9 | import com.wangboot.system.listener.EntityChangeListener; 10 | import javax.validation.constraints.NotBlank; 11 | import javax.validation.constraints.Size; 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.EqualsAndHashCode; 15 | import lombok.NoArgsConstructor; 16 | 17 | /** 18 | * 实体类。 19 | * 20 | * @author wwtg99 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @NoArgsConstructor 25 | @AllArgsConstructor 26 | @EnableOperationLog 27 | @Table( 28 | value = "wb_sys_department", 29 | onInsert = EntityChangeListener.class, 30 | onUpdate = EntityChangeListener.class) 31 | public class SysDepartment extends CommonTreeEntity { 32 | 33 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 34 | private String id; 35 | 36 | @NotBlank(message = "message.name_not_blank") 37 | @Size(max = 90) 38 | private String name; 39 | 40 | @Size(max = 200) 41 | private String fullname = ""; 42 | 43 | @Size(max = 90) 44 | private String leader = ""; 45 | 46 | @Override 47 | public boolean hasChildren() { 48 | return true; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/service/impl/TplRenderExecutionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.service.impl; 2 | 3 | import com.mybatisflex.core.query.QueryWrapper; 4 | import com.mybatisflex.spring.service.impl.ServiceImpl; 5 | import com.wangboot.app.template.entity.TplExecutionResult; 6 | import com.wangboot.app.template.entity.TplRenderExecution; 7 | import com.wangboot.app.template.entity.table.TplExecutionResultTableDef; 8 | import com.wangboot.app.template.mapper.TplRenderExecutionMapper; 9 | import com.wangboot.app.template.service.TplExecutionResultService; 10 | import com.wangboot.app.template.service.TplRenderExecutionService; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import lombok.RequiredArgsConstructor; 14 | import org.springframework.stereotype.Service; 15 | 16 | @RequiredArgsConstructor 17 | @Service 18 | public class TplRenderExecutionServiceImpl 19 | extends ServiceImpl 20 | implements TplRenderExecutionService { 21 | 22 | private final TplExecutionResultService executionResultService; 23 | 24 | @Override 25 | public List getResults(String id) { 26 | QueryWrapper wrapper = 27 | QueryWrapper.create() 28 | .where(TplExecutionResultTableDef.TPL_EXECUTION_RESULT.EXECUTION_ID.eq(id)); 29 | List data = this.executionResultService.list(wrapper); 30 | return new ArrayList<>(this.executionResultService.getEntitiesWithAttachments(data)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/render/TemplateRenderFactory.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.render; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.Objects; 6 | import java.util.Set; 7 | import org.springframework.lang.NonNull; 8 | import org.springframework.lang.Nullable; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.util.StringUtils; 11 | 12 | /** 13 | * 模版渲染器工厂 14 | * 15 | * @author wwtg99 16 | */ 17 | @Component 18 | public class TemplateRenderFactory { 19 | 20 | private final Map map = new HashMap<>(); 21 | 22 | /** 23 | * 注册模板渲染器类型 24 | * 25 | * @param type 类型 26 | * @param templateRender 模版渲染器 27 | * @return 工厂 28 | */ 29 | public TemplateRenderFactory registerTemplateRender(String type, ITemplateRender templateRender) { 30 | if (StringUtils.hasText(type) && Objects.nonNull(templateRender)) { 31 | this.map.put(type, templateRender); 32 | } 33 | return this; 34 | } 35 | 36 | /** 37 | * 根据类型获取模版渲染器 38 | * 39 | * @param type 类型 40 | * @return 模版渲染器 41 | */ 42 | @Nullable 43 | public ITemplateRender getTemplateRender(String type) { 44 | if (StringUtils.hasText(type) && this.map.containsKey(type)) { 45 | return this.map.get(type); 46 | } 47 | return null; 48 | } 49 | 50 | /** 51 | * 获取所有类型 52 | * 53 | * @return 类型集合 54 | */ 55 | @NonNull 56 | public Set getAllTypes() { 57 | return this.map.keySet(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/model/ClientType.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.mybatisflex.annotation.EnumValue; 5 | import com.wangboot.core.utils.ISystemDict; 6 | import lombok.Getter; 7 | import org.springframework.lang.Nullable; 8 | 9 | /** 10 | * 客户端类型
11 | * 生产环境可使用随机码作为 code,以防用户猜测。 TODO 开发自定义,添加自定义客户端类型 12 | * 13 | * @author wwtg99 14 | */ 15 | public enum ClientType implements ISystemDict { 16 | /** 网页 */ 17 | WEB("101", "桌面端"), 18 | /** 网页管理后台 */ 19 | WEB_ADMIN("211", "桌面端管理后台"), 20 | /** H5 */ 21 | H5("505", "H5端"), 22 | /** H5 管理后台 */ 23 | H5_ADMIN("565", "H5端管理后台"), 24 | /** App 应用 */ 25 | APP("699", "App端"), 26 | /** App 安卓应用 */ 27 | APP_ANDROID("707", "安卓端"), 28 | /** App IOS 应用 */ 29 | APP_IOS("809", "IOS端"), 30 | /** 微信小程序 */ 31 | WEIXIN_APP("996", "微信小程序端"); 32 | 33 | @Getter @EnumValue private final String code; 34 | 35 | @Getter private final String name; 36 | 37 | ClientType(String code, String name) { 38 | this.code = code; 39 | this.name = name; 40 | } 41 | 42 | @Nullable 43 | @JsonCreator 44 | public static ClientType resolve(String code) { 45 | for (ClientType clientType : ClientType.values()) { 46 | if (clientType.getCode().equals(code) || clientType.getName().equals(code)) { 47 | return clientType; 48 | } 49 | } 50 | return null; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return this.name; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/relation/SysPolicyDataScopeRel.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.relation; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.model.entity.IUniqueEntity; 9 | import com.wangboot.model.entity.IdEntity; 10 | import com.wangboot.system.entity.relation.table.SysPolicyDataScopeRelTableDef; 11 | import javax.validation.constraints.NotBlank; 12 | import lombok.*; 13 | 14 | /** 15 | * 实体类。 16 | * 17 | * @author wwtg99 18 | */ 19 | @Data 20 | @EqualsAndHashCode 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @Builder 24 | @Table(value = "wb_sys_policy_data_scope_rel") 25 | public class SysPolicyDataScopeRel implements IdEntity, IUniqueEntity { 26 | 27 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 28 | private String id; 29 | 30 | @NotBlank(message = "message.relation_not_empty") 31 | private String policyId; 32 | 33 | @NotBlank(message = "message.relation_not_empty") 34 | private String dataScopeId; 35 | 36 | @Override 37 | @JsonIgnore 38 | public String[][] getUniqueTogetherFields() { 39 | return new String[][] { 40 | { 41 | SysPolicyDataScopeRelTableDef.SYS_POLICY_DATA_SCOPE_REL.POLICY_ID.getName(), 42 | SysPolicyDataScopeRelTableDef.SYS_POLICY_DATA_SCOPE_REL.DATA_SCOPE_ID.getName() 43 | } 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/relation/SysPolicyPermissionRel.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity.relation; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.model.entity.IUniqueEntity; 9 | import com.wangboot.model.entity.IdEntity; 10 | import com.wangboot.system.entity.relation.table.SysPolicyPermissionRelTableDef; 11 | import javax.validation.constraints.NotBlank; 12 | import lombok.*; 13 | 14 | /** 15 | * 实体类。 16 | * 17 | * @author wwtg99 18 | */ 19 | @Data 20 | @EqualsAndHashCode 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @Builder 24 | @Table(value = "wb_sys_policy_permission_rel") 25 | public class SysPolicyPermissionRel implements IdEntity, IUniqueEntity { 26 | 27 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 28 | private String id; 29 | 30 | @NotBlank(message = "message.relation_not_empty") 31 | private String policyId; 32 | 33 | @NotBlank(message = "message.relation_not_empty") 34 | private String permissionId; 35 | 36 | @Override 37 | @JsonIgnore 38 | public String[][] getUniqueTogetherFields() { 39 | return new String[][] { 40 | { 41 | SysPolicyPermissionRelTableDef.SYS_POLICY_PERMISSION_REL.POLICY_ID.getName(), 42 | SysPolicyPermissionRelTableDef.SYS_POLICY_PERMISSION_REL.PERMISSION_ID.getName() 43 | } 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysBgTaskController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.model.entity.FieldConstants; 4 | import com.wangboot.model.entity.controller.ControllerApiGroup; 5 | import com.wangboot.model.entity.controller.EnableApi; 6 | import com.wangboot.model.entity.controller.RestfulApiController; 7 | import com.wangboot.model.entity.request.*; 8 | import com.wangboot.system.entity.SysBgTask; 9 | import com.wangboot.system.service.SysBgTaskService; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @RestController 14 | @RequestMapping("/system/bg_task") 15 | @EnableApi(ControllerApiGroup.READ_ONLY) 16 | public class SysBgTaskController extends RestfulApiController { 17 | 18 | @Override 19 | public SortFilter[] configDefaultSort() { 20 | return new SortFilter[] {new SortFilter(FieldConstants.CREATED_TIME, false)}; 21 | } 22 | 23 | @Override 24 | public ParamFilterDefinition configParamFilterDefinition() { 25 | return ParamFilterDefinition.newInstance() 26 | .addFilter("name") 27 | .addFilter("type") 28 | .addFilter("status") 29 | .addFilter( 30 | "start", 31 | new FieldFilter(FieldConstants.CREATED_TIME, FilterOperator.GE, ParamValType.DATE)) 32 | .addFilter( 33 | "end", 34 | new FieldFilter(FieldConstants.CREATED_TIME, FilterOperator.LE, ParamValType.DATE)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /task/src/main/java/com/wangboot/task/controller/TaskQuickLinkController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.task.controller; 2 | 3 | import com.wangboot.model.entity.controller.ControllerApiGroup; 4 | import com.wangboot.model.entity.controller.EnableApi; 5 | import com.wangboot.model.entity.controller.RestfulApiController; 6 | import com.wangboot.model.entity.request.SearchStrategy; 7 | import com.wangboot.model.entity.request.SortFilter; 8 | import com.wangboot.task.entity.TaskQuickLink; 9 | import com.wangboot.task.entity.table.TaskQuickLinkTableDef; 10 | import com.wangboot.task.service.TaskQuickLinkService; 11 | import org.springframework.lang.NonNull; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | /** 16 | * 快捷菜单接口 17 | * 18 | * @author wwtg99 19 | */ 20 | @RestController 21 | @RequestMapping("/task/quick_link") 22 | @EnableApi(ControllerApiGroup.FULL) 23 | public class TaskQuickLinkController 24 | extends RestfulApiController { 25 | @Override 26 | public SortFilter[] configDefaultSort() { 27 | return new SortFilter[] { 28 | new SortFilter(TaskQuickLinkTableDef.TASK_QUICK_LINK.SORT.getName(), true) 29 | }; 30 | } 31 | 32 | @Override 33 | public String[] configSearchableFields() { 34 | return new String[] {TaskQuickLinkTableDef.TASK_QUICK_LINK.NAME.getName()}; 35 | } 36 | 37 | @NonNull 38 | @Override 39 | public SearchStrategy configSearchStrategy() { 40 | return SearchStrategy.BOTH_LIKE; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysAttachment.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.mybatisflex.annotation.Column; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.model.attachment.IAttachmentModel; 9 | import com.wangboot.model.entity.impl.AppendOnlyEntity; 10 | import lombok.*; 11 | 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | @Builder 17 | @Table(value = "wb_sys_attachment") 18 | public class SysAttachment extends AppendOnlyEntity implements IAttachmentModel { 19 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 20 | private String id; 21 | 22 | private String url = ""; 23 | 24 | private long size = 0; 25 | 26 | private String filename = ""; 27 | 28 | private String originalFilename = ""; 29 | 30 | private String basePath = ""; 31 | 32 | private String path = ""; 33 | 34 | private String ext = ""; 35 | 36 | private String contentType = ""; 37 | 38 | private String platform = ""; 39 | 40 | private String thUrl = ""; 41 | 42 | private String thFilename = ""; 43 | 44 | private long thSize = 0; 45 | 46 | private String thContentType = ""; 47 | 48 | private String hashInfo = ""; 49 | 50 | private String attr = ""; 51 | 52 | private String objectId; 53 | 54 | private String objectType = ""; 55 | 56 | @Column(isLogicDelete = true) 57 | private Boolean deleted = false; 58 | } 59 | -------------------------------------------------------------------------------- /task/src/main/java/com/wangboot/task/entity/TaskQuickLink.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.task.entity; 2 | 3 | import com.mybatisflex.annotation.Id; 4 | import com.mybatisflex.annotation.KeyType; 5 | import com.mybatisflex.annotation.Table; 6 | import com.mybatisflex.core.keygen.KeyGenerators; 7 | import com.wangboot.model.dataauthority.DataAuthority; 8 | import com.wangboot.model.dataauthority.factory.UserIdAuthorizerFactory; 9 | import com.wangboot.model.entity.IdEntity; 10 | import com.wangboot.model.entity.impl.CommonEntity; 11 | import com.wangboot.system.listener.EntityChangeListener; 12 | import javax.validation.constraints.NotBlank; 13 | import javax.validation.constraints.Size; 14 | import lombok.AllArgsConstructor; 15 | import lombok.Data; 16 | import lombok.EqualsAndHashCode; 17 | import lombok.NoArgsConstructor; 18 | 19 | @Data 20 | @EqualsAndHashCode(callSuper = true) 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @DataAuthority(field = "created_by", factory = UserIdAuthorizerFactory.class) 24 | @Table( 25 | value = "wb_task_quick_link", 26 | onInsert = EntityChangeListener.class, 27 | onUpdate = EntityChangeListener.class) 28 | public class TaskQuickLink extends CommonEntity implements IdEntity { 29 | 30 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 31 | private String id; 32 | 33 | @NotBlank(message = "message.name_not_blank") 34 | @Size(max = 90) 35 | private String name; 36 | 37 | @Size(max = 200) 38 | private String icon = ""; 39 | 40 | @Size(max = 200) 41 | private String path = ""; 42 | 43 | private Integer sort = 0; 44 | } 45 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/command/GenerateSM2Pair.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework.command; 2 | 3 | import cn.hutool.core.util.HexUtil; 4 | import cn.hutool.crypto.BCUtil; 5 | import cn.hutool.crypto.SecureUtil; 6 | import com.wangboot.core.utils.StrUtils; 7 | import java.security.KeyPair; 8 | import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey; 9 | import org.springframework.boot.ApplicationArguments; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * 生成 SM2 密钥对
14 | * 使用参数 --generate-sm2 15 | * 16 | * @author wwtg99 17 | */ 18 | @Component 19 | public class GenerateSM2Pair implements IBaseCommand { 20 | 21 | private static final int LINE_WIDTH = 80; 22 | 23 | @Override 24 | public void callCommand(ApplicationArguments args) { 25 | KeyPair pair = SecureUtil.generateKeyPair("SM2"); 26 | String privateKeyStr = HexUtil.encodeHexStr(BCUtil.encodeECPrivateKey(pair.getPrivate())); 27 | this.println("=== Private Key: ==="); 28 | StrUtils.splitStrByLineWidth(privateKeyStr, LINE_WIDTH).forEach(this::println); 29 | String publicKeyStr = 30 | HexUtil.encodeHexStr(((BCECPublicKey) pair.getPublic()).getQ().getEncoded(false)); 31 | this.println("=== Public Key: ==="); 32 | StrUtils.splitStrByLineWidth(publicKeyStr, LINE_WIDTH).forEach(this::println); 33 | } 34 | 35 | @Override 36 | public boolean whetherToRun(ApplicationArguments args) { 37 | return args.containsOption("generate-sm2"); 38 | } 39 | 40 | @Override 41 | public boolean exitAfterCompletion() { 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/attachment/ContentTypes.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.attachment; 2 | 3 | import cn.hutool.core.util.ArrayUtil; 4 | 5 | /** 6 | * 常见文档类型 7 | * 8 | * @author wwtg99 9 | */ 10 | public class ContentTypes { 11 | 12 | public static final String[] OFFICE_WORD_DOCUMENTS = 13 | new String[] { 14 | "application/msword", 15 | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" 16 | }; 17 | 18 | public static final String[] OFFICE_EXCEL_DOCUMENTS = 19 | new String[] { 20 | "application/vnd.ms-excel", 21 | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" 22 | }; 23 | 24 | public static final String[] OFFICE_PPT_DOCUMENTS = 25 | new String[] { 26 | "application/vnd.ms-powerpoint", 27 | "application/vnd.openxmlformats-officedocument.presentationml.presentation" 28 | }; 29 | 30 | public static final String[] OFFICE_PDF_DOCUMENTS = new String[] {"application/pdf"}; 31 | 32 | public static final String[] OFFICE_DOCUMENTS = 33 | ArrayUtil.addAll( 34 | OFFICE_WORD_DOCUMENTS, 35 | OFFICE_EXCEL_DOCUMENTS, 36 | OFFICE_PPT_DOCUMENTS, 37 | OFFICE_PDF_DOCUMENTS); 38 | 39 | public static final String[] ZIP_ARCHIVES = 40 | new String[] {"application/zip", "application/x-zip-compressed"}; 41 | 42 | public static final String[] TEXT_FILE = new String[] {"text/plain"}; 43 | 44 | public static final String[] IMAGES = 45 | new String[] {"image/jpeg", "image/png", "image/gif", "image/tiff"}; 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/datasource/dbsql/DatabaseSqlFactory.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.datasource.dbsql; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import com.wangboot.app.execution.RenderErrorCode; 6 | import com.wangboot.app.execution.datasource.IDatasource; 7 | import com.wangboot.app.execution.datasource.IDatasourceFactory; 8 | import com.wangboot.core.errorcode.ErrorCodeException; 9 | import lombok.RequiredArgsConstructor; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.springframework.lang.Nullable; 12 | import org.springframework.util.StringUtils; 13 | 14 | /** 15 | * 数据库SQL数据源工厂 16 | * 17 | * @author wwtg99 18 | */ 19 | @RequiredArgsConstructor 20 | @Slf4j 21 | public class DatabaseSqlFactory implements IDatasourceFactory { 22 | 23 | private final ObjectMapper objectMapper; 24 | 25 | @Nullable 26 | @Override 27 | public IDatasource connectDatasource(String id, String name, String config) { 28 | if (!StringUtils.hasText(id) || !StringUtils.hasText(name) || !StringUtils.hasText(config)) { 29 | return null; 30 | } 31 | try { 32 | DatabaseSqlConfig databaseSqlConfig = 33 | this.objectMapper.readValue(config, DatabaseSqlConfig.class); 34 | DatabaseSql datasource = new DatabaseSql(name, databaseSqlConfig); 35 | datasource.configDatasource(); 36 | return datasource; 37 | } catch (JsonProcessingException e) { 38 | log.error(e.getMessage()); 39 | throw new ErrorCodeException(RenderErrorCode.INVALID_DATASOURCE_CONFIG); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/RenderExecutionConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.wangboot.app.execution.datasource.DatasourceProcessor; 5 | import com.wangboot.app.execution.datasource.dbsql.DatabaseSqlFactory; 6 | import com.wangboot.app.execution.render.ITemplateRender; 7 | import com.wangboot.app.execution.render.TemplateRenderFactory; 8 | import com.wangboot.app.execution.render.text.FreeMarkerTemplateRender; 9 | import com.wangboot.app.execution.render.word.PoiWordTemplateRender; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | /** 14 | * 配置
15 | * 注册数据源工厂和渲染生成器 16 | * 17 | * @author wwtg99 18 | */ 19 | @Configuration 20 | public class RenderExecutionConfig { 21 | 22 | @Bean 23 | public DatabaseSqlFactory databaseSqlFactory( 24 | DatasourceProcessor datasourceProcessor, ObjectMapper objectMapper) { 25 | DatabaseSqlFactory factory = new DatabaseSqlFactory(objectMapper); 26 | datasourceProcessor.registerDatasourceFactory("db_sql", factory); 27 | return factory; 28 | } 29 | 30 | @Bean 31 | public ITemplateRender poiWordTemplateRender(TemplateRenderFactory factory) { 32 | ITemplateRender render = new PoiWordTemplateRender(); 33 | factory.registerTemplateRender("word", render); 34 | return render; 35 | } 36 | 37 | @Bean 38 | public ITemplateRender freeMarkerTemplateRender(TemplateRenderFactory factory) { 39 | ITemplateRender render = new FreeMarkerTemplateRender(); 40 | factory.registerTemplateRender("text", render); 41 | return render; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysMenuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.core.query.QueryWrapper; 4 | import com.mybatisflex.spring.service.impl.ServiceImpl; 5 | import com.wangboot.model.entity.exception.DeleteCascadeFailedException; 6 | import com.wangboot.system.entity.SysMenu; 7 | import com.wangboot.system.entity.relation.table.SysPolicyMenuRelTableDef; 8 | import com.wangboot.system.mapper.SysMenuMapper; 9 | import com.wangboot.system.service.SysMenuService; 10 | import com.wangboot.system.service.SysPolicyMenuRelService; 11 | import lombok.RequiredArgsConstructor; 12 | import org.springframework.lang.NonNull; 13 | import org.springframework.stereotype.Service; 14 | 15 | /** 16 | * 服务层实现。 17 | * 18 | * @author wwtg99 19 | */ 20 | @Service 21 | @RequiredArgsConstructor 22 | public class SysMenuServiceImpl extends ServiceImpl 23 | implements SysMenuService { 24 | 25 | private final SysPolicyMenuRelService policyMenuRelService; 26 | 27 | @Override 28 | @NonNull 29 | public SysMenu checkBeforeDeleteObject(@NonNull SysMenu entity) { 30 | entity = SysMenuService.super.checkBeforeDeleteObject(entity); 31 | // 存在子节点或关联策略则不允许删除 32 | if (this.getDirectChildrenCount(entity.getId()) > 0) { 33 | throw new DeleteCascadeFailedException(entity.getId()); 34 | } 35 | QueryWrapper wrapper = 36 | policyMenuRelService 37 | .query() 38 | .where(SysPolicyMenuRelTableDef.SYS_POLICY_MENU_REL.MENU_ID.eq(entity.getId())); 39 | if (policyMenuRelService.count(wrapper) > 0) { 40 | throw new DeleteCascadeFailedException(entity.getId()); 41 | } 42 | return entity; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysDataScope.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.model.entity.IUniqueEntity; 9 | import com.wangboot.model.entity.IdEntity; 10 | import com.wangboot.model.entity.event.EnableOperationLog; 11 | import com.wangboot.model.entity.impl.CommonEntity; 12 | import com.wangboot.system.entity.table.SysDataScopeTableDef; 13 | import com.wangboot.system.listener.EntityChangeListener; 14 | import javax.validation.constraints.NotBlank; 15 | import javax.validation.constraints.Size; 16 | import lombok.AllArgsConstructor; 17 | import lombok.Data; 18 | import lombok.EqualsAndHashCode; 19 | import lombok.NoArgsConstructor; 20 | 21 | /** 22 | * 实体类。 23 | * 24 | * @author wwtg99 25 | */ 26 | @Data 27 | @EqualsAndHashCode(callSuper = false) 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | @EnableOperationLog 31 | @Table( 32 | value = "wb_sys_data_scope", 33 | onInsert = EntityChangeListener.class, 34 | onUpdate = EntityChangeListener.class) 35 | public class SysDataScope extends CommonEntity implements IdEntity, IUniqueEntity { 36 | 37 | @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId) 38 | private String id; 39 | 40 | @NotBlank(message = "message.name_not_blank") 41 | @Size(max = 90) 42 | private String name; 43 | 44 | @Override 45 | @JsonIgnore 46 | public String[][] getUniqueTogetherFields() { 47 | return new String[][] {{SysDataScopeTableDef.SYS_DATA_SCOPE.NAME.getName()}}; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/commands/PrepareDatasource.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.commands; 2 | 3 | import com.mybatisflex.core.query.QueryWrapper; 4 | import com.wangboot.app.execution.datasource.DatasourceProcessor; 5 | import com.wangboot.app.template.entity.TplDatasource; 6 | import com.wangboot.app.template.entity.table.TplDatasourceTableDef; 7 | import com.wangboot.app.template.service.TplDatasourceService; 8 | import com.wangboot.framework.command.IBaseCommand; 9 | import java.util.List; 10 | import lombok.RequiredArgsConstructor; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.springframework.boot.ApplicationArguments; 13 | import org.springframework.core.annotation.Order; 14 | import org.springframework.stereotype.Component; 15 | 16 | /** 17 | * 启动后准备数据源 18 | * 19 | * @author wwtg99 20 | */ 21 | @Component 22 | @Order(30) 23 | @RequiredArgsConstructor 24 | @Slf4j 25 | public class PrepareDatasource implements IBaseCommand { 26 | 27 | private final TplDatasourceService datasourceService; 28 | 29 | private final DatasourceProcessor datasourceProcessor; 30 | 31 | @Override 32 | public void callCommand(ApplicationArguments args) { 33 | QueryWrapper wrapper = 34 | this.datasourceService 35 | .query() 36 | .where(TplDatasourceTableDef.TPL_DATASOURCE.CONNECTED.eq(true)); 37 | List datasourceList = this.datasourceService.list(wrapper); 38 | datasourceList.forEach( 39 | ds -> { 40 | log.info("Prepare datasource {}.", ds.getName()); 41 | this.datasourceProcessor.prepareDatasource( 42 | ds.getId(), ds.getName(), ds.getType(), ds.getConfig()); 43 | }); 44 | } 45 | 46 | @Override 47 | public boolean whetherToRun(ApplicationArguments args) { 48 | return true; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/AuthService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.core.auth.model.ILoginBody; 4 | import com.wangboot.core.auth.model.ILogoutBody; 5 | import com.wangboot.core.auth.model.IRefreshTokenBody; 6 | import com.wangboot.core.auth.token.TokenPair; 7 | import com.wangboot.core.auth.user.IUserModel; 8 | import com.wangboot.system.entity.SysDataScope; 9 | import com.wangboot.system.entity.SysMenu; 10 | import com.wangboot.system.entity.SysPermission; 11 | import com.wangboot.system.entity.SysUser; 12 | import com.wangboot.system.model.ChangePasswordBody; 13 | import com.wangboot.system.model.RegisterBody; 14 | import java.util.List; 15 | import org.springframework.lang.NonNull; 16 | import org.springframework.lang.Nullable; 17 | 18 | public interface AuthService { 19 | /** 注册 */ 20 | @NonNull 21 | IUserModel register(@NonNull RegisterBody registerBody); 22 | 23 | /** 登录 */ 24 | @NonNull 25 | TokenPair login(@NonNull ILoginBody loginBody); 26 | 27 | /** 登出 */ 28 | boolean logout(@NonNull ILogoutBody logoutBody); 29 | 30 | /** 用户修改密码 */ 31 | boolean changePassword(@NonNull ChangePasswordBody changePasswordBody); 32 | 33 | /** 管理员直接设置密码 */ 34 | boolean setPassword( 35 | @NonNull IUserModel userModel, @NonNull ChangePasswordBody changePasswordBody); 36 | 37 | /** 获取用户信息 */ 38 | @Nullable 39 | IUserModel getProfile(); 40 | 41 | /** 更新用户信息 */ 42 | @Nullable 43 | IUserModel updateProfile(@Nullable SysUser user); 44 | 45 | /** 刷新令牌 */ 46 | @NonNull 47 | TokenPair refreshToken(IRefreshTokenBody refreshTokenBody); 48 | 49 | @NonNull 50 | List getMyPermissions(); 51 | 52 | @NonNull 53 | List getMyDataScopes(); 54 | 55 | /** 获取当前用户菜单 */ 56 | @NonNull 57 | List getMyMenus(); 58 | } 59 | -------------------------------------------------------------------------------- /framework/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | wang-template-backend 7 | wang.52jing 8 | ${revision} 9 | 10 | 4.0.0 11 | 12 | framework 13 | 14 | ${project.artifactId} 15 | 后端服务框架核心模块 16 | 17 | 18 | 19 | org.springframework.boot 20 | spring-boot-starter-web 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-tomcat 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-undertow 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-aop 37 | 38 | 39 | wang.52jing 40 | wb-spring-boot-starter 41 | 42 | 43 | wang.52jing 44 | wb-model-flex 45 | 46 | 47 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysMenu.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.mybatisflex.annotation.Id; 4 | import com.mybatisflex.annotation.KeyType; 5 | import com.mybatisflex.annotation.Table; 6 | import com.mybatisflex.core.keygen.KeyGenerators; 7 | import com.wangboot.model.entity.event.EnableOperationLog; 8 | import com.wangboot.model.entity.impl.CommonTreeEntity; 9 | import com.wangboot.system.listener.EntityChangeListener; 10 | import javax.validation.constraints.NotBlank; 11 | import javax.validation.constraints.Size; 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.EqualsAndHashCode; 15 | import lombok.NoArgsConstructor; 16 | 17 | /** 18 | * 实体类。 19 | * 20 | * @author wwtg99 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @NoArgsConstructor 25 | @AllArgsConstructor 26 | @EnableOperationLog 27 | @Table( 28 | value = "wb_sys_menu", 29 | onInsert = EntityChangeListener.class, 30 | onUpdate = EntityChangeListener.class) 31 | public class SysMenu extends CommonTreeEntity { 32 | 33 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 34 | private String id; 35 | 36 | @NotBlank(message = "message.name_not_blank") 37 | @Size(max = 90) 38 | private String name; 39 | 40 | @Size(max = 90) 41 | private String caption = ""; 42 | 43 | @Size(max = 200) 44 | private String icon = ""; 45 | 46 | @Size(max = 200) 47 | private String path = ""; 48 | 49 | @Override 50 | public boolean hasChildren() { 51 | return true; 52 | } 53 | 54 | public SysMenu( 55 | String id, 56 | String name, 57 | String caption, 58 | String icon, 59 | String path, 60 | String parentId, 61 | Integer sort) { 62 | this(id, name, caption, icon, path); 63 | this.setParentId(parentId); 64 | this.setSort(sort); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/service/impl/TplTemplateServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.app.template.entity.TplTemplate; 5 | import com.wangboot.app.template.mapper.TplTemplateMapper; 6 | import com.wangboot.app.template.service.TplTemplateService; 7 | import com.wangboot.core.web.response.ListBody; 8 | import com.wangboot.model.attachment.IAttachmentService; 9 | import com.wangboot.model.entity.request.FieldFilter; 10 | import com.wangboot.model.entity.request.SortFilter; 11 | import com.wangboot.system.service.SysAttachmentService; 12 | import lombok.RequiredArgsConstructor; 13 | import org.springframework.lang.NonNull; 14 | import org.springframework.lang.Nullable; 15 | import org.springframework.stereotype.Service; 16 | 17 | @Service 18 | @RequiredArgsConstructor 19 | public class TplTemplateServiceImpl extends ServiceImpl 20 | implements TplTemplateService { 21 | 22 | private final SysAttachmentService attachmentService; 23 | 24 | @Override 25 | @NonNull 26 | public ListBody listResourcesPage( 27 | @Nullable SortFilter[] sortFilters, 28 | @Nullable FieldFilter[] fieldFilters, 29 | @Nullable FieldFilter[] searchFilters, 30 | long page, 31 | long pageSize) { 32 | ListBody data = 33 | TplTemplateService.super.listResourcesPage( 34 | sortFilters, fieldFilters, searchFilters, page, pageSize); 35 | data.setData(this.getEntitiesWithAttachments(data.getData())); 36 | return data; 37 | } 38 | 39 | @Override 40 | @NonNull 41 | public IAttachmentService getAttachmentService() { 42 | return this.attachmentService; 43 | } 44 | 45 | @Override 46 | public String getObjectType() { 47 | return this.getEntityClass().getName(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/service/TplDatasourceService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.service; 2 | 3 | import com.wangboot.app.execution.datasource.DatasourceParamHolder; 4 | import com.wangboot.app.execution.datasource.IDatasource; 5 | import com.wangboot.app.template.entity.TplDatasource; 6 | import com.wangboot.app.template.entity.TplDatasourceParam; 7 | import com.wangboot.model.flex.IFlexRestfulService; 8 | import java.util.List; 9 | import java.util.Set; 10 | import org.springframework.lang.Nullable; 11 | 12 | public interface TplDatasourceService extends IFlexRestfulService { 13 | 14 | /** 15 | * 获取数据源参数 16 | * 17 | * @param id 数据源ID 18 | * @return 参数列表 19 | */ 20 | List getDatasourceParams(String id); 21 | 22 | /** 23 | * 创建数据源参数 24 | * 25 | * @param datasourceId 数据源ID 26 | * @param params 数据集 27 | * @return 是否成功 28 | */ 29 | boolean createDatasourceParams(String datasourceId, List params); 30 | 31 | /** 32 | * 更新数据源参数 33 | * 34 | * @param datasourceId 数据源ID 35 | * @param params 数据集 36 | * @return 是否成功 37 | */ 38 | boolean updateDatasourceParams(String datasourceId, List params); 39 | 40 | /** 41 | * 删除数据源参数 42 | * 43 | * @param id 数据源ID 44 | * @return 是否成功 45 | */ 46 | boolean deleteDatasourceParams(String id); 47 | 48 | /** 49 | * 连接数据源 50 | * 51 | * @param datasource 数据源 52 | * @return 数据源接口 53 | */ 54 | @Nullable 55 | IDatasource connectDatasource(TplDatasource datasource); 56 | 57 | /** 58 | * 获取数据 59 | * 60 | * @param id 数据源ID 61 | * @param params 参数 62 | * @return 数据 63 | */ 64 | @Nullable 65 | Object retrieveData(String id, DatasourceParamHolder params); 66 | 67 | /** 68 | * 获取数据源类型 69 | * 70 | * @return 类型集合 71 | */ 72 | Set getDatasourceTypes(); 73 | } 74 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/command/IBaseCommand.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework.command; 2 | 3 | import cn.hutool.core.lang.Console; 4 | import com.wangboot.core.auth.AuthFlow; 5 | import com.wangboot.core.auth.context.*; 6 | import com.wangboot.core.auth.user.IUserModel; 7 | import com.wangboot.core.auth.user.impl.MockUser; 8 | import java.util.Objects; 9 | import org.springframework.boot.ApplicationArguments; 10 | import org.springframework.boot.ApplicationRunner; 11 | import org.springframework.lang.Nullable; 12 | 13 | /** 14 | * 命令接口 15 | * 16 | * @author wwtg99 17 | */ 18 | public interface IBaseCommand extends ApplicationRunner { 19 | 20 | IUserModel SYSTEM_USER = new MockUser("0", "System", "", true, true, true, false, null); 21 | 22 | ILoginUser SYSTEM = new LoginUser(SYSTEM_USER, AuthFlow.UNKNOWN_FRONTEND, AuthFlow.ALLOW_ALL); 23 | 24 | /** 执行命令 */ 25 | void callCommand(ApplicationArguments args); 26 | 27 | /** 运行条件 */ 28 | boolean whetherToRun(ApplicationArguments args); 29 | 30 | @Nullable 31 | default IAuthContext getAuthContext() { 32 | return new LocalAuthContext(SYSTEM); 33 | } 34 | 35 | default boolean exitAfterCompletion() { 36 | return false; 37 | } 38 | 39 | default void run(ApplicationArguments args) { 40 | if (this.whetherToRun(args)) { 41 | IAuthContext original = AuthContextHolder.getContext(); 42 | IAuthContext authContext = this.getAuthContext(); 43 | if (Objects.nonNull(authContext)) { 44 | AuthContextHolder.setContext(authContext); 45 | } 46 | this.callCommand(args); 47 | if (this.exitAfterCompletion()) { 48 | System.exit(0); 49 | } 50 | AuthContextHolder.setContext(original); 51 | } 52 | } 53 | 54 | default void println(String template, Object... values) { 55 | Console.log(template, values); 56 | } 57 | 58 | default void print(String msg) { 59 | Console.log(msg); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysMenuController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.core.auth.annotation.RequireStaff; 4 | import com.wangboot.core.auth.annotation.RestPermissionPrefix; 5 | import com.wangboot.model.entity.FieldConstants; 6 | import com.wangboot.model.entity.controller.ControllerApi; 7 | import com.wangboot.model.entity.controller.ControllerApiGroup; 8 | import com.wangboot.model.entity.controller.EnableApi; 9 | import com.wangboot.model.entity.controller.RestfulApiController; 10 | import com.wangboot.model.entity.request.ParamFilterDefinition; 11 | import com.wangboot.model.entity.request.SearchStrategy; 12 | import com.wangboot.system.entity.SysMenu; 13 | import com.wangboot.system.entity.table.SysMenuTableDef; 14 | import com.wangboot.system.service.SysMenuService; 15 | import org.springframework.lang.NonNull; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | /** 20 | * 控制层。 21 | * 22 | * @author wwtg99 23 | */ 24 | @RestController 25 | @RequireStaff 26 | @RestPermissionPrefix(group = "system", name = "menu") 27 | @RequestMapping("/system/menu") 28 | @EnableApi( 29 | value = ControllerApiGroup.TREE_FULL, 30 | excludes = {ControllerApi.BATCH_REMOVE}) 31 | public class SysMenuController extends RestfulApiController { 32 | 33 | @Override 34 | public String[] configSearchableFields() { 35 | return new String[] {SysMenuTableDef.SYS_MENU.NAME.getName()}; 36 | } 37 | 38 | @NonNull 39 | @Override 40 | public SearchStrategy configSearchStrategy() { 41 | return SearchStrategy.BOTH_LIKE; 42 | } 43 | 44 | @Override 45 | public ParamFilterDefinition configParamFilterDefinition() { 46 | return ParamFilterDefinition.newInstance() 47 | .addFilter("name") 48 | .addFilter(FieldConstants.PARENT_ID_CAMEL); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /framework/src/main/java/com/wangboot/framework/config/AsyncConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.framework.config; 2 | 3 | import com.wangboot.starter.autoconfiguration.WbProperties; 4 | import java.util.concurrent.Executor; 5 | import java.util.concurrent.ThreadPoolExecutor; 6 | import lombok.Generated; 7 | import lombok.RequiredArgsConstructor; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.scheduling.annotation.AsyncConfigurer; 12 | import org.springframework.scheduling.annotation.EnableAsync; 13 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 14 | 15 | /** 16 | * 异步线程池配置 17 | * 18 | * @author wuwentao 19 | */ 20 | @Configuration 21 | @EnableAsync 22 | @RequiredArgsConstructor 23 | @Slf4j 24 | public class AsyncConfig implements AsyncConfigurer { 25 | 26 | private final WbProperties wbProperties; 27 | 28 | @Override 29 | public Executor getAsyncExecutor() { 30 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); 31 | executor.setThreadNamePrefix(wbProperties.getThreads().getPrefix()); 32 | executor.setMaxPoolSize(wbProperties.getThreads().getMaxPoolSize()); 33 | executor.setCorePoolSize(wbProperties.getThreads().getCorePoolSize()); 34 | executor.setQueueCapacity(wbProperties.getThreads().getQueueCapacity()); 35 | executor.setKeepAliveSeconds(wbProperties.getThreads().getKeepAliveSeconds()); 36 | executor.setWaitForTasksToCompleteOnShutdown(true); 37 | // 拒绝处理策略:抛出异常 38 | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy()); 39 | executor.initialize(); 40 | return executor; 41 | } 42 | 43 | @Generated 44 | @Override 45 | public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { 46 | return (ex, method, params) -> log.error("{} 发生异常:{}", method.getName(), ex.getMessage()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/analysis/AnalysisManager.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.analysis; 2 | 3 | import cn.hutool.extra.spring.SpringUtil; 4 | import com.wangboot.app.analysis.exception.MoonShotRequestException; 5 | import com.wangboot.app.analysis.model.*; 6 | import java.io.IOException; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | import java.util.Objects; 10 | import org.springframework.stereotype.Component; 11 | 12 | @Component 13 | public class AnalysisManager { 14 | 15 | public MoonShotClient getMoonShotClient() { 16 | return SpringUtil.getBean(MoonShotClient.class); 17 | } 18 | 19 | public List analysisIndicators( 20 | byte[] bytes, String filename, String contentType) throws IOException { 21 | MoonShotClient client = getMoonShotClient(); 22 | FileUploadResponseBody response = client.uploadFile(bytes, filename, contentType); 23 | if (Objects.isNull(response)) { 24 | throw new MoonShotRequestException("Upload file failed"); 25 | } 26 | String fileId = response.getId(); 27 | FileContentResponseBody response1 = client.getFileContent(fileId); 28 | if (Objects.isNull(response1)) { 29 | throw new MoonShotRequestException("Get file content failed"); 30 | } 31 | ChatMessage chatMessage1 = 32 | new ChatMessage("system", "你是一个专业且高效的文档分析助理,能够精准地为用户阅读报告并准确提取其中的关键主要指标。"); 33 | ChatMessage chatMessage2 = new ChatMessage("system", response1.getContent()); 34 | ChatMessage chatMessage3 = new ChatMessage("user", "请提取文件中的主要指标"); 35 | ChatCompletionsRequestBody body = 36 | new ChatCompletionsRequestBody( 37 | "moonshot-v1-8k", Arrays.asList(chatMessage1, chatMessage2, chatMessage3), 0.3); 38 | ChatCompletionsResponseBody response2 = client.chatCompletions(body); 39 | if (Objects.isNull(response2)) { 40 | throw new MoonShotRequestException("Get indicator failed"); 41 | } 42 | return response2.getChoices(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/test/java/com/wangboot/app/AITest.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app; 2 | 3 | import cn.hutool.core.io.resource.ResourceUtil; 4 | import com.wangboot.app.analysis.MoonShotClient; 5 | import com.wangboot.app.analysis.model.*; 6 | import java.util.Arrays; 7 | import lombok.SneakyThrows; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.Disabled; 10 | import org.junit.jupiter.api.DisplayName; 11 | import org.junit.jupiter.api.Test; 12 | 13 | @DisplayName("AI测试") 14 | public class AITest { 15 | 16 | public static final String MOONSHOT_ACCESS_TOKEN = ""; 17 | 18 | @Disabled 19 | @Test 20 | @SneakyThrows 21 | public void testMoonShotClient() { 22 | MoonShotClient client = new MoonShotClient(MOONSHOT_ACCESS_TOKEN); 23 | // byte[] bytes = ResourceUtil.readBytes("aaa.pdf"); 24 | // FileUploadResponseBody response = client.uploadFile(bytes, "aaa.pdf", "application/pdf"); 25 | byte[] bytes = ResourceUtil.readBytes("aaa.docx"); 26 | FileUploadResponseBody response = client.uploadFile(bytes, "aaa.docx", "application/msword"); 27 | System.out.println(response); 28 | Assertions.assertNotNull(response); 29 | String fileId = response.getId(); 30 | FileContentResponseBody response1 = client.getFileContent(fileId); 31 | System.out.println(response1); 32 | Assertions.assertNotNull(response1); 33 | ChatMessage chatMessage1 = 34 | new ChatMessage("system", "你是一个专业且高效的文档分析助理,能够精准地为用户阅读报告并准确提取其中的关键主要指标。"); 35 | ChatMessage chatMessage2 = new ChatMessage("system", response1.getContent()); 36 | ChatMessage chatMessage3 = new ChatMessage("user", "请提取文件中的主要指标"); 37 | ChatCompletionsRequestBody body = 38 | new ChatCompletionsRequestBody( 39 | "moonshot-v1-8k", Arrays.asList(chatMessage1, chatMessage2, chatMessage3), 0.3); 40 | ChatCompletionsResponseBody response2 = client.chatCompletions(body); 41 | System.out.println(response2); 42 | Assertions.assertNotNull(response2); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/entity/TplExecutionResult.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.entity; 2 | 3 | import cn.hutool.core.bean.BeanUtil; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import com.mybatisflex.annotation.Id; 6 | import com.mybatisflex.annotation.KeyType; 7 | import com.mybatisflex.annotation.Table; 8 | import com.mybatisflex.core.keygen.KeyGenerators; 9 | import com.wangboot.model.attachment.IAttachmentListRelatedModel; 10 | import com.wangboot.model.attachment.IAttachmentModel; 11 | import com.wangboot.model.entity.impl.AppendOnlyEntity; 12 | import com.wangboot.system.entity.vo.AttachmentVo; 13 | import com.wangboot.system.listener.EntityChangeListener; 14 | import java.util.List; 15 | import java.util.stream.Collectors; 16 | import lombok.AllArgsConstructor; 17 | import lombok.Data; 18 | import lombok.EqualsAndHashCode; 19 | import lombok.NoArgsConstructor; 20 | 21 | @Data 22 | @EqualsAndHashCode(callSuper = false) 23 | @NoArgsConstructor 24 | @AllArgsConstructor 25 | @Table( 26 | value = "wb_template_execution_result", 27 | onInsert = EntityChangeListener.class, 28 | onUpdate = EntityChangeListener.class) 29 | public class TplExecutionResult extends AppendOnlyEntity 30 | implements IAttachmentListRelatedModel { 31 | 32 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 33 | private String id; 34 | 35 | private String executionId; 36 | 37 | private String message = ""; 38 | 39 | private ExecutionStatus status; 40 | 41 | private List attachments; 42 | 43 | @JsonIgnore 44 | @Override 45 | public List getAttachmentList() { 46 | return this.attachments; 47 | } 48 | 49 | @Override 50 | public void setAttachmentList(List attachments) { 51 | this.attachments = 52 | attachments.stream() 53 | .map(d -> BeanUtil.copyProperties(d, AttachmentVo.class)) 54 | .collect(Collectors.toList()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysDataScopeController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.core.auth.annotation.RequireStaff; 4 | import com.wangboot.core.auth.annotation.RestPermissionPrefix; 5 | import com.wangboot.model.entity.FieldConstants; 6 | import com.wangboot.model.entity.controller.ControllerApiGroup; 7 | import com.wangboot.model.entity.controller.EnableApi; 8 | import com.wangboot.model.entity.controller.RestfulApiController; 9 | import com.wangboot.model.entity.request.ParamFilterDefinition; 10 | import com.wangboot.model.entity.request.SearchStrategy; 11 | import com.wangboot.model.entity.request.SortFilter; 12 | import com.wangboot.system.entity.SysDataScope; 13 | import com.wangboot.system.entity.table.SysDataScopeTableDef; 14 | import com.wangboot.system.service.SysDataScopeService; 15 | import org.springframework.lang.NonNull; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | /** 20 | * 控制层。 21 | * 22 | * @author wwtg99 23 | */ 24 | @RestController 25 | @RequireStaff 26 | @RestPermissionPrefix(group = "system", name = "data_scope") 27 | @RequestMapping("/system/data_scope") 28 | @EnableApi(ControllerApiGroup.FULL) 29 | public class SysDataScopeController 30 | extends RestfulApiController { 31 | @Override 32 | public SortFilter[] configDefaultSort() { 33 | return new SortFilter[] {new SortFilter(FieldConstants.UPDATED_TIME, false)}; 34 | } 35 | 36 | @Override 37 | public String[] configSearchableFields() { 38 | return new String[] {SysDataScopeTableDef.SYS_DATA_SCOPE.NAME.getName()}; 39 | } 40 | 41 | @NonNull 42 | @Override 43 | public SearchStrategy configSearchStrategy() { 44 | return SearchStrategy.BOTH_LIKE; 45 | } 46 | 47 | @Override 48 | public ParamFilterDefinition configParamFilterDefinition() { 49 | return ParamFilterDefinition.newInstance().addFilter("name"); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysFrontendController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.core.auth.annotation.RequireStaff; 4 | import com.wangboot.core.auth.annotation.RestPermissionPrefix; 5 | import com.wangboot.model.entity.FieldConstants; 6 | import com.wangboot.model.entity.controller.ControllerApiGroup; 7 | import com.wangboot.model.entity.controller.EnableApi; 8 | import com.wangboot.model.entity.controller.RestfulApiController; 9 | import com.wangboot.model.entity.request.ParamFilterDefinition; 10 | import com.wangboot.model.entity.request.SearchStrategy; 11 | import com.wangboot.model.entity.request.SortFilter; 12 | import com.wangboot.system.entity.SysFrontend; 13 | import com.wangboot.system.entity.table.SysFrontendTableDef; 14 | import com.wangboot.system.service.SysFrontendService; 15 | import org.springframework.lang.NonNull; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | /** 20 | * 控制层。 21 | * 22 | * @author wwtg99 23 | */ 24 | @RestController 25 | @RequireStaff 26 | @RestPermissionPrefix(group = "system", name = "frontend") 27 | @RequestMapping("/system/frontend") 28 | @EnableApi(ControllerApiGroup.FULL) 29 | public class SysFrontendController 30 | extends RestfulApiController { 31 | @Override 32 | public SortFilter[] configDefaultSort() { 33 | return new SortFilter[] {new SortFilter(FieldConstants.UPDATED_TIME, false)}; 34 | } 35 | 36 | @Override 37 | public String[] configSearchableFields() { 38 | return new String[] {SysFrontendTableDef.SYS_FRONTEND.NAME.getName()}; 39 | } 40 | 41 | @NonNull 42 | @Override 43 | public SearchStrategy configSearchStrategy() { 44 | return SearchStrategy.BOTH_LIKE; 45 | } 46 | 47 | @Override 48 | public ParamFilterDefinition configParamFilterDefinition() { 49 | return ParamFilterDefinition.newInstance().addFilter("name").addFilter("clientType"); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysRole.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.RelationManyToMany; 7 | import com.mybatisflex.annotation.Table; 8 | import com.mybatisflex.core.keygen.KeyGenerators; 9 | import com.wangboot.model.entity.IUniqueEntity; 10 | import com.wangboot.model.entity.IdEntity; 11 | import com.wangboot.model.entity.event.EnableOperationLog; 12 | import com.wangboot.model.entity.impl.CommonEntity; 13 | import com.wangboot.system.entity.table.SysRoleTableDef; 14 | import com.wangboot.system.listener.EntityChangeListener; 15 | import java.util.List; 16 | import javax.validation.constraints.NotBlank; 17 | import javax.validation.constraints.Size; 18 | import lombok.AllArgsConstructor; 19 | import lombok.Data; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.NoArgsConstructor; 22 | 23 | /** 24 | * 实体类。 25 | * 26 | * @author wwtg99 27 | */ 28 | @Data 29 | @EqualsAndHashCode( 30 | callSuper = false, 31 | exclude = {"policies"}) 32 | @NoArgsConstructor 33 | @AllArgsConstructor 34 | @EnableOperationLog 35 | @Table( 36 | value = "wb_sys_role", 37 | onInsert = EntityChangeListener.class, 38 | onUpdate = EntityChangeListener.class) 39 | public class SysRole extends CommonEntity implements IdEntity, IUniqueEntity { 40 | 41 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 42 | private String id; 43 | 44 | @NotBlank(message = "message.name_not_blank") 45 | @Size(max = 90) 46 | private String name; 47 | 48 | @RelationManyToMany( 49 | joinTable = "wb_sys_role_policy_rel", 50 | joinSelfColumn = "role_id", 51 | joinTargetColumn = "policy_id") 52 | private List policies; 53 | 54 | @Override 55 | @JsonIgnore 56 | public String[][] getUniqueTogetherFields() { 57 | return new String[][] {{SysRoleTableDef.SYS_ROLE.NAME.getName()}}; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/SysPolicyService.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service; 2 | 3 | import com.wangboot.model.flex.IFlexRestfulService; 4 | import com.wangboot.system.entity.SysDataScope; 5 | import com.wangboot.system.entity.SysMenu; 6 | import com.wangboot.system.entity.SysPermission; 7 | import com.wangboot.system.entity.SysPolicy; 8 | import java.io.Serializable; 9 | import java.util.Collection; 10 | import java.util.List; 11 | import org.springframework.lang.NonNull; 12 | import org.springframework.lang.Nullable; 13 | 14 | /** 15 | * 服务层。 16 | * 17 | * @author wwtg99 18 | */ 19 | public interface SysPolicyService extends IFlexRestfulService { 20 | 21 | /** 获取权限 */ 22 | @NonNull 23 | List getPolicyPermissions(@Nullable Collection ids); 24 | 25 | /** 添加策略权限 */ 26 | boolean addPolicyPermissions(String id, @Nullable List entities); 27 | 28 | /** 设置策略权限 */ 29 | boolean setPolicyPermissions(String id, @Nullable List entities); 30 | 31 | /** 移除策略权限 */ 32 | boolean removePolicyPermissions(String id, @Nullable List entityIds); 33 | 34 | /** 获取数据权限 */ 35 | @NonNull 36 | List getPolicyDataScopes(@Nullable Collection ids); 37 | 38 | /** 添加策略数据权限 */ 39 | boolean addPolicyDataScopes(String id, @Nullable List entities); 40 | 41 | /** 设置策略数据权限 */ 42 | boolean setPolicyDataScopes(String id, @Nullable List entities); 43 | 44 | /** 移除策略数据权限 */ 45 | boolean removePolicyDataScopes(String id, @Nullable List entityIds); 46 | 47 | /** 获取菜单 */ 48 | @NonNull 49 | List getPolicyMenus(@Nullable Collection ids); 50 | 51 | /** 添加策略菜单 */ 52 | boolean addPolicyMenus(String id, @Nullable List entities); 53 | 54 | /** 设置策略菜单 */ 55 | boolean setPolicyMenus(String id, @Nullable List entities); 56 | 57 | /** 移除策略菜单 */ 58 | boolean removePolicyMenus(String id, @Nullable List entityIds); 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/Application.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app; 2 | 3 | import org.dromara.x.file.storage.spring.EnableFileStorage; 4 | import org.mybatis.spring.annotation.MapperScan; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 9 | import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; 10 | import org.springframework.cache.annotation.EnableCaching; 11 | import org.springframework.context.ConfigurableApplicationContext; 12 | import org.springframework.context.annotation.ComponentScan; 13 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 14 | import org.springframework.core.env.Environment; 15 | import org.springframework.scheduling.annotation.EnableScheduling; 16 | 17 | /** 18 | * 启动程序 19 | * 20 | * @author wwtg99 21 | */ 22 | @SpringBootApplication( 23 | exclude = { 24 | DataSourceAutoConfiguration.class, 25 | SecurityAutoConfiguration.class, 26 | ManagementWebSecurityAutoConfiguration.class 27 | }) 28 | // 表示通过aop框架暴露该代理对象,AopContext能够访问 29 | @EnableAspectJAutoProxy(exposeProxy = true) 30 | // 启用缓存 31 | @EnableCaching 32 | // 启用计划任务 33 | @EnableScheduling 34 | // 启用存储 35 | @EnableFileStorage 36 | // 指定要扫描的Mapper类的包的路径 37 | @MapperScan("com.wangboot.**.mapper") 38 | // 指定要扫描的组件的包的路径 39 | @ComponentScan("com.wangboot.**") 40 | public class Application { 41 | public static void main(String[] args) { 42 | ConfigurableApplicationContext context = SpringApplication.run(Application.class, args); 43 | Environment env = context.getEnvironment(); 44 | String port = env.getProperty("server.port"); 45 | String path = env.getProperty("server.servlet.context-path"); 46 | System.out.println("^O^ 后台服务启动成功 o(^@^)o"); 47 | System.out.println("服务地址:http://localhost:" + port + path); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysPermission.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.model.entity.IEditableEntity; 9 | import com.wangboot.model.entity.IUniqueEntity; 10 | import com.wangboot.model.entity.IdEntity; 11 | import com.wangboot.model.entity.event.EnableOperationLog; 12 | import com.wangboot.model.entity.impl.CommonEntity; 13 | import com.wangboot.system.entity.table.SysPermissionTableDef; 14 | import com.wangboot.system.listener.EntityChangeListener; 15 | import javax.validation.constraints.NotBlank; 16 | import javax.validation.constraints.Size; 17 | import lombok.AllArgsConstructor; 18 | import lombok.Data; 19 | import lombok.EqualsAndHashCode; 20 | import lombok.NoArgsConstructor; 21 | 22 | /** 23 | * 实体类。 24 | * 25 | * @author wwtg99 26 | */ 27 | @Data 28 | @EqualsAndHashCode(callSuper = false) 29 | @NoArgsConstructor 30 | @AllArgsConstructor 31 | @EnableOperationLog 32 | @Table( 33 | value = "wb_sys_permission", 34 | onInsert = EntityChangeListener.class, 35 | onUpdate = EntityChangeListener.class) 36 | public class SysPermission extends CommonEntity 37 | implements IdEntity, IEditableEntity, IUniqueEntity { 38 | 39 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 40 | private String id; 41 | 42 | @NotBlank(message = "message.name_not_blank") 43 | @Size(max = 90) 44 | private String name; 45 | 46 | @NotBlank(message = "message.label_not_blank") 47 | @Size(max = 90) 48 | private String label; 49 | 50 | private Boolean readonly = false; 51 | 52 | @Override 53 | public boolean readonly() { 54 | return this.readonly; 55 | } 56 | 57 | @Override 58 | @JsonIgnore 59 | public String[][] getUniqueTogetherFields() { 60 | return new String[][] {{SysPermissionTableDef.SYS_PERMISSION.NAME.getName()}}; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysPermissionController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.core.auth.annotation.RequireStaff; 4 | import com.wangboot.core.auth.annotation.RestPermissionPrefix; 5 | import com.wangboot.model.entity.FieldConstants; 6 | import com.wangboot.model.entity.controller.ControllerApiGroup; 7 | import com.wangboot.model.entity.controller.EnableApi; 8 | import com.wangboot.model.entity.controller.RestfulApiController; 9 | import com.wangboot.model.entity.request.ParamFilterDefinition; 10 | import com.wangboot.model.entity.request.SearchStrategy; 11 | import com.wangboot.model.entity.request.SortFilter; 12 | import com.wangboot.system.entity.SysPermission; 13 | import com.wangboot.system.entity.table.SysPermissionTableDef; 14 | import com.wangboot.system.service.SysPermissionService; 15 | import org.springframework.lang.NonNull; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | /** 20 | * 控制层。 21 | * 22 | * @author wwtg99 23 | */ 24 | @RestController 25 | @RequireStaff 26 | @RestPermissionPrefix(group = "system", name = "permission") 27 | @RequestMapping("/system/permission") 28 | @EnableApi(ControllerApiGroup.FULL) 29 | public class SysPermissionController 30 | extends RestfulApiController { 31 | @Override 32 | public SortFilter[] configDefaultSort() { 33 | return new SortFilter[] {new SortFilter(FieldConstants.UPDATED_TIME, false)}; 34 | } 35 | 36 | @Override 37 | public String[] configSearchableFields() { 38 | return new String[] { 39 | SysPermissionTableDef.SYS_PERMISSION.NAME.getName(), 40 | SysPermissionTableDef.SYS_PERMISSION.LABEL.getName() 41 | }; 42 | } 43 | 44 | @NonNull 45 | @Override 46 | public SearchStrategy configSearchStrategy() { 47 | return SearchStrategy.BOTH_LIKE; 48 | } 49 | 50 | @Override 51 | public ParamFilterDefinition configParamFilterDefinition() { 52 | return ParamFilterDefinition.newInstance().addFilter("name"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysAnnouncementController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.core.auth.annotation.RequireStaff; 4 | import com.wangboot.core.auth.annotation.RestPermissionPrefix; 5 | import com.wangboot.model.entity.FieldConstants; 6 | import com.wangboot.model.entity.controller.ControllerApiGroup; 7 | import com.wangboot.model.entity.controller.EnableApi; 8 | import com.wangboot.model.entity.controller.RestfulApiController; 9 | import com.wangboot.model.entity.request.*; 10 | import com.wangboot.system.entity.SysAnnouncement; 11 | import com.wangboot.system.entity.table.SysAnnouncementTableDef; 12 | import com.wangboot.system.service.SysAnnouncementService; 13 | import org.springframework.lang.NonNull; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | @RestController 18 | @RequireStaff 19 | @RestPermissionPrefix(group = "system", name = "announcement") 20 | @RequestMapping("/system/announcement") 21 | @EnableApi(ControllerApiGroup.FULL) 22 | public class SysAnnouncementController 23 | extends RestfulApiController { 24 | 25 | @Override 26 | public SortFilter[] configDefaultSort() { 27 | return new SortFilter[] {new SortFilter(FieldConstants.UPDATED_TIME, false)}; 28 | } 29 | 30 | @Override 31 | public String[] configSearchableFields() { 32 | return new String[] {SysAnnouncementTableDef.SYS_ANNOUNCEMENT.TITLE.getName()}; 33 | } 34 | 35 | @NonNull 36 | @Override 37 | public SearchStrategy configSearchStrategy() { 38 | return SearchStrategy.BOTH_LIKE; 39 | } 40 | 41 | @Override 42 | public ParamFilterDefinition configParamFilterDefinition() { 43 | return ParamFilterDefinition.newInstance() 44 | .addFilter("type") 45 | .addFilter( 46 | "display", 47 | new FieldFilter( 48 | SysAnnouncementTableDef.SYS_ANNOUNCEMENT.DISPLAY.getName(), 49 | FilterOperator.EQ, 50 | ParamValType.BOOL)); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysAnnouncementServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.core.query.QueryWrapper; 4 | import com.mybatisflex.spring.service.impl.ServiceImpl; 5 | import com.wangboot.model.attachment.IAttachmentService; 6 | import com.wangboot.system.entity.SysAnnouncement; 7 | import com.wangboot.system.entity.table.SysAnnouncementTableDef; 8 | import com.wangboot.system.mapper.SysAnnouncementMapper; 9 | import com.wangboot.system.model.AnnouncementType; 10 | import com.wangboot.system.service.SysAnnouncementService; 11 | import com.wangboot.system.service.SysAttachmentService; 12 | import java.util.Collections; 13 | import java.util.List; 14 | import java.util.Objects; 15 | import lombok.RequiredArgsConstructor; 16 | import org.springframework.lang.NonNull; 17 | import org.springframework.stereotype.Service; 18 | import org.springframework.util.StringUtils; 19 | 20 | @Service 21 | @RequiredArgsConstructor 22 | public class SysAnnouncementServiceImpl extends ServiceImpl 23 | implements SysAnnouncementService { 24 | 25 | private final SysAttachmentService attachmentService; 26 | 27 | @Override 28 | @NonNull 29 | public List getDisplayedAnnouncements(String type) { 30 | if (!StringUtils.hasText(type)) { 31 | return Collections.emptyList(); 32 | } 33 | AnnouncementType announcementType = AnnouncementType.resolve(type); 34 | if (Objects.isNull(announcementType)) { 35 | return Collections.emptyList(); 36 | } 37 | QueryWrapper wrapper = 38 | this.query() 39 | .where(SysAnnouncementTableDef.SYS_ANNOUNCEMENT.TYPE.eq(type)) 40 | .and(SysAnnouncementTableDef.SYS_ANNOUNCEMENT.DISPLAY.eq(true)) 41 | .orderBy(SysAnnouncementTableDef.SYS_ANNOUNCEMENT.SORT, true); 42 | return this.list(wrapper); 43 | } 44 | 45 | @Override 46 | @NonNull 47 | public IAttachmentService getAttachmentService() { 48 | return this.attachmentService; 49 | } 50 | 51 | @Override 52 | public String getObjectType() { 53 | return this.getEntityClass().getName(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysParamController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.core.auth.annotation.RequireStaff; 4 | import com.wangboot.core.auth.annotation.RestPermissionPrefix; 5 | import com.wangboot.model.entity.FieldConstants; 6 | import com.wangboot.model.entity.controller.ControllerApiGroup; 7 | import com.wangboot.model.entity.controller.EnableApi; 8 | import com.wangboot.model.entity.controller.RestfulApiController; 9 | import com.wangboot.model.entity.request.ParamFilterDefinition; 10 | import com.wangboot.model.entity.request.SearchStrategy; 11 | import com.wangboot.model.entity.request.SortFilter; 12 | import com.wangboot.system.entity.SysParam; 13 | import com.wangboot.system.entity.table.SysParamTableDef; 14 | import com.wangboot.system.service.SysParamService; 15 | import org.springframework.lang.NonNull; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | /** 20 | * 控制层。 21 | * 22 | * @author wwtg99 23 | */ 24 | @RestController 25 | @RequireStaff 26 | @RestPermissionPrefix(group = "system", name = "param") 27 | @RequestMapping("/system/param") 28 | @EnableApi(ControllerApiGroup.FULL) 29 | public class SysParamController extends RestfulApiController { 30 | @Override 31 | public SortFilter[] configDefaultSort() { 32 | return new SortFilter[] {new SortFilter(FieldConstants.UPDATED_TIME, false)}; 33 | } 34 | 35 | @Override 36 | public String[] configSearchableFields() { 37 | return new String[] { 38 | SysParamTableDef.SYS_PARAM.NAME.getName(), 39 | SysParamTableDef.SYS_PARAM.PARAM_GROUP.getName(), 40 | SysParamTableDef.SYS_PARAM.PARAM_KEY.getName() 41 | }; 42 | } 43 | 44 | @NonNull 45 | @Override 46 | public SearchStrategy configSearchStrategy() { 47 | return SearchStrategy.BOTH_LIKE; 48 | } 49 | 50 | @Override 51 | public ParamFilterDefinition configParamFilterDefinition() { 52 | return ParamFilterDefinition.newInstance() 53 | .addFilter("name") 54 | .addFilter("paramGroup") 55 | .addFilter("paramKey"); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysFrontendServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.spring.service.impl.ServiceImpl; 4 | import com.wangboot.core.auth.frontend.IFrontendModel; 5 | import com.wangboot.core.cache.CacheUtil; 6 | import com.wangboot.system.entity.SysFrontend; 7 | import com.wangboot.system.entity.table.SysFrontendTableDef; 8 | import com.wangboot.system.mapper.SysFrontendMapper; 9 | import com.wangboot.system.service.SysFrontendService; 10 | import java.util.Collections; 11 | import java.util.List; 12 | import java.util.Objects; 13 | import org.springframework.lang.NonNull; 14 | import org.springframework.lang.Nullable; 15 | import org.springframework.stereotype.Service; 16 | 17 | /** 18 | * 服务层实现。 19 | * 20 | * @author wwtg99 21 | */ 22 | @Service 23 | public class SysFrontendServiceImpl extends ServiceImpl 24 | implements SysFrontendService { 25 | 26 | private static final String CACHE_PREFIX = "frontend_cache_"; 27 | 28 | /** 缓存10秒 */ 29 | private static final long CACHE_TTL = 10000; 30 | 31 | @Override 32 | @Nullable 33 | public IFrontendModel getFrontendModelById(String id) { 34 | return CacheUtil.getOrSet( 35 | CACHE_PREFIX + id, IFrontendModel.class, CACHE_TTL, () -> getById(id)); 36 | } 37 | 38 | @Override 39 | @Nullable 40 | public IFrontendModel getFrontendModelByName(String name) { 41 | return CacheUtil.getOrSet( 42 | CACHE_PREFIX + name, 43 | IFrontendModel.class, 44 | CACHE_TTL, 45 | () -> getOne(query().where(SysFrontendTableDef.SYS_FRONTEND.NAME.eq(name)))); 46 | } 47 | 48 | @Override 49 | @NonNull 50 | @SuppressWarnings("unchecked") 51 | public List getFrontendModelsByType(String type) { 52 | List lists = 53 | CacheUtil.getOrSet( 54 | CACHE_PREFIX + type, 55 | List.class, 56 | CACHE_TTL, 57 | () -> list(query().where(SysFrontendTableDef.SYS_FRONTEND.CLIENT_TYPE.eq(type)))); 58 | if (Objects.nonNull(lists)) { 59 | return lists; 60 | } 61 | return Collections.emptyList(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/command/CreateUser.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.command; 2 | 3 | import com.wangboot.framework.command.IBaseCommand; 4 | import com.wangboot.model.entity.exception.CreateFailedException; 5 | import com.wangboot.system.entity.SysUser; 6 | import com.wangboot.system.service.SysUserService; 7 | import lombok.RequiredArgsConstructor; 8 | import org.springframework.boot.ApplicationArguments; 9 | import org.springframework.security.crypto.password.PasswordEncoder; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * 创建用户
14 | * 执行命令: --create-user --username= --password= --superuser --staff 15 | * 16 | * @author wwtg99 17 | */ 18 | @Component 19 | @RequiredArgsConstructor 20 | public class CreateUser implements IBaseCommand { 21 | 22 | private final PasswordEncoder passwordEncoder; 23 | 24 | private final SysUserService userService; 25 | 26 | @Override 27 | public void callCommand(ApplicationArguments args) { 28 | if (!args.containsOption("username")) { 29 | throw new IllegalArgumentException("No username provided!"); 30 | } 31 | if (!args.containsOption("password")) { 32 | throw new IllegalArgumentException("No password provided!"); 33 | } 34 | String username = args.getOptionValues("username").get(0); 35 | String password = args.getOptionValues("password").get(0); 36 | boolean superuser = args.containsOption("superuser"); 37 | boolean staff = args.containsOption("staff"); 38 | SysUser user = new SysUser(); 39 | user.setUsername(username); 40 | user.setPassword(passwordEncoder.encode(password)); 41 | user.setSuperuser(superuser); 42 | user.setStaff(staff); 43 | user.setNickname(username); 44 | user.setActive(true); 45 | boolean ret = userService.createResource(user); 46 | if (!ret) { 47 | throw new CreateFailedException(); 48 | } else { 49 | this.println("Create user {}", username); 50 | } 51 | } 52 | 53 | @Override 54 | public boolean whetherToRun(ApplicationArguments args) { 55 | return args.containsOption("create-user"); 56 | } 57 | 58 | @Override 59 | public boolean exitAfterCompletion() { 60 | return true; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/execution/render/text/FreeMarkerTemplateRender.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.execution.render.text; 2 | 3 | import com.wangboot.app.execution.RenderErrorCode; 4 | import com.wangboot.app.execution.render.BaseTemplateRender; 5 | import com.wangboot.app.execution.render.RenderContext; 6 | import com.wangboot.app.template.entity.TplTemplate; 7 | import com.wangboot.core.errorcode.ErrorCodeException; 8 | import freemarker.cache.ByteArrayTemplateLoader; 9 | import freemarker.template.Configuration; 10 | import freemarker.template.TemplateException; 11 | import java.io.IOException; 12 | import java.io.OutputStream; 13 | import java.io.OutputStreamWriter; 14 | import java.nio.charset.Charset; 15 | import lombok.Getter; 16 | import lombok.extern.slf4j.Slf4j; 17 | 18 | @Slf4j 19 | public class FreeMarkerTemplateRender extends BaseTemplateRender { 20 | 21 | public static final String DEFAULT_ENCODING = "UTF-8"; 22 | private static final String TEMPLATE_NAME = "template"; 23 | private static final String CONTENT_TYPE = "text/plain"; 24 | 25 | private final Configuration configuration; 26 | 27 | private final ByteArrayTemplateLoader templateLoader; 28 | 29 | @Getter private TplTemplate template; 30 | 31 | public FreeMarkerTemplateRender() { 32 | this.configuration = new Configuration(Configuration.VERSION_2_3_32); 33 | this.configuration.setDefaultEncoding(DEFAULT_ENCODING); 34 | this.templateLoader = new ByteArrayTemplateLoader(); 35 | this.configuration.setTemplateLoader(this.templateLoader); 36 | } 37 | 38 | @Override 39 | public String getContentType() { 40 | return CONTENT_TYPE; 41 | } 42 | 43 | @Override 44 | public void renderAndOutput(RenderContext context, OutputStream outputStream) throws IOException { 45 | this.templateLoader.putTemplate(TEMPLATE_NAME, this.getTemplateBytes()); 46 | try (OutputStreamWriter writer = 47 | new OutputStreamWriter(outputStream, Charset.forName(DEFAULT_ENCODING))) { 48 | this.configuration.getTemplate(TEMPLATE_NAME).process(context, writer); 49 | writer.flush(); 50 | } catch (TemplateException e) { 51 | log.error(e.getMessage()); 52 | throw new ErrorCodeException(RenderErrorCode.INVALID_TEMPLATE); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysOperationLogController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.core.auth.annotation.RequireStaff; 4 | import com.wangboot.core.auth.annotation.RestPermissionPrefix; 5 | import com.wangboot.model.entity.FieldConstants; 6 | import com.wangboot.model.entity.controller.ControllerApiGroup; 7 | import com.wangboot.model.entity.controller.EnableApi; 8 | import com.wangboot.model.entity.controller.RestfulApiController; 9 | import com.wangboot.model.entity.request.*; 10 | import com.wangboot.system.entity.SysOperationLog; 11 | import com.wangboot.system.entity.table.SysOperationLogTableDef; 12 | import com.wangboot.system.service.SysOperationLogService; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | @RestController 17 | @RequireStaff 18 | @RestPermissionPrefix(group = "log", name = "operation_log") 19 | @RequestMapping("/log/operation_log") 20 | @EnableApi(ControllerApiGroup.READ_ONLY) 21 | public class SysOperationLogController 22 | extends RestfulApiController { 23 | 24 | @Override 25 | public SortFilter[] configDefaultSort() { 26 | return new SortFilter[] { 27 | new SortFilter(FieldConstants.CREATED_TIME, false), 28 | }; 29 | } 30 | 31 | @Override 32 | public String[] configSearchableFields() { 33 | return new String[] { 34 | SysOperationLogTableDef.SYS_OPERATION_LOG.EVENT.getName(), 35 | SysOperationLogTableDef.SYS_OPERATION_LOG.RESOURCE.getName() 36 | }; 37 | } 38 | 39 | @Override 40 | public ParamFilterDefinition configParamFilterDefinition() { 41 | return ParamFilterDefinition.newInstance() 42 | .addFilter("event") 43 | .addFilter("resource") 44 | .addFilter("resourceId") 45 | .addFilter("username") 46 | .addFilter(FieldConstants.CREATED_BY_CAMEL) 47 | .addFilter( 48 | "start", 49 | new FieldFilter(FieldConstants.CREATED_TIME, FilterOperator.GE, ParamValType.DATE)) 50 | .addFilter( 51 | "end", 52 | new FieldFilter(FieldConstants.CREATED_TIME, FilterOperator.LE, ParamValType.DATE)); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/wangboot/app/template/entity/TplTemplate.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app.template.entity; 2 | 3 | import cn.hutool.core.bean.BeanUtil; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import com.mybatisflex.annotation.Id; 6 | import com.mybatisflex.annotation.KeyType; 7 | import com.mybatisflex.annotation.Table; 8 | import com.mybatisflex.core.keygen.KeyGenerators; 9 | import com.wangboot.model.attachment.IAttachmentListRelatedModel; 10 | import com.wangboot.model.attachment.IAttachmentModel; 11 | import com.wangboot.model.entity.event.EnableOperationLog; 12 | import com.wangboot.model.entity.impl.CommonEntity; 13 | import com.wangboot.system.entity.vo.AttachmentVo; 14 | import com.wangboot.system.listener.EntityChangeListener; 15 | import java.util.List; 16 | import java.util.stream.Collectors; 17 | import javax.validation.constraints.NotBlank; 18 | import javax.validation.constraints.Size; 19 | import lombok.AllArgsConstructor; 20 | import lombok.Data; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.NoArgsConstructor; 23 | 24 | @Data 25 | @EqualsAndHashCode(callSuper = false) 26 | @NoArgsConstructor 27 | @AllArgsConstructor 28 | @EnableOperationLog 29 | @Table( 30 | value = "wb_template_template", 31 | onInsert = EntityChangeListener.class, 32 | onUpdate = EntityChangeListener.class) 33 | public class TplTemplate extends CommonEntity implements IAttachmentListRelatedModel { 34 | 35 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 36 | private String id; 37 | 38 | @NotBlank(message = "message.name_not_blank") 39 | @Size(max = 100) 40 | private String name; 41 | 42 | @NotBlank(message = "message.type_not_blank") 43 | @Size(max = 100) 44 | private String type; 45 | 46 | @Size(max = 200) 47 | private String defFilename = ""; 48 | 49 | private List attachments; 50 | 51 | @JsonIgnore 52 | @Override 53 | public List getAttachmentList() { 54 | return this.attachments; 55 | } 56 | 57 | @Override 58 | public void setAttachmentList(List attachments) { 59 | this.attachments = 60 | attachments.stream() 61 | .map(d -> BeanUtil.copyProperties(d, AttachmentVo.class)) 62 | .collect(Collectors.toList()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysUserDictController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.core.auth.annotation.RequireStaff; 4 | import com.wangboot.core.auth.annotation.RestPermissionPrefix; 5 | import com.wangboot.model.entity.controller.ControllerApiGroup; 6 | import com.wangboot.model.entity.controller.EnableApi; 7 | import com.wangboot.model.entity.controller.RestfulApiController; 8 | import com.wangboot.model.entity.request.ParamFilterDefinition; 9 | import com.wangboot.model.entity.request.SearchStrategy; 10 | import com.wangboot.model.entity.request.SortFilter; 11 | import com.wangboot.system.entity.SysUserDict; 12 | import com.wangboot.system.entity.table.SysUserDictTableDef; 13 | import com.wangboot.system.service.SysUserDictService; 14 | import org.springframework.lang.NonNull; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | /** 19 | * 控制层。 20 | * 21 | * @author wwtg99 22 | */ 23 | @RestController 24 | @RequireStaff 25 | @RestPermissionPrefix(group = "system", name = "user_dict") 26 | @RequestMapping("/system/user_dict") 27 | @EnableApi(ControllerApiGroup.FULL) 28 | public class SysUserDictController 29 | extends RestfulApiController { 30 | 31 | @Override 32 | public SortFilter[] configDefaultSort() { 33 | return new SortFilter[] { 34 | new SortFilter(SysUserDictTableDef.SYS_USER_DICT.DICT_GROUP.getName()), 35 | new SortFilter(SysUserDictTableDef.SYS_USER_DICT.SORT.getName()) 36 | }; 37 | } 38 | 39 | @Override 40 | public String[] configSearchableFields() { 41 | return new String[] { 42 | SysUserDictTableDef.SYS_USER_DICT.NAME.getName(), 43 | SysUserDictTableDef.SYS_USER_DICT.DICT_GROUP.getName(), 44 | SysUserDictTableDef.SYS_USER_DICT.DICT_CODE.getName() 45 | }; 46 | } 47 | 48 | @NonNull 49 | @Override 50 | public SearchStrategy configSearchStrategy() { 51 | return SearchStrategy.BOTH_LIKE; 52 | } 53 | 54 | @Override 55 | public ParamFilterDefinition configParamFilterDefinition() { 56 | return ParamFilterDefinition.newInstance() 57 | .addFilter("name") 58 | .addFilter("dictGroup") 59 | .addFilter("dictCode"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysDepartmentController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.core.auth.annotation.RequireStaff; 4 | import com.wangboot.core.auth.annotation.RestPermissionPrefix; 5 | import com.wangboot.model.entity.FieldConstants; 6 | import com.wangboot.model.entity.controller.ControllerApi; 7 | import com.wangboot.model.entity.controller.ControllerApiGroup; 8 | import com.wangboot.model.entity.controller.EnableApi; 9 | import com.wangboot.model.entity.controller.RestfulApiController; 10 | import com.wangboot.model.entity.request.ParamFilterDefinition; 11 | import com.wangboot.model.entity.request.SearchStrategy; 12 | import com.wangboot.model.entity.request.SortFilter; 13 | import com.wangboot.system.entity.SysDepartment; 14 | import com.wangboot.system.entity.table.SysDepartmentTableDef; 15 | import com.wangboot.system.service.SysDepartmentService; 16 | import org.springframework.lang.NonNull; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | /** 21 | * 控制层。 22 | * 23 | * @author wwtg99 24 | */ 25 | @RestController 26 | @RequireStaff 27 | @RestPermissionPrefix(group = "system", name = "department") 28 | @RequestMapping("/system/department") 29 | @EnableApi( 30 | value = ControllerApiGroup.TREE_FULL, 31 | excludes = {ControllerApi.BATCH_REMOVE}) 32 | public class SysDepartmentController 33 | extends RestfulApiController { 34 | 35 | @Override 36 | public SortFilter[] configDefaultSort() { 37 | return new SortFilter[] {new SortFilter(FieldConstants.UPDATED_TIME, false)}; 38 | } 39 | 40 | @Override 41 | public String[] configSearchableFields() { 42 | return new String[] { 43 | SysDepartmentTableDef.SYS_DEPARTMENT.NAME.getName(), 44 | SysDepartmentTableDef.SYS_DEPARTMENT.FULLNAME.getName() 45 | }; 46 | } 47 | 48 | @NonNull 49 | @Override 50 | public SearchStrategy configSearchStrategy() { 51 | return SearchStrategy.BOTH_LIKE; 52 | } 53 | 54 | @Override 55 | public ParamFilterDefinition configParamFilterDefinition() { 56 | return ParamFilterDefinition.newInstance() 57 | .addFilter("name") 58 | .addFilter(FieldConstants.PARENT_ID_CAMEL); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysBgTask.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import cn.hutool.core.bean.BeanUtil; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import com.mybatisflex.annotation.Column; 6 | import com.mybatisflex.annotation.Id; 7 | import com.mybatisflex.annotation.KeyType; 8 | import com.mybatisflex.annotation.Table; 9 | import com.mybatisflex.core.keygen.KeyGenerators; 10 | import com.wangboot.model.attachment.IAttachmentListRelatedModel; 11 | import com.wangboot.model.attachment.IAttachmentModel; 12 | import com.wangboot.model.dataauthority.DataAuthority; 13 | import com.wangboot.model.dataauthority.factory.UserIdAuthorizerFactory; 14 | import com.wangboot.model.entity.impl.CommonEntity; 15 | import com.wangboot.system.entity.vo.AttachmentVo; 16 | import com.wangboot.system.listener.EntityChangeListener; 17 | import com.wangboot.system.model.BgTaskStatus; 18 | import java.util.List; 19 | import java.util.stream.Collectors; 20 | import lombok.AllArgsConstructor; 21 | import lombok.Data; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.NoArgsConstructor; 24 | 25 | @Data 26 | @EqualsAndHashCode(callSuper = false) 27 | @NoArgsConstructor 28 | @AllArgsConstructor 29 | @DataAuthority(field = "created_by", factory = UserIdAuthorizerFactory.class) 30 | @Table( 31 | value = "wb_sys_bg_task", 32 | onInsert = EntityChangeListener.class, 33 | onUpdate = EntityChangeListener.class) 34 | public class SysBgTask extends CommonEntity implements IAttachmentListRelatedModel { 35 | 36 | @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId) 37 | private String id; 38 | 39 | private String name; 40 | 41 | private String type; 42 | 43 | private BgTaskStatus status = BgTaskStatus.PENDING; 44 | 45 | private String result = ""; 46 | 47 | @Column(ignore = true) 48 | private List attachments; 49 | 50 | @JsonIgnore 51 | @Override 52 | public List getAttachmentList() { 53 | return this.attachments; 54 | } 55 | 56 | @Override 57 | public void setAttachmentList(List attachments) { 58 | this.attachments = 59 | attachments.stream() 60 | .map(d -> BeanUtil.copyProperties(d, AttachmentVo.class)) 61 | .collect(Collectors.toList()); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/attachment/EasyBytesExporter.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.attachment; // package com.wangboot.system.attachment; 2 | // 3 | // import cn.hutool.core.bean.BeanUtil; 4 | // import cn.hutool.core.date.DateUtil; 5 | // import com.alibaba.excel.EasyExcel; 6 | // import com.wangboot.model.attachment.IAttachmentModel; 7 | // import com.wangboot.model.attachment.IExcelExporter; 8 | // import com.wangboot.system.entity.vo.AttachmentVo; 9 | // import java.io.ByteArrayInputStream; 10 | // import java.io.ByteArrayOutputStream; 11 | // import java.io.IOException; 12 | // import java.util.Collection; 13 | // import java.util.function.Supplier; 14 | // import lombok.RequiredArgsConstructor; 15 | // import org.dromara.x.file.storage.core.FileInfo; 16 | // import org.dromara.x.file.storage.core.FileStorageService; 17 | // import org.springframework.lang.NonNull; 18 | // import org.springframework.stereotype.Component; 19 | // 20 | /// ** 21 | // * 基于内存的简单导出服务 22 | // * 23 | // * @author wwtg99 24 | // */ 25 | // @Component 26 | // @RequiredArgsConstructor 27 | // public class EasyBytesExporter implements IExcelExporter { 28 | // 29 | // public static final String XLSX_CONTENT_TYPE = 30 | // "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; 31 | // 32 | // private final FileStorageService fileStorageService; 33 | // 34 | // @Override 35 | // @NonNull 36 | // public IAttachmentModel export( 37 | // String filename, 38 | // @NonNull Class entityClass, 39 | // @NonNull Supplier> supplier, 40 | // String sheetName) 41 | // throws IOException { 42 | // ByteArrayOutputStream bos = new ByteArrayOutputStream(); 43 | // EasyExcel.write(bos, entityClass).sheet(sheetName).doWrite(supplier.get()); 44 | // bos.flush(); 45 | // ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); 46 | // FileInfo fileInfo = 47 | // this.fileStorageService 48 | // .of(bis) 49 | // .setOriginalFilename(filename) 50 | // .setContentType(XLSX_CONTENT_TYPE) 51 | // .setObjectType(entityClass.getName()) 52 | // .setPath(DateUtil.today() + "/exports/") 53 | // .setHashCalculatorMd5() 54 | // .upload(); 55 | // return BeanUtil.copyProperties(fileInfo, AttachmentVo.class); 56 | // } 57 | // } 58 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysParam.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.model.entity.IUniqueEntity; 9 | import com.wangboot.model.entity.IdEntity; 10 | import com.wangboot.model.entity.event.EnableOperationLog; 11 | import com.wangboot.model.entity.impl.CommonEntity; 12 | import com.wangboot.system.entity.table.SysParamTableDef; 13 | import com.wangboot.system.listener.EntityChangeListener; 14 | import com.wangboot.system.model.ParamType; 15 | import javax.validation.constraints.NotBlank; 16 | import javax.validation.constraints.Size; 17 | import lombok.AllArgsConstructor; 18 | import lombok.Data; 19 | import lombok.EqualsAndHashCode; 20 | import lombok.NoArgsConstructor; 21 | 22 | /** 23 | * 实体类。 24 | * 25 | * @author wwtg99 26 | */ 27 | @Data 28 | @EqualsAndHashCode(callSuper = false) 29 | @NoArgsConstructor 30 | @AllArgsConstructor 31 | @EnableOperationLog 32 | @Table( 33 | value = "wb_sys_param", 34 | onInsert = EntityChangeListener.class, 35 | onUpdate = EntityChangeListener.class) 36 | public class SysParam extends CommonEntity implements IdEntity, IUniqueEntity { 37 | 38 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 39 | private String id; 40 | 41 | @NotBlank(message = "message.name_not_blank") 42 | @Size(max = 90) 43 | private String name; 44 | 45 | @Size(max = 90) 46 | private String paramGroup = ""; 47 | 48 | @NotBlank(message = "message.key_not_blank") 49 | @Size(max = 90) 50 | private String paramKey; 51 | 52 | private String paramVal; 53 | 54 | private ParamType paramType = ParamType.STR; 55 | 56 | public SysParam( 57 | String id, 58 | String name, 59 | String paramGroup, 60 | String paramKey, 61 | String paramVal, 62 | ParamType paramType, 63 | String remark) { 64 | this(id, name, paramGroup, paramKey, paramVal, paramType); 65 | this.setRemark(remark); 66 | } 67 | 68 | @Override 69 | @JsonIgnore 70 | public String[][] getUniqueTogetherFields() { 71 | return new String[][] {{SysParamTableDef.SYS_PARAM.PARAM_KEY.getName()}}; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/controller/SysUserLogController.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.controller; 2 | 3 | import com.wangboot.core.auth.annotation.RequireStaff; 4 | import com.wangboot.core.auth.annotation.RestPermissionPrefix; 5 | import com.wangboot.model.entity.FieldConstants; 6 | import com.wangboot.model.entity.controller.ControllerApiGroup; 7 | import com.wangboot.model.entity.controller.EnableApi; 8 | import com.wangboot.model.entity.controller.RestfulApiController; 9 | import com.wangboot.model.entity.request.*; 10 | import com.wangboot.system.entity.SysUserLog; 11 | import com.wangboot.system.entity.table.SysUserLogTableDef; 12 | import com.wangboot.system.service.SysUserLogService; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | @RestController 17 | @RequireStaff 18 | @RestPermissionPrefix(group = "log", name = "user_log") 19 | @RequestMapping("/log/user_log") 20 | @EnableApi(ControllerApiGroup.READ_ONLY) 21 | public class SysUserLogController 22 | extends RestfulApiController { 23 | @Override 24 | public SortFilter[] configDefaultSort() { 25 | return new SortFilter[] { 26 | new SortFilter(FieldConstants.CREATED_TIME, false), 27 | }; 28 | } 29 | 30 | @Override 31 | public String[] configSearchableFields() { 32 | return new String[] {SysUserLogTableDef.SYS_USER_LOG.EVENT.getName()}; 33 | } 34 | 35 | @Override 36 | public ParamFilterDefinition configParamFilterDefinition() { 37 | return ParamFilterDefinition.newInstance() 38 | .addFilter("event") 39 | .addFilter("status") 40 | .addFilter("userId") 41 | .addFilter("username") 42 | .addFilter("frontendId") 43 | .addFilter( 44 | "frontendName", 45 | new FieldFilter( 46 | SysUserLogTableDef.SYS_USER_LOG.FRONTEND_NAME.getName(), 47 | FilterOperator.CONTAINS, 48 | ParamValType.STR)) 49 | .addFilter("ip") 50 | .addFilter( 51 | "start", 52 | new FieldFilter(FieldConstants.CREATED_TIME, FilterOperator.GE, ParamValType.DATE)) 53 | .addFilter( 54 | "end", 55 | new FieldFilter(FieldConstants.CREATED_TIME, FilterOperator.LE, ParamValType.DATE)); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysUserDict.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.model.entity.IUniqueEntity; 9 | import com.wangboot.model.entity.IdEntity; 10 | import com.wangboot.model.entity.event.EnableOperationLog; 11 | import com.wangboot.model.entity.impl.CommonEntity; 12 | import com.wangboot.system.entity.table.SysUserDictTableDef; 13 | import com.wangboot.system.listener.EntityChangeListener; 14 | import com.wangboot.system.model.ParamType; 15 | import javax.validation.constraints.Max; 16 | import javax.validation.constraints.Min; 17 | import javax.validation.constraints.NotBlank; 18 | import javax.validation.constraints.Size; 19 | import lombok.AllArgsConstructor; 20 | import lombok.Data; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.NoArgsConstructor; 23 | 24 | /** 25 | * 实体类。 26 | * 27 | * @author wwtg99 28 | */ 29 | @Data 30 | @EqualsAndHashCode(callSuper = false) 31 | @NoArgsConstructor 32 | @AllArgsConstructor 33 | @EnableOperationLog 34 | @Table( 35 | value = "wb_sys_user_dict", 36 | onInsert = EntityChangeListener.class, 37 | onUpdate = EntityChangeListener.class) 38 | public class SysUserDict extends CommonEntity implements IdEntity, IUniqueEntity { 39 | 40 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 41 | private String id; 42 | 43 | @NotBlank(message = "message.name_not_blank") 44 | @Size(max = 90) 45 | private String name; 46 | 47 | @NotBlank(message = "message.group_not_blank") 48 | @Size(max = 90) 49 | private String dictGroup; 50 | 51 | @NotBlank(message = "message.code_not_blank") 52 | @Size(max = 90) 53 | private String dictCode; 54 | 55 | private String dictVal; 56 | 57 | private ParamType dictType = ParamType.STR; 58 | 59 | @Max(10000) 60 | @Min(-10000) 61 | private Integer sort = 0; 62 | 63 | @Override 64 | @JsonIgnore 65 | public String[][] getUniqueTogetherFields() { 66 | return new String[][] { 67 | { 68 | SysUserDictTableDef.SYS_USER_DICT.DICT_GROUP.getName(), 69 | SysUserDictTableDef.SYS_USER_DICT.DICT_CODE.getName() 70 | } 71 | }; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /report/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | wang-template-backend 7 | wang.52jing 8 | ${revision} 9 | 10 | 4.0.0 11 | 12 | report 13 | 14 | report 15 | 单元测试报告 16 | 17 | pom 18 | 19 | 20 | 21 | wang.52jing 22 | framework 23 | ${project.parent.version} 24 | 25 | 26 | wang.52jing 27 | system 28 | ${project.parent.version} 29 | 30 | 31 | wang.52jing 32 | task 33 | ${project.parent.version} 34 | 35 | 36 | wang.52jing 37 | app 38 | ${project.parent.version} 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.jacoco 46 | jacoco-maven-plugin 47 | 48 | 49 | jacoco-report-aggregate 50 | test 51 | 52 | report-aggregate 53 | 54 | 55 | target/test-report 56 |
WangBoot
57 |
58 |
59 |
60 |
61 |
62 |
63 | 64 |
-------------------------------------------------------------------------------- /app/src/main/resources/i18n/messages_zh_CN.properties: -------------------------------------------------------------------------------- 1 | # Http错误 2 | ok=成功 3 | bad_request=错误的请求! 4 | unauthorized=未授权访问! 5 | payment_required=需要支付! 6 | forbidden=禁止访问! 7 | not_found=未找到资源! 8 | method_not_allowed=方法被禁用! 9 | not_acceptable=不接受访问! 10 | proxy_authentication_required=需要代理授权! 11 | request_timeout=请求超时! 12 | too_many_requests=请求太频繁,请稍后再试! 13 | internal_server_error=服务器内部错误! 14 | not_implemented=尚未实现! 15 | bad_gateway=网关错误! 16 | service_unavailable=服务不可用! 17 | gateway_timeout=网关超时! 18 | # 认证错误 19 | error.captcha_mismatch=验证码错误! 20 | error.expired_account=账户{0}已超期! 21 | error.invalid_account=无效的账户{0}! 22 | error.invalid_token=令牌无效! 23 | error.login_kicked_out=用户已在其他地方登录! 24 | error.locked_account=账户{0}已锁定! 25 | error.login_failed=登录失败! 26 | error.user_login_locked=账户{0}被登录锁定! 27 | error.logout_failed=注销失败! 28 | error.non_exist_frontend=前端{0}不存在! 29 | error.refresh_token_failed=刷新令牌失败! 30 | error.captcha_error=验证码错误! 31 | error.register_failed=注册失败! 32 | error.pwd_change_failed=密码更新失败! 33 | error.pwd_check_failed=不符合要求的密码策略! 34 | error.duplicated_username=用户名已存在! 35 | # 文件错误 36 | error.file_exceed_max_size=文件超过大小限制! 37 | error.upload_failed=上传失败! 38 | error.not_allowed_format=不允许的格式! 39 | error.export_failed=导出失败! 40 | # 数据和校验错误 41 | error.create_failed=创建失败! 42 | error.update_failed=更新失败{0}! 43 | error.delete_failed=删除失败{0}! 44 | error.delete_cascade_failed=存在子元素或关联元素,无法删除{0}! 45 | error.duplicated_record=数据重复! 46 | # 渲染错误 47 | error.invalid_template=无效的模板! 48 | error.invalid_datasource=无效的数据源! 49 | error.invalid_datasource_config=数据源配置错误! 50 | error.param_is_required=数据源参数{0}没有提供! 51 | error.render_failed=渲染错误! 52 | error.retrieve_empty_data=数据源获取数据为空! 53 | error.connect_datasource_failed=连接数据源失败! 54 | # 其他错误 55 | error.crypto_error=加密错误! 56 | error.in_maintenance=维护中...{0} 57 | error.analysis_not_enabled=分析模块未启用! 58 | error.analysis_failed=分析失败! 59 | # 数据校验及消息 60 | message.username_not_blank=用户名不能为空! 61 | message.name_not_blank=名称不能为空! 62 | message.type_not_blank=类型不能为空! 63 | message.label_not_blank=标签不能为空! 64 | message.group_not_blank=分组不能为空! 65 | message.key_not_blank=键不能为空! 66 | message.code_not_blank=代码不能为空! 67 | message.pwd_not_blank=密码不能为空! 68 | message.ids_not_empty=ID 列表不能为空! 69 | message.relation_not_empty=关联键不能为空! 70 | message.invalid_email=错误的邮箱! 71 | message.invalid_telephone_format=错误的手机号码格式! 72 | message.invalid_idcard_format=错误的身份证号格式! 73 | message.created=创建成功! 74 | message.updated=更新成功! 75 | message.deleted=删除成功! 76 | message.attachment_not_empty=附件不能为空! 77 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysAnnouncement.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import cn.hutool.core.bean.BeanUtil; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import com.mybatisflex.annotation.Column; 6 | import com.mybatisflex.annotation.Id; 7 | import com.mybatisflex.annotation.KeyType; 8 | import com.mybatisflex.annotation.Table; 9 | import com.mybatisflex.core.keygen.KeyGenerators; 10 | import com.wangboot.model.attachment.IAttachmentListRelatedModel; 11 | import com.wangboot.model.attachment.IAttachmentModel; 12 | import com.wangboot.model.entity.event.EnableOperationLog; 13 | import com.wangboot.model.entity.impl.CommonEntity; 14 | import com.wangboot.system.entity.vo.AttachmentVo; 15 | import com.wangboot.system.listener.EntityChangeListener; 16 | import com.wangboot.system.model.AnnouncementType; 17 | import java.util.List; 18 | import java.util.stream.Collectors; 19 | import javax.validation.constraints.Max; 20 | import javax.validation.constraints.Min; 21 | import javax.validation.constraints.Size; 22 | import lombok.AllArgsConstructor; 23 | import lombok.Data; 24 | import lombok.EqualsAndHashCode; 25 | import lombok.NoArgsConstructor; 26 | 27 | /** 28 | * 实体类。 29 | * 30 | * @author wwtg99 31 | */ 32 | @Data 33 | @EqualsAndHashCode( 34 | callSuper = false, 35 | exclude = {"attachments"}) 36 | @NoArgsConstructor 37 | @AllArgsConstructor 38 | @EnableOperationLog 39 | @Table( 40 | value = "wb_sys_announcement", 41 | onInsert = EntityChangeListener.class, 42 | onUpdate = EntityChangeListener.class) 43 | public class SysAnnouncement extends CommonEntity implements IAttachmentListRelatedModel { 44 | 45 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 46 | private String id; 47 | 48 | @Size(min = 3, max = 200) 49 | private String title = ""; 50 | 51 | private String content = ""; 52 | 53 | private AnnouncementType type = AnnouncementType.NORMAL; 54 | 55 | private Boolean display = true; 56 | 57 | @Max(10000) 58 | @Min(-10000) 59 | private Integer sort = 0; 60 | 61 | @Column(ignore = true) 62 | private List attachments; 63 | 64 | @JsonIgnore 65 | @Override 66 | public List getAttachmentList() { 67 | return this.attachments; 68 | } 69 | 70 | @Override 71 | public void setAttachmentList(List attachments) { 72 | this.attachments = 73 | attachments.stream() 74 | .map(d -> BeanUtil.copyProperties(d, AttachmentVo.class)) 75 | .collect(Collectors.toList()); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/service/impl/SysPermissionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.service.impl; 2 | 3 | import com.mybatisflex.core.query.QueryWrapper; 4 | import com.mybatisflex.spring.service.impl.ServiceImpl; 5 | import com.wangboot.model.entity.IdEntity; 6 | import com.wangboot.model.entity.exception.DeleteCascadeFailedException; 7 | import com.wangboot.system.entity.SysPermission; 8 | import com.wangboot.system.entity.relation.table.SysPolicyPermissionRelTableDef; 9 | import com.wangboot.system.mapper.SysPermissionMapper; 10 | import com.wangboot.system.service.SysPermissionService; 11 | import com.wangboot.system.service.SysPolicyPermissionRelService; 12 | import java.util.Collection; 13 | import java.util.stream.Collectors; 14 | import lombok.RequiredArgsConstructor; 15 | import org.springframework.lang.NonNull; 16 | import org.springframework.stereotype.Service; 17 | 18 | /** 19 | * 服务层实现。 20 | * 21 | * @author wwtg99 22 | */ 23 | @Service 24 | @RequiredArgsConstructor 25 | public class SysPermissionServiceImpl extends ServiceImpl 26 | implements SysPermissionService { 27 | 28 | private final SysPolicyPermissionRelService policyPermissionRelService; 29 | 30 | @Override 31 | @NonNull 32 | public SysPermission checkBeforeDeleteObject(@NonNull SysPermission entity) { 33 | entity = SysPermissionService.super.checkBeforeDeleteObject(entity); 34 | // 存在关联策略,则不允许删除 35 | QueryWrapper wrapper = 36 | policyPermissionRelService 37 | .query() 38 | .where( 39 | SysPolicyPermissionRelTableDef.SYS_POLICY_PERMISSION_REL.PERMISSION_ID.eq( 40 | entity.getId())); 41 | if (policyPermissionRelService.count(wrapper) > 0) { 42 | throw new DeleteCascadeFailedException(entity.getId()); 43 | } 44 | return entity; 45 | } 46 | 47 | @Override 48 | @NonNull 49 | public Collection checkBeforeBatchDeleteObjects( 50 | @NonNull Collection entities) { 51 | entities = SysPermissionService.super.checkBeforeBatchDeleteObjects(entities); 52 | // 存在关联策略,则不允许删除 53 | Collection ids = entities.stream().map(IdEntity::getId).collect(Collectors.toList()); 54 | QueryWrapper wrapper = 55 | policyPermissionRelService 56 | .query() 57 | .where(SysPolicyPermissionRelTableDef.SYS_POLICY_PERMISSION_REL.PERMISSION_ID.in(ids)); 58 | if (policyPermissionRelService.count(wrapper) > 0) { 59 | throw new DeleteCascadeFailedException(String.join(",", ids)); 60 | } 61 | return entities; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /system/src/main/java/com/wangboot/system/entity/SysFrontend.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.system.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.mybatisflex.annotation.Id; 5 | import com.mybatisflex.annotation.KeyType; 6 | import com.mybatisflex.annotation.Table; 7 | import com.mybatisflex.core.keygen.KeyGenerators; 8 | import com.wangboot.core.auth.frontend.IFrontendModel; 9 | import com.wangboot.model.entity.IUniqueEntity; 10 | import com.wangboot.model.entity.IdEntity; 11 | import com.wangboot.model.entity.event.EnableOperationLog; 12 | import com.wangboot.model.entity.impl.CommonEntity; 13 | import com.wangboot.system.entity.table.SysFrontendTableDef; 14 | import com.wangboot.system.listener.EntityChangeListener; 15 | import com.wangboot.system.model.ClientType; 16 | import java.util.Optional; 17 | import javax.validation.constraints.NotBlank; 18 | import javax.validation.constraints.NotNull; 19 | import javax.validation.constraints.Size; 20 | import lombok.AllArgsConstructor; 21 | import lombok.Data; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.NoArgsConstructor; 24 | 25 | /** 26 | * 实体类。 27 | * 28 | * @author wwtg99 29 | */ 30 | @Data 31 | @EqualsAndHashCode(callSuper = false) 32 | @NoArgsConstructor 33 | @AllArgsConstructor 34 | @EnableOperationLog 35 | @Table( 36 | value = "wb_sys_frontend", 37 | onInsert = EntityChangeListener.class, 38 | onUpdate = EntityChangeListener.class) 39 | public class SysFrontend extends CommonEntity 40 | implements IdEntity, IFrontendModel, IUniqueEntity { 41 | 42 | @Id(keyType = KeyType.Generator, value = KeyGenerators.uuid) 43 | private String id; 44 | 45 | @NotBlank(message = "message.name_not_blank") 46 | @Size(max = 90) 47 | private String name; 48 | 49 | private String description = ""; 50 | 51 | @Size(max = 90) 52 | private String author = ""; 53 | 54 | @Size(max = 200) 55 | private String domain = ""; 56 | 57 | @NotNull(message = "message.type_not_blank") 58 | private ClientType clientType; 59 | 60 | private Boolean allowRegister = false; 61 | 62 | private Boolean staffOnly = false; 63 | 64 | @Override 65 | public String getType() { 66 | return Optional.ofNullable(this.clientType).map(ClientType::getName).orElse(""); 67 | } 68 | 69 | @Override 70 | public boolean staffOnly() { 71 | return this.staffOnly; 72 | } 73 | 74 | @Override 75 | public boolean allowRegister() { 76 | return allowRegister; 77 | } 78 | 79 | @JsonIgnore 80 | @Override 81 | public String[][] getUniqueTogetherFields() { 82 | return new String[][] {{SysFrontendTableDef.SYS_FRONTEND.NAME.getName()}}; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/test/java/com/wangboot/app/TemplateTest.java: -------------------------------------------------------------------------------- 1 | package com.wangboot.app; 2 | 3 | import cn.hutool.core.io.FileUtil; 4 | import cn.hutool.core.io.resource.ResourceUtil; 5 | import cn.hutool.core.util.RandomUtil; 6 | import com.wangboot.app.execution.render.RenderContext; 7 | import com.wangboot.app.execution.render.text.FreeMarkerTemplateRender; 8 | import com.wangboot.app.execution.render.word.PoiWordTemplateRender; 9 | import java.io.File; 10 | import java.io.FileOutputStream; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | import lombok.SneakyThrows; 14 | import org.junit.jupiter.api.Assertions; 15 | import org.junit.jupiter.api.BeforeAll; 16 | import org.junit.jupiter.api.DisplayName; 17 | import org.junit.jupiter.api.Test; 18 | 19 | @DisplayName("模板测试") 20 | public class TemplateTest { 21 | 22 | @BeforeAll 23 | public static void beforeAll() { 24 | File tmpDir = new File("tmp"); 25 | if (!tmpDir.exists()) { 26 | FileUtil.mkdir(tmpDir); 27 | } 28 | } 29 | 30 | @Test 31 | @SneakyThrows 32 | public void testPoiWordTemplate() { 33 | String outName = "tmp/out.docx"; 34 | File outFile = new File(outName); 35 | if (FileUtil.exist(outFile)) { 36 | FileUtil.del(outFile); 37 | } 38 | String templateName = RandomUtil.randomString(6); 39 | PoiWordTemplateRender templateRender = new PoiWordTemplateRender(); 40 | byte[] bytes = ResourceUtil.readBytes("word.docx"); 41 | templateRender.setTemplate(templateName, bytes); 42 | RenderContext context = new RenderContext(); 43 | Map map = new HashMap<>(); 44 | map.put("title", "Wang"); 45 | context.setData(map); 46 | FileOutputStream outputStream = new FileOutputStream(outFile); 47 | templateRender.renderAndOutput(context, outputStream); 48 | Assertions.assertTrue(FileUtil.exist(outFile)); 49 | } 50 | 51 | @Test 52 | @SneakyThrows 53 | public void testFreeMarkerTemplateRender() { 54 | String outName = "tmp/out.md"; 55 | File outFile = new File(outName); 56 | if (FileUtil.exist(outFile)) { 57 | FileUtil.del(outFile); 58 | } 59 | String templateName = RandomUtil.randomString(6); 60 | FreeMarkerTemplateRender templateRender = new FreeMarkerTemplateRender(); 61 | byte[] bytes = ResourceUtil.readBytes("text.tpl"); 62 | templateRender.setTemplate(templateName, bytes); 63 | RenderContext context = new RenderContext(); 64 | Map map = new HashMap<>(); 65 | map.put("title", "Wang"); 66 | context.setData(map); 67 | FileOutputStream outputStream = new FileOutputStream(outFile); 68 | templateRender.renderAndOutput(context, outputStream); 69 | Assertions.assertTrue(FileUtil.exist(outFile)); 70 | } 71 | } 72 | --------------------------------------------------------------------------------